/* Order Delta — дизайн-система (основа перенесена из Delta, упрощена) */
: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; padding: 16px; }

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; }
h1 { font-size: 24px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 24px 0 12px; }
h3 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--c-muted); font-size: 13px; }
.small { font-size: 12px; }
.status-ok { color: var(--c-ok); font-weight: 600; }
.status-off { color: var(--c-error); font-weight: 600; }
.req { color: var(--c-error); font-weight: 700; }
.hint { display: block; color: var(--c-muted); font-size: 12px; margin-top: 3px; }
.pill {
    display: inline-block; background: #eef3fb; color: var(--c-primary);
    border-radius: 8px; padding: 1px 8px; font-size: 11.5px; font-weight: 600; margin-left: 4px;
}
.crumb { color: var(--c-muted); font-weight: 500; }

/* ── App shell ───────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px; 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-link.soon { opacity: 0.55; cursor: default; }
.sb-link.soon:hover { background: none; color: #cdd9e8; }
.sb-link.soon small { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; background: rgba(255,255,255,0.12); border-radius: 6px; padding: 1px 6px; }
.sb-foot { border-top: 1px solid rgba(255,255,255,0.10); padding: 12px 16px 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; }

@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; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.page-header h1 { margin: 0; }
.page-header > .muted { max-width: 640px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.block-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }

/* ── Login ───────────────────────────────────────────────────────── */
.login-card {
    background: var(--c-card); padding: 32px; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08); min-width: 300px; max-width: 400px; width: 100%;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-card p { text-align: center; margin: 0 0 20px; }
.login-card .small { margin: 14px 0 0; }

