/* =====================================================================
   ТранспортAi — design system
   Identity: road signage. Asphalt navigation, sign-blue actions,
   lane-marking yellow reserved for "you are here" + brand.
   ===================================================================== */

:root {
    /* palette */
    --asphalt-900: #141b24;
    --asphalt-800: #1b2430;
    --asphalt-700: #263241;
    --asphalt-600: #34424f;
    --asphalt-300: #93a1b0;
    --sign-blue: #1f5fbf;
    --sign-blue-600: #184d9c;
    --sign-blue-50: #e9f0fb;
    --lane-yellow: #f2b705;

    /* semantic */
    --bg: #f2f4f7;
    --surface: #ffffff;
    --surface-2: #f7f9fb;
    --surface-3: #eef1f5;
    --ink: #16202b;
    --ink-2: #3c4a58;
    --muted: #6a7887;
    --line: #dde3ea;
    --line-strong: #c7d0da;
    --primary: var(--sign-blue);
    --primary-hover: var(--sign-blue-600);
    --primary-soft: var(--sign-blue-50);
    --on-primary: #ffffff;
    --focus: #1f5fbf;

    --success: #1e8a57;
    --success-soft: #e3f4ea;
    --warning: #a86a00;
    --warning-soft: #fdf1d6;
    --danger: #c4312b;
    --danger-soft: #fbe6e4;
    --info: #0e7490;
    --info-soft: #e0f2f6;
    --neutral: #5b6877;
    --neutral-soft: #eceff3;

    --nav-bg: var(--asphalt-800);
    --nav-bg-2: var(--asphalt-900);
    --nav-ink: #c9d3dd;
    --nav-ink-strong: #ffffff;
    --nav-hover: var(--asphalt-700);

    /* type */
    --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --fs-xs: 0.75rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.875rem;
    --fs-md: 1rem;
    --fs-lg: 1.25rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 2rem;

    /* space / shape */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
    --r-sm: 6px;
    --r: 8px;
    --r-lg: 12px;
    --shadow-pop: 0 10px 30px rgba(20, 27, 36, 0.16), 0 2px 6px rgba(20, 27, 36, 0.08);
    --sidebar-w: 252px;
    --sidebar-w-collapsed: 68px;
    --topbar-h: 60px;
    --touch: 40px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f151c; --surface: #172029; --surface-2: #1b252f; --surface-3: #212c37;
        --ink: #e6ecf2; --ink-2: #bdc8d3; --muted: #8b99a8; --line: #2a3643; --line-strong: #3a4756;
        --primary: #4d8ae6; --primary-hover: #6a9eec; --primary-soft: #1b2d45; --focus: #7aa9f0;
        --success: #45b981; --success-soft: #16322a; --warning: #e0a53a; --warning-soft: #362a12;
        --danger: #f0716a; --danger-soft: #3a1c1c; --info: #3fb2cf; --info-soft: #132e36;
        --neutral: #9aa7b5; --neutral-soft: #25303b;
        --nav-bg: #111820; --nav-bg-2: #0b1117; --nav-hover: #1c2631;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0f151c; --surface: #172029; --surface-2: #1b252f; --surface-3: #212c37;
    --ink: #e6ecf2; --ink-2: #bdc8d3; --muted: #8b99a8; --line: #2a3643; --line-strong: #3a4756;
    --primary: #4d8ae6; --primary-hover: #6a9eec; --primary-soft: #1b2d45; --focus: #7aa9f0;
    --success: #45b981; --success-soft: #16322a; --warning: #e0a53a; --warning-soft: #362a12;
    --danger: #f0716a; --danger-soft: #3a1c1c; --info: #3fb2cf; --info-soft: #132e36;
    --neutral: #9aa7b5; --neutral-soft: #25303b;
    --nav-bg: #111820; --nav-bg-2: #0b1117; --nav-hover: #1c2631;
    color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    font-feature-settings: "tnum" 1, "locl" 0;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 var(--s3); line-height: 1.25; font-weight: 600; color: var(--ink); }
