/* BluRabbit VideoTelematics — design system */
:root {
  --brand: #15298a;
  --brand-600: #1c36ad;
  --brand-700: #102070;
  --brand-50: #eef1fb;
  --brand-100: #dde3f7;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e3e7ef;
  --border-strong: #cfd6e3;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --ok: #15803d;
  --ok-bg: #e9f7ee;
  --warn: #b45309;
  --warn-bg: #fdf3e2;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* elements with their own display must still hide */
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- buttons & inputs ---------- */
.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); color: var(--text-2);
       font: 500 14px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--surface-2); border-color: #b9c2d3; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); border-color: #f2b8b8; }
.btn.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 32px; height: 32px; padding: 0; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 14px var(--font); transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, .btn:focus-visible { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.field { margin-bottom: 16px; }

/* chips (checkbox groups) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 999px;
             border: 1px solid var(--border-strong); color: var(--text-2); font-weight: 500; background: var(--surface); }
.chip input:checked + span { border-color: var(--brand); background: var(--brand-50); color: var(--brand); }
.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-100); }

/* switch */
.switch { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; }
.switch .track { flex: none; width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .15s; margin-top: 1px; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--brand-100); }
.switch .txt b { display: block; font-weight: 600; color: var(--text-2); }
.switch .txt small { color: var(--muted); font-size: 12.5px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-h h3 { font-size: 15px; font-weight: 650; }
.card-h .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.card-b { padding: 20px; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }
.empty svg.i { width: 28px; height: 28px; color: #b5bfd0; display: block; margin: 0 auto 8px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.brand { background: var(--brand-50); color: var(--brand); }
.badge.muted { background: #eef1f5; color: var(--muted); }
.badge.live { background: #fdecec; color: #dc2626; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }
.dot.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.msg { font-size: 13px; margin-top: 10px; }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--bad); }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #fff; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 20px 14px; }
.sidebar .logo { display: block; padding: 4px 10px 6px; }
.sidebar .logo img { height: 30px; width: auto; display: block; }
.sidebar .product { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: rgba(255,255,255,.55); padding: 4px 10px 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px; border-radius: var(--radius-sm); color: rgba(255,255,255,.78); font-weight: 500; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.15); color: #fff; }
.nav .count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.sidebar .foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.14); padding: 14px 10px 0; font-size: 13px; }
.sidebar .foot .box { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.85); margin-bottom: 4px; }
.sidebar .foot .box .dot { width: 8px; height: 8px; background: #94a3b8; }
.sidebar .foot .box.on .dot { background: #4ade80; }
.sidebar .foot .box.off .dot { background: #f87171; }
.sidebar .foot .meta { color: rgba(255,255,255,.55); font-size: 12px; margin-bottom: 12px; padding-left: 16px; }
.sidebar .foot button { width: 100%; background: rgba(255,255,255,.1); border: 0; color: #fff; height: 36px; border-radius: var(--radius-sm); font: 500 14px var(--font); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; }
.sidebar .foot button:hover { background: rgba(255,255,255,.18); }

.main { min-width: 0; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; display: flex; align-items: center; gap: 14px; padding: 16px 32px; background: rgba(244,246,250,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.menu-btn { display: none; }
.content { padding: 24px 32px 48px; max-width: 1440px; }
.page { display: grid; gap: 20px; }

/* ---------- live view ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.stat .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; flex: none; }
.stat .ic.ok { background: var(--ok-bg); color: var(--ok); }
.stat .ic.bad { background: var(--bad-bg); color: var(--bad); }
.stat .ic.warn { background: var(--warn-bg); color: var(--warn); }
.stat .body { min-width: 0; flex: 1; }
.stat .k { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.stat .v { font-size: 20px; font-weight: 700; line-height: 1.25; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter { height: 6px; border-radius: 999px; background: #e8ecf3; overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width .5s; }
.meter.warn > div { background: #f59e0b; }
.meter.full > div { background: var(--bad); }

.cams { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 20px; }
.cam { overflow: hidden; }
.cam .head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 52px; }
.cam .name { font-weight: 650; font-size: 15px; }
.cam .badges { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.screen { position: relative; aspect-ratio: 16 / 9; background: #0b1020; }
.screen video { width: 100%; height: 100%; object-fit: contain; display: block; }
.status { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; color: #cbd5e1; font-size: 14px; background: rgba(11,16,32,.72); }
.status[data-kind="error"] { color: #fca5a5; }
.status[data-kind="off"] { color: #e2e8f0; background: #0b1020; }
.sound { position: absolute; right: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 999px;
         background: rgba(11,16,32,.72); color: #fff; font: 500 12.5px var(--font); cursor: pointer; backdrop-filter: blur(4px); }
.sound:hover { background: rgba(11,16,32,.9); }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }
.toggle { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border-strong);
          background: var(--surface); color: var(--text-2); font: 500 13px var(--font); cursor: pointer; transition: all .15s; }
.toggle:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.toggle .dot { background: #94a3b8; }
.toggle.on { border-color: #b7c3ee; background: var(--brand-50); color: var(--brand); }
.toggle.on .dot { background: #16a34a; }
.toggle.rec-toggle.on .dot { background: #dc2626; animation: pulse 1.6s infinite; }
.toggle:disabled { cursor: default; opacity: .6; }
.toggle.readonly:disabled { opacity: 1; }
.controls .note { font-size: 12.5px; color: var(--warn); margin-left: 4px; }
.controls .spacer { flex: 1; }

/* ---------- alerts ---------- */
.alerts-banner { display: grid; gap: 10px; }
.alerts-banner:empty { display: none; }
.alert { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); border: 1px solid; background: var(--surface); }
.alert svg.i { margin-top: 1px; }
.alert.critical { border-color: #f3c0c0; background: var(--bad-bg); color: var(--bad); }
.alert.warning { border-color: #f1d9a8; background: var(--warn-bg); color: var(--warn); }
.alert .t { font-weight: 650; }
.alert .d { color: var(--text-2); margin-top: 2px; }
.alert .s { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ---------- lists & tables ---------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: #eceff5; border-radius: 10px; }
.tabs button { height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: 500 13px var(--font); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbfd; }
td .primary-text { font-weight: 600; }
td .secondary-text { color: var(--muted); font-size: 12.5px; }
td.actions { text-align: right; }
td.actions .row { display: inline-flex; gap: 6px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.timeline li:last-child { border-bottom: 0; }
.timeline .tic { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand); }
.timeline .tic.bad { background: var(--bad-bg); color: var(--bad); }
.timeline .tic.ok { background: var(--ok-bg); color: var(--ok); }
.timeline .tic.warn { background: var(--warn-bg); color: var(--warn); }
.timeline .what { color: var(--text); }
.timeline .when { color: var(--muted); font-size: 12.5px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.create-grid { display: grid; grid-template-columns: minmax(200px, 1.6fr) auto minmax(150px, .8fr) minmax(220px, 1.3fr) auto; gap: 16px 20px; align-items: end; }
.create-grid .field { margin: 0; }
.create-grid .switch { padding-bottom: 2px; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }
.linkbox { display: flex; gap: 8px; margin-top: 16px; padding: 12px; border-radius: var(--radius-sm); background: var(--brand-50); border: 1px solid var(--brand-100); flex-wrap: wrap; }
.linkbox .t { width: 100%; font-size: 12.5px; font-weight: 600; color: var(--brand); }
.linkbox input { flex: 1 1 200px; font-family: var(--mono); font-size: 12.5px; background: #fff; }
.big-number { font-size: 28px; font-weight: 750; letter-spacing: -.02em; }
.row-inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* ---------- auth / public pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth .panel { background: var(--brand); color: #fff; padding: 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth .panel img { height: 38px; width: auto; align-self: flex-start; position: relative; z-index: 1; }
.auth .panel .pitch { margin-top: auto; max-width: 440px; position: relative; z-index: 1; }
.auth .panel .tag { font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .6; margin-bottom: 14px; }
.auth .panel h2 { font-size: 32px; line-height: 1.2; font-weight: 750; }
.auth .panel p { opacity: .8; font-size: 15px; margin: 12px 0 0; }
.auth .panel .feats { display: grid; gap: 12px; margin-top: 32px; }
.auth .panel .feats div { display: flex; gap: 10px; align-items: center; opacity: .92; }
.auth .panel .feats svg.i { opacity: .85; }
.auth .panel .glow { position: absolute; width: 640px; height: 640px; border-radius: 50%; right: -220px; top: -220px; background: radial-gradient(closest-side, rgba(255,255,255,.14), transparent); }
.auth .panel .glow2 { position: absolute; width: 520px; height: 520px; border-radius: 50%; left: -200px; bottom: -260px; background: radial-gradient(closest-side, rgba(255,255,255,.08), transparent); }
.auth .form { display: grid; place-items: center; padding: 32px 24px; }
.auth .form .box { width: 100%; max-width: 380px; }
.auth .form h1 { font-size: 24px; font-weight: 750; }
.auth .form .lead { color: var(--muted); margin: 6px 0 28px; }
.auth .form .btn { width: 100%; height: 42px; }
.auth .form .foot { margin-top: 32px; color: var(--muted); font-size: 12.5px; }
.auth .mobile-logo { display: none; height: 30px; margin-bottom: 28px; }

.public-top { background: var(--surface); border-bottom: 1px solid var(--border); }
.public-top .in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 14px 24px; flex-wrap: wrap; }
.public-top img { height: 28px; width: auto; display: block; }
.public-top .divider { width: 1px; height: 26px; background: var(--border); }
.public-top .title b { display: block; font-size: 15px; }
.public-top .title small { color: var(--muted); }
.public-top .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.public-main { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.public-foot { max-width: 1280px; margin: 0 auto; padding: 8px 24px 32px; color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 8px; }
.public-foot img { height: 15px; opacity: .85; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.notice { width: 100%; max-width: 440px; text-align: center; padding: 36px 32px; }
.notice img.logo { height: 30px; margin-bottom: 28px; }
.notice .ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 16px; background: var(--warn-bg); color: var(--warn); }
.notice .ic.bad { background: var(--bad-bg); color: var(--bad); }
.notice .ic svg.i { width: 24px; height: 24px; }
.notice h1 { font-size: 20px; }
.notice p { color: var(--muted); margin: 8px 0 0; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .create-grid { grid-template-columns: 1fr 1fr; }
  .create-grid .wide { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; z-index: 50; transform: translateX(-100%); transition: transform .2s; height: 100%; padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 40; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .grid-halves { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth .panel { display: none; }
  .auth .mobile-logo { display: block; }
}
@media (max-width: 560px) {
  .stats { gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat .ic { width: 30px; height: 30px; border-radius: 8px; }
  .stat .ic svg.i { width: 16px; height: 16px; }
  .stat .v { font-size: 16px; }
  .stat .s { display: none; }
  .topbar .sub, .topbar .right .hide-sm { display: none; }
  .topbar h1 { font-size: 18px; }
  .create-grid { grid-template-columns: 1fr; }
  .public-top .divider { display: none; }
}
