:root {
  --bg: #f3f4f6; --panel: #fff; --text: #1b2230; --muted: #667085; --line: #dfe3ea;
  --accent: #2563c9; --accent-soft: #e5eefc;
  --ok: #18864b; --ok-soft: #e1f4e8; --warn: #b26a00; --warn-soft: #fdf0d5;
  --bad: #c9302c; --bad-soft: #fbe3e2; --gray-soft: #eceef2; --side: #1d2738; --side-text: #c9d1e0;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b2029; --text: #e6e9ef; --muted: #98a2b3; --line: #2b323e;
    --accent: #6b9bf2; --accent-soft: #22304a;
    --ok: #46c07b; --ok-soft: #1a3325; --warn: #e3a23a; --warn-soft: #382d17;
    --bad: #f07470; --bad-soft: #3c2022; --gray-soft: #252b36; --side: #0d1016; --side-text: #aeb7c7;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; }
h3 { font-size: 12px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* каркас */
.layout { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 16px 10px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.side .brand { color: #fff; font-weight: 650; font-size: 15px; padding: 2px 10px 14px; line-height: 1.25; }
.side .brand small { display: block; font-weight: 400; color: var(--side-text); font-size: 11px; }
.side a { color: var(--side-text); padding: 9px 10px; border-radius: 8px; display: block; }
.side a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.side a.active { background: var(--accent); color: #fff; }
.side .spacer { flex: 1; }
.side .who { padding: 10px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.side .who b { display: block; color: #fff; font-size: 13px; }
.side select { width: 100%; margin-top: 8px; background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.15); border-radius: 6px; padding: 4px; font-size: 12px; }
.side select option { color: #000; }
.side button.link { background: none; border: none; color: var(--side-text); padding: 6px 0 0; cursor: pointer; font: inherit; font-size: 12px; }
.main { padding: 18px 22px 40px; min-width: 0; }
.pagehead { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

/* элементы */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.btn, button.btn { display: inline-block; cursor: pointer; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 8px; padding: 7px 13px; font: inherit; min-height: 34px; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 9px; min-height: 26px; font-size: 12px; }
input, select, textarea { font: inherit; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; max-width: 100%; }
textarea { width: 100%; }
label.field { display: grid; gap: 4px; margin-bottom: 10px; }
label.field > span { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 8px; color: var(--muted); }
.tabs a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; white-space: nowrap; background: var(--gray-soft); }
.b-blue { background: var(--accent-soft); color: var(--accent); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }

.msgs { margin-bottom: 12px; display: grid; gap: 6px; }
.msg { padding: 9px 12px; border-radius: 8px; background: var(--accent-soft); }
.msg.success { background: var(--ok-soft); color: var(--ok); }
.msg.error { background: var(--bad-soft); color: var(--bad); }
.msg.warning { background: var(--warn-soft); color: var(--warn); }

table.t { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.t th, table.t td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
table.t tr:last-child td { border-bottom: none; }
table.t tr.red td { background: var(--bad-soft); }
table.t tr.yellow td { background: var(--warn-soft); }
table.t tr.dim td { color: var(--muted); }
.tablewrap { overflow-x: auto; }
.bar { height: 6px; border-radius: 99px; background: var(--gray-soft); overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.ok > i { background: var(--ok); }

/* человек */
.person { display: inline-flex; align-items: center; gap: 7px; vertical-align: middle; }
.person-txt { display: inline-flex; flex-direction: column; line-height: 1.2; }
.person-txt b { font-weight: 600; }
.person-pos { font-size: 11px; color: var(--muted); }
.ava { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex: none; }
.ava-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; }
.people { display: flex; flex-wrap: wrap; gap: 6px 16px; }

/* главный экран */
.dash-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.dash-title { flex: 1 1 220px; }
.dash-title .clock { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; }
.counter { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; min-width: 112px; }
.counter b { display: block; font-size: 24px; line-height: 1.1; }
.counter span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.c-work b { color: var(--ok); } .c-wait b { color: var(--warn); } .c-open b { color: var(--accent); } .c-new b { color: var(--bad); }
.dash { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.35fr) minmax(280px, 1fr); gap: 12px; }
.dash .span-a { grid-column: 1 / 2; } .dash .wide-l { grid-column: 1 / 3; } .dash .wide-r { grid-column: 3 / 4; }
@media (max-width: 1180px) { .dash { grid-template-columns: 1fr 1fr; } .dash .wide-l, .dash .wide-r { grid-column: auto; } }
@media (max-width: 760px) { .dash { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .side { position: static; height: auto; } }
.block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.block > h2 { display: flex; justify-content: space-between; align-items: baseline; }
.block.focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.list li:last-child { border-bottom: none; }
.empty { color: var(--muted); font-size: 12px; padding: 4px 0; }

.map { position: relative; height: 330px; border-radius: 10px; background:
  linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 32px,
  linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 32px 100%, var(--gray-soft); overflow: hidden; }
.pin { position: absolute; transform: translate(-50%, -50%); padding: 3px 8px; border-radius: 8px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--panel); border: 2px solid var(--line); color: var(--text); }
.pin:hover { z-index: 3; text-decoration: none; }
.pin { max-width: 46%; overflow: visible; text-overflow: ellipsis; text-align: center; line-height: 1.25; white-space: normal; }
.pin small { font-weight: 400; display: block; font-size: 10px; white-space: nowrap; }
.pin.t-work { border-color: var(--ok); background: var(--ok-soft); }
.pin.t-wait, .pin.t-idle { border-color: var(--warn); background: var(--warn-soft); }
.pin.t-closed, .pin.t-done { border-color: var(--accent); background: var(--accent-soft); }
.pin .dot { position: absolute; top: -6px; right: -6px; width: 14px; height: 14px; border-radius: 50%; background: var(--bad); color: #fff; font-size: 9px; line-height: 14px; text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.crew { border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; }
.crew.t-work { border-left-color: var(--ok); } .crew.t-wait, .crew.t-idle { border-left-color: var(--warn); }
.crew.t-closed, .crew.t-done { border-left-color: var(--accent); }
.crew-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.crew-top b { font-size: 14px; }
.stages { display: flex; gap: 3px; margin: 7px 0 2px; }
.stages span { flex: 1; font-size: 10px; text-align: center; padding: 3px 2px; border-radius: 4px; background: var(--gray-soft); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stages span.on { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.unit-title { display: flex; justify-content: space-between; margin: 12px 0 6px; font-weight: 600; }
.unit-title:first-of-type { margin-top: 0; }
.foot { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* карточки объектов */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
.cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 980px) { .cols, .grid2, .grid3 { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 12px; }
.steps { display: flex; gap: 4px; flex-wrap: wrap; margin: 8px 0 0; }
.steps span { padding: 4px 10px; border-radius: 99px; background: var(--gray-soft); color: var(--muted); font-size: 12px; }
.steps span.on { background: var(--ok-soft); color: var(--ok); } .steps span.now { background: var(--accent); color: #fff; font-weight: 600; }
.steps span.bad { background: var(--bad-soft); color: var(--bad); font-weight: 600; }
pre.text { white-space: pre-wrap; font: inherit; margin: 0; }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: min(380px, 100%); padding: 26px; }
.login input { width: 100%; }
.demo-users { margin-top: 16px; font-size: 12px; }
.demo-users button { margin: 2px 2px 0 0; }

@media print {
  .side, .noprint, .msgs { display: none !important; }
  .layout { display: block; } .main { padding: 0; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .card, table.t { border-color: #000; border-radius: 0; }
  table.t th, table.t td { border: 1px solid #000; color: #000; background: #fff !important; }
}

/* экраны «под палец» (ТТ, Б.5): кнопки не меньше 48 px */
.touch .btn, .touch-btn, .touch input, .touch select { min-height: 48px; font-size: 15px; }
.touch-btn { padding: 10px 22px; }
.taskline { border: 1px solid var(--line); border-left: 5px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.taskline.ok { border-left-color: var(--ok); } .taskline.part { border-left-color: var(--warn); }
.taskline-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.big-qty { font-size: 24px; font-weight: 650; white-space: nowrap; } .big-qty small { font-size: 13px; font-weight: 400; color: var(--muted); }
button:disabled { opacity: .5; cursor: not-allowed; }
