:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #192740;
  --muted: #667085;
  --line: #dbe4ef;
  --brand: #21469d;
  --brand-dark: #193578;
  --navy: #142952;
  --brand-tint: #edf3fc;
  --danger: #c0392b;
  --ok: #087f73;
  --warn: #9a6700;
  --shadow: 0 10px 30px rgba(24, 42, 75, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: linear-gradient(180deg, #edf3fb 0, var(--bg) 260px);
  color: var(--ink);
  font: 14px/1.55 Inter, "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 21px; letter-spacing: .2px; }
h2 { font-size: 17px; }
h3 { font-size: 16px; }
main { width: min(1440px, calc(100% - 32px)); margin: 22px auto 40px; }
.startup-message { margin: 10vh auto 0; text-align: center; color: var(--muted); }
.login-card {
  width: min(900px, 100%);
  margin: clamp(24px, 10vh, 96px) auto 0;
  display: grid;
  grid-template-columns: 1fr minmax(0, 1fr);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-banner { display: grid; align-content: center; min-height: 360px; padding: clamp(24px, 4vw, 42px);
  color: #fff; background: radial-gradient(ellipse at 80% 90%, #087f7366, transparent 70%),
  linear-gradient(140deg, var(--navy), #1e4082); border-bottom: 3px solid var(--ok); }
.login-banner .brand { align-items: flex-start; flex-direction: column; gap: 18px; }
.login-banner h1 { font-size: clamp(23px, 3vw, 32px); }
.login-banner .muted { color: #dbe6f8; margin-top: 6px; }
.login-body { display: grid; align-content: center; gap: 14px; padding: clamp(22px, 4vw, 40px); min-width: 0; }
.login-body .stack { margin-top: 0; }
.login-body .notice { margin-top: 0; overflow-wrap: anywhere; }
.feedback { color: #9b2d24; overflow-wrap: anywhere; }
.feedback:empty { display: none; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand.compact { gap: 10px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: block; object-fit: contain; flex: none;
  background: #fff;
}
.stack { display: grid; gap: 14px; margin-top: 24px; }
label { display: grid; gap: 6px; color: #344054; font-size: 13px; }
input, select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #dbe8ff; }
.primary {
  border: 0; border-radius: 10px; padding: 10px 16px;
  background: var(--brand); color: #fff; font-weight: 600;
}
.primary:hover { background: var(--brand-dark); }
.ghost {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 13px;
  background: #fff; color: #344054;
}
.ghost:hover { border-color: #b9c7da; background: #f8fafc; }
button:disabled { opacity: .55; cursor: default; }
:is(button, a):focus-visible { outline: 2px solid #3874c4; outline-offset: 2px; }
.danger-link { border: 0; background: none; color: var(--danger); padding: 4px; }
.ok-link { border: 0; background: none; color: var(--brand); padding: 4px; }
.notice {
  margin-top: 18px; padding: 11px 13px; border-radius: 10px;
  background: #fff7e6; border: 1px solid #ffe0a3; color: #7a4d00;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; margin-bottom: 18px; padding: 15px 18px;
  background: linear-gradient(110deg, var(--navy), #1e4082); color: #fff; border-radius: 14px;
}
.topbar .muted { color: #dbe6f8; }
.topbar .ghost { color: #fff; background: #ffffff19; border-color: #ffffff55; }
.topbar .ghost:hover { background: #ffffff30; }
.workspace-switch { text-decoration:none; display:inline-flex; align-items:center; }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stats article {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; min-width: 0; border-top: 3px solid var(--brand);
  box-shadow: 0 5px 18px rgba(24, 42, 75, .04);
}
.stats span { display: block; color: var(--muted); font-size: 12px; letter-spacing: .4px; }
.stats strong { display: block; margin-top: 4px; font-size: clamp(19px, 2.1vw, 26px); font-variant-numeric: tabular-nums; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 5px 18px rgba(24, 42, 75, .04);
  margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.inline { display: flex; align-items: end; flex-wrap: wrap; gap: 9px; }
.inline label { flex: 1 1 145px; min-width: 0; }
.inline label:first-child { flex-basis: 195px; }
.inline select { min-width: 0; text-overflow: ellipsis; }
#company-unit-hint, #api-clients-panel > p { padding: 10px 20px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 11px 15px; border-bottom: 1px solid #edf1f6; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 600; background: #fbfcfe; }
tr:last-child td { border-bottom: 0; }
.state {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
}
.state.queued { background: #eef2f7; color: #475467; }
.state.assigned, .state.running { background: #e8f1ff; color: #1858c4; }
.state.paused { background: #fff4df; color: #8a5a00; }
.state.done { background: #e7f6ee; color: #157f56; }
.state.failed, .state.canceled { background: #fdecea; color: #b42318; }
.state.online { background: #e7f6ee; color: #157f56; }
.state.offline { background: #eef2f7; color: #667085; }
.progress { min-width: 160px; }
.bar { height: 7px; border-radius: 999px; background: #edf1f6; overflow: hidden; margin-top: 5px; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: inherit; width: 0; }
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  width: min(620px, calc(100% - 28px)); box-shadow: 0 20px 60px rgba(15, 23, 42, .2);
}
#modal-body { padding: 18px 20px 20px; }
#modal-body > .stack { margin: 0; }
#dialog-error:not(:empty) { margin-top: 12px; }
dialog::backdrop { background: rgba(15, 23, 42, .35); }
.dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--line);
}
.icon-button { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--muted); }
.dialog-body { padding: 20px; }
.dialog-body .stack { margin-top: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.token-box {
  word-break: break-all; background: #f5f8fc; border: 1px dashed #b9c7da;
  border-radius: 10px; padding: 12px; font-family: ui-monospace, Consolas, monospace;
  font-size: 12px; margin-top: 10px;
}
.msg { margin-top: 12px; padding: 9px 11px; border-radius: 8px; font-size: 13px; }
.msg.ok { background: #e7f6ee; color: #157f56; }
.msg.err { background: #fdecea; color: #b42318; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.console-workspace { display:grid; grid-template-columns:190px minmax(0,1fr); align-items:start; gap:18px; }
.console-content { min-width:0; }
.console-nav { display:grid; gap:5px; position:sticky; top:14px; padding:9px; border:1px solid var(--line); border-radius:12px; background:white; }
.console-nav a { padding:10px 12px; text-decoration:none; color:var(--ink); font-weight:600; border-radius:7px; white-space:nowrap; border-left:2px solid transparent; }
.console-nav a:is(:hover,:focus-visible,[aria-current]) { background:var(--brand-tint); color:var(--brand); }
.console-nav a[aria-current] { border-left-color:var(--brand); }
.console-heading { display:flex; align-items:baseline; flex-wrap:wrap; justify-content:space-between; column-gap:16px; margin-bottom:12px; }
.console-heading h2 { font-size:23px; }
.stats article:nth-child(3n+2) { border-top-color:#0e8979; }
.stats article:nth-child(3n+3) { border-top-color:#d38c31; }
.table-wrap tr:hover td { background:#f3f7fc; }
.vehicle-filters { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.vehicle-filters label { flex: 1 1 124px; }
.vehicle-filters label:first-child { flex: 2 1 190px; }
.vehicle-filter-actions { flex: 0 0 auto; width: auto; }
.vehicle-filter-actions button { min-height: 41px; }
.vehicle-meta { padding: 11px 20px; }
.vehicle-meta.feedback { color: var(--danger); }
.vehicle-plate { font-weight: 650; padding: 4px 0; }
.vehicle-plate:hover { text-decoration: underline; }
#vehicles-panel .table-wrap:focus-visible, #vehicle-detail-dialog .table-wrap:focus-visible {
  outline: 2px solid var(--brand); outline-offset: -2px;
}
.vehicle-pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line);
}
#vehicle-detail-dialog { width: min(1120px, calc(100% - 28px)); max-height: 90dvh; }
#vehicle-detail-dialog .table-wrap { max-height: 68dvh; }
#vehicle-detail-dialog th { position: sticky; top: 0; }
#vehicle-detail-dialog td:nth-child(2), #vehicle-detail-dialog td:nth-child(3) {
  min-width: 130px; max-width: 260px; white-space: normal;
}
.console-panel:not([hidden]), .login-card:not(.hidden), dialog[open] { animation:console-appear .18s ease-out; }
button, .console-nav a { transition:background-color .16s,border-color .16s; }
button { white-space:nowrap; }
@keyframes console-appear { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
@media (max-width:940px) {
  .console-workspace { grid-template-columns:minmax(0,1fr); gap:10px; }
  .console-nav { display:flex; flex-wrap:wrap; position:static; }
}
@media (max-width:750px) {
  .panel-head { align-items:flex-start; flex-direction:column; gap:12px; }
  .inline { width:100%; }
}
@media (max-width:600px) {
  main { width:calc(100% - 24px); margin-top:12px; }
  .topbar { align-items:flex-start; flex-direction:column; gap:12px; }
  .login-card { grid-template-columns:minmax(0,1fr); }
  .login-banner { min-height:0; }
  .login-banner .brand { gap:10px; }
  .console-nav { gap:2px; }
  .console-nav a { padding:7px 8px; font-size:13px; }
}
@media (prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation-duration:.01ms !important; transition-duration:.01ms !important; scroll-behavior:auto !important; }
}
