:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #eef2f6;
    --ink: #18212f;
    --muted: #667085;
    --line: #d7dde6;
    --brand: #008b7a;
    --brand-dark: #00675f;
    --blue: #2563eb;
    --amber: #d97706;
    --red: #dc2626;
    --green: #15803d;
    --shadow: 0 14px 36px rgba(20, 32, 45, .08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
}

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

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

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

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 24px;
    background: #121923;
    color: #f8fafc;
}

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

.brand-logo-frame {
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: #0b1220;
    border: 1px solid rgba(20, 184, 166, .36);
}

.brand-logo {
    width: 48px;
    height: 48px;
    display: block;
    object-fit: contain;
}

.brand-copy {
    min-width: 0;
}

.brand strong {
    display: block;
    font-size: 18px;
    letter-spacing: 0;
}

.brand span,
.user-mini span,
.muted {
    color: var(--muted);
}

.sidebar .brand span,
.sidebar .user-mini span {
    color: #aeb9c8;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: #d7dee9;
}

.nav a:hover,
.nav a.active {
    background: rgba(255, 255, 255, .09);
    color: #ffffff;
}

.nav-icon {
    width: 24px;
    text-align: center;
    font-weight: 800;
    color: #7dd3fc;
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 14px;
}

.user-mini {
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: var(--radius);
}

.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.topbar h1,
.page-title h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0;
}

.content {
    width: 100%;
    max-width: 1380px;
    margin: 0 auto;
    padding: 26px 28px 48px;
}

.page-title {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.page-title p {
    margin: 4px 0 0;
    color: var(--muted);
}

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

.toolbar form,
.filter-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    color: var(--muted);
}

.pagination-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (max-width: 560px) {
    .pagination {
        align-items: flex-start;
        flex-direction: column;
    }
}

.btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.btn:hover {
    border-color: #aeb9c8;
}

.btn.primary {
    border-color: var(--brand);
    background: var(--brand);
    color: #ffffff;
}

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

.btn.blue {
    border-color: var(--blue);
    background: var(--blue);
    color: #ffffff;
}

.btn.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.btn.ghost {
    background: transparent;
    color: inherit;
}

