/* ============================================================
   V2 APP.CSS — ПОЛНЫЙ ФАЙЛ СТИЛЕЙ
   ============================================================ */

:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0891b2;
    --radius: 18px;
    --radius-sm: 13px;
    --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.45;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.muted {
    color: var(--muted);
}

code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text);
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.24);
}

.brand strong {
    display: block;
    font-size: 16px;
    line-height: 1.1;
}

.brand small {
    color: var(--muted);
    font-size: 12px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.provider-badge,
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.ghost-link {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: all 0.2s ease;
}

.ghost-link:hover {
    color: var(--danger);
    border-color: var(--danger);
}

/* ============================================================
   V2 NAVIGATION
   ============================================================ */

.v2-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.v2-nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.v2-nav-inner::-webkit-scrollbar {
    display: none;
}

.v2-nav-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 18px;
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.v2-nav-tab i {
    font-size: 14px;
}

.v2-nav-tab:hover {
    color: var(--text);
    background: var(--surface-2);
}

.v2-nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============================================================
   PAGE / LAYOUT / PANELS
   ============================================================ */

.page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.layout {
    display: grid;
    grid-template-columns: 460px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-head {
    padding: 20px 22px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.panel-head h1,
.panel-head h2 {
    margin: 0;
    font-size: 24px;
    letter-spacing: -0.02em;
}

.panel-head p {
    margin: 6px 0 0;
    max-width: 420px;
    color: var(--muted);
}

.panel-body {
    padding: 20px 22px 22px;
}

.composer {
    position: sticky;
    top: 84px;
}

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 18px;
    font-weight: 600;
    border: 1px solid transparent;
}

.alert.warning {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.16);
}

.alert.error {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.15);
}

.alert.success {
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
    border-color: rgba(5, 150, 105, 0.15);
}

/* ============================================================
   STATUS BADGE
   ============================================================ */

.status-badge {
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.status-badge.open {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
}

.status-badge.closed {
    background: rgba(220, 38, 38, 0.1);
    color: var(--danger);
}

.status-badge.online {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.12);
    color: var(--muted);
}

/* ============================================================
   TABS
   ============================================================ */

.tabs {
    display: inline-flex;
    gap: 6px;
    padding: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    margin-bottom: 18px;
}

.tab {
    border: 0;
    background: transparent;
    padding: 9px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    color: var(--muted);
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

/* ============================================================
   FORMS
   ============================================================ */

.field {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--muted);
}

