/* LogiHub — app styles. Colors are tokens; dark theme redefines them. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #15181d;
  --muted: #5f6877;
  --accent: #1d5bd8;
  --accent-hover: #174bb4;
  --accent-weak: #e8effd;
  --on-accent: #ffffff;
  --ok: #157a45;
  --ok-weak: #e4f3ea;
  --teal: #0c7184;
  --teal-weak: #e0f1f4;
  --warn: #a25f00;
  --warn-weak: #fdf1dc;
  --danger: #c0352d;
  --danger-weak: #fbe9e8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 248px;
  --font: "Onest", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115; --surface: #161a20; --surface-2: #1c2129; --border: #2a313b; --border-strong: #3a4350;
    --text: #e8ebef; --muted: #9ba5b3; --accent: #6b97ff; --accent-hover: #86aaff; --accent-weak: #1b2a4a; --on-accent: #0b1220;
    --ok: #4cc583; --ok-weak: #12301f; --teal: #4cc3d6; --teal-weak: #0f2c33; --warn: #f0a640; --warn-weak: #33270f;
    --danger: #ff6f66; --danger-weak: #3a1716; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1115; --surface: #161a20; --surface-2: #1c2129; --border: #2a313b; --border-strong: #3a4350;
  --text: #e8ebef; --muted: #9ba5b3; --accent: #6b97ff; --accent-hover: #86aaff; --accent-weak: #1b2a4a; --on-accent: #0b1220;
  --ok: #4cc583; --ok-weak: #12301f; --teal: #4cc3d6; --teal-weak: #0f2c33; --warn: #f0a640; --warn-weak: #33270f;
  --danger: #ff6f66; --danger-weak: #3a1716; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 10px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 16px; font-weight: 700; font-size: 17px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.brand-mark .ic { width: 18px; height: 18px; }
.nav-group { margin: 10px 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--accent-weak); color: var(--accent); }
.nav a .ic { color: var(--muted); }
.nav a.active .ic { color: var(--accent); }
.nav .soon { margin-left: auto; font-size: 10.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 99px; padding: 0 7px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--muted); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.burger { display: none; }
.search { position: relative; flex: 1; max-width: 520px; }
.search input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.search > .ic { position: absolute; left: 11px; top: 10px; color: var(--muted); }
.search kbd { position: absolute; right: 9px; top: 9px; font: 11px var(--font); color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.search-results { position: absolute; top: 44px; left: 0; right: 0; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.search-results h4 { margin: 8px 8px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.search-results a { display: flex; justify-content: space-between; gap: 12px; padding: 7px 8px; border-radius: 6px; color: var(--text); }
.search-results a:hover, .search-results a.sel { background: var(--accent-weak); text-decoration: none; }
.search-results a span:last-child { color: var(--muted); font-size: 12.5px; text-align: right; }
.search-empty { padding: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); }
.user-chip b { font-weight: 600; font-size: 13px; }
.user-chip small { color: var(--muted); font-size: 11.5px; display: block; line-height: 1.1; }
.content { padding: 24px; width: 100%; max-width: 1440px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 0 10px; height: 34px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent-weak); color: var(--accent); }

input, select, textarea { width: 100%; min-height: 38px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
textarea { resize: vertical; }
input[type="checkbox"] { width: 16px; min-height: 16px; height: 16px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.fld label { display: block; font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.fld small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }
.req { color: var(--danger); }
.check { display: flex; align-items: center; gap: 8px; min-height: 38px; align-self: end; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.grid-form.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-form.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-form .full { grid-column: 1 / -1; }

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px 0; }
.card-head + .card-pad { padding-top: 12px; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpis.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { padding: 14px 16px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi-top .ic { width: 28px; height: 28px; padding: 5px; border-radius: 7px; background: var(--surface-2); }
.kpi-val { margin-top: 8px; font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi.alert .kpi-top .ic { color: var(--danger); background: var(--danger-weak); }
.kpi.alert .kpi-val { color: var(--danger); }

.chart-box { position: relative; height: 260px; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.feed li:first-child { border-top: 0; }
.feed .dot { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.feed .dot .ic { width: 16px; height: 16px; }
.feed .t-danger .dot { background: var(--danger-weak); color: var(--danger); }
.feed .t-warn .dot { background: var(--warn-weak); color: var(--warn); }
.feed .t-info .dot { background: var(--accent-weak); color: var(--accent); }
.feed b { font-weight: 600; }
.feed small { display: block; color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .arr { font-size: 10px; margin-left: 3px; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl .sub, .kv .sub { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
.tbl .row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search-sm { position: relative; flex: 1; min-width: 200px; max-width: 340px; }
.toolbar .search-sm input { padding-left: 32px; height: 34px; min-height: 34px; }
.toolbar .search-sm .ic { position: absolute; left: 9px; top: 8px; color: var(--muted); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip .c { opacity: .7; margin-left: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { background: var(--accent-weak); color: var(--accent); }
.st-in_progress { background: var(--warn-weak); color: var(--warn); }
.st-delivered { background: var(--teal-weak); color: var(--teal); }
.st-paid { background: var(--ok-weak); color: var(--ok); }
.st-cancelled { background: var(--surface-2); color: var(--muted); }
.st-late { background: var(--danger-weak); color: var(--danger); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tag.adr { background: var(--warn-weak); color: var(--warn); border-color: transparent; }
.stars { color: var(--warn); letter-spacing: 1px; }

/* trip detail */
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.status-flow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-flow .step { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 500; }
.status-flow .step.done { color: var(--text); }
.status-flow .step .n { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border-strong); display: grid; place-items: center; font-size: 11px; }
.status-flow .step.done .n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.status-flow .sep { width: 22px; height: 1.5px; background: var(--border-strong); }
.map { height: 360px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.route-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.fact { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 12px; }
.fact small { display: block; color: var(--muted); font-size: 12px; }
.fact b { font-size: 16px; font-variant-numeric: tabular-nums; }
.borders { margin: 10px 0 0; padding: 0; list-style: none; }
.borders li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px dashed var(--border); }
.calc-lines { width: 100%; border-collapse: collapse; margin-top: 12px; }
.calc-lines td { padding: 6px 0; border-top: 1px solid var(--border); }
.calc-lines td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.calc-lines tr.total td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--border-strong); }
.margin-box { display: flex; gap: 10px; margin-top: 12px; }
.margin-box .fact { flex: 1; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }

