:root {
  color-scheme: dark;
  --y: #ffd200;
  --y2: #ffb700;
  --bg: #0a0b0d;
  --panel: #131519;
  --field: #1b1e24;
  --line: rgba(255, 255, 255, .08);
  --line2: rgba(255, 255, 255, .18);
  --text: #eceef2;
  --muted: #8b919d;
  --bad: #ff5d4d;
  --ok: #37c871;
  --info: #5aa9ff;
  --r: 8px;
  --shadow: 0 12px 32px rgba(0, 0, 0, .4);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1100px 520px at 72% -8%, rgba(255, 210, 0, .07), transparent 62%), var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
}
:focus-visible { outline: 2px solid var(--y); outline-offset: 2px; }

/* ---------- шапка ---------- */
header {
  display: flex; align-items: center; gap: 22px; flex: none;
  height: 58px; padding: 0 22px; border-bottom: 1px solid var(--line); background: rgba(10, 11, 13, .7);
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: 2.5px; display: flex; align-items: center; gap: 11px; }
.logo { width: 13px; height: 24px; background: linear-gradient(var(--y) 0 70%, #000 70%); border: 2px solid var(--y); border-radius: 2px; box-shadow: 0 0 14px rgba(255, 210, 0, .45); }
.pages { display: flex; gap: 2px; }
.pages a { padding: 6px 12px; border-radius: var(--r); color: var(--muted); text-decoration: none; font-weight: 600; transition: color .15s, background .15s; }
.pages a:hover { color: var(--text); }
.pages a.on { color: var(--text); background: rgba(255, 255, 255, .08); }
#tabs { display: flex; gap: 2px; padding: 3px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 10px; }
#tabs:empty { display: none; }
#tabs button {
  font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .8px; cursor: pointer;
  height: 26px; padding: 0 14px; border: 0; border-radius: 7px;
  background: transparent; color: var(--muted); transition: color .15s, background .15s;
}
#tabs button:hover { color: var(--text); }
#tabs button.on { background: linear-gradient(#ffe04a, var(--y2)); color: #141000; box-shadow: 0 2px 10px rgba(255, 200, 0, .3); }
.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
#status { font-size: 12px; color: var(--muted); min-width: 120px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#status:not(:empty)::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); vertical-align: 1px; }
#status.err { color: var(--bad); }
#status.err::before { background: var(--bad); box-shadow: 0 0 8px var(--bad); }

/* ---------- кнопки и поля ---------- */
.actions button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  height: 32px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--line); background: rgba(255, 255, 255, .05); color: var(--text);
  transition: color .15s, background .15s, border-color .15s, filter .15s;
}
.actions button:hover:not(:disabled), .btn:hover:not(:disabled) { background: rgba(255, 255, 255, .1); border-color: var(--line2); }
button:disabled { opacity: .4; cursor: not-allowed; }
.actions button.warn { border-color: rgba(255, 210, 0, .45); color: var(--y); background: rgba(255, 210, 0, .06); }
.btn.small { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.primary {
  display: block; width: 100%; height: 40px; margin-top: 20px; border: 0; font-weight: 700;
  background: linear-gradient(#ffe04a, var(--y2)); color: #141000; box-shadow: 0 6px 20px rgba(255, 200, 0, .22);
}
.btn.primary:hover:not(:disabled) { background: linear-gradient(#ffe04a, var(--y2)); filter: brightness(1.08); }
.btn.danger { margin-top: 26px; width: 100%; color: var(--bad); border-color: rgba(255, 93, 77, .4); background: rgba(255, 93, 77, .06); }
.btn.del { color: var(--bad); border-color: transparent; background: transparent; }
.btn.danger:hover:not(:disabled), .btn.del:hover:not(:disabled) { background: var(--bad); border-color: var(--bad); color: #140300; }

input:is([type=text], [type=password]), select, textarea {
  font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color .15s, box-shadow .15s;
}
input:is([type=text], [type=password]), textarea { display: block; width: 100%; margin-top: 5px; padding: 7px 11px; }
textarea { resize: vertical; }
select {
  height: 34px; padding: 0 30px 0 11px; max-width: 100%; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238b919d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
select:disabled { opacity: .5; cursor: not-allowed; }
input:is([type=text], [type=password]):hover, select:hover:not(:disabled), textarea:hover { border-color: var(--line2); }
input:is([type=text], [type=password]):focus, select:focus, textarea:focus { outline: none; border-color: var(--y); box-shadow: 0 0 0 3px rgba(255, 210, 0, .16); }
::placeholder { color: #5d626d; }
input[type=checkbox] { accent-color: var(--y); width: 15px; height: 15px; margin: 0; flex: none; cursor: pointer; }

/* ---------- схема ---------- */
main { flex: 1; display: flex; min-height: 0; }
.canvas {
  flex: 1; position: relative; min-width: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, .055) 1px, transparent 1.5px) 0 0 / 26px 26px;
}
.pan { height: 100%; }
#svg { width: 100%; height: 100%; display: block; user-select: none; }
.legend {
  position: absolute; left: 18px; bottom: 16px; display: flex; gap: 18px; padding: 7px 14px;
  font-size: 12px; color: var(--muted); pointer-events: none;
  background: rgba(19, 21, 25, .85); border: 1px solid var(--line); border-radius: 10px;
}
.ln { display: inline-block; width: 24px; height: 0; border-top: 2px solid rgba(255, 210, 0, .6); vertical-align: middle; margin-right: 5px; }
.ln.bad { border-top: 2px dashed var(--bad); }

.env-label { fill: rgba(255, 255, 255, .04); font-size: 120px; font-weight: 900; letter-spacing: 4px; text-anchor: middle; }
.zone { fill: rgba(255, 255, 255, .025); stroke: rgba(255, 255, 255, .09); }
.zone-label { fill: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 2.5px; }
.link { stroke: var(--y); stroke-width: 1.1; opacity: .36; }
.link.bad { stroke: var(--bad); stroke-width: 1.8; stroke-dasharray: 6 5; opacity: 1; }
.link.hl { stroke-width: 2.4; opacity: 1; }
.has-sel .link:not(.hl):not(.bad) { opacity: .07; }
.nodes { filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }
.node { cursor: pointer; }
.node .shape { transition: filter .15s; }
.node:hover .shape { filter: brightness(1.1); }
.node.service .shape { stroke: var(--y); stroke-width: 2; }
.node.service:hover .shape { filter: brightness(1.5); }
.node.sel .shape, .node.sel:hover .shape { stroke: #fff; stroke-width: 3; filter: drop-shadow(0 0 12px rgba(255, 210, 0, .7)); }
.node text { text-anchor: middle; pointer-events: none; fill: #191400; }
.node .nm { font-weight: 800; font-size: 14px; }
.node .meta { font-size: 10.5px; opacity: .78; }
.node.service .nm { fill: var(--y); }
.node.service .meta { fill: #c5c1ae; opacity: 1; }
.node.service .pre { font-size: 9.5px; fill: var(--muted); letter-spacing: .5px; }
.node.sys text { fill: #14161a; }
.node.sys .nm { font-size: 18px; }
.node.sys .meta { font-size: 12.5px; }

/* ---------- боковая панель ---------- */
aside {
  width: 330px; flex: none; margin: 14px 14px 14px 0; padding: 20px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
aside.wide { width: 390px; }
aside h2 { margin: 0 0 2px; font-size: 18px; letter-spacing: .2px; }
.hint { color: var(--muted); font-size: 13px; }
aside label { display: block; margin-top: 14px; font-size: 12px; color: var(--muted); }
aside select { width: 100%; margin-top: 5px; }
aside h3 { margin: 26px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 5px 10px; }
.links label { margin: 0; color: var(--text); font-size: 13px; display: flex; gap: 8px; align-items: center; cursor: pointer; }
.links label.bad { color: var(--bad); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
table.sum { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; font-variant-numeric: tabular-nums; }
table.sum td, table.sum th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.sum th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
table.sum tr:last-child td { border-bottom: 0; }
aside table.sum td:not(:first-child) { white-space: nowrap; color: var(--muted); }
table.sum tr.r { cursor: pointer; }
table.sum tr.r:hover td { color: var(--y); background: rgba(255, 210, 0, .05); }
td.nw { white-space: nowrap; color: var(--muted); }
.formerr { margin-top: 14px; padding: 9px 12px; color: var(--y); font-size: 13px; background: rgba(255, 210, 0, .07); border: 1px solid rgba(255, 210, 0, .25); border-radius: var(--r); }

/* ---------- векторы ---------- */
.vcol { flex: 1; min-width: 0; overflow-y: auto; padding: 26px 28px 48px; }
.vh { font-size: 20px; letter-spacing: .2px; margin: 0 0 16px; }
.vh span { color: var(--y); }
.vcol .vh:not(:first-child) { margin-top: 40px; }
.change { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; background: rgba(255, 255, 255, .025); }
.change .row { margin: 0; }
.change .row select { flex: 1; min-width: 0; }
.change input:is([type=text], [type=password]), .change select { margin-top: 0; }
.patch {
  position: relative; padding: 16px 18px 14px 22px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
  --st: var(--y);
}
.patch::before { content: ''; position: absolute; left: 8px; top: 16px; bottom: 16px; width: 3px; border-radius: 3px; background: var(--st); box-shadow: 0 0 10px var(--st); }
.patch.approval { --st: var(--info); }
.patch.success { --st: var(--ok); }
.patch.fail { --st: var(--bad); }
.patch.accepted { background: linear-gradient(90deg, rgba(55, 200, 113, .08), transparent 40%), var(--panel); }
.phead { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pkey { font-weight: 800; color: var(--y); font-variant-numeric: tabular-nums; }
.ptitle { font-weight: 700; font-size: 15px; }
.badge { font-size: 10px; font-weight: 800; letter-spacing: .8px; padding: 3px 9px; border-radius: 10px; background: rgba(255, 210, 0, .14); color: var(--y); }
.badge.fix { background: rgba(90, 169, 255, .14); color: var(--info); }
.badge.acc { background: rgba(55, 200, 113, .16); color: var(--ok); }
.pchanges { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 4px; font-variant-numeric: tabular-nums; }
.pchanges li { padding: 6px 11px; border-radius: var(--r); background: rgba(255, 255, 255, .035); }
.pchanges li.bad { color: var(--bad); background: rgba(255, 93, 77, .08); }
.pscope { margin: 0 0 12px; font-size: 13px; white-space: pre-wrap; }
.pscope .k { color: var(--muted); }
.pscope .bad { color: var(--bad); }
.padd { margin: 0 0 12px; max-width: 420px; }
.padd .change select { width: 100%; }
.pfail { margin: 0 0 12px; }
.pfail label { display: block; font-size: 12px; color: var(--bad); margin-bottom: 6px; }
/* путь вектора по площадкам: TEST › PREPROD › PROD */
.track { display: flex; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.chip { position: relative; font-size: 12px; padding: 3px 11px; border-radius: 12px; border: 1px solid var(--line); color: var(--muted); }
.chip + .chip { margin-left: 22px; }
.chip + .chip::before { content: '›'; position: absolute; left: -15px; top: 1px; color: #5d626d; font-size: 14px; }
.chip.here { border-color: currentColor; background: rgba(255, 255, 255, .04); }
.chip.none.here { border-color: var(--line2); }
.chip.approval { color: var(--info); }
.chip.testing { color: var(--y); }
.chip.success { color: var(--ok); }
.chip.fail { color: var(--bad); }
.pact { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.pact label { display: flex; align-items: center; gap: 7px; }
.pact select { height: 26px; font-size: 12px; border-radius: 7px; }
.pact .grp { display: flex; gap: 4px; align-items: center; }
.pact .del { margin-left: auto; }
.jf { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.jf label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#journal:has(table) { padding: 0 14px 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
#journal table.sum { margin-top: 0; }
#journal table.sum th { padding-top: 12px; padding-bottom: 10px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 9px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: var(--text); }

/* ---------- сущности, которые векторы добавляют и удаляют ---------- */
.node.new .shape { stroke: var(--ok); stroke-width: 3; stroke-dasharray: 7 4; }
.node.gone { opacity: .4; }
.node.gone .shape { stroke: var(--bad); stroke-width: 2.5; stroke-dasharray: 5 4; }
.node.new.sel .shape, .node.gone.sel .shape { stroke: #fff; stroke-dasharray: none; }
.link.gone { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 5; opacity: .3; }
.ln.new { border-top: 2px dashed var(--ok); }
.ln.gone { border-top: 2px dotted var(--muted); }
table.sum tr.gone td:first-child { text-decoration: line-through; color: var(--muted); }
table.sum tr.new td:first-child::after { content: ' +'; color: var(--ok); font-weight: 700; }
.pchanges li.add { color: var(--ok); background: rgba(55, 200, 113, .08); }
.pchanges li.del { color: var(--bad); background: rgba(255, 93, 77, .08); }
.formerr.add { color: var(--ok); background: rgba(55, 200, 113, .07); border-color: rgba(55, 200, 113, .3); }
.formerr.del { color: var(--bad); background: rgba(255, 93, 77, .07); border-color: rgba(255, 93, 77, .3); }

/* ---------- вход и режим «только просмотр» ---------- */
#auth { display: flex; align-items: center; gap: 10px; padding-left: 12px; border-left: 1px solid var(--line); }
#auth:empty { display: none; }
.who { font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
a.btn.primary { display: flex; }
.ro .auth-only { display: none !important; }
.ro .node { cursor: default; }
input:is([type=text], [type=password]):disabled, textarea:disabled { background: transparent; color: var(--text); -webkit-text-fill-color: var(--text); opacity: 1; cursor: default; }
input[type=checkbox]:disabled { cursor: default; }
.ro .links label { cursor: default; }

body.login { align-items: center; justify-content: center; padding: 20px; }
.login .card {
  width: 100%; max-width: 380px; padding: 30px 28px 26px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.login h2 { margin: 26px 0 6px; font-size: 22px; }
.login .hint { margin: 0 0 8px; }
.login label { display: block; margin-top: 16px; font-size: 12px; color: var(--muted); }
.login input:is([type=text], [type=password]) { padding: 10px 12px; font-size: 16px; }
.login .skip { display: block; margin-top: 18px; text-align: center; font-size: 13px; color: var(--muted); text-decoration: none; }
.login .skip:hover { color: var(--text); }

/* ---------- телефоны и узкие экраны ---------- */
@media (max-width: 900px) {
  html, body { height: auto; }
  body { display: block; min-height: 100%; }
  body.login { display: flex; min-height: 100vh; min-height: 100svh; }
  #auth { padding-left: 0; border-left: 0; }
  header { height: auto; flex-wrap: wrap; gap: 10px 14px; padding: 10px 14px; }
  .brand { font-size: 15px; }
  .pages { margin-left: auto; }
  #tabs { order: 3; width: 100%; }
  #tabs button { flex: 1; height: 34px; padding: 0 6px; }
  .actions { order: 4; width: 100%; margin-left: 0; flex-wrap: wrap; }
  #status { min-width: 0; margin-left: auto; }

  /* крупнее под палец; шрифт 16px — чтобы iOS не увеличивал страницу при фокусе на поле */
  .actions button, .btn { height: 40px; }
  .btn.small { height: 34px; padding: 0 12px; font-size: 13px; }
  .btn.primary { height: 46px; }
  input:is([type=text], [type=password]), select, textarea { font-size: 16px; }
  input:is([type=text], [type=password]), textarea { padding: 9px 12px; }
  select, .pact select { height: 42px; font-size: 16px; }
  input[type=checkbox] { width: 20px; height: 20px; }

  main { display: block; }
  /* схема не сжимается под экран, а прокручивается по горизонтали */
  .pan { height: auto; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }
  #svg { width: 1120px; height: 640px; }
  .legend { position: static; margin: 4px 14px 0; flex-wrap: wrap; gap: 6px 16px; }
  .legend span:last-child { display: none; }
  aside, aside.wide { width: auto; margin: 14px; padding: 18px 16px; overflow: visible; }
  .links { gap: 12px 10px; }
  .links label { font-size: 14px; }

  .vcol { overflow: visible; padding: 20px 14px 4px; }
  .vh { font-size: 18px; }
  .vcol .vh:not(:first-child) { margin-top: 30px; }
  .patch { padding: 14px 14px 12px 22px; }
  .padd { max-width: none; }
  .track { gap: 6px; }
  .chip + .chip { margin-left: 0; }
  .chip + .chip::before { display: none; }
  .pact { gap: 10px; }
  .pact .del { margin-left: 0; }

  /* журнал: вместо таблицы — строки-карточки, текст записи под датой и действием */
  #journal table.sum, #journal tbody { display: block; }
  #journal tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
  #journal tr:first-child { display: none; }
  #journal tr:last-child { border-bottom: 0; }
  #journal table.sum td { padding: 0; border: 0; }
  #journal td:last-child { flex-basis: 100%; }
}
