:root {
  --bg: #14171c; --panel: #1d2128; --panel2: #262b34; --line: #343a45; --text: #eef1f5; --muted: #9aa3b0;
  --accent: #d6342b; --ok: #3f9a64; --warn: #e0a020; --danger: #e04040; --btn: #2d6cdf;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #eceef2; --line: #d3d7de; --text: #15181d; --muted: #5b6370;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 18px; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
.small { font-size: 14px; color: var(--muted); }
.big { font-size: 28px; font-weight: 700; }

/* Header */
.header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.header img { height: 36px; width: auto; border-radius: 6px; }
.header .title { flex: 1; min-width: 0; font-size: 14px; line-height: 1.2; }
.header .title b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clock { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.paused { background: var(--warn); }
.dot.off { background: var(--danger); }
.offline { background: var(--danger); color: #fff; padding: 8px 16px; font-size: 14px; text-align: center; }
.offline.local { background: var(--panel2); color: var(--muted); }
.iconbtn { min-width: 44px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; }

.page { max-width: 480px; margin: 0 auto; padding: 16px 16px 100px; }
.wide { max-width: none; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 12px; }
.btn { display: flex; align-items: center; justify-content: center; min-height: 56px; padding: 0 16px; border-radius: 12px; border: none; background: var(--btn); color: #fff; font-size: 18px; font-weight: 600; text-decoration: none; text-align: center; }
.btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1 1 0; min-width: 0; }
input[type=text], input[type=number], input[type=time], select, textarea { width: 100%; min-height: 48px; font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
label.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }

/* Chips and badges */
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chips button { flex: 1 1 0; min-height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; }
.chips button.on { background: var(--btn); border-color: var(--btn); color: #fff; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 14px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ISSUED { background: var(--warn); color: #111; border: none; }
.badge.IN_EFFECT { background: var(--ok); color: #fff; border: none; }
.badge.CONDITIONAL { background: #7a5cc4; color: #fff; border: none; }
.badge.AVAILABLE { background: var(--ok); color: #fff; border: none; }

/* Job cards */
.job { display: flex; gap: 12px; align-items: stretch; text-decoration: none; }
.job .stripe { width: 8px; border-radius: 4px; flex: none; }
.job .body { flex: 1; min-width: 0; }
.job .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Strip map */
.strip { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; }
.strip svg { display: block; }

/* Warrant */
.warrant { background: #fbf8ec; color: #1a1a1a; border-radius: 10px; padding: 14px; }
.warrant h3 { margin: 0 0 6px; font-size: 18px; }
.warrant .box { display: flex; gap: 10px; padding: 6px 0; border-top: 1px solid #ddd6bf; }
.warrant .box .n { width: 28px; flex: none; font-weight: 700; }
.warrant .box.off { color: #b0a98f; }
.warrant .sq { width: 18px; height: 18px; border: 2px solid #1a1a1a; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.warrant .box.off .sq { border-color: #c9c1a6; }
.warrant .meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; margin-bottom: 6px; }

/* Bottom bar */
.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--panel); border-top: 1px solid var(--line); padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); }
.bar .inner { max-width: 448px; margin: 0 auto; display: flex; gap: 8px; }
.bar .primary { flex: 1 1 auto; min-height: 64px; font-size: 18px; }
.bar .more { flex: 0 0 72px; min-height: 64px; }
.holdbtn { position: relative; overflow: hidden; }
.holdbtn .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: rgba(255,255,255,0.25); }
.holdbtn.holding .fill { width: 100%; transition: width 600ms linear; }

/* Sheets and modals */
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 480px; background: var(--panel); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 12px; }
.check { display: flex; gap: 12px; align-items: center; min-height: 56px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--panel2); }
.check input { width: 28px; height: 28px; flex: none; }
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(10,12,16,0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 18px; }
.allstop { position: fixed; inset: 0; z-index: 40; background: #b3121b; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 28px; font-weight: 700; gap: 12px; }
.snack { position: fixed; left: 50%; transform: translateX(-50%); bottom: 96px; z-index: 25; background: #333a46; color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: center; font-size: 16px; }
.snack button { min-height: 44px; min-width: 88px; border-radius: 10px; border: none; background: var(--warn); color: #111; font-weight: 700; }

/* Dispatcher */
.dgrid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
@media (max-width: 1000px) { .dgrid { grid-template-columns: minmax(0, 1fr); } }
.board { overflow-x: auto; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
.tabs button { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 14px; }
.tabs button.on { background: var(--btn); color: #fff; border-color: var(--btn); }
.log { max-height: 520px; overflow-y: auto; font-size: 14px; }
.log div { padding: 6px 0; border-bottom: 1px solid var(--line); }
.log .k-alarm { color: var(--danger); }
.log .k-warrant { color: var(--warn); }
.alarmbar { background: var(--danger); color: #fff; border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.controls { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 12px; }
.controls .btn { min-height: 48px; font-size: 15px; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.seg button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); font-size: 15px; }
.seg button.on { background: var(--btn); color: #fff; border-color: var(--btn); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
td, th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
@media print { .header, .bar, .noprint { display: none !important; } body { background: #fff; } }