input[type="text"],
input[type="time"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

textarea {
    resize: vertical;
    min-height: 74px;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.hint {
    display: block;
    margin-top: 7px;
    color: var(--muted);
    font-size: 12px;
}

.params-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr 0.8fr;
    gap: 12px;
}

.km-wrap {
    position: relative;
}

.km-source {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: 800;
    color: var(--success);
    background: rgba(5, 150, 105, 0.1);
    padding: 4px 8px;
    border-radius: 999px;
    pointer-events: none;
}

.km-source:empty {
    display: none;
}

/* ============================================================
   AUTOCOMPLETE
   ============================================================ */

.place-field {
    margin-bottom: 12px;
}

.autocomplete {
    position: relative;
}

.autocomplete input {
    padding-right: 42px;
}

.clear-input {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.clear-input:hover {
    background: var(--border);
    color: var(--text);
}

.suggest {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 40;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow: auto;
    padding: 6px;
}

.suggest-item {
    width: 100%;
    border: 0;
    background: transparent;
    padding: 10px 11px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 4px 10px;
    align-items: center;
}

.suggest-item:hover {
    background: var(--surface-2);
}

.suggest-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}

.suggest-badge.type-location {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    border-color: rgba(37, 99, 235, 0.14);
}

.suggest-badge.type-recent {
    background: rgba(217, 119, 6, 0.08);
    color: var(--warning);
    border-color: rgba(217, 119, 6, 0.15);
}

.suggest-badge.type-address {
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
    border-color: rgba(5, 150, 105, 0.15);
}

.suggest-badge.type-create {
    background: rgba(17, 24, 39, 0.05);
    color: var(--text);
}

.suggest-label {
    font-weight: 700;
    grid-column: 2;
}

.suggest-sub {
    grid-column: 2;
    color: var(--muted);
    font-size: 12px;
}

.place-badge {
    min-height: 20px;
    margin-top: 7px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.selected-badge,
.coords-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
}

.selected-badge {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.coords-badge {
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
}

/* ============================================================
   SWAP / BUTTONS
   ============================================================ */

.swap-row {
    display: flex;
    justify-content: center;
    margin: 2px 0 12px;
}

.swap-btn {
    width: 38px;
    height: 38px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 999px;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.2s ease;
}

.swap-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn.primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.btn.primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn.secondary {
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn.danger {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.btn.danger:hover:not(:disabled) {
    background: rgba(220, 38, 38, 0.15);
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 12px;
}

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

/* ============================================================
   LINK TAB
   ============================================================ */

.link-result-box {
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 18px;
    padding: 16px;
    margin-top: 16px;
}

.link-result-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.link-result-top strong {
    font-size: 18px;
}

.link-points {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.link-point {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 9px 11px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    font-size: 14px;
}

.link-point-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: space-between;
}

.link-point-num {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.link-point-route {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.link-point-route i {
    color: var(--muted);
    font-size: 12px;
}

.link-point-km {
    font-weight: 800;
    color: var(--success);
    white-space: nowrap;
}

.link-result-actions {
    margin-top: 14px;
}

/* ============================================================
   LINK COMMENTS — комментарии к участкам маршрута
   ============================================================ */

.link-comment-hint {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: rgba(37, 99, 235, 0.06);
    border: 1px solid rgba(37, 99, 235, 0.15);
    border-radius: 12px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.5;
}

.link-comment-hint i {
    color: var(--primary);
    margin-top: 2px;
    flex-shrink: 0;
}

.link-comment-field {
    display: flex;
    padding-left: 34px;
}

.link-comment-field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-comment-field input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.link-comment-field input::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.link-single-comment {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
}

.link-single-comment label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.link-single-comment textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    outline: none;
    resize: vertical;
    min-height: 56px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-single-comment textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ============================================================
   TIMELINE / TRIP LIST
   ============================================================ */

.empty-state {
    padding: 42px 20px;
    text-align: center;
    color: var(--muted);
}

.empty-state i {
    font-size: 42px;
    opacity: 0.35;
    display: block;
    margin-bottom: 10px;
}

.trip-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trip-item {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.trip-item:hover {
    border-color: rgba(37, 99, 235, 0.35);
    transform: translateY(-1px);
}

.trip-time {
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
}

.trip-time span {
    display: block;
    margin-top: 2px;
    font-weight: 600;
}

.trip-route {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.trip-route i {
    color: var(--muted);
    font-size: 12px;
}

.trip-comment {
    width: 100%;
    color: var(--muted);
    font-size: 13px;
}

.trip-km {
    padding: 8px 11px;
    border-radius: 999px;
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
    font-weight: 800;
    white-space: nowrap;
}

.trip-photo-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
}

/* ============================================================
   TOAST
   ============================================================ */

#toastContainer {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 250px;
    max-width: 360px;
    padding: 13px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.25s ease;
}

.toast.success {
    border-color: rgba(5, 150, 105, 0.22);
}

.toast.success i {
    color: var(--success);
}

.toast.error {
    border-color: rgba(220, 38, 38, 0.22);
}

.toast.error i {
    color: var(--danger);
}

.toast.hide {
    opacity: 0;
    transform: translateX(18px);
    transition: all 0.3s ease;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   MODALS
   ============================================================ */

body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 20px;
}

.modal-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    width: 100%;
    max-width: 760px;
    max-height: 90vh;
    overflow: auto;
    padding: 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

.modal-small {
    max-width: 480px;
}

.modal-large {
    max-width: 1100px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ============================================================
   ADMIN STATS
   ============================================================ */

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.admin-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    text-align: center;
}

.admin-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
}

.admin-stat-label {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

/* ============================================================
   ADMIN GRID
   ============================================================ */

.admin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.admin-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.admin-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.1);
}

.admin-card-icon {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 12px;
}

.admin-card h3 {
    margin: 0 0 6px;
    font-size: 16px;
}

.admin-card p {
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}

/* ============================================================
   ADMIN FORM GRID
   ============================================================ */

.admin-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.admin-form-grid .field-wide {
    grid-column: 1 / -1;
}

.address-row {
    display: flex;
    gap: 10px;
}

.address-row input {
    flex: 1;
}

/* ============================================================
   BADGES (COORD / TYPE / KM / TIME)
   ============================================================ */

.coord-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.coord-badge.ok {
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
}

.coord-badge.missing {
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
}

.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.type-badge.official {
    background: rgba(37, 99, 235, 0.08);
    color: var(--primary);
}

.type-badge.custom {
    background: rgba(217, 119, 6, 0.08);
    color: var(--warning);
}

.km-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(5, 150, 105, 0.08);
    color: var(--success);
}

.time-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(8, 145, 178, 0.08);
    color: var(--info);
    margin-right: 4px;
}

/* ============================================================
   CHECKBOX
   ============================================================ */

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--surface);
}