/* ── Inputs ──────────────────────────────────────────────────────── */
label { display: block; margin-bottom: 12px; }
label > span { display: block; margin-bottom: 4px; font-size: 13px; color: var(--c-muted); }
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], input[type="tel"], input[type="url"], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--c-border); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff; color: var(--c-text);
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(24,100,171,0.15); }
input:disabled, select:disabled, textarea:disabled { background: #f3f4f6; color: var(--c-muted); }
input.num { width: 120px; text-align: right; }
fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset.grid-form { display: contents; }
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; }
label.check input { width: 16px; height: 16px; margin: 0; }
label.check span { font-size: 14px; color: var(--c-text); margin: 0; }
.check-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 2px 16px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
    display: inline-block; padding: 10px 18px; border: none; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; text-decoration: none;
}
.btn-primary { background: var(--c-primary); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--c-primary-hover); text-decoration: none; }
.btn-inline { width: auto; }
.btn-sm {
    display: inline-block; padding: 5px 11px; font-size: 12.5px; border: 1px solid var(--c-border);
    background: #fff; border-radius: 6px; cursor: pointer; font-family: inherit; color: var(--c-text);
    line-height: 1.4;
}
.btn-sm:hover { background: #f3f4f6; }
.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; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── 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; }
.invite-box strong { display: block; margin-bottom: 6px; }
.invite-box small { display: block; margin-top: 6px; color: #1e40af; opacity: .85; }
.copy-row { display: flex; gap: 6px; align-items: center; }
.copy-row input { font-size: 12.5px; font-family: ui-monospace, Consolas, monospace; }

/* ── Cards & stats ───────────────────────────────────────────────── */
.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); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.card p { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.stat {
    background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: 14px 16px;
    display: flex; flex-direction: column; color: var(--c-text);
}
.stat:hover { text-decoration: none; box-shadow: 0 4px 10px rgba(0,0,0,0.08); }
.stat-n { font-size: 28px; font-weight: 800; color: var(--c-primary); line-height: 1.1; }
.stat-l { font-weight: 600; margin-top: 2px; }
.stat small { color: var(--c-muted); font-size: 12px; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-block { background: #fff; border: 1px solid var(--c-border); border-radius: 12px; padding: 14px 18px; margin-bottom: 14px; }
.form-block summary { cursor: pointer; padding: 4px 0; list-style: none; }
.form-block summary::-webkit-details-marker { display: none; }
.form-block summary::before { content: "▸ "; color: var(--c-muted); }
.form-block[open] > summary::before { content: "▾ "; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 12px; margin-top: 12px; }
.grid-form label { margin: 0; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; }
.grid-cap { grid-column: 1 / -1; font-weight: 700; font-size: 13px; margin-top: 6px; border-top: 1px solid var(--c-border); padding-top: 10px; }
.inline-details { display: inline-block; vertical-align: top; }
.inline-details > summary { list-style: none; display: inline-block; }
.inline-details > summary::-webkit-details-marker { display: none; }
.inline-details[open] { display: block; background: #f9fafb; border: 1px solid var(--c-border); border-radius: 10px; padding: 10px 12px; margin-top: 6px; min-width: 280px; }
.inline-details[open] > summary { margin-bottom: 4px; }
.inline-details .grid-form { margin-top: 8px; min-width: 260px; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 12px; box-shadow: var(--shadow); background: #fff; }
.data-table { width: 100%; border-collapse: collapse; background: #fff; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--c-border); font-size: 13px; vertical-align: top; }
.data-table th { background: #f9fafb; font-weight: 600; color: var(--c-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.5px; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.row-disabled { background: var(--c-row-disabled); }
.row-disabled > td, .row-disabled > summary { color: var(--c-muted); }
.kv { border-collapse: collapse; width: 100%; }
.kv th, .kv td { padding: 7px 10px; border-bottom: 1px solid var(--c-border); text-align: left; font-size: 13.5px; vertical-align: top; }
.kv th { color: var(--c-muted); font-weight: 600; 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: 2px 6px 2px 0; }
.inline-form input[type="text"] { padding: 4px 8px; font-size: 12px; width: 150px; }

/* ── Badges & tabs ───────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; text-transform: uppercase; vertical-align: middle; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-operator { background: #dbeafe; color: #1e40af; }
.badge-client { background: #ede9fe; color: #5b21b6; }
.badge-driver { background: #d1fae5; color: #065f46; }
.badge-cancel { background: #fee2e2; color: #991b1b; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 16px; }
.tab {
    border: 1px solid var(--c-border); background: #fff; border-radius: 10px; padding: 8px 14px;
    font-size: 14px; font-weight: 600; color: #344; cursor: pointer; font-family: inherit; display: inline-flex; gap: 8px; align-items: center;
}
.tab:hover { background: #f7faff; }
.tab.active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.tab .cnt { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 7px; background: #eef1f5; color: #475; font-size: 12px; font-weight: 700; }
.tab.active .cnt { background: rgba(255,255,255,.25); color: #fff; }
.tab-panel[hidden] { display: none; }

/* ── Empty / error ───────────────────────────────────────────────── */
.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 12px; color: var(--c-muted); }
.empty-state .es-ico { font-size: 44px; margin-bottom: 8px; }
.error-state h1 { margin-bottom: 8px; }

/* ── Заявки: статусы, доска, форма, таймлайн ─────────────────────── */
.badge.st-new { background: #dbeafe; color: #1e40af; }
.badge.st-clarification { background: #fef3c7; color: #92400e; }
.badge.st-accepted { background: #e0f2fe; color: #075985; }
.badge.st-assigned { background: #ede9fe; color: #5b21b6; }
.badge.st-picked_up { background: #fef9c3; color: #854d0e; }
.badge.st-delivered { background: #dcfce7; color: #166534; }
.badge.st-closed { background: #e5e7eb; color: #374151; }
.badge.st-cancelled, .badge.st-rejected { background: #fee2e2; color: #991b1b; }
.badge.ts-planned { background: #dbeafe; color: #1e40af; }
.badge.ts-in_progress { background: #fef3c7; color: #92400e; }
.badge.ts-done { background: #dcfce7; color: #166534; }
.badge.ts-cancelled { background: #fee2e2; color: #991b1b; }
body.driver-mode .order-row { padding: 14px 16px; }
body.driver-mode .kv th { width: 110px; }
.igroup { margin-bottom: 18px; }
.igroup[hidden] { display: none; }
.igroup-head { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; }
.gh-cap { font-size: 16px; font-weight: 800; }
.gh-date { font-size: 13px; color: var(--c-muted); font-weight: 600; }
.gh-cnt { margin-left: auto; font-size: 12.5px; color: var(--c-muted); background: #eef1f5; border-radius: 8px; padding: 3px 10px; font-weight: 600; }
.order-row {
    display: flex; justify-content: space-between; gap: 12px; align-items: center; background: #fff;
    border: 1px solid var(--c-border); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px;
    color: var(--c-text); box-shadow: var(--shadow);
}
.order-row:hover { text-decoration: none; border-color: var(--c-primary); }
.order-row.is-new { border-left: 4px solid var(--c-primary); }
.or-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; white-space: nowrap; }
.date-chip {
    display: inline-flex; align-items: center; gap: 5px; background: #e7f0fb; color: var(--c-primary);
    border-radius: 8px; padding: 1px 9px; font-weight: 800; font-size: 14px; white-space: nowrap;
}
.dropzone {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border: 2px dashed var(--c-border);
    border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; background: #fafbfd;
}
.dropzone input[type="file"] { flex: 1; min-width: 220px; font-size: 13px; }
.pos-wrap { margin-top: 8px; }
.pos-table input[type="text"], .pos-table input[type="date"] { padding: 6px 8px; font-size: 13px; min-width: 110px; }
.pos-table input.num { width: 120px; }
.pos-doc { font-size: 12.5px; max-width: 260px; }
.pos-warn { color: #92400e; font-size: 12px; margin-top: 3px; }
.radio-group { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; }
.radio-group .check { margin: 0; }
#positionsEmpty[hidden], #pickupBlock[hidden] { display: none; }
.order-form section h3 { margin-bottom: 6px; }
.timeline { list-style: none; padding: 0; margin: 0 0 12px; }
.tl-item { border-left: 2px solid var(--c-border); padding: 2px 0 10px 12px; margin-left: 6px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-primary); }
.tl-status::before { background: var(--c-ok); }
.tl-change_request::before { background: var(--c-warn); }
.tl-time { display: block; font-size: 11.5px; color: var(--c-muted); }
.tl-who { font-weight: 600; font-size: 13px; margin-right: 6px; }
.tl-text { font-size: 13.5px; }
.ops-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }

/* ── Driver mode: крупные зоны нажатия ───────────────────────────── */
body.driver-mode .btn, body.driver-mode .btn-sm { font-size: 16px; padding: 12px 18px; }
body.driver-mode .container { max-width: 720px; }

.data-table td.num, .data-table th.num { text-align: right; white-space: nowrap; }