.btn.slim {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.grid {
    display: grid;
    gap: 16px;
}

.grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.panel-header,
.panel-body {
    padding: 18px;
}

.panel-header {
    border-bottom: 1px solid var(--line);
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 17px;
}

.stat {
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.stat span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat strong {
    display: block;
    margin-top: 6px;
    font-size: 30px;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #465467;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: #f8fafc;
}

tr:last-child td {
    border-bottom: 0;
}

.actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

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

.field {
    display: grid;
    gap: 7px;
    grid-column: span 4;
}

.field.span-2 {
    grid-column: span 2;
}

.field.span-3 {
    grid-column: span 3;
}

.field.span-6 {
    grid-column: span 6;
}

.field.span-8 {
    grid-column: span 8;
}

.field.span-12 {
    grid-column: 1 / -1;
}

label {
    color: #344054;
    font-weight: 700;
    font-size: 13px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--ink);
}

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

.checkline {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 40px;
}

.checkline.compact {
    min-height: 28px;
    font-size: 13px;
}

.unit-repeat-list {
    display: grid;
    gap: 8px;
}

.unit-repeat-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.unit-repeat-row .btn {
    min-width: 92px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf2f7;
    color: #344054;
    font-weight: 800;
    font-size: 12px;
}

.badge.green {
    background: #dcfce7;
    color: #166534;
}

.badge.amber {
    background: #fef3c7;
    color: #92400e;
}

.badge.red {
    background: #fee2e2;
    color: #991b1b;
}

.badge.blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge.gray {
    background: #e5e7eb;
    color: #374151;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
}

.flash {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    font-weight: 700;
}

.flash.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.flash.danger {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}

.flash.warning {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.media-thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.vehicle-photo {
    width: 100%;
    max-height: 260px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.seat-map {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
}

.seat {
    min-height: 154px;
    display: grid;
    gap: 10px;
    align-content: start;
    padding: 13px;
    border: 2px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.seat.normal {
    border-color: #bfdbfe;
}

.seat.special {
    border-color: #fbbf24;
    background: #fffbeb;
}

.seat.bed {
    border-color: #99f6e4;
    background: #f0fdfa;
}

.seat.reserved {
    border-color: #94a3b8;
    background: #f8fafc;
}

.seat-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.seat-visual {
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: #e7eef7;
    color: #243348;
    font-weight: 900;
    letter-spacing: .08em;
}

.inline-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.autocomplete-field {
    position: relative;
}

.autocomplete-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 18;
    max-height: 280px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: 0 16px 34px rgba(20, 32, 45, .14);
}

.autocomplete-panel[hidden] {
    display: none;
}

.autocomplete-item {
    display: grid;
    gap: 3px;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: #ffffff;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}

.autocomplete-item:last-child {
    border-bottom: 0;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
    background: #f1f8f7;
    outline: none;
}

.autocomplete-item strong {
    font-size: 14px;
}

.autocomplete-item span {
    color: var(--muted);
    font-size: 12px;
}

.address-block {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.address-block input:nth-child(2),
.address-block input:nth-child(4),
.address-block input:nth-child(5) {
    grid-column: 1 / -1;
}

button:disabled,
.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .52);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-panel {
    width: min(100%, 820px);
    max-height: min(92vh, 860px);
    overflow: auto;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin: 0;
    font-size: 18px;
}

.modal-panel form {
    padding: 18px;
}

.route-list {
    display: grid;
    gap: 12px;
}

.route-stop {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.route-number {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--brand);
    color: #ffffff;
    font-weight: 900;
}

.seat.bed .seat-visual {
    height: 34px;
    border-radius: 999px;
    background: #ccfbf1;
}

.seat.special .seat-visual {
    background: #fde68a;
}

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

.auth-screen {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(135deg, #08111d 0%, #101b2b 58%, #052f2c 100%);
}

.auth-box {
    width: min(100%, 430px);
    padding: 28px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
    overflow: hidden;
}

.auth-brand {
    display: grid;
    place-items: center;
    margin: -28px -28px 22px;
    padding: 28px 24px 24px;
    background: #0b1220;
    border-bottom: 1px solid rgba(20, 184, 166, .28);
}

.auth-logo {
    width: 138px;
    height: 138px;
    display: block;
    object-fit: contain;
}

.auth-box h1 {
    margin: 0 0 6px;
    font-size: 24px;
    text-align: center;
}

.auth-box p {
    margin: 0 0 20px;
    color: var(--muted);
    text-align: center;
}

.driver-shell {
    min-height: 100vh;
    background: #f6f8fb;
}

.driver-topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: #111827;
    color: #ffffff;
}

.driver-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.driver-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    display: block;
    object-fit: contain;
    padding: 5px;
    border-radius: var(--radius);
    background: #0b1220;
    border: 1px solid rgba(20, 184, 166, .34);
}

.driver-content {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 18px;
}

.driver-trip {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.presence-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.presence-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.request-group-title {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.transport-request-card {
    position: relative;
}

.request-selection {
    padding: 8px 10px;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    background: #eff6ff;
}

.transport-trip-option {
    align-items: flex-start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #ffffff;
}

.compact-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

.bpa-filter {
    margin-bottom: 16px;
}

.bpa-filter-action,
.bpa-edit-patient {
    align-content: end;
}

.bpa-stats {
    margin-bottom: 16px;
}

.bpa-settings {
    margin-bottom: 22px;
    overflow: hidden;
}

.bpa-settings > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}

.bpa-settings > summary::-webkit-details-marker {
    display: none;
}

.bpa-settings[open] > summary {
    border-bottom: 1px solid var(--line);
}

.bpa-issues-block,
.bpa-row-issues {
    display: grid;
    gap: 6px;
}

.bpa-issue,
.bpa-row-issues span {
    padding: 7px 9px;
    border-left: 3px solid #ef4444;
    background: #fff1f2;
    color: #991b1b;
    font-size: 12px;
    font-weight: 700;
}

.bpa-production-toolbar {
    margin-top: 4px;
}

.bpa-table td {
    vertical-align: top;
}

.bpa-table .badge + .badge {
    margin-top: 5px;
}

.bpa-history-title {
    margin-top: 30px;
}

.bpa-history-title h1 {
    font-size: 19px;
}

.hash-value {
    white-space: nowrap;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        padding: 18px;
    }

    .nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        padding: 16px 18px;
    }

    .content {
        padding: 18px;
    }

    .grid.cols-2,
    .grid.cols-3,
    .grid.cols-4 {
        grid-template-columns: 1fr;
    }

    .field,
    .field.span-2,
    .field.span-3,
    .field.span-6,
    .field.span-8 {
        grid-column: 1 / -1;
    }
}

@media (max-width: 680px) {
    .page-title,
    .toolbar,
    .presence-row {
        align-items: stretch;
        flex-direction: column;
        display: flex;
    }

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

    th,
    td {
        padding: 11px 10px;
    }

    .unit-repeat-row {
        grid-template-columns: 1fr;
    }

    .unit-repeat-row .btn {
        width: 100%;
    }
}

@media print {
    .sidebar,
    .topbar,
    .no-print {
        display: none !important;
    }

    .app-shell {
        display: block;
    }

    .content {
        max-width: none;
        padding: 0;
    }

    .panel,
    .table-wrap,
    .stat {
        box-shadow: none;
    }
}