.inco { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.inco td { padding: 6px 0; border-top: 1px solid var(--border); }
.inco td:last-child { text-align: right; font-weight: 600; }
.who-S { color: var(--accent); }
.who-B { color: var(--teal); }
.who-N { color: var(--muted); font-weight: 500 !important; }
.note { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.note.warn { background: var(--warn-weak); color: var(--warn); }

.form-sections { display: grid; gap: 16px; }
.form-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }

/* planned module page */
.planned { max-width: 760px; }
.planned ul { margin: 12px 0 0; padding-left: 18px; }
.planned li { margin: 4px 0; }

/* modal + toast */
.modal-wrap { position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 20, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s ease-out; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal.wide { max-width: 760px; }
.modal-form { display: flex; flex-direction: column; min-height: 0; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: grid; gap: 8px; }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--text); color: var(--surface); box-shadow: var(--shadow-lg); font-weight: 500; animation: pop .18s ease-out; max-width: 360px; }
.toast.err { background: var(--danger); color: #fff; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: var(--accent); color: var(--on-accent); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 34px; max-width: 460px; letter-spacing: -.02em; }
.login-art p { opacity: .85; max-width: 440px; font-size: 15px; }
.login-art ul { list-style: none; padding: 0; margin: 20px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; max-width: 460px; opacity: .9; }
.login-art li::before { content: "— "; }
.login-side { display: grid; place-items: center; padding: 32px 16px; position: relative; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 22px; margin-bottom: 4px; }
.login-box form { display: grid; gap: 12px; margin-top: 20px; }
.login-tools { position: absolute; top: 16px; right: 16px; display: flex; gap: 6px; }
.demo-users { margin-top: 22px; }
.demo-users button { display: flex; justify-content: space-between; width: 100%; padding: 8px 10px; margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; text-align: left; }
.demo-users button:hover { border-color: var(--accent); }
.demo-users small { color: var(--muted); }
.err-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

/* leaflet in dark theme */
:root[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); } }
.leaflet-container { font: inherit; }


