/* RU: Стили пульта — те же токены, что в макете maket/pult.html. EN: Panel styles — same tokens as the maket/pult.html mockup. */
:root {
  color-scheme: light;
  --bg: #f6f6f3; --surface: #ffffff; --surface-2: #f3f2ee; --line: #e3e2dc;
  --ink: #141413; --ink-2: #55544f; --muted: #8a8882;
  --accent: #4338ca; --accent-soft: #ecebfb; --accent-ink: #ffffff;
  --good-ink: #0a6e0a; --good-soft: #e5f5e5;
  --warn-ink: #7a5000; --warn-soft: #fff3d4;
  --bad-ink: #b02a2a; --bad-soft: #fbe8e8;
  --info-ink: #1c5cab; --info-soft: #e5effb;
  --t-services: #eb6834; --t-jobs: #1baf7a; --t-goods: #2a78d6;
  --bar: #2a78d6; --line2: #eb6834; --grid: #e1e0d9;
  --shadow: 0 1px 2px rgba(20,20,19,.06), 0 4px 16px rgba(20,20,19,.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #222220; --line: #2f2f2c;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86;
    --accent: #8b84f0; --accent-soft: #26244a; --accent-ink: #0f0f0e;
    --good-ink: #3cc93c; --good-soft: #15301a; --warn-ink: #f2b84a; --warn-soft: #362a10;
    --bad-ink: #ee7b7b; --bad-soft: #3a1b1b; --info-ink: #86b6ef; --info-soft: #172a44;
    --t-services: #d95926; --t-jobs: #199e70; --t-goods: #3987e5;
    --bar: #3987e5; --line2: #f08a5d; --grid: #2c2c2a; --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #222220; --line: #2f2f2c;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86;
  --accent: #8b84f0; --accent-soft: #26244a; --accent-ink: #0f0f0e;
  --good-ink: #3cc93c; --good-soft: #15301a; --warn-ink: #f2b84a; --warn-soft: #362a10;
  --bad-ink: #ee7b7b; --bad-soft: #3a1b1b; --info-ink: #86b6ef; --info-soft: #172a44;
  --t-services: #d95926; --t-jobs: #199e70; --t-goods: #3987e5;
  --bar: #3987e5; --line2: #f08a5d; --grid: #2c2c2a; --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.wide { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 13.5px; }

/* Вход */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 13.5px; font-weight: 600; margin-top: 8px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.login-card .btn { margin-top: 12px; }
.err { color: var(--bad-ink); min-height: 1.2em; margin: 4px 0 0; font-size: 13.5px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }

/* Каркас */
.shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side nav a.on { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.badge { font-size: 12px; font-weight: 700; color: var(--good-ink); background: var(--good-soft); border-radius: 999px; padding: 2px 9px; }
.main { padding: 20px 24px 60px; min-width: 0; }
.top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.top h1 { margin: 0; font-size: 24px; }
.top-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--surface); padding: 5px 11px; border-radius: 999px; font-size: 13.5px; cursor: pointer; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.custom { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.custom input { padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.syncbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.dotst { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--good-ink); }
.dotst.bad { background: var(--bad-ink); }
.dotst.run { background: var(--warn-ink); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand b { display: none; }
  .side nav { flex-direction: row; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
  .side nav a { white-space: nowrap; padding: 6px 9px; }
  .side-foot { margin: 0; flex-direction: row; flex-wrap: wrap; align-items: center; width: 100%; min-width: 0; }
  .side-foot #acc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main { padding: 14px 16px 60px; }
}

/* Карточки */
.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 12px; }
.g2 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.g2e { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1000px) { .g2 { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g2e { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 10px; font-weight: 600; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12.5px; color: var(--ink-2); }
.up { color: var(--good-ink); }
.down { color: var(--bad-ink); }
.alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.alert { border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.alert.bad { background: var(--bad-soft); color: var(--bad-ink); }
.alert.warn { background: var(--warn-soft); color: var(--warn-ink); }
.alert.info { background: var(--info-soft); color: var(--info-ink); }
.rows { display: flex; flex-direction: column; }
.rowkv { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rowkv:last-child { border-bottom: 0; }
.rowkv b { font-variant-numeric: tabular-nums; }

/* График */
.chart svg { width: 100%; height: 220px; display: block; }
.chart .b { fill: var(--bar); }
.chart .b:hover { opacity: .75; }
.chart .ln { fill: none; stroke: var(--line2); stroke-width: 2; }
.chart .pt { fill: var(--line2); }
.chart .gr { stroke: var(--grid); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 8px; border-radius: 2px; margin-right: 5px; }
.legend .lb { background: var(--bar); }
.legend .ll { background: var(--line2); height: 3px; vertical-align: middle; }
.tip { font-size: 12.5px; color: var(--ink-2); min-height: 1.4em; margin-top: 4px; }

/* Таблицы */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.st { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.st.active { background: var(--good-soft); color: var(--good-ink); }
.st.old, .st.removed, .st.gone { background: var(--surface-2); color: var(--ink-2); }
.st.blocked, .st.rejected { background: var(--bad-soft); color: var(--bad-ink); }
.st.ok { background: var(--good-soft); color: var(--good-ink); }
.st.fail { background: var(--bad-soft); color: var(--bad-ink); }
.spark { width: 90px; height: 24px; display: block; }
.spark .b { fill: var(--bar); }
.ttl a { color: var(--ink); text-decoration: none; font-weight: 600; }
.ttl a:hover { text-decoration: underline; }
@media (max-width: 700px) {
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { border: 0; padding: 3px 14px; text-align: left; }
  table.stack td::before { content: attr(data-l); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
}
.empty { padding: 28px; text-align: center; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
.theme-btn { position: fixed; right: 14px; bottom: 14px; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; box-shadow: var(--shadow); font-size: 18px; z-index: 20; }

/* Сообщения */
.side nav a .cnt { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; text-align: center; margin-left: 4px; }
.ibar { margin-bottom: 12px; }
.inbox { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 12px; align-items: start; }
.qlist { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 210px); overflow-y: auto; }
.qi { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.qi.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.qi b { font-size: 14px; }
.qt { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qh { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; justify-content: space-between; }
.st.cli { background: var(--info-soft); color: var(--info-ink); }
.st.cand { background: var(--good-soft); color: var(--good-ink); }
.st.warn { background: var(--warn-soft); color: var(--warn-ink); }
.thread { display: flex; flex-direction: column; gap: 10px; min-height: 300px; }
.th-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.th-head .back { display: none; }
.msgs { display: flex; flex-direction: column; gap: 6px; max-height: 42vh; overflow-y: auto; padding: 4px 2px; }
.bub { max-width: 85%; padding: 8px 11px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 2px; }
.bub.in { align-self: flex-start; background: var(--surface-2); border-radius: 12px 12px 12px 4px; }
.bub.sys { align-self: center; background: transparent; border: 1px dashed var(--line); color: var(--ink-2); font-size: 13px; max-width: 95%; }
.bub.out { align-self: flex-end; background: var(--accent-soft); border-radius: 12px 12px 4px 12px; }
.draft { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.draft p { margin: 0; color: var(--ink-2); }
.draft textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; resize: vertical; }
.miss, .prob { border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.miss { background: var(--warn-soft); color: var(--warn-ink); }
.miss ul { margin: 4px 0 0; padding-left: 18px; }
.prob { background: var(--bad-soft); color: var(--bad-ink); }
.acts { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 820px) {
  .inbox { grid-template-columns: minmax(0, 1fr); }
  .inbox .thread { display: none; }
  .inbox.open .qlist { display: none; }
  .inbox.open .thread { display: flex; }
  .th-head .back { display: inline; }
  .qlist { max-height: none; }
}

/* Конструктор */
.newad { display: flex; flex-direction: column; gap: 6px; padding: 12px; }
.newad select, #adVer, .thread input, .thread .fgrid textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; width: 100%; }
#adVer { width: auto; max-width: 100%; }
.thread textarea#adText { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; resize: vertical; line-height: 1.45; }
.brief summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.fgrid label { display: flex; flex-direction: column; gap: 3px; }
@media (max-width: 560px) { .fgrid { grid-template-columns: 1fr; } }
.st.old { background: var(--surface-2); color: var(--ink-2); }
.chk { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }
.chk li.bad { color: var(--bad-ink); }
.chk li.warn { color: var(--warn-ink); }
.pkg { width: 100%; font-size: 13.5px; }
.pkg td { padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pkg .pv { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 0; width: 70%; }
#maxCard { margin-bottom: 12px; }
#maxCard p { margin: 0 0 8px; }

/* Подбор */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; overflow-x: auto; margin: 12px 0; padding-bottom: 4px; }
.kcol { background: var(--surface-2); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.kcol h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-2); }
.kc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px; display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
@media (max-width: 820px) { .kanban { grid-template-columns: minmax(0, 1fr); overflow-x: visible; } }
.btn.danger { color: var(--bad-ink); border-color: var(--bad-soft); }
#opsCard, #maxCard { margin-bottom: 12px; }
#auditCard { margin-bottom: 12px; }
#auditCard .table-wrap { box-shadow: none; max-height: 420px; overflow-y: auto; }
.cover { width: 100%; max-width: 560px; aspect-ratio: 4 / 3; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* RU: Фаза А плана v3: действия в тревогах и вопросы базы знаний. EN: Plan v3 phase A: alert actions and knowledge questions. */
.alert.act { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.alert.act span { flex: 1 1 260px; }
.alert.act .btn { flex: none; }
.kbq { border-top: 1px solid var(--line); padding: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.kbq:first-of-type { border-top: 0; }
.kbq textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; resize: vertical; }
.rev .rv-text { margin: 8px 0 0; white-space: pre-wrap; }
.rev textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; resize: vertical; }
.rev .confirm { border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; background: var(--accent-soft); }
.rev .confirm p { margin: 0 0 8px; color: var(--ink); }
.auto-f { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 10px 0; }
.auto-f input, .card select, #apText { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; }
.hb { display: grid; grid-template-columns: minmax(120px, 180px) 1fr 44px; gap: 8px; align-items: center; font-size: 13.5px; margin: 5px 0; }
.hb .track { height: 14px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.hb .track i { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.hb b { text-align: right; font-variant-numeric: tabular-nums; }
.lead .pick { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.lead .pick textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; }
.slots-g { display: flex; flex-wrap: wrap; gap: 6px; }
.slots-g .chip:disabled { opacity: .4; text-decoration: line-through; }
.toggle-l { display: block; padding: 4px 0; }
#fdMail { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; min-width: 220px; }
h2.mt { margin-top: 14px; }
