:root {
    --c-bg: #f6f8fb;
    --c-card: #ffffff;
    --c-text: #1a1a1a;
    --c-muted: #6b7280;
    --c-border: #e5e7eb;
    --c-primary: #1864ab;
    --c-primary-hover: #114e85;
    --c-sidebar: #0f2740;
    --c-ok: #2b8a3e;
    --c-error: #c92a2a;
    --c-warn: #f59f00;
    --c-row-disabled: #f3f4f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: var(--c-bg);
    color: var(--c-text);
    font-size: 14px;
    line-height: 1.5;
}

body.centered {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ── App shell (боковое меню) ──────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 222px;
    flex-shrink: 0;
    background: var(--c-sidebar);
    color: #cdd9e8;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}
.sb-brand {
    color: #fff; font-weight: 800; font-size: 18px;
    padding: 18px 18px 14px; display: flex; gap: 8px; align-items: center;
}
.sb-brand:hover { text-decoration: none; }
.sb-nav { flex: 1; padding: 2px 10px 16px; }
.sb-cap {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px;
    color: #6f8197; margin: 16px 12px 6px; font-weight: 700;
}
.sb-link {
    display: flex; gap: 11px; align-items: center;
    padding: 9px 12px; border-radius: 8px;
    color: #cdd9e8; font-size: 14px; font-weight: 500; margin-bottom: 2px;
}
.sb-link:hover { background: rgba(255,255,255,0.07); text-decoration: none; color: #fff; }
.sb-link.active { background: var(--c-primary); color: #fff; }
.sb-link .em { width: 20px; text-align: center; font-size: 15px; }

.sb-foot {
    border-top: 1px solid rgba(255,255,255,0.10);
    padding: 12px 16px 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.sb-who { display: block; color: #e6edf5; font-size: 13px; font-weight: 600; }
.sb-role { display: block; color: #8aa0b8; font-size: 12px; margin-bottom: 10px; }
.sb-logout {
    width: 100%; text-align: left;
    background: rgba(255,255,255,0.08); border: none; color: #cdd9e8;
    padding: 9px 12px; border-radius: 8px; cursor: pointer; font: inherit;
}
.sb-logout:hover { background: rgba(255,255,255,0.16); color: #fff; }

.app-main { flex: 1; min-width: 0; }

/* Мобильная шапка (видна только на узких экранах) */
.mobile-topbar { display: none; }
.brand-m { font-weight: 800; font-size: 17px; color: var(--c-text); }
.brand-m:hover { text-decoration: none; }
.ham {
    width: 38px; height: 38px; border: none; background: #f1f4f8;
    border-radius: 8px; font-size: 18px; cursor: pointer; line-height: 1;
}
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--c-primary); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.topbar-avatar:hover { text-decoration: none; }

.sb-overlay { display: none; }

.btn-link {
    background: none; border: none; color: var(--c-primary);
    cursor: pointer; font-size: 14px; padding: 0;
}
.btn-link:hover { text-decoration: underline; }
.inline { display: inline; }

@media (max-width: 860px) {
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; height: 100dvh;
        transform: translateX(-100%); transition: transform 0.22s ease; z-index: 60;
        box-shadow: 4px 0 24px rgba(0,0,0,0.25);
    }
    .sidebar.open { transform: translateX(0); }
    .sb-overlay {
        display: block; position: fixed; inset: 0;
        background: rgba(8,16,28,0.5); opacity: 0; pointer-events: none;
        transition: opacity 0.2s; z-index: 55;
    }
    .sb-overlay.open { opacity: 1; pointer-events: auto; }
    .mobile-topbar {
        display: flex; align-items: center; gap: 12px;
        background: #fff; border-bottom: 1px solid var(--c-border);
        box-shadow: var(--shadow); padding: 9px 14px;
        position: sticky; top: 0; z-index: 40;
    }
    .mobile-topbar .brand-m { flex: 1; }
    .container { margin: 16px auto; padding: 0 16px; }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }

/* ── Login card ──────────────────────────────────────────────────────────── */
.login-card {
    background: var(--c-card);
    padding: 32px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    min-width: 320px;
    max-width: 380px;
    width: 100%;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-card p { text-align: center; margin: 0 0 24px; }
.login-card label, .grid-form label {
    display: block;
    margin-bottom: 14px;
}
.login-card label > span, .grid-form label > span {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--c-muted);
}
input[type="text"], input[type="password"], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(24, 100, 171, 0.15);
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-primary { background: var(--c-primary); color: white; width: 100%; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--c-border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}
.btn-sm:hover { background: #f3f4f6; }
/* Маленькая «основная» кнопка (Сохранить и т.п.): без этого правила фон из
   .btn-sm (#fff) перебивает синий из .btn-primary — кнопка становилась белой
   с белым текстом и была почти не видна. */
.btn-sm.btn-primary {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
    width: auto;
}
.btn-sm.btn-primary:hover { background: var(--c-primary-hover); }
.btn-danger { color: var(--c-error); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 13px;
}
.alert-error { background: #fef2f2; color: var(--c-error); border: 1px solid #fecaca; }
.alert-ok { background: #ecfdf5; color: var(--c-ok); border: 1px solid #a7f3d0; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Cards (dashboard) ──────────────────────────────────────────────────── */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    color: var(--c-text);
    transition: transform 0.1s, box-shadow 0.1s;
}
a.card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.08); text-decoration: none; }
.card.disabled { opacity: 0.55; }
.card h3 { margin: 0 0 8px; font-size: 16px; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-block {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.form-block summary { cursor: pointer; padding: 4px 0; }
.grid-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.form-actions { grid-column: 1 / -1; }
.grid-cap {
    grid-column: 1 / -1; font-weight: 700; font-size: 13px;
    color: var(--c-text); margin-top: 6px;
    border-top: 1px solid var(--c-border); padding-top: 10px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
    vertical-align: middle;
}
.data-table th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--c-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}
.data-table tr:last-child td { border-bottom: none; }
.row-disabled { background: var(--c-row-disabled); }
.row-disabled td { color: var(--c-muted); }

.kv { border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.kv th, .kv td { padding: 10px 14px; border-bottom: 1px solid var(--c-border); text-align: left; font-size: 14px; }
.kv th { background: #f9fafb; color: var(--c-muted); font-weight: 600; min-width: 140px; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: none; }

.actions { white-space: nowrap; }
.inline-form { display: inline-flex; gap: 4px; align-items: center; margin-right: 6px; }
.inline-form input { padding: 4px 8px; font-size: 12px; width: 140px; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-dispatcher { background: #dbeafe; color: #1e40af; }
.badge-driver { background: #d1fae5; color: #065f46; }
.badge-draft { background: #f3f4f6; color: #374151; }
.badge-planned { background: #dbeafe; color: #1e40af; }
.badge-progress { background: #fef3c7; color: #92400e; }
.badge-done { background: #d1fae5; color: #065f46; }
.badge-cancel { background: #fee2e2; color: #991b1b; }

/* ── Page header + empty state ──────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.page-header h1 { margin: 0; }
.btn-inline { width: auto; }
.empty-state {
    background: #fff;
    border: 1px dashed var(--c-border);
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
}
.empty-state p { margin: 0 0 16px; color: var(--c-muted); }

.filters {
    display: flex;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}
.filters label { margin: 0; min-width: 180px; }

/* ── Map ────────────────────────────────────────────────────────────────── */
.map-canvas {
    width: 100%;
    height: 480px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    background: #eef2f6;
    margin-bottom: 24px;
}

/* Поля ширины для координат в инлайн-форме */
.inline-form input[name="lat"],
.inline-form input[name="lng"] {
    width: 90px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

/* ── Этап 10.6: автокомплит адреса (2ГИС Suggest) ───────────────────────── */
.coords-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: stretch;
    min-width: 260px;
}
.coords-pair { display: flex; gap: 4px; align-items: center; }
.suggest-wrap { position: relative; }
.suggest-input {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    box-sizing: border-box;
}
.suggest-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 1px solid var(--c-border, #cbd3e0);
    border-radius: 6px;
    margin-top: 2px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.suggest-item {
    padding: 7px 10px;
    font-size: 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f2f6;
    white-space: normal;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: #eef3fb; }

.status-ok { color: var(--c-ok); font-weight: 600; }
.status-off { color: var(--c-error); font-weight: 600; }

.muted { color: var(--c-muted); font-size: 13px; }

/* ── Driver: прогресс + действия по точкам ──────────────────────────── */
.progress-block {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.progress-bar {
    display: flex;
    height: 16px;
    width: 100%;
    background: #f3f4f6;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}
.progress-fill {
    background: var(--c-ok);
    transition: width 0.3s;
}
.progress-fill.skipped { background: var(--c-warn); }
.progress-stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    font-size: 13px;
}

.row-delivered { background: #f0fdf4; }
.row-delivered td { color: #166534; }

.point-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}
.point-form { background: none; }
.point-form summary {
    display: inline-block;
    text-align: center;
    width: 100%;
    list-style: none;
    cursor: pointer;
    font-weight: 600;
}
.point-form summary::-webkit-details-marker { display: none; }
.btn-ok-summary {
    background: #ecfdf5 !important;
    border-color: #a7f3d0 !important;
    color: #065f46;
}
.btn-ok-summary:hover { background: #d1fae5 !important; }
.btn-skip-summary {
    background: #fef3c7 !important;
    border-color: #fde68a !important;
    color: #92400e;
}
.btn-skip-summary:hover { background: #fde68a !important; }
.point-form-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
    padding: 6px;
    background: #f9fafb;
    border-radius: 6px;
}
.point-form-body input[type="text"] { padding: 6px 8px; font-size: 12px; }
.btn-ok-submit { background: var(--c-ok); color: white; border-color: var(--c-ok); }
.btn-ok-submit:hover { background: #1e6f30; }
.btn-skip-submit { background: var(--c-warn); color: white; border-color: var(--c-warn); }
.btn-skip-submit:hover { background: #d68a00; }

/* ── Next-point card (point-by-point Navi для водителя) ─────────────────── */
.next-point-card {
    background: #fff;
    border: 2px solid var(--c-primary);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0 24px;
    box-shadow: 0 4px 12px rgba(24, 100, 171, 0.15);
}
.next-point-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.next-point-badge {
    background: var(--c-primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
}
.next-point-label {
    color: var(--c-muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.next-point-address {
    font-size: 20px;
    font-weight: 600;
    color: var(--c-text);
    margin: 12px 0 20px;
    line-height: 1.3;
}
.btn-next-nav {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 18px;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: 8px;
    text-decoration: none;
}
.btn-next-nav:hover { text-decoration: none; }
.next-point-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.next-point-form summary {
    cursor: pointer;
    list-style: none;
    text-align: center;
}
.next-point-form summary::-webkit-details-marker { display: none; }
.next-point-form[open] summary {
    border-radius: 8px 8px 0 0;
}
.btn-ok-big {
    background: var(--c-ok);
    color: white;
    border: 1px solid var(--c-ok);
    padding: 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    display: block;
    width: 100%;
}
.btn-ok-big:hover { background: #1e6f30; }
.btn-skip-big {
    background: var(--c-warn);
    color: white;
    border: 1px solid var(--c-warn);
    padding: 14px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    display: block;
    width: 100%;
}
.btn-skip-big:hover { background: #d68a00; }
.next-point-form-body {
    background: #f9fafb;
    padding: 12px;
    border-radius: 0 0 8px 8px;
    margin-top: -1px;
    border: 1px solid var(--c-border);
    border-top: none;
}
.next-point-form-body input[type="text"] {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    margin-bottom: 8px;
    border: 1px solid var(--c-border);
    border-radius: 6px;
}
.next-point-hint {
    margin: 14px 0 0;
    font-size: 13px;
    text-align: center;
}

/* На узких экранах кнопки «Доставлено/Пропустить» — в столбик */
@media (max-width: 480px) {
    .next-point-actions { grid-template-columns: 1fr; }
    .next-point-address { font-size: 18px; }
    .btn-next-nav { font-size: 16px; padding: 14px; }
}

/* ── Единый заметный фильтр по дате (п.4) ── */
.date-filter {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 2px solid var(--c-primary);
    border-radius: 10px;
    padding: 7px 14px;
    margin: 6px 0 18px;
    box-shadow: var(--shadow);
}
.date-filter .df-ico { font-size: 20px; line-height: 1; }
.date-filter .df-label {
    color: var(--c-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.date-filter .df-input {
    font-size: 18px;
    font-weight: 800;
    color: var(--c-primary);
    border: none;
    background: transparent;
    padding: 2px 2px;
    cursor: pointer;
    font-family: inherit;
}
.date-filter .df-input:focus { outline: none; }
.date-filter .df-today {
    background: var(--c-primary);
    color: #fff;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}
.date-filter .df-today[hidden] { display: none; }
@media (max-width: 480px) {
    .date-filter { display: flex; width: 100%; flex-wrap: wrap; }
}

/* ── Единый компонент выбора даты date_nav (см. _components.html) ──
   По умолчанию — компактная «лента-сегмент» (офис). Скин «крупная карточка»
   для водителя/ТСД подключается ниже через body.driver-mode / body.tsd-mode. */
.date-nav {
    display: inline-flex;
    align-items: stretch;
    background: #fff;
    border: 1.5px solid var(--c-border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 6px 0 18px;
    vertical-align: middle;
}
.date-nav .dn-nav {
    border: none;
    background: #fff;
    color: var(--c-primary);
    font-size: 20px;
    width: 42px;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-family: inherit;
}
.date-nav .dn-nav:hover { background: #eef4fb; }
.date-nav .dn-face {
    border: none;
    border-left: 1px solid var(--c-border);
    border-right: 1px solid var(--c-border);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 16px;
    font-family: inherit;
}
.date-nav .dn-face:hover { background: #f7faff; }
.date-nav .dn-ico { font-size: 18px; }
.date-nav .dn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}
.date-nav .dn-label {
    font-size: 10px;
    color: var(--c-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .04em;
}
.date-nav .dn-d { font-size: 16px; font-weight: 800; color: var(--c-primary); }
.date-nav .dn-dow {
    font-size: 11px;
    color: var(--c-muted);
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: .03em;
}
.date-nav .dn-today-badge {
    margin-top: 3px;
    background: var(--c-ok);
    color: #fff;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.date-nav .dn-today-badge[hidden] { display: none; }
.date-nav .dn-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}
@media (max-width: 480px) {
    .date-nav { display: flex; width: 100%; }
    .date-nav .dn-face { flex: 1; justify-content: center; }
}

/* Скин «крупная карточка» — водитель и ТСД (большие зоны нажатия). */
body.driver-mode .date-nav,
body.tsd-mode .date-nav {
    align-items: center;
    gap: 14px;
    border: 2px solid var(--c-primary);
    border-radius: 16px;
    padding: 10px 16px;
    overflow: visible;
}
body.driver-mode .date-nav .dn-nav,
body.tsd-mode .date-nav .dn-nav {
    border: 1px solid var(--c-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 24px;
    line-height: 1;
}
body.driver-mode .date-nav .dn-nav:hover,
body.tsd-mode .date-nav .dn-nav:hover {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}
body.driver-mode .date-nav .dn-face,
body.tsd-mode .date-nav .dn-face {
    border: none;
    flex-direction: column;
    align-items: center;
    gap: 0;
    min-width: 160px;
    text-align: center;
    padding: 4px 8px;
}
body.driver-mode .date-nav .dn-ico,
body.tsd-mode .date-nav .dn-ico,
body.driver-mode .date-nav .dn-label,
body.tsd-mode .date-nav .dn-label { display: none; }
body.driver-mode .date-nav .dn-text,
body.tsd-mode .date-nav .dn-text { align-items: center; }
body.driver-mode .date-nav .dn-d,
body.tsd-mode .date-nav .dn-d { font-size: 24px; }
body.driver-mode .date-nav .dn-dow,
body.tsd-mode .date-nav .dn-dow {
    font-size: 13px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    margin-top: 2px;
}
body.driver-mode .date-nav .dn-today-badge,
body.tsd-mode .date-nav .dn-today-badge {
    font-size: 12px;
    padding: 2px 12px;
    text-transform: none;
    letter-spacing: 0;
}
body.driver-mode .date-nav .dn-d,
body.tsd-mode .date-nav .dn-d { white-space: nowrap; }
@media (max-width: 480px) {
    body.driver-mode .date-nav,
    body.tsd-mode .date-nav { display: flex; width: 100%; gap: 8px; padding: 10px 10px; }
    body.driver-mode .date-nav .dn-face,
    body.tsd-mode .date-nav .dn-face { flex: 1; min-width: 0; padding: 4px 2px; }
    body.driver-mode .date-nav .dn-nav,
    body.tsd-mode .date-nav .dn-nav { width: 44px; height: 44px; flex: none; }
    body.driver-mode .date-nav .dn-d,
    body.tsd-mode .date-nav .dn-d { font-size: 20px; }
}

/* ──────────────────────────────────────────────────────────
   ТСД-интерфейс (киоск): шапка сверху + крупные вкладки снизу.
   Только flexbox — без CSS grid (старый WebView Android 5.1).
   ────────────────────────────────────────────────────────── */
.tsd-mode { background: #eef2f7; }
.tsd-shell { display: flex; flex-direction: column; min-height: 100vh; }

/* Тонкая верхняя строка: бренд + пользователь */
.tsd-top {
    position: fixed; top: 0; left: 0; right: 0; height: 32px; z-index: 31;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--c-sidebar); color: #fff; padding: 0 12px;
}
.tsd-brand { font-weight: 700; font-size: 12px; letter-spacing: .2px; }
.tsd-user {
    color: #b9c6d6; font-size: 11px; text-decoration: none; max-width: 55%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Вкладки навигации — СВЕРХУ, сразу под шапкой (хорошо видны) */
.tsd-tabs {
    position: fixed; top: 32px; left: 0; right: 0; height: 44px; z-index: 30;
    display: flex; background: #fff; border-bottom: 1px solid var(--c-border);
    box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.tsd-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px;
    text-decoration: none; color: var(--c-muted); font-size: 13px; font-weight: 600;
    border-bottom: 3px solid transparent;
}
.tsd-tab .ti { font-size: 16px; line-height: 1; }
.tsd-tab.active { color: var(--c-primary); border-bottom-color: var(--c-primary); background: #f5f9ff; }
.tsd-tab:active { background: #eef4fb; }

.tsd-main {
    flex: 1; width: 100%; max-width: 720px; margin: 0 auto;
    padding: 88px 12px 24px;  /* под фикс-шапку (32) + вкладки (44) */
}

/* Компактный, простой вид на ТСД — мельче шрифты */
.tsd-mode h1 { font-size: 17px; margin: 0 0 4px; }
.tsd-mode h2 { font-size: 14px; margin: 16px 0 6px; }
.tsd-mode p, .tsd-mode .muted { font-size: 11px; line-height: 1.35; }
.tsd-mode .btn, .tsd-mode .btn-primary, .tsd-mode .btn-sm { font-size: 13px; }
.tsd-mode .btn, .tsd-mode .btn-primary { padding: 9px 13px; }
.tsd-mode input[type=text], .tsd-mode input[type=date],
.tsd-mode input[type=number], .tsd-mode select { font-size: 14px; }
.tsd-mode .date-filter { width: 100%; box-sizing: border-box; }
.tsd-mode table.data-table { font-size: 12px; }
.tsd-mode table.data-table th, .tsd-mode table.data-table td { padding: 6px 8px; }
.tsd-mode #scan-input { font-size: 17px !important; padding: 11px !important; }
.tsd-mode .page-header { margin-bottom: 8px; }

/* ──────────────────────────────────────────────────────────
   ТСД: узкий экран WVGA 480×800 (4"). Всё строго в пределах
   ширины окна — без горизонтальной прокрутки.
   ────────────────────────────────────────────────────────── */
.tsd-mode { overflow-x: hidden; }
.tsd-mode *, .tsd-mode *::before, .tsd-mode *::after { box-sizing: border-box; }
.tsd-main { overflow-x: hidden; }
.tsd-mode .form-block, .tsd-mode .scan-block,
.tsd-mode input, .tsd-mode select, .tsd-mode textarea { max-width: 100%; }
.tsd-mode #scan-input { width: 100%; }

/* Базовое: таблицы вписываются по ширине, длинные значения переносятся */
.tsd-mode table.data-table { width: 100%; border-collapse: collapse; }
.tsd-mode table.data-table td {
    word-break: break-word; overflow-wrap: anywhere; vertical-align: top;
}
/* Заголовки НЕ рвём по буквам (иначе «СУММА» в столбик) — только по словам */
.tsd-mode table.data-table th {
    word-break: normal; overflow-wrap: normal; white-space: normal; vertical-align: bottom;
}

/* Поля выбора (машина / водитель и пр.) — на всю ширину, подпись сверху.
   !important перебивает инлайн min-width в шаблоне, из-за которого поле не влезало. */
.tsd-mode .form-block .inline-form,
.tsd-mode .card-block .inline-form { display: block; }
.tsd-mode .form-block .inline-form > label,
.tsd-mode .card-block .inline-form > label { display: block; margin: 0 0 4px; }
.tsd-mode .form-block select,
.tsd-mode .card-block select {
    min-width: 0 !important; width: 100% !important; box-sizing: border-box;
    padding: 9px 10px; font-size: 14px;
}

/* Переключатель вида ленты (показывается только на ТСД) */
.feed-view-switch { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.feed-view-switch > span { font-size: 12px; flex: 0 0 auto; }
.feed-view-switch button {
    flex: 1 1 0; min-width: 0; padding: 7px 4px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--c-border); background: #fff; border-radius: 6px;
    color: var(--c-muted);
}
.feed-view-switch button.active {
    background: var(--c-primary); color: #fff; border-color: var(--c-primary);
}

/* ВАРИАНТ 1 — компактная таблица, заголовки-пиктограммы (🏷 Код · 📍 Точка · ⚙) */
.data-table.tv1 { table-layout: fixed; }
.data-table.tv1 th:nth-child(2), .data-table.tv1 td:nth-child(2),
.data-table.tv1 th:nth-child(4), .data-table.tv1 td:nth-child(4) { display: none; }
.data-table.tv1 th:nth-child(1), .data-table.tv1 td:nth-child(1) { width: 36%; }
.data-table.tv1 th:nth-child(3), .data-table.tv1 td:nth-child(3) { width: 38%; }
.data-table.tv1 th:nth-child(5), .data-table.tv1 td:nth-child(5) { width: 26%; }
.data-table.tv1 thead th { font-size: 0; text-align: center; padding: 6px 2px; }
.data-table.tv1 thead th:nth-child(1)::after { content: "🏷"; font-size: 15px; }
.data-table.tv1 thead th:nth-child(3)::after { content: "📍"; font-size: 15px; }
.data-table.tv1 thead th:nth-child(5)::after { content: "⚙"; font-size: 15px; }
.data-table.tv1 td { font-size: 11px; padding: 5px 4px; }
.data-table.tv1 td code { font-size: 11px; }
.data-table.tv1 .actions { display: flex; flex-wrap: wrap; gap: 3px; }
.data-table.tv1 .actions .btn-sm { padding: 4px 6px; font-size: 11px; }
.data-table.tv1 .inline-form { display: inline; }

/* ВАРИАНТ 2 — карточки (короб = карточка) */
.data-table.tv2, .data-table.tv2 tbody, .data-table.tv2 tr, .data-table.tv2 td {
    display: block; width: 100%;
}
.data-table.tv2 thead { display: none; }
.data-table.tv2 tr {
    border: 1px solid var(--c-border); border-radius: 8px; background: #fff;
    padding: 8px 10px; margin-bottom: 8px;
}
.data-table.tv2 td { border: none; padding: 2px 0; }
.data-table.tv2 td:nth-child(2), .data-table.tv2 td:nth-child(4) { display: none; }
.data-table.tv2 td:nth-child(1) { font-size: 15px; font-weight: 700; }
.data-table.tv2 td:nth-child(1)::before { content: "🏷 "; }
.data-table.tv2 td:nth-child(3) { font-size: 12px; color: var(--c-muted); }
.data-table.tv2 td:nth-child(3)::before { content: "📍 "; }
.data-table.tv2 td:nth-child(5) { margin-top: 6px; }
.data-table.tv2 .actions { display: flex; gap: 6px; }
.data-table.tv2 .actions .btn-sm { font-size: 12px; padding: 6px 10px; }
.data-table.tv2 .inline-form { display: inline-flex; }

/* ВАРИАНТ 3 — плотный список (одна строка на короб, с обрезкой …) */
.data-table.tv3, .data-table.tv3 tbody { display: block; width: 100%; }
.data-table.tv3 thead { display: none; }
.data-table.tv3 tr {
    display: flex; align-items: center; gap: 8px;
    border-bottom: 1px solid var(--c-border); padding: 6px 2px;
}
.data-table.tv3 td { display: block; border: none; padding: 0; }
.data-table.tv3 td:nth-child(2), .data-table.tv3 td:nth-child(4) { display: none; }
.data-table.tv3 td:nth-child(1) {
    flex: 0 0 92px; font-size: 12px; font-weight: 700;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.data-table.tv3 td:nth-child(3) {
    flex: 1 1 auto; min-width: 0; font-size: 11px; color: var(--c-muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.data-table.tv3 td:nth-child(5) { flex: 0 0 auto; }
.data-table.tv3 .actions { display: flex; gap: 3px; }
.data-table.tv3 .actions .btn-sm { padding: 4px 6px; font-size: 11px; }
.data-table.tv3 .inline-form { display: inline; }

/* Заметная дата в карточках/деталях (не фильтр, а отображение значения) */
.date-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #e7f0fb;
    color: var(--c-primary);
    border-radius: 8px;
    padding: 2px 9px;
    font-weight: 800;
    font-size: 15px;
    white-space: nowrap;
}
.date-chip::before { content: "📅"; font-size: 14px; }