h1 { font-size: var(--fs-xl); letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
p { margin: 0 0 var(--s3); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--s4) 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--primary-soft); }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; border-radius: var(--r); }
.skip-link:focus { left: 8px; }

/* ---------------------------------------------------------------- app shell */
.app { min-height: 100vh; display: flex; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
    color: var(--nav-ink);
    display: flex; flex-direction: column;
    transition: width .2s ease, transform .25s ease;
}
.sidebar-brand {
    height: var(--topbar-h); display: flex; align-items: center; gap: var(--s3);
    padding: 0 var(--s4); color: var(--nav-ink-strong); font-weight: 600; font-size: var(--fs-md);
    border-bottom: 1px solid rgba(255,255,255,.06); white-space: nowrap; overflow: hidden;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 8px; flex: none; display: grid; place-items: center;
    background: var(--lane-yellow); color: var(--asphalt-900);
}
.brand-mark .icon { stroke-width: 2.2; }
.brand-text small { display: block; font-size: var(--fs-xs); color: var(--asphalt-300); font-weight: 400; }
.nav { flex: 1; overflow-y: auto; padding: var(--s3) var(--s2) var(--s6); scrollbar-width: thin; scrollbar-color: var(--asphalt-600) transparent; }
.nav-item, .nav-group > summary {
    position: relative; display: flex; align-items: center; gap: var(--s3);
    min-height: var(--touch); padding: 8px 12px; border-radius: var(--r);
    color: var(--nav-ink); cursor: pointer; white-space: nowrap; list-style: none; user-select: none;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-item:hover, .nav-group > summary:hover { background: var(--nav-hover); color: var(--nav-ink-strong); text-decoration: none; }
.nav-item.active, .nav-group.has-active > summary { color: var(--nav-ink-strong); }
.nav-item.active { background: var(--nav-hover); }
.nav-item.active::before, .nav-sub .nav-item.active::before {
    content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 3px 3px 0;
    background: var(--lane-yellow);
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-chevron { transition: transform .2s; opacity: .6; }
.nav-group[open] > summary .nav-chevron { transform: rotate(90deg); }
.nav-sub { padding: 2px 0 6px 30px; }
.nav-sub .nav-item { min-height: 36px; padding: 6px 12px; font-size: var(--fs-sm); }
.nav-sub .nav-item.active::before { left: -38px; }
.sidebar-foot { padding: var(--s3) var(--s4); border-top: 1px solid rgba(255,255,255,.06); font-size: var(--fs-xs); color: var(--asphalt-300); white-space: nowrap; overflow: hidden; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); transition: margin-left .2s ease; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
    display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--line);
}
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar-search input { padding-left: 36px; background: var(--surface-2); }
.search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow-pop); max-height: 420px; overflow: auto; display: none; z-index: 50;
}
.search-results.open { display: block; }
.search-results a { display: flex; gap: var(--s3); padding: 9px 12px; color: var(--ink); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a.focused { background: var(--surface-2); text-decoration: none; }
.search-results .sr-type { font-size: var(--fs-xs); color: var(--muted); min-width: 88px; }
.search-results .sr-empty { padding: 12px; color: var(--muted); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: var(--s1); }
.content { padding: var(--s6) var(--s6) var(--s8); flex: 1; width: 100%; max-width: 1600px; }

body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .nav-label, body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-chevron,
body.sidebar-collapsed .nav-sub, body.sidebar-collapsed .sidebar-foot { display: none; }
body.sidebar-collapsed .nav-item, body.sidebar-collapsed .nav-group > summary { justify-content: center; padding: 8px; }

.backdrop { position: fixed; inset: 0; background: rgba(15, 21, 28, .5); z-index: 35; display: none; }

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); width: min(86vw, 300px); box-shadow: var(--shadow-pop); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .backdrop { display: block; }
    .main, body.sidebar-collapsed .main { margin-left: 0; }
    body.sidebar-collapsed .sidebar { width: min(86vw, 300px); }
    body.sidebar-collapsed .nav-label, body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-chevron,
    body.sidebar-collapsed .nav-sub, body.sidebar-collapsed .sidebar-foot { display: revert; }
    .topbar { padding: 0 var(--s3); }
    .content { padding: var(--s4) var(--s4) var(--s8); }
}
@media (max-width: 600px) {
    .topbar-search { display: none; }
    .topbar-search.open { display: block; position: absolute; left: 8px; right: 8px; top: 10px; max-width: none; }
    .hide-sm { display: none !important; }
}
@media (min-width: 601px) { .show-sm { display: none !important; } }

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-start; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--muted); margin: 4px 0 0; font-size: var(--fs-sm); }
.page-head .actions { margin-left: auto; display: flex; gap: var(--s2); flex-wrap: wrap; }
.breadcrumbs { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs span[aria-hidden] { opacity: .5; }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: var(--touch); padding: 8px 14px; border-radius: var(--r);
    border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
    font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); background: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: var(--fs-sm); }
