:root {
    --bg: #f5f7fa;
    --bg-soft: #eef1f6;
    --surface: #ffffff;
    --surface-2: #fafbfc;
    --text: #0f172a;
    --text-soft: #334155;
    --muted: #64748b;
    --muted-soft: #94a3b8;
    --border: #e5e9f0;
    --border-strong: #cbd5e1;

    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-darker: #1e40af;
    --primary-soft: #dbeafe;
    --primary-text: #1e3a8a;

    --success: #059669;
    --success-dark: #047857;
    --success-soft: #d1fae5;
    --success-text: #065f46;

    --warning: #d97706;
    --warning-soft: #fef3c7;
    --warning-text: #92400e;

    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --danger-soft: #fee2e2;
    --danger-text: #991b1b;

    --indigo-soft: #e0e7ff;
    --indigo-text: #3730a3;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .07), 0 2px 4px -2px rgba(15, 23, 42, .04);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .08), 0 4px 6px -4px rgba(15, 23, 42, .06);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, .08), 0 8px 10px -6px rgba(15, 23, 42, .05);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-dark); }

::selection { background: var(--primary-soft); color: var(--primary-text); }

/* === TOPBAR === */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
    backdrop-filter: saturate(180%) blur(8px);
}
.topbar__inner {
    max-width: 1280px; margin: 0 auto; padding: 0 24px; height: 60px;
    display: flex; align-items: center; gap: 28px;
}
.brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 700; font-size: 16px; color: var(--text); letter-spacing: -.01em;
}
.brand__logo {
    width: 36px; height: 36px; border-radius: 9px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.brand__logo img { display: block; filter: brightness(0) invert(1); }
.brand__sub {
    color: var(--muted-soft); font-weight: 500; font-size: 12px;
    letter-spacing: .08em; margin-left: 2px;
}
.brand:hover { color: var(--text); }
.user-info { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; line-height: 1.2; }
.btn--icon { padding: 8px; }
.btn--icon svg { width: 18px; height: 18px; }

.nav { display: flex; gap: 4px; flex-grow: 1; }
.nav a {
    color: var(--muted); font-weight: 500; font-size: 14px;
    padding: 7px 12px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; gap: 7px;
    transition: all .15s;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav a.active { color: var(--primary); background: var(--primary-soft); }
.nav a svg { width: 16px; height: 16px; opacity: .7; }
.nav a.active svg { opacity: 1; }

.user-block { display: flex; align-items: center; gap: 12px; }
.user-name { font-weight: 600; font-size: 13px; color: var(--text-soft); }

/* === BADGES === */
.badge {
    font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    display: inline-flex; align-items: center; gap: 5px;
    line-height: 1.5;
}
.badge::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}
.badge--admin    { background: var(--danger-soft);  color: var(--danger-text); }
.badge--guard    { background: var(--primary-soft); color: var(--primary-text); }
.badge--active   { background: var(--success-soft); color: var(--success-text); }
.badge--blocked  { background: var(--danger-soft);  color: var(--danger-text); }
.badge--expired  { background: var(--warning-soft); color: var(--warning-text); }
.badge--in       { background: var(--success-soft); color: var(--success-text); }
.badge--out      { background: var(--indigo-soft);  color: var(--indigo-text); }
.badge--plain    { background: var(--bg-soft); color: var(--muted); }
.badge--object   { background: var(--bg-soft); color: var(--muted); }
.badge--object::before { display: none; }
.badge--object svg { width: 12px; height: 12px; }
.badge--lg { font-size: 12px; padding: 5px 12px; }

/* === LAYOUT === */
.container {
    max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px;
}

.page-header {
    display: flex; align-items: center; gap: 16px; margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h1 {
    margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; color: var(--text);
    flex-grow: 1; display: flex; align-items: center; gap: 12px;
}
.page-header__sub { color: var(--muted); font-size: 14px; margin-top: 4px; font-weight: 400; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 18px; color: var(--text); }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; color: var(--text); letter-spacing: -.01em; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 10px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .04em; }

.footer { padding: 30px 0 20px; }
.footer__inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; color: var(--muted-soft); font-size: 12px; }