.table thead {
    background: var(--surface-2);
}

.table th {
    padding: 13px 14px;
    text-align: left;
    font-weight: 700;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tbody tr {
    transition: background 0.15s ease;
}

.table tbody tr:hover {
    background: var(--surface-2);
}

.table tfoot td,
.table tfoot th {
    background: var(--surface-2);
    font-weight: 700;
}

/* ============================================================
   ACTIONS CELL
   ============================================================ */

.actions-cell {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

body.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.18), transparent 30%),
        radial-gradient(circle at bottom right, rgba(79, 70, 229, 0.16), transparent 28%),
        var(--bg);
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 430px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    padding: 30px 24px;
    text-align: center;
}

.login-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 14px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.16);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.login-header h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

.login-header p {
    margin: 0;
    opacity: 0.92;
}

.login-body {
    padding: 24px;
}

.login-body .field {
    margin-bottom: 18px;
}

.login-body label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.login-body input[type="text"],
.login-body input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-body input[type="text"]:focus,
.login-body input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.login-body input[type="text"]::placeholder,
.login-body input[type="password"]::placeholder {
    color: var(--muted);
}

.login-submit {
    width: 100%;
    margin-top: 12px;
    padding: 14px 18px;
    font-size: 15px;
    font-weight: 800;
}

.login-error {
    padding: 14px 18px;
    border-radius: 16px;
    margin-bottom: 18px;
    font-weight: 600;
    background: rgba(220, 38, 38, 0.08);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ============================================================
   LINE CHART (SVG) — ГРАФИК ДИНАМИКИ КИЛОМЕТРАЖА
   ============================================================ */

.line-chart-container {
    display: flex;
    gap: 12px;
    height: 340px;
    margin: 20px 0;
}

.line-chart-container .chart-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-end;
    align-self: stretch;
    height: 100%;
    padding: 10px 8px 30px 0;
    min-width: 70px;
    text-align: right;
}

.line-chart-container .y-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 600;
    line-height: 1;
}

.line-chart-area {
    flex: 1;
    position: relative;
    min-width: 0;
    border-left: 2px solid var(--border);
    border-bottom: 2px solid var(--border);
}

.line-chart-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}

.chart-point-group {
    cursor: pointer;
}

.chart-point {
    transition: all 0.2s ease;
}

.chart-point-group:hover .chart-point {
    r: 6;
    stroke-width: 3;
    filter: drop-shadow(0 0 6px rgba(37, 99, 235, 0.6));
}

.chart-point-group:hover .hover-line {
    opacity: 0.4 !important;
}

.hover-area {
    cursor: pointer;
}

.hover-line {
    transition: opacity 0.2s ease;
}