/* ---------- tables (spreadsheet) ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tpl { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; text-align: left; cursor: pointer; font: inherit; color: inherit; transition: border-color .15s, transform .1s; }
.tpl:hover { border-color: var(--accent); }
.tpl:active { transform: translateY(1px); }
.tpl small { color: var(--muted); }
.tpl-ic { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); }
.sheet-title { border: 1px solid transparent; background: transparent; font-size: 22px; font-weight: 600; padding: 2px 6px; margin: 4px 0 0 -7px; min-height: 0; max-width: 640px; }
.sheet-title:hover { border-color: var(--border); }
.sheet-card { overflow: hidden; }
.sheet-tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.sheet-tools .sep { width: 1px; height: 22px; background: var(--border); margin: 0 2px; }
.sheet-tools .btn.on { background: var(--accent-weak); border-color: var(--accent); color: var(--accent); }
.sm-sel { width: auto; height: 30px; min-height: 30px; padding: 0 6px; font-size: 13px; }
.hdr-row { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.hdr-row input { width: 58px; height: 30px; min-height: 30px; padding: 0 6px; }
.fbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.fbar #cellName { min-width: 70px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px; }
.fbar .fx { color: var(--muted); font-style: italic; }
.fbar input { height: 32px; min-height: 32px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.view-note { padding: 6px 12px; background: var(--accent-weak); color: var(--accent); font-size: 13px; }
.linklike { border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 0; }
.sheet-wrap { position: relative; overflow: auto; height: calc(100vh - 290px); min-height: 320px; outline: none; }
table.sheet { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; user-select: none; }
.sheet th, .sheet td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); height: 28px; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-weight: 600; font-size: 12px; color: var(--muted); text-align: center; cursor: s-resize; }
.sheet thead .filter-row th { top: 29px; padding: 2px 3px; cursor: default; }
.sheet .filter-row input { height: 24px; min-height: 24px; font-size: 12px; padding: 2px 6px; }
.sheet tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface-2); color: var(--muted); font-weight: 500; font-size: 12px; text-align: center; }
.sheet thead th.corner { left: 0; z-index: 3; }
.sheet td { background: var(--surface); cursor: cell; }
.sheet td.n { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.e { color: var(--danger); text-align: center; font-weight: 600; }
.sheet td.bo { text-align: center; }
.sheet td.b { font-weight: 650; }
.sheet td.mu { color: var(--muted); }
.sheet td.in { background: var(--warn-weak); }
.sheet tr.hdr td { background: var(--surface-2); }
.sheet td.rng { background: var(--accent-weak); }
.sheet td.sel { outline: 2px solid var(--accent); outline-offset: -2px; }
.col-rs { position: absolute; right: -3px; top: 0; width: 7px; height: 100%; cursor: col-resize; z-index: 1; }
.cell-ed { position: absolute; z-index: 5; border: 2px solid var(--accent); border-radius: 0; padding: 0 5px; font-size: 13px; min-height: 0; background: var(--surface); box-shadow: var(--shadow-lg); }
.cell-ed:focus { box-shadow: var(--shadow-lg); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
@media (max-width: 1024px) { .tpl-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .sheet-wrap { height: calc(100vh - 340px); } .tpl-grid { grid-template-columns: 1fr; } }


/* ---------- game ---------- */
.gamebar { display: flex; align-items: center; gap: 10px; margin-left: 4px; }
.gb-clock { display: flex; flex-direction: column; line-height: 1.1; min-width: 74px; }
.gb-clock b { font-size: 17px; font-variant-numeric: tabular-nums; }
.gb-clock small, .gb-stat small { color: var(--muted); font-size: 11.5px; }
.gb-speed button { padding: 0 8px; height: 30px; }
.gb-stat { display: flex; flex-direction: column; line-height: 1.15; min-width: 84px; }
.gb-stat b { font-variant-numeric: tabular-nums; }
.xpbar { display: block; width: 90px; height: 6px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin-top: 3px; }
.xpbar i, .progress i { display: block; height: 100%; background: var(--accent); }
.progress { height: 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 10px 0 2px; }
.progress i { transition: width .4s linear; }
.decision { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.decision:first-child { border-top: 0; padding-top: 0; }
.decision small { display: block; color: var(--muted); }
.decision-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.attention { border-color: var(--warn); }
.gp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.haggle { width: 92px; height: 30px; min-height: 30px; padding: 0 8px; }
.st-assigned { background: var(--teal-weak); color: var(--teal); }
.feed li.good .dot { background: var(--ok-weak); color: var(--ok); }
@media (max-width: 1280px) { .gb-hide { display: none; } }
@media (max-width: 1024px) { .topbar .search { display: none; } }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .gamebar { order: 3; width: 100%; justify-content: space-between; margin: 0; gap: 6px; }
  .gb-stat small, .gb-clock small { display: none; }
  .gb-clock { min-width: 0; }
  .gb-stat { min-width: 0; }
  .gb-speed button { padding: 0 7px; }
}


