/* Панель MEGAWATT. Цвета — переменными: светлая и тёмная тема меняются в одном месте. */
:root {
  color-scheme: light;
  --bg: #f3f2ee; --surface: #fcfcfb; --line: #e3e1da; --line-soft: #eeece6;
  --text: #0b0b0b; --text-2: #52514e; --text-3: #85837c;
  --accent: #2a78d6; --accent-soft: #e6f0fc;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --good: #0ca30c; --warning: #fab219; --serious: #ec835a; --critical: #d03b3b;
  --good-bg: #e7f6e7; --warning-bg: #fef4d9; --critical-bg: #fbe7e7; --neutral-bg: #eeece6;
  --shadow: 0 1px 2px rgba(20, 20, 15, .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110; --surface: #1a1a19; --line: #32322f; --line-soft: #262624;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8e85;
    --accent: #5a9cec; --accent-soft: #1b2b40;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --good-bg: #17301a; --warning-bg: #3a2f10; --critical-bg: #3b1b1b; --neutral-bg: #262624;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0 0 12px; }
.muted { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* каркас: меню слева, на телефоне — лента сверху */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0;
  height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 800; letter-spacing: .04em; font-size: 15px; padding: 2px 10px 14px; }
.brand small { display: block; font-weight: 500; letter-spacing: 0; color: var(--text-3); font-size: 12px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.side nav a:hover { background: var(--line-soft); text-decoration: none; }
.side nav a.on { background: var(--accent-soft); color: var(--accent); }
.who { margin-top: auto; padding: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.who b { display: block; }
.who button { margin-top: 8px; }
main { padding: 22px 26px 40px; max-width: 1480px; width: 100%; }
.head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.head .sub { color: var(--text-3); font-size: 13px; }
.head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* переключатель периода и фильтры */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; flex-wrap: wrap; }
.seg a { padding: 5px 11px; border-radius: 7px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg a.on { background: var(--accent); color: #fff; }
.seg a:hover { text-decoration: none; }
button, .btn { font: inherit; font-weight: 500; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; display: inline-block; }
button:hover, .btn:hover { border-color: var(--text-3); text-decoration: none; }
.btn-main { background: var(--accent); border-color: var(--accent); color: #fff; padding: 10px 18px; font-size: 15px; }
input[type=search] { font: inherit; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); min-width: 220px; }

/* плитки с цифрами */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.tile { padding: 14px 16px; }
.tile .label { color: var(--text-2); font-size: 13px; }
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .value small { font-size: 13px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.tile .note { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.delta { font-weight: 600; }
.delta.up { color: var(--good); } .delta.down { color: var(--critical); }
.tile.alert { border-color: var(--critical); }
.tile.alert .value { color: var(--critical); }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); margin-bottom: 14px; }
.card { padding: 16px; grid-column: span 12; min-width: 0; }
.c8 { grid-column: span 8; } .c7 { grid-column: span 7; } .c6 { grid-column: span 6; } .c5 { grid-column: span 5; } .c4 { grid-column: span 4; }
.card .hint { color: var(--text-3); font-size: 12.5px; margin: -8px 0 12px; }
.chart { position: relative; height: 270px; }
.chart.tall { height: 330px; }
.empty { color: var(--text-3); padding: 18px 0; text-align: center; }

/* таблицы */
.tablewrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; color: var(--text-3); font-weight: 500; font-size: 12.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; padding-right: 0; padding-left: 10px; }
tbody tr:hover td { background: var(--line-soft); }
tfoot td { font-weight: 700; border-top: 1px solid var(--line); }

/* метки состояния: цвет всегда вместе со значком и словом */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  font-weight: 600; background: var(--neutral-bg); color: var(--text-2); white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--text); }
.badge.warning { background: var(--warning-bg); color: var(--text); }
.badge.critical { background: var(--critical-bg); color: var(--text); }
.badge.good::before { content: "✓"; color: var(--good); }
.badge.warning::before { content: "!"; color: var(--serious); font-weight: 800; }
.badge.critical::before { content: "▲"; color: var(--critical); font-size: 9px; }

/* «требует внимания» */
.attn { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.attn a { display: block; padding: 10px 12px; border-radius: 10px; color: var(--text); border-left: 4px solid var(--warning); background: var(--warning-bg); }
.attn a.critical { border-left-color: var(--critical); background: var(--critical-bg); }
.attn a:hover { text-decoration: none; filter: brightness(.98); }
.attn b { display: block; } .attn span { color: var(--text-2); font-size: 12.5px; }

/* доска производства */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(178px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--line-soft); border-radius: 12px; padding: 10px; min-height: 120px; }
.col h3 { margin: 0 0 2px; font-size: 13px; }
.col .colsum { color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.kcard { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; color: var(--text); }
.kcard:hover { border-color: var(--accent); text-decoration: none; }
.kcard.late { border-left: 4px solid var(--critical); }
.kcard .top { display: flex; justify-content: space-between; gap: 6px; font-weight: 700; }
.kcard .cl { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .meta { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--text-3); margin-top: 6px; flex-wrap: wrap; }
progress { width: 100%; height: 6px; appearance: none; -webkit-appearance: none; border: 0; border-radius: 3px; overflow: hidden; background: var(--line); display: block; margin-top: 6px; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--series-1); }
progress::-moz-progress-bar { background: var(--series-1); }

/* карточка заказа */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; }
.tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); }
.tl li { position: relative; padding: 0 0 12px 12px; }
.tl li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--series-1); border: 2px solid var(--surface); }
.tl time { display: block; color: var(--text-3); font-size: 12px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { max-width: 420px; padding: 28px; text-align: center; }
.login ol { text-align: left; color: var(--text-2); padding-left: 20px; }
.login .err { color: var(--critical); font-weight: 600; }

@media (max-width: 1100px) { .c8, .c7, .c6, .c5, .c4 { grid-column: span 12; } }
@media (max-width: 820px) {
  .shell { display: block; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 4px; white-space: nowrap; } .brand small { display: none; }
  .side nav { flex-direction: row; } .side nav a { white-space: nowrap; }
  .who { margin: 0 0 0 auto; border: 0; padding: 0 4px; white-space: nowrap; } .who b, .who span { display: none; } .who button { margin: 0; }
  main { padding: 14px 12px 30px; }
  .tile .value { font-size: 22px; }
}
@media print { .side, .head .right { display: none; } .shell { display: block; } body { background: #fff; } }
main > .card { margin-bottom: 14px; }
.card table + h2, .card .tablewrap + h2 { margin-top: 20px; }
th.r + th:not(.r), td.r + td:not(.r) { padding-left: 20px; }
td a b { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 10px; text-align: left; margin: 14px 0; }
.stack input { font: inherit; font-size: 18px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.stack label { color: var(--text-2); font-size: 13px; }
.task { border-top: 1px solid var(--line-soft); padding: 12px 0; }
.task:first-of-type { border-top: 0; padding-top: 0; }
.task-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.task ul { margin: 8px 0 0; padding-left: 18px; }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--good-bg); } .flash.err { background: var(--critical-bg); }
.rowform { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.rowform label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.rowform .grow { flex: 1; min-width: 140px; }
.rowform input { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.rowform .btn-main, form.inline .btn-main { padding: 8px 14px; font-size: 14px; }
form.inline { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
details.confirm summary { cursor: pointer; color: var(--text-3); list-style: none; }
details.confirm[open] summary { display: none; }
button.danger { border-color: var(--critical); color: var(--critical); }
.tile .value { white-space: nowrap; font-size: clamp(18px, 1.8vw, 26px); }
details.confirm summary { font-size: 12.5px; white-space: nowrap; }
.flash.wait { background: var(--warning-bg); }
.card.actions .actrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.card.actions .actrow + .actrow { margin-top: 4px; }
.card.actions form { margin: 0; }
.rowform.tight { border-top: 0; margin-top: 8px; padding-top: 0; }
select { font: inherit; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.card.upload { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.card.upload label { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 260px; }
.card.upload input[type=file] { font: inherit; }
details.edit { margin-top: 14px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
details.edit summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.edit-table input { font: inherit; width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.edit-table input.n { width: 70px; text-align: right; } .edit-table input.u { width: 56px; } .edit-table input.p { width: 120px; text-align: right; }
.edit-table input[type=checkbox] { width: auto; }
.edit-table tr.new td { background: var(--line-soft); }
.edit-table td.wide { min-width: 240px; width: 100%; }
.card.actions details.confirm { margin-left: auto; }
form.fields { display: flex; flex-direction: column; gap: 10px; }
form.fields label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); }
form.fields input, form.fields textarea { font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
form.fields textarea { resize: vertical; font-family: inherit; }
.card h2 + p .btn + .btn { margin-left: 6px; }
.buyform input { font: inherit; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.buyform input.n { width: 70px; text-align: right; } .buyform input.p { width: 110px; text-align: right; } .buyform input.v { width: 140px; }
.buyform { justify-content: flex-start; align-items: center; }
a.btn-main.btn { color: #fff; }
progress.big { height: 10px; margin: -6px 0 14px; }
button.big { font-size: 18px; padding: 14px 22px; width: 100%; }
.shopitem.done { opacity: .75; }
.stages { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.stages button { flex: 1 1 auto; min-height: 44px; }
.stages button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
code.screen-url { word-break: break-all; }
/* экран цеха: крупно, читается с 5 метров */
body.screen { background: #111110; color: #f0efec; min-height: 100vh; }
body.screen header { display: flex; gap: 24px; align-items: baseline; padding: 18px 28px; font-size: 26px; }
body.screen header span { color: #c3c2b7; } body.screen header em { color: #ff6b6b; font-style: normal; font-weight: 700; }
body.screen header time { margin-left: auto; color: #c3c2b7; }
.screen-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; padding: 0 28px 28px; }
.scard { background: #1f1f1d; border-radius: 16px; padding: 18px 20px; border-left: 10px solid #3987e5; }
.scard.late { border-left-color: #e5484d; background: #2b1717; }
.scard.ready { border-left-color: #1baf7a; }
.scard.new { border-left-color: #fab219; }
.sno { font-size: 40px; font-weight: 800; letter-spacing: -.02em; }
.sstate { font-size: 22px; margin: 4px 0 12px; color: #e4e3dc; }
.scard.late .sstate { color: #ff8b8b; font-weight: 700; }
.scard progress { height: 12px; background: #32322f; }
.scard progress::-webkit-progress-bar { background: #32322f; }
.smeta { display: flex; justify-content: space-between; font-size: 18px; color: #c3c2b7; margin-top: 8px; }
.smaster { font-size: 16px; color: #8f8e85; margin-top: 4px; }
.sempty { font-size: 28px; color: #8f8e85; }
.scard.soon { border-left-color: #fab219; } .scard.soon .sstate { color: #ffd166; font-weight: 700; }
details.problem { margin: 14px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
details.problem summary { cursor: pointer; font-weight: 600; color: var(--critical); }
form.fields select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 15px !important; color: var(--text) !important; }
label.check input { width: 22px; height: 22px; }
label.camera input { font: inherit; padding: 14px; border: 2px dashed var(--line); border-radius: 12px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.err { color: var(--critical); font-weight: 600; }
input.copy, textarea.copy { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--line-soft); color: var(--text); resize: vertical; }
.clientpage { max-width: 760px; margin: 0 auto; padding: 22px 14px 40px; }
.clientpage .brand { padding: 0 2px 14px; }
.clientpage .card { margin-bottom: 14px; }
.steps { list-style: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; padding: 0; margin: 16px 0; counter-reset: s; }
.steps li { padding: 10px 8px; border-radius: 10px; background: var(--line-soft); color: var(--text-3); font-size: 13px; font-weight: 600; text-align: center; }
.steps li.done { background: var(--good-bg); color: var(--text); }
.steps li.done::before { content: "✓ "; color: var(--good); }
.steps li.now { background: var(--accent); color: #fff; }
@media (max-width: 520px) { .steps { grid-template-columns: 1fr 1fr; } }
