:root {
    --app-bg: #f5f7f8;
    --app-surface: #ffffff;
    --app-text: #1f2933;
    --app-muted: #667085;
    --app-border: #d9e1e7;
    --app-primary: #256f78;
    --app-primary-dark: #19565d;
    --app-success: #287d4f;
    --app-radius: 8px;
    --app-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

* {
    letter-spacing: 0;
}

body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-navbar {
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--app-border);
    backdrop-filter: blur(10px);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
}

.brand-mark {
    color: var(--app-primary);
    display: inline-flex;
    font-size: 1.35rem;
}

.navbar-nav .nav-link {
    align-items: center;
    border-radius: var(--app-radius);
    display: inline-flex;
    gap: 0.45rem;
    min-height: 42px;
    padding-inline: 0.75rem;
}

.navbar-nav .nav-link.active {
    background: #e7f2f3;
    color: var(--app-primary-dark);
    font-weight: 700;
}

.app-shell {
    min-height: calc(100vh - 116px);
}

.app-footer {
    align-items: center;
    border-top: 1px solid var(--app-border);
    color: var(--app-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    justify-content: center;
    min-height: 58px;
    padding: 0.8rem 1rem;
    text-align: center;
}

.app-footer a {
    color: var(--app-primary-dark);
    font-weight: 800;
    text-decoration: none;
}

.auth-footer {
    border-top: 0;
}

.page-heading {
    align-items: center;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.page-heading h1 {
    font-size: 1.65rem;
    font-weight: 800;
    margin: 0;
}

.page-heading p {
    color: var(--app-muted);
    margin: 0.25rem 0 0;
}

.touch-button {
    align-items: center;
    display: inline-flex;
    gap: 0.45rem;
    justify-content: center;
    min-height: 52px;
    padding-inline: 1rem;
    white-space: nowrap;
}

.icon-btn {
    align-items: center;
    display: inline-flex;
    height: 40px;
    justify-content: center;
    min-width: 40px;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
    --bs-btn-active-bg: var(--app-primary-dark);
    --bs-btn-active-border-color: var(--app-primary-dark);
}

.btn-success {
    --bs-btn-bg: var(--app-success);
    --bs-btn-border-color: var(--app-success);
}

.payment-due-alert {
    background: #eaf7ef;
    border: 2px solid #1f7a4d;
    box-shadow: 0 0.8rem 1.8rem rgba(31, 122, 77, 0.16);
    color: #123d28;
    font-size: 1.35rem;
    font-weight: 900;
    line-height: 1.25;
    padding-block: 1rem;
}

.metric-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-tile {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-left: 6px solid var(--app-primary);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    color: inherit;
    min-height: 124px;
    padding: 1rem;
    text-decoration: none;
}

.metric-link {
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.metric-link:hover,
.metric-link:focus-visible {
    border-color: var(--app-primary);
    box-shadow: 0 14px 34px rgba(31, 41, 51, 0.13);
    color: inherit;
    transform: translateY(-1px);
}

.metric-tile span {
    color: var(--app-muted);
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
}

.metric-tile strong {
    display: block;
    font-size: 2rem;
    line-height: 1.1;
    margin-top: 0.7rem;
    overflow-wrap: anywhere;
}

.accent-teal {
    border-left-color: #229f8c;
}

.accent-indigo {
    border-left-color: #5661b3;
}

.accent-amber {
    border-left-color: #d89a20;
}

.accent-rose {
    border-left-color: #c4566a;
}

.content-grid {
    display: grid;
    gap: 1rem;
}

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

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

.panel-heading {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.panel-heading h2 {
    font-size: 1.05rem;
    font-weight: 800;
    margin: 0;
}

.panel-heading i {
    color: var(--app-primary);
    font-size: 1.25rem;
}

.list-stack {
    display: grid;
    gap: 0.65rem;
}

.list-row {
    align-items: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: flex;
    justify-content: space-between;
    min-height: 64px;
    padding: 0.75rem;
}

.list-row strong,
.list-row span {
    display: block;
}

.list-row span,
.list-row time {
    color: var(--app-muted);
    font-size: 0.9rem;
}

.entry-layout {
    display: grid;
    gap: 1rem;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
}

.entry-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 300px;
}

.entry-exit-button {
    font-weight: 800;
    min-height: 54px;
    padding-inline: 1.25rem;
    box-shadow: 0 0.75rem 1.4rem rgba(220, 53, 69, 0.24);
}

.entry-primary-actions {
    display: grid;
    gap: 0.7rem;
    max-width: 320px;
}

.entry-primary-actions .touch-button {
    justify-content: center;
    width: 100%;
}

.plate-input {
    font-size: 2rem;
    font-weight: 800;
    min-height: 74px;
}

.camera-reader {
    background: #f8fbfb;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: grid;
    gap: 0.75rem;
    padding: 0.85rem;
}

.camera-reader-head {
    align-items: center;
    display: flex;
    gap: 0.6rem;
    justify-content: space-between;
}

.camera-reader-head strong {
    font-size: 0.95rem;
    font-weight: 850;
}

.camera-reader-head i {
    color: var(--app-primary-dark);
    font-size: 1.15rem;
}

.camera-reader-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.camera-preview {
    background: #111827;
    border: 1px solid #263243;
    border-radius: var(--app-radius);
    overflow: hidden;
    position: relative;
}

.camera-preview video {
    background: #111827;
    display: block;
    max-height: 340px;
    object-fit: contain;
    width: 100%;
}

.plate-scan-frame {
    border: 3px solid rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    box-shadow: 0 0 0 999px rgba(17, 24, 39, 0.28), 0 0 16px rgba(0, 0, 0, 0.35);
    height: 18%;
    left: 10%;
    pointer-events: none;
    position: absolute;
    right: 10%;
    top: 37%;
}

.camera-status {
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 650;
    margin: 0;
}

.status-strip {
    display: grid;
    gap: 1rem;
}

.vehicle-list {
    display: grid;
    gap: 0.85rem;
}

.exit-search {
    margin-bottom: 1rem;
}

.exit-search .form-label {
    font-weight: 700;
}

.search-control {
    align-items: center;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: grid;
    gap: 0.5rem;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    padding: 0.45rem;
}

.search-control > i {
    color: var(--app-muted);
    font-size: 1.2rem;
    margin-left: 0.45rem;
}

.search-control .form-control {
    border: 0;
    box-shadow: none;
    font-weight: 800;
    min-height: 52px;
    padding-inline: 0.25rem;
}

.exit-camera-panel {
    max-width: 620px;
}

.exit-search .camera-status {
    margin-top: 0.55rem;
}

.receipt-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

.receipt-actions-top {
    background: #ffffff;
    border: 1px solid var(--app-border);
    border-left: 6px solid var(--app-primary);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    justify-content: space-between;
    padding: 0.75rem;
}

.receipt-status {
    color: var(--app-muted);
    flex: 1 1 220px;
    font-size: 0.92rem;
    font-weight: 750;
    min-height: 1.4rem;
}

.vehicle-item {
    align-items: center;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    display: grid;
    gap: 1rem;
    grid-template-columns: 1.05fr 0.75fr 0.9fr 1.25fr;
    padding: 1rem;
}

.vehicle-main strong {
    display: block;
    font-size: 1.45rem;
    line-height: 1.1;
}

.vehicle-main span,
.vehicle-fee span {
    color: var(--app-muted);
    display: block;
    margin-top: 0.25rem;
}

.vehicle-fee strong {
    display: block;
    font-size: 1.25rem;
}

.vehicle-action {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: minmax(130px, 1fr) minmax(120px, auto);
}

.vehicle-edit {
    align-items: center;
    display: grid;
    gap: 0.5rem;
    grid-template-columns: minmax(120px, 1fr) auto;
}

.vehicle-edit .form-control {
    font-weight: 800;
}

.filter-bar {
    align-items: end;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(160px, 1fr)) auto;
}

.stack-form {
    display: grid;
    gap: 1rem;
}

.tariff-stack {
    display: grid;
    gap: 0.75rem;
}

.tariff-rule-panel {
    margin-bottom: 1rem;
}

.tariff-rule-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tariff-rule-grid div {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 0.85rem;
}

.tariff-rule-grid .form-label {
    color: var(--app-muted);
    font-weight: 700;
}

.tariff-rule-grid span {
    color: var(--app-muted);
    display: block;
    font-weight: 700;
}

.tariff-rule-grid strong {
    display: block;
    font-size: 1.35rem;
    margin-top: 0.35rem;
}

.tariff-row {
    align-items: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: grid;
    gap: 0.5rem;
    grid-template-columns: 1.4fr 0.8fr 0.7fr 0.65fr 0.6fr auto auto;
    padding: 0.75rem;
}

.tariff-check {
    align-items: center;
    display: flex;
    gap: 0.4rem;
    margin: 0;
    white-space: nowrap;
}

.empty-state,
.auth-error {
    align-items: center;
    background: var(--app-surface);
    border: 1px dashed var(--app-border);
    border-radius: var(--app-radius);
    color: var(--app-muted);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 220px;
    padding: 2rem;
    text-align: center;
}

.empty-state i,
.auth-error i {
    color: var(--app-primary);
    font-size: 2.4rem;
    margin-bottom: 0.5rem;
}

.auth-body {
    background: #edf3f1;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    min-height: 100vh;
    min-height: 100dvh;
}

.auth-shell {
    align-items: start;
    display: flex;
    justify-content: center;
    min-height: 0;
    overflow-y: auto;
    padding: max(0.75rem, env(safe-area-inset-top)) 0.75rem 0.75rem;
    width: 100%;
}

.auth-panel {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow);
    max-width: 430px;
    padding: 1rem;
    width: 100%;
}

.auth-panel .stack-form {
    gap: 0.75rem;
}

.auth-panel .mb-3 {
    margin-bottom: 0 !important;
}

.auth-brand {
    align-items: center;
    display: flex;
    gap: 0.8rem;
    margin-bottom: 0.9rem;
}

.auth-brand h1 {
    font-size: 1.2rem;
    font-weight: 800;
    margin: 0;
}

.auth-brand p {
    color: var(--app-muted);
    margin: 0.15rem 0 0;
}

.auth-panel .form-label {
    font-size: 0.92rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
}

.auth-panel .form-control-lg {
    font-size: 1.05rem;
    min-height: 54px;
    padding: 0.75rem 0.85rem;
}

.login-check {
    align-items: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: flex;
    gap: 0.65rem;
    min-height: 50px;
    padding: 0.75rem;
}

.login-check input {
    flex: 0 0 auto;
    height: 1.15rem;
    width: 1.15rem;
}

.login-check span {
    font-weight: 750;
}

.login-verification {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: grid;
    gap: 0.7rem;
    padding: 0.75rem;
}

.login-verification .login-check {
    border: 0;
    min-height: auto;
    padding: 0;
}

.shape-verification {
    display: grid;
    gap: 0.65rem;
}

.shape-verification > span {
    color: var(--app-muted);
    font-size: 0.92rem;
    font-weight: 800;
}

.shape-options {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.shape-option {
    cursor: pointer;
    margin: 0;
}

.shape-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.shape-option span {
    align-items: center;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    color: var(--app-text);
    display: flex;
    gap: 0.25rem;
    justify-content: center;
    min-height: 58px;
    padding: 0.55rem 0.35rem;
    text-align: center;
}

.shape-option i {
    color: var(--app-primary);
    font-size: 1.25rem;
    line-height: 1;
}

.shape-option small {
    font-size: 0.78rem;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.shape-option input:checked + span,
.shape-option input:focus-visible + span {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 111, 120, 0.16);
}

.auth-footer {
    font-size: 0.86rem;
    gap: 0.25rem 0.7rem;
    min-height: auto;
    padding: 0.55rem max(0.75rem, env(safe-area-inset-right)) max(0.65rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.user-edit-stack {
    display: grid;
    gap: 0.85rem;
}

.user-edit-row {
    align-items: end;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr 0.9fr 1fr 1fr minmax(130px, auto) auto;
    padding: 0.85rem;
}

.user-edit-row .form-label {
    color: var(--app-muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.user-edit-meta {
    display: grid;
    gap: 0.35rem;
}

.user-edit-meta small {
    color: var(--app-muted);
    white-space: nowrap;
}

.receipt-print {
    display: none;
}

.receipt-pdf-overlay {
    background: #eef3f3;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    inset: 0;
    position: fixed;
    z-index: 2000;
}

.receipt-pdf-toolbar {
    align-items: center;
    background: var(--app-surface);
    box-shadow: 0 0.35rem 1.2rem rgba(15, 23, 42, 0.14);
    display: grid;
    gap: 0.6rem;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) 0.75rem max(0.75rem, env(safe-area-inset-left));
}

.receipt-preview-stage {
    align-items: start;
    display: grid;
    justify-items: center;
    min-height: 0;
    overflow: auto;
    padding: 1rem;
}

.receipt-preview-paper {
    aspect-ratio: 2 / 1;
    background: #ffffff;
    box-shadow: 0 1rem 2.4rem rgba(15, 23, 42, 0.18);
    box-sizing: border-box;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
    padding: 8px 10px;
    width: min(92vw, 560px);
}

.receipt-preview-paper h2 {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.1;
    margin: 0 0 4px;
    text-align: center;
}

.receipt-preview-type {
    border: 1px solid #000000;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.1;
    margin: 0 0 4px;
    padding: 2px;
    text-align: center;
}

.receipt-preview-paper dl {
    margin: 0;
}

.receipt-preview-row {
    border-bottom: 1px solid #000000;
    display: grid;
    font-size: 17px;
    gap: 0.35rem;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1fr);
    line-height: 1.05;
    padding: 3px 0;
}

.receipt-preview-row dt,
.receipt-preview-row dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.receipt-preview-row dt {
    font-weight: 800;
}

.receipt-preview-row dd {
    font-weight: 800;
    text-align: right;
}

.receipt-preview-total {
    background: #f2f2f2;
    border: 2px solid #000000;
    font-size: 19px;
    margin-block: 3px;
    padding: 4px 3px;
}

.receipt-preview-total dd {
    font-size: 22px;
    line-height: 1;
}

.receipt-preview-note {
    font-size: 15px;
    font-weight: 800;
    line-height: 1.1;
    margin: 4px 0 0;
    text-align: center;
}

.receipt-pdf-status {
    background: var(--app-surface);
    border-top: 1px solid var(--app-border);
    color: var(--app-muted);
    font-size: 0.86rem;
    font-weight: 750;
    padding: 0.55rem max(0.75rem, env(safe-area-inset-right)) max(0.65rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}

.table {
    min-width: 720px;
}

.report-subtotal-row th {
    background: #f1f6f7;
    border-top: 2px solid var(--app-border);
    font-size: 1rem;
}

@media (max-width: 991.98px) {
    .metric-grid,
    .tariff-rule-grid,
    .two-columns,
    .entry-layout {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .vehicle-action {
        grid-template-columns: 1fr 1fr;
    }

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

    .user-edit-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 575.98px) {
    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .page-heading .btn,
    .touch-button {
        width: 100%;
    }

    .metric-grid,
    .tariff-rule-grid,
    .two-columns,
    .entry-layout,
    .filter-bar {
        grid-template-columns: 1fr;
    }

    .metric-tile {
        min-height: 104px;
    }

    .metric-tile strong {
        font-size: 1.65rem;
    }

    .plate-input {
        font-size: 1.65rem;
    }

    .vehicle-action {
        grid-template-columns: 1fr;
    }

    .list-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }

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

    .user-edit-row {
        grid-template-columns: 1fr;
    }

    .navbar-brand {
        max-width: calc(100vw - 96px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-footer {
        align-items: center;
        flex-direction: column;
    }
}