.btn-icon { width: var(--touch); padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn .badge-count { margin-left: 2px; }
.icon-btn { position: relative; }
.icon-btn .dot {
    position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--danger); color: #fff; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
    border: 2px solid var(--surface);
}
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r) 0 0 var(--r); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r) var(--r) 0; }
.btn-group .btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); z-index: 1; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s4) var(--s4); }
.form-grid > * { grid-column: span 12; min-width: 0; }
@media (min-width: 768px) {
    .col-3 { grid-column: span 3 !important; } .col-4 { grid-column: span 4 !important; }
    .col-6 { grid-column: span 6 !important; } .col-8 { grid-column: span 8 !important; }
    .col-9 { grid-column: span 9 !important; } .col-2 { grid-column: span 2 !important; }
}
.form-section { grid-column: span 12; margin-top: var(--s3); padding-top: var(--s4); border-top: 1px solid var(--line); font-weight: 600; color: var(--ink-2); }
.form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.field label, .label { display: block; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
.field .req { color: var(--danger); margin-left: 2px; }
.field label.switch, .field label.check { display: inline-flex; margin-bottom: 0; font-size: var(--fs-base); color: var(--ink); }
.input, .select, .textarea, input[type="text"].input {
    width: 100%; min-height: var(--touch); padding: 8px 11px;
    font: inherit; color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--r);
    transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a7887' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.select[multiple] { background-image: none; padding-right: 11px; min-height: 110px; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input[readonly], .input:disabled, .select:disabled { background: var(--surface-3); color: var(--muted); }
.input-sm, .select.input-sm { min-height: 32px; padding: 4px 9px; font-size: var(--fs-sm); }
.select.input-sm { padding-right: 28px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea,
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: var(--fs-xs); margin-top: 4px; }
.field-help { color: var(--muted); font-size: var(--fs-xs); margin-top: 4px; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r) 0 0 var(--r); }
.input-group .addon { display: inline-flex; align-items: center; padding: 0 11px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r) var(--r) 0; background: var(--surface-3); color: var(--muted); font-size: var(--fs-sm); white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; min-height: var(--touch); }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: var(--touch); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-actions { display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--s5); margin-top: var(--s5); border-top: 1px solid var(--line); }
.file-drop { border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: var(--s4); text-align: center; color: var(--muted); background: var(--surface-2); cursor: pointer; }
.file-drop.dragover { border-color: var(--primary); background: var(--primary-soft); }
@media (max-width: 600px) {
    .form-actions .btn { flex: 1; }
    .input, .select, .textarea { font-size: 16px; } /* prevent iOS zoom */
}