/* ---------- ops: badges, docs, chat ---------- */
.nbadge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.nbadge[hidden] { display: none; }
.doc-state { font-size: 12px; font-weight: 600; }
.chat { display: grid; grid-template-columns: 300px 1fr; min-height: 520px; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: calc(100vh - 260px); }
.chat-list button { display: flex; gap: 10px; width: 100%; text-align: left; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent; cursor: pointer; font: inherit; color: inherit; }
.chat-list button:hover, .chat-list button.on { background: var(--accent-weak); }
.chat-list b { display: block; font-weight: 600; }
.chat-list small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px; }
.chat-list .cnt { margin-left: auto; align-self: center; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column-reverse; gap: 10px; max-height: calc(100vh - 330px); }
.bubble { max-width: 78%; padding: 9px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.bubble.me { align-self: flex-end; background: var(--accent-weak); border-color: transparent; }
.bubble small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.bubble .tr { display: block; color: var(--muted); font-size: 12.5px; margin-top: 4px; font-style: italic; }
.chat-reply { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.doc-paper { background: #fff; color: #111; padding: 22px; border: 1px solid #ccc; font: 12.5px/1.45 Arial, sans-serif; }
.doc-paper h3 { font-size: 16px; margin: 0 0 6px; }
.doc-paper table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.doc-paper td, .doc-paper th { border: 1px solid #999; padding: 5px 7px; vertical-align: top; text-align: left; }
.doc-paper .box { font-size: 10px; color: #555; display: block; }
.queue-up { color: var(--danger); } .queue-down { color: var(--ok); }
@media (max-width: 760px) { .chat { grid-template-columns: 1fr; } .chat-list { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border); } }

/* ---------- responsive ---------- */
@media (max-width: 1280px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; width: 270px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 14, 20, .4); z-index: 40; }
  .burger { display: inline-grid; }
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; gap: 6px; }
  .content { padding: 16px; }
  .kpis, .kpis.three { grid-template-columns: 1fr 1fr; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .grid-form, .grid-form.cols-3, .grid-form.cols-4 { grid-template-columns: 1fr; }
  .user-chip b, .user-chip small, .search kbd { display: none; }
  .user-chip { padding: 2px; border: 0; background: transparent; }
  .route-facts { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 120px 1fr; }
  .modal-wrap { padding: 0; place-items: end stretch; }
  .modal, .modal.wide { max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
