/* Motor Town Hub tablet. Dark "rugged device" look, amber road-sign accent. */
:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-2: #18202a;
  --line: #243040;
  --text: #e6edf3;
  --muted: #8b98a8;
  --amber: #f2b631;
  --amber-ink: #1a1300;
  --police: #4c8dff;
  --ems: #ff5a5f;
  --mechanic: #ff9a3c;
  --taxi: #ffd84d;
  --ok: #3fcf8e;
  --warn: #f2b631;
  --bad: #ff5a5f;
  --radius: 14px;
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #05070a; color: var(--text); font: 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--amber); }

/* The device frame: full screen on phones, a tablet on desktops. */
.device {
  display: flex; flex-direction: column; height: 100%;
  background: var(--bg);
}
@media (min-width: 900px) {
  body { display: grid; place-items: center; padding: 24px;
    background: radial-gradient(1200px 600px at 50% -10%, #1a2330 0%, #05070a 60%); }
  .device { width: min(1180px, 100%); height: min(820px, calc(100vh - 48px));
    border-radius: 28px; border: 10px solid #1b222b; box-shadow: 0 0 0 1px #2b3540, 0 30px 80px #000c;
    overflow: hidden; }
}

.statusbar {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 14px;
  background: #0e141b; border-bottom: 1px solid var(--line); flex: none;
}
.sb-home { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2);
  display: grid; place-items: center; cursor: pointer; }
.sb-home svg { width: 18px; height: 18px; fill: var(--amber); }
.sb-title { font-weight: 650; letter-spacing: .02em; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-right { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.sb-clock { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.sb-server { display: inline-flex; align-items: center; gap: 6px; }
.sb-server i { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px #ff5a5f22; }
.sb-server.up i { background: var(--ok); box-shadow: 0 0 0 3px #3fcf8e22; }
.sb-duty { padding: 3px 9px; border-radius: 999px; font-weight: 650; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.sb-duty[data-duty=police] { color: var(--police); border-color: #4c8dff55; }
.sb-duty[data-duty=ems] { color: var(--ems); border-color: #ff5a5f55; }
.sb-duty[data-duty=mechanic] { color: var(--mechanic); border-color: #ff9a3c55; }
.sb-duty[data-duty=taxi] { color: var(--taxi); border-color: #ffd84d55; }

.view { flex: 1; overflow: auto; padding: 18px; outline: none; }
.view.flush { padding: 0; overflow: hidden; display: flex; }

/* Home: app grid */
.home-hello { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 4px 18px; flex-wrap: wrap; }
.home-hello h1 { margin: 0; font-size: 26px; font-weight: 700; }
.home-hello p { margin: 0; color: var(--muted); }
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 14px; }
.app { display: flex; flex-direction: column; align-items: center; gap: 9px; padding: 16px 8px 12px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); cursor: pointer; text-decoration: none; color: var(--text);
  transition: transform .08s, border-color .15s, background .15s; position: relative; }
.app:hover { border-color: #3a4a5e; background: var(--panel-2); }
.app:active { transform: scale(.97); }
.app .ico { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; background: var(--c, var(--amber)); }
.app .ico svg { width: 28px; height: 28px; fill: none; stroke: #0b0f14; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.app span { font-size: 13px; font-weight: 600; text-align: center; }
.app .badge { position: absolute; top: 8px; right: 10px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--bad); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; }

.home-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 18px; }

/* Cards, lists, forms */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card h2, .card h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: .02em; }
.card h2 small, .card h3 small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.stack > * + * { margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-weight: 600; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: #3a4a5e; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.btn.danger { background: #3a1416; border-color: #ff5a5f66; color: #ffb3b5; }
.btn.police { background: #13254a; border-color: #4c8dff66; color: #b9d0ff; }
.btn.ems { background: #3a1416; border-color: #ff5a5f66; color: #ffc2c4; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.big { padding: 14px 18px; font-size: 16px; border-radius: 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: #0b1118; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--amber); }
textarea { min-height: 70px; resize: vertical; }
.field + .field { margin-top: 10px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 0; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; border: 1px solid var(--line);
  background: var(--panel-2); text-transform: capitalize; }
.pill.open { color: var(--amber); border-color: #f2b63155; }
.pill.accepted, .pill.active { color: var(--police); border-color: #4c8dff55; }
.pill.done, .pill.closed { color: var(--muted); }
.pill.cancelled { color: var(--muted); text-decoration: line-through; }
.pill.p1 { color: #fff; background: #b3262b; border-color: #b3262b; }
.pill.p2 { color: var(--amber); }
.pill.p3 { color: var(--muted); }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.list td { padding: 9px 8px; border-bottom: 1px solid #1c2531; vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #16202b; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sign in */
.signin { max-width: 520px; margin: 30px auto; text-align: center; }
.signin h1 { font-size: 26px; margin: 0 0 6px; }
.code { font-family: var(--mono); font-size: 34px; font-weight: 700; letter-spacing: .12em; padding: 16px 20px; margin: 18px 0;
  border-radius: 14px; border: 2px dashed #f2b63188; background: #1a1505; color: var(--amber); user-select: all; }
.signin ol { text-align: left; color: var(--muted); line-height: 1.9; }

/* Services */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.svc { padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
  text-align: left; display: flex; flex-direction: column; gap: 6px; }
.svc:hover { border-color: var(--c); }
.svc b { font-size: 16px; }
.svc .dot { width: 34px; height: 34px; border-radius: 10px; background: var(--c); display: grid; place-items: center; }
.svc .dot svg { width: 20px; height: 20px; stroke: #0b0f14; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.svc.sel { border-color: var(--c); box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 30%, transparent); }

.req { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #1c2531; }
.req:last-child { border-bottom: 0; }
.req .k { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--c); flex: none; }
.req .k svg { width: 20px; height: 20px; stroke: #0b0f14; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.req .body { flex: 1; min-width: 0; }
.req .body b { display: block; }
.req .body span { color: var(--muted); font-size: 13px; }

/* CAD / MDT: three-column console on wide screens */
.cad { display: grid; grid-template-columns: 300px 1fr 300px; gap: 0; height: 100%; width: 100%; }
.cad > section { overflow: auto; padding: 14px; border-right: 1px solid var(--line); }
.cad > section:last-child { border-right: 0; }
@media (max-width: 1100px) { .cad { grid-template-columns: 1fr; height: auto; } .view.flush { overflow: auto; display: block; } .cad > section { border-right: 0; border-bottom: 1px solid var(--line); } }
.cad h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.unit { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 8px; }
.unit .cs { font-family: var(--mono); font-weight: 700; font-size: 13px; min-width: 64px; }
.unit .nm { flex: 1; min-width: 0; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit .st { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; text-transform: uppercase; letter-spacing: .04em; }
.st-available { background: #0f3324; color: var(--ok); }
.st-busy, .st-investigation { background: #3a2c08; color: var(--amber); }
.st-enroute { background: #13254a; color: #9fc0ff; }
.st-onscene { background: #2a1a4a; color: #c9a8ff; }
.st-break { background: #222c38; color: var(--muted); }
.st-offline { background: #161b22; color: #5d6b7c; }
.unit.dept-police { border-left: 3px solid var(--police); }
.unit.dept-ems { border-left: 3px solid var(--ems); }
.call { padding: 10px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; }
.call:hover { border-color: #3a4a5e; }
.call.sel { border-color: var(--amber); }
.call.panic { border-color: #ff5a5f; background: #2a1012; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px #ff5a5f33; } }
.call .t { font-weight: 650; }
.call .m { font-size: 12px; color: var(--muted); margin-top: 3px; }
.statusbtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
.statusbtns .btn { font-size: 12px; padding: 8px 6px; }
.statusbtns .btn.on { outline: 2px solid var(--amber); }
.note { padding: 8px 10px; border-left: 2px solid var(--line); margin: 6px 0; font-size: 14px; }
.note .m { font-size: 12px; color: var(--muted); }

/* Map */
.mapwrap { position: relative; flex: 1; background: #0a0e13; }
.mapwrap canvas { width: 100%; height: 100%; display: block; cursor: grab; }
.mapwrap canvas:active { cursor: grabbing; }
.maplegend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: 10px;
  background: #0b0f14dd; border: 1px solid var(--line); font-size: 12px; }
.maplegend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.mapinfo { position: absolute; right: 12px; top: 12px; width: 260px; max-height: calc(100% - 24px); overflow: auto; padding: 10px 12px;
  border-radius: 12px; background: #0b0f14ee; border: 1px solid var(--line); font-size: 13px; }

/* Toasts / alerts */
.toasts { position: fixed; right: 18px; top: 70px; display: flex; flex-direction: column; gap: 10px; z-index: 50; width: min(360px, calc(100vw - 36px)); }
.toast { background: #141c26; border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 30px #000a; animation: slide .2s ease-out; cursor: pointer; }
.toast.cad { border-left-color: var(--police); }
.toast.p1 { border-left-color: var(--bad); background: #2a1012; }
.toast b { display: block; margin-bottom: 2px; }
.toast.err { border-left-color: var(--bad); }
@keyframes slide { from { transform: translateY(-8px); opacity: 0; } }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { padding: 7px 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 13px; }
.tabs button.on { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }

.stat { display: flex; flex-direction: column; }
.stat b { font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }

.devbar { margin-top: 18px; border-style: dashed; border-color: #f2b63166; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 18px; width: min(460px, 92vw); }
dialog::backdrop { background: #000a; }