/* === CARDS === */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.card--soft { background: var(--surface-2); }
.card--padded { padding: 28px; }
.card__title { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card__title h2 { margin: 0; }

/* === STATS === */
.stats {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px;
}
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 14px;
    transition: all .15s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat__icon {
    width: 44px; height: 44px; border-radius: var(--radius-sm); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.stat__icon svg { width: 22px; height: 22px; }
.stat__icon--primary { background: var(--primary-soft); color: var(--primary); }
.stat__icon--success { background: var(--success-soft); color: var(--success); }
.stat__icon--warning { background: var(--warning-soft); color: var(--warning); }
.stat__icon--indigo  { background: var(--indigo-soft);  color: var(--indigo-text); }
.stat__icon--danger  { background: var(--danger-soft);  color: var(--danger); }
.stat__label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.stat__value { font-size: 24px; font-weight: 700; color: var(--text); letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }

/* === FLASH === */
.flash {
    padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px;
    border: 1px solid transparent; font-size: 14px;
    display: flex; align-items: flex-start; gap: 10px;
}
.flash::before { font-size: 16px; flex-shrink: 0; }
.flash--success { background: var(--success-soft); color: var(--success-text); border-color: #a7f3d0; }
.flash--success::before { content: '✓'; font-weight: bold; }
.flash--error   { background: var(--danger-soft);  color: var(--danger-text);  border-color: #fecaca; }
.flash--error::before { content: '✕'; font-weight: bold; }
.flash--info    { background: var(--primary-soft); color: var(--primary-text); border-color: #bfdbfe; }
.flash--info::before { content: 'ⓘ'; }
.flash--warning { background: var(--warning-soft); color: var(--warning-text); border-color: #fde68a; }
.flash--warning::before { content: '⚠'; }

/* === FORMS === */
.form-grid {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px;
}
.form-grid .full { grid-column: 1 / -1; }

label {
    display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 6px;
    font-weight: 500;
}
label .req { color: var(--danger); }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="date"], input[type="datetime-local"], input[type="number"],
input[type="search"], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: 14px; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--muted-soft); }
input:hover, select:hover, textarea:hover { border-color: var(--muted-soft); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
textarea { min-height: 88px; resize: vertical; font-family: inherit; }

select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
    padding-right: 36px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
    line-height: 1.3; transition: all .15s; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn--primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37, 99, 235, .2); }
.btn--primary:hover { background: var(--primary-dark); color: #fff; box-shadow: 0 4px 8px rgba(37, 99, 235, .25); }

.btn--success { background: var(--success); color: #fff; box-shadow: 0 1px 2px rgba(5, 150, 105, .2); }
.btn--success:hover { background: var(--success-dark); color: #fff; box-shadow: 0 4px 8px rgba(5, 150, 105, .25); }

.btn--danger { background: var(--danger); color: #fff; box-shadow: 0 1px 2px rgba(220, 38, 38, .2); }
.btn--danger:hover { background: var(--danger-dark); color: #fff; }

.btn--ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border-strong); }
.btn--ghost:hover { background: var(--bg-soft); color: var(--text); border-color: var(--muted-soft); }

.btn--link { background: transparent; color: var(--primary); padding-left: 4px; padding-right: 4px; }
.btn--link:hover { color: var(--primary-dark); background: transparent; }

.btn--lg { padding: 14px 22px; font-size: 16px; gap: 10px; }
.btn--lg svg { width: 20px; height: 20px; }
.btn--block { display: flex; width: 100%; }
.btn--xl { padding: 18px 24px; font-size: 17px; font-weight: 700; gap: 12px; }
.btn--xl svg { width: 22px; height: 22px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* === TABLE === */
.table-wrap {
    overflow-x: auto; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; }
th {
    background: var(--surface-2); font-size: 11px; text-transform: uppercase;
    color: var(--muted); letter-spacing: .06em; font-weight: 600;
    border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
td { border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }

.cell-muted { color: var(--muted); font-size: 12px; }
.cell-num { font-variant-numeric: tabular-nums; }
.cell-strong { font-weight: 600; color: var(--text); }

.empty-row td {
    text-align: center; padding: 48px 16px !important;
    color: var(--muted); font-size: 14px;
}

/* === TOOLBAR === */
.toolbar {
    display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 18px;
}
.toolbar .grow { flex-grow: 1; }
.toolbar h1 { margin: 0; }

/* === FILTERS === */
.filters {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; align-items: end;
}
.filters .full { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }

/* === KEY-VALUE === */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 10px 20px; }
.kv dt { color: var(--muted); font-weight: 500; font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; color: var(--text); font-size: 14px; }

/* === QR === */
.qr-block {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 20px; background: linear-gradient(180deg, #fff, #fafbfc);
    border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.qr-block img {
    width: 240px; height: 240px;
    background: #fff; padding: 8px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.qr-block code {
    word-break: break-all; background: var(--bg-soft); padding: 8px 10px;
    border-radius: var(--radius-sm); font-size: 11px; color: var(--text-soft);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    width: 100%; box-sizing: border-box;
}

/* === SPLIT LAYOUT === */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }

/* === CHECK PAGE (на смартфоне у охранника) === */
.check-page { max-width: 460px; margin: 20px auto; }
.check-page h1 { font-size: 22px; }
.status-banner {
    padding: 18px 20px; border-radius: var(--radius); font-weight: 700; text-align: center;
    margin-bottom: 18px; font-size: 17px; letter-spacing: -.01em;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}
.status-banner svg { width: 24px; height: 24px; }
.status-banner--ok       { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: var(--success-text); border: 1px solid #6ee7b7; }
.status-banner--blocked  { background: linear-gradient(135deg, #fee2e2, #fecaca); color: var(--danger-text); border: 1px solid #fca5a5; }
.status-banner--expired  { background: linear-gradient(135deg, #fef3c7, #fde68a); color: var(--warning-text); border: 1px solid #fcd34d; }

.big-num {
    font-size: 32px; font-weight: 800; letter-spacing: .02em; text-align: center;
    margin: 0 0 16px; color: var(--text); font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    padding: 14px; background: var(--bg-soft); border-radius: var(--radius); border: 1px solid var(--border);
}

/* === LOGIN === */
.login-bg {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background:
        radial-gradient(circle at 20% 30%, rgba(37, 99, 235, .08), transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(99, 102, 241, .08), transparent 50%),
        var(--bg);
}
.login-card {
    width: 100%; max-width: 400px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 32px; box-shadow: var(--shadow-xl);
}
.login-card__head { text-align: center; margin-bottom: 24px; }
.login-card__logo {
    width: 64px; height: 64px; border-radius: var(--radius); margin: 0 auto 16px;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.login-card__logo img { display: block; filter: brightness(0) invert(1); }
.login-card__logo svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card__sub { color: var(--muted); font-size: 13px; margin: 0; }
.login-field { margin-bottom: 14px; }

/* === CHECK LIST === */
.check-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px; background: var(--surface-2);
}
.check-list__item {
    display: flex; align-items: flex-start; gap: 10px; padding: 9px 12px;
    background: var(--surface); border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; transition: all .12s;
    margin-bottom: 0; color: var(--text);
}
.check-list__item:hover { border-color: var(--border-strong); }
.check-list__item input[type="checkbox"] {
    width: 16px; height: 16px; margin-top: 2px; flex-shrink: 0; accent-color: var(--primary);
    cursor: pointer;
}
.check-list__item span { display: flex; flex-direction: column; gap: 2px; line-height: 1.3; min-width: 0; }
.check-list__item small { font-size: 12px; }
.check-list__item:has(input:checked) {
    background: var(--primary-soft); border-color: var(--primary);
}
.check-list__all {
    grid-column: 1 / -1; background: transparent !important;
    border: 1px dashed var(--border-strong) !important;
}

/* === DASHBOARD === */
.kpi-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--primary);
}
.kpi--inside::before { background: #6366f1; }
.kpi--in::before     { background: var(--success); }
.kpi--period::before { background: var(--primary); }
.kpi--avg::before    { background: var(--warning); }
.kpi--active::before { background: #0891b2; }
.kpi__label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.kpi__value { font-size: 30px; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 4px; }
.kpi__sub { font-size: 12px; color: var(--muted); }

.dash-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px;
}
.dash-grid > .card { margin-bottom: 0; }

.empty-state { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* hourly bar chart */
.bar-chart {
    display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px;
    align-items: end; height: 160px; padding: 8px 4px 0;
}
.bar-chart__col { display: flex; flex-direction: column; align-items: stretch; height: 100%; gap: 4px; }
.bar-chart__bar {
    flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-end;
    background: var(--bg-soft); border-radius: 4px 4px 0 0; min-height: 6px; overflow: hidden;
    transition: filter .15s;
}
.bar-chart__col:hover .bar-chart__bar { filter: brightness(0.95); }
.bar-chart__seg--in  { background: var(--success); }
.bar-chart__seg--out { background: #6366f1; }
.bar-chart__label { font-size: 10px; color: var(--muted); text-align: center; height: 14px; }
.legend {
    display: flex; gap: 16px; justify-content: center; margin-top: 6px;
    font-size: 12px; color: var(--muted);
}
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* horizontal bars (top vehicles, object load) */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbars__row {
    display: grid; grid-template-columns: minmax(120px, 1.3fr) 2fr 50px;
    gap: 12px; align-items: center; font-size: 13px;
}
.hbars__name { display: flex; gap: 8px; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars__name strong, .hbars__name a { font-weight: 600; color: var(--text); }
.hbars__rank { font-size: 11px; color: var(--muted); font-weight: 700; }
.hbars__name small { font-size: 11px; }
.hbars__track { height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.hbars__fill  { height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s; }
.hbars__val   { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; font-variant-numeric: tabular-nums; }

/* currently inside list */
.inside-list { display: flex; flex-direction: column; gap: 4px; }
.inside-row {
    display: grid; grid-template-columns: 8px 1fr 1.4fr 1.4fr auto;
    gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm);
    color: var(--text); font-size: 13px; transition: background .12s;
}
.inside-row:hover { background: var(--surface-2); text-decoration: none; }
.inside-dot { width: 8px; height: 8px; border-radius: 50%; }
.inside-num { font-weight: 700; }
.inside-driver { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inside-obj { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inside-time { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* journey */
.journey-summary {
    display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 16px;
    background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13px;
}
.journey-legend {
    display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; font-size: 12px;
}
.journey-legend__item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.journey-legend__item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.journey-flow {
    display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
    padding: 8px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.journey-stop {
    flex: 0 1 220px; min-width: 200px; padding: 12px 16px; margin: 8px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: #fff; border-left: 4px solid var(--stop-color, var(--primary));
    box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px;
}
.journey-stop__name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.journey-stop__name svg { width: 14px; height: 14px; color: var(--stop-color); }
.journey-stop__live   { font-size: 10px; padding: 2px 7px; background: var(--success-soft); color: var(--success-text); border-radius: 999px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.journey-stop__orphan { font-size: 10px; padding: 2px 7px; background: var(--bg-soft); color: var(--muted); border-radius: 999px; }
.journey-stop__time { font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.journey-stop__dur  { font-size: 12px; color: var(--muted); }

.journey-transit {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 8px 4px; min-width: 70px; color: var(--muted); font-size: 11px; gap: 4px;
}
.journey-transit svg { width: 24px; height: 24px; opacity: .55; }
.journey-transit span { font-weight: 600; white-space: nowrap; }

@media (max-width: 1100px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
    .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi__value { font-size: 24px; }
    .bar-chart { height: 120px; }
    .inside-row { grid-template-columns: 8px 1fr 1fr auto; }
    .inside-driver { display: none; }
    .journey-stop { flex-basis: 100%; }
    .journey-transit { width: 100%; flex-direction: row; padding: 6px 0; }
    .journey-transit svg { transform: rotate(90deg); }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* === SCAN PAGE === */
.scan-page {
    max-width: 480px; margin: 8px auto; display: flex; flex-direction: column; gap: 12px;
}
.scan-info {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 14px; font-size: 13px; color: var(--text-soft);
    display: flex; gap: 10px; align-items: flex-start; line-height: 1.45;
}
.scan-info svg { flex-shrink: 0; color: var(--primary); margin-top: 2px; }

.scan-reader {
    width: 100%; aspect-ratio: 1; background: #000;
    border-radius: var(--radius); overflow: hidden; position: relative;
    box-shadow: var(--shadow-md);
}
.scan-reader video,
.scan-reader > div {
    width: 100% !important; height: 100% !important;
    object-fit: cover; max-width: 100%;
}
.scan-reader__placeholder {
    position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
    align-items: center; justify-content: center; color: rgba(255,255,255,.7);
    font-size: 14px; text-align: center; padding: 20px;
}
.scan-reader__placeholder svg { opacity: .55; }

.scan-error {
    background: var(--danger-soft); color: var(--danger-text); border: 1px solid #fecaca;
    padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
    line-height: 1.5;
}
.scan-error:empty { display: none; padding: 0; border: 0; }

.scan-actions { display: grid; gap: 8px; }

.scan-cta { margin-bottom: 18px; }
.scan-again { margin-bottom: 14px; }

/* библиотека рисует свой select камеры — поджимаем */
#reader__dashboard_section, #reader__scan_region img { display: none !important; }

/* === DISCREPANCY === */
.discrepancy {
    margin-top: 14px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.discrepancy > summary {
    list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 600;
    color: var(--warning-text); background: var(--warning-soft);
    display: flex; align-items: center; gap: 8px; transition: background .15s;
}
.discrepancy > summary::-webkit-details-marker { display: none; }
.discrepancy > summary::before {
    content: '+'; font-size: 18px; font-weight: 400; color: var(--muted);
    width: 20px; display: inline-flex; justify-content: center;
}
.discrepancy[open] > summary::before { content: '−'; }
.discrepancy > summary:hover { background: #fde68a; }
.discrepancy__body {
    padding: 16px; display: flex; flex-direction: column; gap: 10px;
    font-size: 13px; line-height: 1.5; color: var(--text-soft);
}
.discrepancy__body p { margin: 0; }
.discrepancy__body .btn { margin-top: 6px; }

.duration-picker {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px;
    margin-top: 4px;
}
.duration-picker__label { font-weight: 600; color: var(--text); margin: 0; font-size: 13px; }
.duration-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.duration-q {
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    color: var(--text-soft); transition: all .12s;
}
.duration-q:hover { border-color: var(--primary); color: var(--primary); }
.duration-q--active {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.duration-custom { display: flex; gap: 8px; align-items: center; }
.duration-custom input { flex: 1; max-width: 220px; }
.duration-picker p.muted { font-size: 12px; margin: 0; }

/* === GUARD HOME === */
.guard-home { max-width: 880px; margin: 0 auto; }
.guard-home__hero {
    text-align: center; padding: 32px 20px 24px;
}
.guard-home__logo {
    width: 64px; height: 64px; border-radius: var(--radius); margin: 0 auto 16px;
    background: var(--primary); display: flex; align-items: center; justify-content: center;
}
.guard-home__logo img { display: block; filter: brightness(0) invert(1); }
.guard-home__hero h1 { font-size: 26px; margin: 0 0 6px; }
.guard-home__sub { color: var(--muted); margin: 0; font-size: 15px; }

.guard-home__grid {
    display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; margin-bottom: 16px;
}
.guard-home__card { margin-bottom: 0; }
.guard-home__card h2 { display: flex; align-items: center; gap: 8px; }
.guard-home__metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding-top: 4px; }
.guard-home__metric {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 16px; text-align: center;
}
.guard-home__metric-num { font-size: 32px; font-weight: 800; color: var(--primary); letter-spacing: -.02em; line-height: 1.05; }
.guard-home__metric-label { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }

.guard-home__instructions { padding: 24px 28px; }
.guard-home__steps { padding-left: 22px; line-height: 1.7; color: var(--text-soft); }
.guard-home__steps li { margin-bottom: 8px; }
.guard-home__steps strong { color: var(--text); }
.guard-home__note {
    margin-top: 16px; padding: 12px 14px; background: var(--bg-soft);
    border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); line-height: 1.5;
}

@media (max-width: 720px) {
    .guard-home__grid { grid-template-columns: 1fr; }
    .guard-home__hero { padding: 20px 12px 16px; }
    .guard-home__hero h1 { font-size: 22px; }
}

/* === MISC === */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.no-wrap { white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.row-actions { display: inline-flex; gap: 4px; }
.row-actions .btn { padding: 6px 12px; font-size: 13px; font-weight: 500; }

/* === RESPONSIVE === */
@media (max-width: 960px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .split { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .container { padding: 18px 14px 40px; }
    .topbar__inner { padding: 0 14px; height: auto; padding-top: 12px; padding-bottom: 12px;
        flex-wrap: wrap; gap: 12px; }
    .nav { width: 100%; order: 3; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .nav a { white-space: nowrap; }
    .brand__sub { display: none; }
    .form-grid, .filters { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { padding-top: 8px; }
    .qr-block img { width: 220px; height: 220px; }
    h1 { font-size: 20px; }
    .user-name { display: none; }
}

@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
}

/* === PRINT === */
@media print {
    .topbar, .footer, .actions, .toolbar, .filters, .nav, .user-block { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; }
    .qr-block img { width: 280px; height: 280px; }
}