/* ---------------------------------------------------------------- cards / panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card + .card { margin-top: var(--s5); }
.card-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-md); }
.card-head .actions { margin-left: auto; display: flex; gap: var(--s2); flex-wrap: wrap; }
.card-body { padding: var(--s5); }
.card-body.flush { padding: 0; }
.card-foot { padding: var(--s3) var(--s5); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@media (max-width: 600px) { .card-body { padding: var(--s4); } .card-head { padding: var(--s3) var(--s4); } }

.grid { display: grid; gap: var(--s5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1199px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 991px) { .grid-2, .grid-3, .grid-main-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
    .page-head .grow { flex-basis: 100%; }
    .page-head .actions { margin-left: 0; }
}

/* KPI tiles */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s4) var(--s5); display: flex; flex-direction: column; gap: 4px; position: relative; overflow: hidden; min-height: 132px; }
.kpi-label { color: var(--muted); font-size: var(--fs-sm); display: flex; align-items: center; gap: 8px; }
.kpi-value { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
.kpi-value small { font-size: var(--fs-sm); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.kpi-foot { font-size: var(--fs-xs); color: var(--muted); }
.kpi-chart { height: 42px; margin-top: auto; }
.kpi .kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.trend-up { color: var(--success); } .trend-down { color: var(--danger); }

/* definition lists (record details) */
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s4) var(--s6); margin: 0; }
.details div { min-width: 0; }
.details dt { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.details dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.details .wide { grid-column: 1 / -1; }

/* simple list rows (dashboard widgets) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s5); border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- badges / plate */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500; line-height: 1.6; white-space: nowrap; background: var(--neutral-soft); color: var(--neutral); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge.plain::before { display: none; }
.count-pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 600; line-height: 20px; text-align: center; background: var(--surface-3); color: var(--ink-2); }

