/* Страницы входа и управления пользователями.
   Палитра и шрифт - из основного приложения: зелёный маркер на карте, Segoe UI. */

:root {
    --ink: #1d2b22;
    --muted: #6b7a70;
    --paper: #eef2ee;
    --card: #ffffff;
    --line: #dde4de;
    --green: #4caf50;
    --green-deep: #2e7d32;
    --road: #f5b800;
    --danger: #d84315;
    --danger-bg: #fdeee9;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.45;
}

h1, h2, h3 { margin: 0; line-height: 1.2; }

:focus-visible {
    outline: 3px solid var(--road);
    outline-offset: 2px;
}

/* ---------- Вход ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
    padding: 0 28px 28px;
    overflow: hidden;
}

/* Дорожная разметка со значком ТС, как на карте */
.road {
    position: relative;
    height: 34px;
    margin: 0 -28px 22px;
    background: var(--ink);
}

.road::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 3px;
    transform: translateY(-50%);
    background: repeating-linear-gradient(90deg, var(--road) 0 18px, transparent 18px 34px);
}

.road-dot {
    position: absolute;
    top: 50%; left: 28px;
    width: 22px; height: 22px;
    transform: translateY(-50%);
    border-radius: 50%;
    background: var(--green);
    border: 2px solid #fff;
    box-shadow: 0 0 0 3px var(--ink);
}

.auth-card h1 {
    font-size: 22px;
    margin-bottom: 4px;
}

.auth-sub {
    margin: 0 0 18px;
    color: var(--muted);
    font-size: 14px;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 2px solid var(--line);
}

.tab {
    flex: 1;
    background: none;
    border: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 8px 4px;
    font: inherit;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
}

.tab.active {
    color: var(--green-deep);
    border-bottom-color: var(--green);
}

.field {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    font-weight: 600;
}

.field input,
.field select {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    font: inherit;
    font-weight: 400;
    font-size: 16px; /* 16px - чтобы iOS не увеличивал страницу при фокусе */
    color: var(--ink);
    background: #fff;
    border: 1px solid #c9d3cb;
    border-radius: 6px;
}

.field input:focus,
.field select:focus {
    border-color: var(--green);
    outline: 2px solid rgba(76, 175, 80, 0.35);
    outline-offset: 0;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -4px 0 16px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}

.form-error {
    margin-bottom: 14px;
    padding: 9px 12px;
    border-radius: 6px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 13px;
}

.btn-primary {
    width: 100%;
    padding: 11px;
    border: 0;
    border-radius: 6px;
    background: var(--green);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: var(--green-deep); }
.btn-primary:disabled { background: #a5c9a7; cursor: wait; }

.hint {
    margin: 14px 0 0;
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Админка ---------- */

.admin-page { padding: 0 0 40px; }

.admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--ink);
    color: #fff;
}

.admin-header h1 { font-size: 18px; }

.admin-header nav { display: flex; gap: 8px; }

.admin-header a,
.admin-header button {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 5px;
    background: none;
    color: #fff;
    font: inherit;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.admin-header a:hover,
.admin-header button:hover { background: rgba(255, 255, 255, 0.12); }

.admin-main {
    max-width: 1080px;
    margin: 0 auto;
    padding: 20px 16px 0;
}

.panel-box {
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
    padding: 18px 20px;
    margin-bottom: 18px;
}

.panel-box h2 {
    font-size: 16px;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--green);
}

.roles-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin: 0;
    font-size: 13px;
}

.roles-legend dt { font-weight: 700; }
.roles-legend dd { margin: 2px 0 0; color: var(--muted); }

.create-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    align-items: end;
}

.create-form .field { margin: 0; }
.create-form .btn-primary { width: auto; padding: 10px 18px; }

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

table.users {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.users th {
    text-align: left;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--muted);
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}

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

table.users tr.inactive td { opacity: 0.55; }
table.users tr.inactive td:last-child { opacity: 1; }

.u-name { font-weight: 600; }
.u-phone { font-size: 12px; color: var(--muted); }
.u-you {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 10px;
    background: #e8f5e9;
    color: var(--green-deep);
    font-size: 11px;
    font-weight: 600;
}

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

table.users select {
    padding: 6px 8px;
    font: inherit;
    font-size: 14px;
    border: 1px solid #c9d3cb;
    border-radius: 5px;
    background: #fff;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}

.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.btn-small {
    padding: 6px 10px;
    border: 1px solid #c9d3cb;
    border-radius: 5px;
    background: #fff;
    font: inherit;
    font-size: 13px;
    color: var(--ink);
    cursor: pointer;
}

.btn-small:hover { background: #f1f8f2; border-color: var(--green); }
.btn-small.danger { color: var(--danger); }
.btn-small.danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ---------- Диалоги ---------- */

dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 20px;
    border: 0;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    color: var(--ink);
}

dialog::backdrop { background: rgba(20, 30, 24, 0.5); }

dialog h3 { font-size: 16px; margin-bottom: 4px; }
dialog .dlg-sub { margin: 0 0 14px; font-size: 13px; color: var(--muted); }

.vehicle-picks {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

.vehicle-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
    cursor: pointer;
}

.vehicle-pick:last-child { border-bottom: 0; }
.vehicle-pick:hover { background: #f1f8f2; }
.vehicle-pick small { display: block; color: var(--muted); font-size: 12px; }

.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dlg-actions .btn-primary { width: auto; padding: 9px 16px; }

.btn-ghost {
    padding: 9px 14px;
    border: 1px solid #c9d3cb;
    border-radius: 6px;
    background: #fff;
    font: inherit;
    cursor: pointer;
}

#toast {
    position: fixed;
    left: 50%;
    bottom: 22px;
    transform: translateX(-50%);
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    border-radius: 6px;
    background: var(--ink);
    color: #fff;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

#toast.error { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Пул ТС, поиск, страницы ---------- */

.box-text { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.create-form + .box-text { margin: 12px 0 0; }

.pool-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }

.toolbar-input,
.toolbar-select {
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    border: 1px solid #c9d3cb;
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
}

.toolbar-input { flex: 1 1 220px; min-width: 0; }
.toolbar-count { margin-left: auto; font-size: 13px; color: var(--muted); }

dialog .toolbar-input { width: 100%; }

.empty { text-align: center; padding: 24px 10px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; font-size: 13px; }
.pager .btn-small:disabled { opacity: 0.45; cursor: default; }

.btn-small.custom { border-color: var(--road); background: #fff9e0; }

.picks-tools { display: flex; align-items: center; gap: 14px; margin-top: 10px; font-size: 13px; }
.picks-tools .muted { margin-left: auto; }

.link-action {
    padding: 0;
    border: 0;
    background: none;
    color: var(--green-deep);
    font: inherit;
    font-size: 13px;
    text-decoration: underline;
    cursor: pointer;
}

.dlg-actions { align-items: center; }
.dlg-actions .spacer { flex: 1; }