/* ============================================================
   PROGRESS BAR (для топ-5)
   ============================================================ */

.progress-bar-container {
    background: var(--surface-2);
    border-radius: 999px;
    height: 24px;
    overflow: hidden;
    min-width: 120px;
    border: 1px solid var(--border);
}

.progress-bar {
    background: linear-gradient(135deg, #059669, #34d399);
    height: 100%;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    transition: width 0.5s ease;
    white-space: nowrap;
    min-width: 40px;
}

/* ============================================================
   PHOTO UPLOAD ZONE
   ============================================================ */

.photo-upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--surface-2);
}

.photo-upload-zone:hover,
.photo-upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

.photo-upload-zone .upload-placeholder i {
    font-size: 32px;
    color: var(--muted);
    margin-bottom: 8px;
    display: block;
}

.photo-upload-zone .upload-placeholder p {
    margin: 8px 0;
    color: var(--muted);
    font-size: 14px;
}

.photo-upload-zone .upload-placeholder small {
    color: var(--muted);
    font-size: 12px;
}

.photo-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.photo-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
}

.photo-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-preview-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 10px;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-preview-size {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 10px;
}

.photo-preview-remove {
    position: absolute;
    top: 4px;
    left: 4px;
    background: var(--danger);
    color: #fff;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.photo-preview-remove:hover {
    transform: scale(1.15);
}

/* ============================================================
   DARK THEME — переопределение переменных
   ============================================================ */

[data-theme="dark"] {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #232733;
    --text: #e4e6eb;
    --muted: #9ca3af;
    --border: #2d3140;
    --primary: #667eea;
    --primary-dark: #5a6fd6;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .topbar {
    background: rgba(26, 29, 39, 0.92);
}

[data-theme="dark"] .brand-icon {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

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

    .composer {
        position: static;
    }
}

@media (max-width: 768px) {
    .line-chart-container {
        height: 260px;
    }

    .line-chart-container .chart-y-axis {
        min-width: 50px;
    }

    .line-chart-container .y-label {
        font-size: 9px;
    }

    .params-grid {
        grid-template-columns: 1fr;
    }

    .trip-item {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .trip-km {
        justify-self: start;
    }

    .topbar-inner {
        flex-wrap: wrap;
    }

    .suggest-item {
        grid-template-columns: 1fr;
    }

    .suggest-badge {
        justify-self: start;
    }

    .suggest-label,
    .suggest-sub {
        grid-column: 1;
    }

    .admin-form-grid {
        grid-template-columns: 1fr;
    }

    .address-row {
        flex-direction: column;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .actions-cell {
        flex-direction: column;
        align-items: stretch;
    }

    .actions-cell .btn {
        width: 100%;
        justify-content: center;
    }

    .photo-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 6px;
    }

    .link-comment-field {
        padding-left: 0;
    }

    .link-point-row {
        flex-wrap: wrap;
    }
}

/* ============================================================
   PRINT
   ============================================================ */

@media print {
    body {
        background: #fff;
        color: #000;
    }

    .topbar,
    .v2-nav,
    .btn,
    .toast,
    #toastContainer,
    .modal,
    .actions,
    .tabs,
    #themeToggleBtn {
        display: none !important;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
/* ============================================================
   LINK TIME FIELDS — время начала/конца участков
   ============================================================ */

.link-time-row {
    display: flex;
    gap: 12px;
    padding-left: 34px;
    margin-top: 4px;
}

.link-time-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.link-time-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    margin: 0;
}

.link-time-field label i {
    font-size: 10px;
}

.link-time-field input[type="time"] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.link-time-field input[type="time"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

@media (max-width: 768px) {
    .link-time-row {
        padding-left: 0;
        flex-direction: column;
        gap: 8px;
    }
/* ============================================================
   TRIP COMMENT CELL — полный комментарий в таблице поездок
   ============================================================ */

.trip-comment-cell {
    max-width: 350px;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .trip-comment-cell {
        max-width: 200px;
    }
}
}