/* Bulgarian registration plate — the system's signature element */
.plate {
    display: inline-flex; align-items: stretch; height: 24px; border-radius: 4px; overflow: hidden;
    border: 1.5px solid #1c2530; background: #fff; color: #111; font-weight: 600; font-size: 12.5px;
    letter-spacing: .06em; white-space: nowrap; font-family: var(--font); line-height: 1; box-shadow: 0 1px 0 rgba(0,0,0,.08);
    font-feature-settings: "tnum" 1;
}
.plate::before {
    content: "BG"; display: flex; align-items: flex-end; justify-content: center; width: 15px; padding-bottom: 3px;
    background: #1f4fb5; color: #fff; font-size: 7px; letter-spacing: 0; font-weight: 600;
    background-image: radial-gradient(circle at 50% 32%, #f2c500 0 2.2px, transparent 2.6px);
}
.plate span { display: flex; align-items: center; padding: 0 7px; }
.plate-lg { height: 34px; font-size: 18px; }
.plate-lg::before { width: 20px; font-size: 9px; padding-bottom: 4px; }
a:hover .plate { border-color: var(--primary); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table thead th {
    position: sticky; top: 0; z-index: 2; background: var(--surface-2);
    font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2); white-space: nowrap;
    border-bottom: 1px solid var(--line-strong);
}
.table tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table td.text-end, .table th.text-end { text-align: right; white-space: nowrap; }
.table .actions-col { width: 1%; white-space: nowrap; text-align: right; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.table-compact th, .table-compact td { padding: 7px 10px; }
.sort-link { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-link:hover { color: var(--primary); text-decoration: none; }
.sort-link .icon { width: 13px; height: 13px; opacity: .35; }
.sort-link.active { color: var(--primary); }
.sort-link.active .icon { opacity: 1; }
.link-strong { font-weight: 500; }
.text-muted { color: var(--muted); }
.row-actions { display: inline-flex; gap: 2px; }
.row-actions .btn { width: 32px; min-height: 32px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.row-actions .btn:hover { background: var(--surface-3); color: var(--ink); }
.row-actions .btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.table-scroll-y { max-height: 540px; overflow: auto; }

/* data table chrome */
.dt { position: relative; }
.dt-toolbar { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.dt-search { position: relative; flex: 1 1 240px; max-width: 360px; }
.dt-search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.dt-search .input { padding-left: 34px; }
.dt-toolbar .spacer { flex: 1; }
.dt-filters { display: none; padding: var(--s4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.dt-filters.open { display: block; }
.dt-filters .form-grid { gap: var(--s3); }
.dt-filters .filter-actions { display: flex; gap: var(--s2); align-items: flex-end; }
.dt-foot { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; padding: var(--s3) var(--s4); border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--muted); }
.dt-foot .per-page { display: flex; align-items: center; gap: 6px; }
.dt.loading::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--surface) 55%, transparent); border-radius: var(--r-lg); }
.dt.loading .dt-progress { display: block; }
.dt-progress { display: none; position: absolute; top: 0; left: 0; right: 0; height: 2px; overflow: hidden; z-index: 3; }
.dt-progress::after { content: ""; position: absolute; left: -40%; width: 40%; height: 100%; background: var(--primary); animation: dtbar 1s linear infinite; }
@keyframes dtbar { to { left: 100%; } }
.pagination { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.pagination a, .pagination span { min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: var(--r-sm); border: 1px solid var(--line); color: var(--ink-2); background: var(--surface); }
.pagination a:hover { background: var(--surface-3); text-decoration: none; }
.pagination .current { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.pagination .disabled { opacity: .45; }
.pagination .gap { border: 0; background: none; }
.empty { text-align: center; padding: var(--s8) var(--s4); color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: var(--line-strong); margin-bottom: var(--s2); }
.empty p { margin: 4px 0 var(--s3); }

/* Mobile: table rows become cards */
@media (max-width: 767px) {
    .table.responsive thead { display: none; }
    .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
    .table.responsive tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); position: relative; }
    .table.responsive tbody tr:hover td { background: none; }
    .table.responsive td { border: 0; padding: 3px 0; display: flex; gap: var(--s3); justify-content: space-between; align-items: baseline; text-align: right; min-height: 0; }
    .table.responsive td::before { content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); text-align: left; flex: none; max-width: 45%; }
    .table.responsive td.cell-primary { font-size: var(--fs-md); font-weight: 600; text-align: left; justify-content: flex-start; padding-right: 96px; }
    .table.responsive td.cell-primary::before { display: none; }
    .table.responsive td.mobile-hide { display: none; }
    .table.responsive td.actions-col { position: absolute; top: var(--s2); right: var(--s2); width: auto; padding: 0; }
    .table.responsive td.actions-col::before { display: none; }
    .table.responsive tfoot { display: block; }
    .table.responsive tfoot tr { display: flex; flex-wrap: wrap; gap: 8px; }
    .table.responsive tfoot td:empty { display: none; }
    .dt-search { max-width: none; }
    .dt-foot .pagination { margin-left: 0; width: 100%; justify-content: center; }
}

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: var(--s5); }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; min-height: 44px; color: var(--muted); border: 0; background: none; font: inherit; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active, .tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }

/* ---------------------------------------------------------------- dropdown */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; z-index: 60;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
    padding: 6px; display: none;
}
.dropdown.open > .dropdown-menu { display: block; }
.dropdown-menu.left { left: 0; right: auto; }
.dropdown-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; min-height: 36px; }
.dropdown-item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--line); margin: 6px 0; }
.dropdown-header { padding: 6px 10px; font-size: var(--fs-xs); color: var(--muted); }

/* notifications panel */
.notif-menu { width: min(380px, calc(100vw - 24px)); padding: 0; }
.notif-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-head strong { flex: 1; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: var(--ink); }
.notif:hover { background: var(--surface-2); text-decoration: none; }
.notif.unread { background: color-mix(in srgb, var(--primary-soft) 55%, transparent); }
.notif .n-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--info); }
.notif .n-dot.warning { background: var(--warning); } .notif .n-dot.danger { background: var(--danger); } .notif .n-dot.success { background: var(--success); }
.notif .n-title { font-weight: 500; }
.notif .n-body { font-size: var(--fs-sm); color: var(--ink-2); }
.notif .n-meta { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.notif-foot { padding: 10px 14px; text-align: center; font-size: var(--fs-sm); }

/* avatar */
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-weight: 600; font-size: var(--fs-sm); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 72px; height: 72px; font-size: var(--fs-lg); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 4px 8px 4px 4px; border-radius: 999px; border: 1px solid transparent; background: none; cursor: pointer; color: var(--ink); font: inherit; }
.user-chip:hover { background: var(--surface-3); }
.user-chip .u-name { font-weight: 500; line-height: 1.2; text-align: left; }
.user-chip .u-role { font-size: var(--fs-xs); color: var(--muted); }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: var(--s4); background: rgba(15, 21, 28, .55); }
.modal.open { display: flex; }
.modal-dialog { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal-dialog.lg { max-width: 820px; }
.modal-head { display: flex; align-items: center; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: var(--fs-md); flex: 1; }
.modal-body { padding: var(--s5); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 600px) {
    .modal { align-items: flex-end; padding: 0; }
    .modal-dialog { border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92vh; }
    .modal-foot .btn { flex: 1; }
}

/* ---------------------------------------------------------------- toasts / alerts */
.toasts { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 90; display: flex; flex-direction: column; gap: var(--s2); max-width: min(400px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--asphalt-800); color: #fff; box-shadow: var(--shadow-pop); animation: pop .2s ease-out; border-left: 4px solid var(--info); }
.toast.success { border-left-color: #3cc47c; } .toast.error { border-left-color: #f0716a; } .toast.warning { border-left-color: var(--lane-yellow); }
.toast .t-msg { flex: 1; }
.toast button { background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; padding: 0; }
@media (max-width: 600px) { .toasts { left: var(--s3); right: var(--s3); bottom: var(--s3); max-width: none; } }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r); border: 1px solid; margin-bottom: var(--s4); }
.alert-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--ink); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--ink); }
.alert-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--ink); }
.alert-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 30%, transparent); color: var(--ink); }
.alert .icon { margin-top: 1px; }

/* ---------------------------------------------------------------- auth pages */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--surface); }
.auth-visual {
    position: relative; overflow: hidden; color: #fff; padding: 48px;
    background: var(--asphalt-900);
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-visual .road { position: absolute; inset: 0; opacity: .9; }
.auth-visual::after { content: ""; position: absolute; inset: 45% 0 0 0; background: linear-gradient(180deg, transparent, rgba(20,27,36,.92) 55%); }
.auth-visual .brand { position: relative; display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: var(--fs-lg); }
.auth-visual .claim { position: relative; z-index: 1; max-width: 440px; }
.auth-visual .claim h2 { color: #fff; font-size: 2rem; font-weight: 500; line-height: 1.2; letter-spacing: -0.015em; }
.auth-visual .claim p { color: var(--asphalt-300); }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: var(--s6); }
.auth-card .field { margin-bottom: var(--s4); }
.otp-input { font-size: 1.6rem !important; letter-spacing: .5em; text-align: center; font-family: var(--font-mono); padding-left: .5em !important; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: var(--s4); font-size: var(--fs-sm); }
@media (max-width: 860px) {
    .auth-body { grid-template-columns: 1fr; }
    .auth-visual { min-height: 180px; padding: 24px; }
    .auth-visual .claim h2 { font-size: 1.35rem; }
    .auth-visual .claim p { display: none; }
}

/* ---------------------------------------------------------------- GPS */
.gps-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: calc(100vh - var(--topbar-h) - 48px); min-height: 520px; border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.gps-side { display: flex; flex-direction: column; border-right: 1px solid var(--line); min-height: 0; }
.gps-side-head { padding: var(--s3); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--s2); }
.gps-list { overflow-y: auto; flex: 1; }
.gps-vehicle { display: flex; gap: 10px; padding: 11px var(--s3); border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-left: 3px solid transparent; width: 100%; text-align: left; font: inherit; color: var(--ink); }
.gps-vehicle:hover { background: var(--surface-2); }
.gps-vehicle.selected { background: var(--primary-soft); border-left-color: var(--primary); }
.gps-vehicle .gv-main { flex: 1; min-width: 0; }
.gps-vehicle .gv-meta { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gps-vehicle .gv-speed { font-weight: 600; font-size: var(--fs-md); text-align: right; white-space: nowrap; }
.gps-vehicle .gv-speed small { display: block; font-size: var(--fs-xs); font-weight: 400; color: var(--muted); }
.gps-map { position: relative; min-height: 0; }
.gps-map #map, .map-box { position: absolute; inset: 0; }
.map-static { position: relative; height: 420px; border-radius: var(--r-lg); overflow: hidden; border: 1px solid var(--line); }
.gps-panel { position: absolute; right: 12px; top: 12px; z-index: 500; width: 310px; max-height: calc(100% - 24px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); }
.gps-panel[hidden] { display: none; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); }
.metric { background: var(--surface); padding: 10px 12px; }
.metric .m-label { font-size: var(--fs-xs); color: var(--muted); }
.metric .m-value { font-weight: 600; font-size: var(--fs-md); }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--neutral); flex: none; }
.status-dot.moving { background: var(--success); } .status-dot.idle { background: var(--warning); }
.status-dot.stopped { background: var(--neutral); } .status-dot.offline { background: var(--danger); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.veh-marker { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); }
.veh-marker svg { width: 16px; height: 16px; }
.veh-marker.moving { background: var(--success); } .veh-marker.idle { background: #d19000; }
.veh-marker.stopped { background: #5b6877; } .veh-marker.offline { background: #c4312b; }
.veh-label { background: #fff; color: #111; font-weight: 600; font-size: 11px; padding: 1px 5px; border-radius: 3px; border: 1px solid #1c2530; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.leaflet-container { font-family: var(--font); background: var(--surface-3); }
@media (max-width: 991px) {
    .gps-layout { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
    .gps-map { order: -1; min-height: 55vh; }
    .gps-side { border-right: 0; border-top: 1px solid var(--line); }
    .gps-list { max-height: 60vh; }
    .gps-panel { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 55%; }
}

/* ---------------------------------------------------------------- misc */
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.progress { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.progress.warning > span { background: var(--warning); } .progress.danger > span { background: var(--danger); } .progress.success > span { background: var(--success); }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 var(--s4) var(--s3); }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li.done::before { background: var(--primary); }
.ai-box { border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line)); background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%); border-radius: var(--r-lg); padding: var(--s4) var(--s5); }
.ai-box .ai-head { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 8px; color: var(--primary); }
.ai-box .ai-text { white-space: pre-line; }
.ai-box ul { margin: 6px 0; padding-left: 20px; }
.qr { background: #fff; padding: 8px; border-radius: var(--r); display: inline-block; border: 1px solid var(--line); }

.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; } .gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-3 { gap: var(--s3); } .gap-4 { gap: var(--s4); }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0 !important; } .mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); } .mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mb-0 { margin-bottom: 0 !important; } .mb-2 { margin-bottom: var(--s2); } .mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); } .mb-5 { margin-bottom: var(--s5); }
.p-0 { padding: 0 !important; }
.text-end { text-align: right; } .text-center { text-align: center; }
.text-sm { font-size: var(--fs-sm); } .text-xs { font-size: var(--fs-xs); } .text-lg { font-size: var(--fs-lg); }
.fw-600 { font-weight: 600; } .nowrap { white-space: nowrap; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-primary { color: var(--primary); }
.w-100 { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- print */
@media print {
    .sidebar, .topbar, .page-head .actions, .dt-toolbar, .dt-foot, .row-actions, .actions-col, .toasts, .btn { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0; }
    .card { border: 0; }
    body { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
