:root {
    --ink: #12161d;
    --muted: #656e7a;
    --paper: #eeece3;
    --surface: #ffffff;
    --border: rgba(18, 22, 29, 0.12);
    --border-strong: rgba(18, 22, 29, 0.22);

    --chrome-bg: #12161d;
    --chrome-text: #f4f1ea;
    --chrome-muted: #9aa3b2;

    --pix: #0f8b83;
    --pix-dark: #0b6f69;
    --pix-soft: #e1f3f0;

    --plate-blue: #1341a6;
    --amber: #9c6308;
    --amber-soft: #fbedd3;

    --danger: #c8402c;
    --danger-dark: #a52f1f;
    --danger-soft: #fbe6e2;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --shadow-card: 0 1px 2px rgba(18, 22, 29, 0.05), 0 10px 24px -16px rgba(18, 22, 29, 0.35);

    --font-display: "Oswald", "Arial Narrow", sans-serif;
    --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --tabbar-height: 68px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #eef1f5;
        --muted: #9aa4b2;
        --paper: #14171d;
        --surface: #1b1f27;
        --border: rgba(238, 241, 245, 0.12);
        --border-strong: rgba(238, 241, 245, 0.24);
        --pix-soft: rgba(15, 139, 131, 0.2);
        --amber-soft: rgba(156, 99, 8, 0.22);
        --danger-soft: rgba(200, 64, 44, 0.2);
        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 26px -16px rgba(0, 0, 0, 0.7);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}

a {
    color: inherit;
}

:focus-visible {
    outline: 2px solid var(--pix);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Topbar: fixed dark instrument-panel bezel, always dark regardless of theme */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.1rem;
    background: var(--chrome-bg);
    color: var(--chrome-text);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--chrome-text);
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 20px;
    background: var(--plate-blue);
    color: #fff;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.6rem;
    letter-spacing: 0.04em;
    border-radius: 4px;
}

.brand-word {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    letter-spacing: 0.01em;
}

/* Bottom tab bar: primary mobile navigation, reachable by thumb */
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    background: var(--chrome-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-item-form {
    flex: 1;
    display: flex;
    margin: 0;
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.55rem 0.25rem 0.6rem;
    color: var(--chrome-muted);
    background: none;
    border: none;
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    min-height: 56px;
    touch-action: manipulation;
}

.tab-item svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
}

.tab-item.is-active {
    color: var(--chrome-text);
}

.tab-item.is-active svg {
    stroke: var(--pix);
}

main.container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 1.25rem 1rem calc(var(--tabbar-height) + 1.5rem);
}

/* Pages without a bottom nav (login, reset) don't need the reserved space */
body:not(:has(.tabbar)) main.container {
    padding-bottom: 1.5rem;
}

.eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--amber);
    margin-bottom: 0.35rem;
}

h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.65rem;
    letter-spacing: 0.005em;
    margin: 0 0 1rem;
}

h2 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.05rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin: 0 0 0.7rem;
}

.tagline {
    color: var(--muted);
    margin: -0.5rem 0 1rem;
}

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

.error {
    color: var(--danger);
    font-weight: 500;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem;
    margin-bottom: 1rem;
}

.card.notice {
    border-color: var(--pix);
    background: var(--pix-soft);
}

/* Summary strip: at-a-glance car + pending-total tiles atop the dashboard */
.summary-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem;
    margin-bottom: 1.1rem;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 0.85rem 0.95rem;
}

.stat-tile-label {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.stat-tile-value {
    display: block;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    letter-spacing: 0.005em;
}

.stat-tile-value.is-amount {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    color: var(--pix-dark);
}

.stat-tile-sub {
    display: block;
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.count-pill {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    letter-spacing: 0;
    text-transform: none;
}

.centered-card {
    max-width: 420px;
    margin: 1.5rem auto;
}

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

.page-header h1 {
    margin: 0;
}

form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

form.inline-form {
    display: inline-flex;
}

label {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.6rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    color: var(--ink);
}

input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 0.7rem 0.75rem;
    font-size: 1rem;
    font-family: var(--font-body);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

textarea {
    resize: vertical;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    min-height: 44px;
    touch-action: manipulation;
    transition: background-color 0.15s ease, transform 0.05s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--pix);
    color: #fff;
}

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

.btn-secondary {
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger-soft);
    color: var(--danger-dark);
}

.btn-link {
    background: none;
    border: none;
    color: var(--pix);
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.2rem;
    font-size: 0.95rem;
}

.charge-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.charge-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem 1rem 1rem;
    overflow: hidden;
}

.charge-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--pix);
}

.charge-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.15rem;
}

.charge-header h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1.05rem;
}

.charge-amount {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--pix-dark);
    white-space: nowrap;
}

.charge-description {
    color: var(--muted);
    margin: 0.4rem 0 0.2rem;
}

/* Ticket-tear: perforated stub between charge details and payment actions */
.ticket-tear {
    position: relative;
    border-top: 2px dashed var(--border-strong);
    margin: 0.9rem -1rem 0.8rem;
}

.ticket-tear::before,
.ticket-tear::after {
    content: "";
    position: absolute;
    top: -9px;
    width: 18px;
    height: 18px;
    background: var(--paper);
    border-radius: 50%;
}

.ticket-tear::before {
    left: -9px;
}

.ticket-tear::after {
    right: -9px;
}

/* Single-row charge actions: QR code / reveal Pix code / copy */
.charge-actions {
    display: flex;
    gap: 0.5rem;
}

.charge-action {
    flex: 1;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.55rem 0.35rem;
    font-size: 0.72rem;
    line-height: 1.1;
    min-height: 58px;
}

.charge-action svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    flex-shrink: 0;
}

.charge-action.is-active {
    background: var(--pix-soft);
    color: var(--pix-dark);
}

.copia-cola-reveal {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    transition: max-height 0.2s ease, opacity 0.15s ease, margin-top 0.2s ease;
}

.copia-cola-reveal.is-open {
    max-height: 200px;
    opacity: 1;
    margin-top: 0.6rem;
}

.copia-cola-code {
    display: block;
    word-break: break-all;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.7rem;
    transition: background-color 0.2s ease;
}

/* QR modal: shared <dialog> populated per-card via data attributes */
.qr-modal {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 0;
    background: var(--surface);
    color: var(--ink);
    width: min(340px, calc(100vw - 2.5rem));
}

.qr-modal::backdrop {
    background: rgba(18, 22, 29, 0.55);
}

.qr-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border);
}

.qr-modal-head h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 1rem;
}

.qr-modal-close {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
}

.qr-modal-close:hover {
    background: var(--border);
    color: var(--ink);
}

.qr-modal-body {
    display: flex;
    justify-content: center;
    padding: 1.25rem;
}

.qr-modal-body img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    padding: 0.5rem;
}

/* Copy confirmation toast */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-height) + 1rem);
    transform: translateX(-50%) translateY(10px);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--chrome-bg);
    color: var(--chrome-text);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 30;
}

.toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast svg {
    width: 18px;
    height: 18px;
    stroke: var(--pix);
    flex-shrink: 0;
}

@media (min-width: 860px) {
    .toast { bottom: 1.25rem; }
}

.item-list {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.item-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.assign-form {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.assign-form select {
    width: auto;
}

.badge {
    display: inline-block;
    background: var(--amber-soft);
    color: var(--amber);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* Plate chip: the car's real license plate, rendered as UI */
.plate-chip {
    display: inline-flex;
    align-items: stretch;
    background: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    max-width: 100%;
}

.plate-chip-strip {
    flex-shrink: 0;
    width: 22px;
    background: var(--plate-blue);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-family: var(--font-mono);
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.plate-chip-body {
    padding: 0.5rem 0.85rem;
    min-width: 0;
}

.plate-chip-number {
    display: block;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.13em;
    color: #12161d;
}

.plate-chip-model {
    display: block;
    font-size: 0.82rem;
    color: var(--muted);
    margin-top: 0.1rem;
}

/* Compact plate chip nested inside a summary stat tile */
.plate-chip-sm {
    box-shadow: none;
    margin-top: 0.2rem;
}
.plate-chip-sm .plate-chip-strip { width: 18px; font-size: 0.5rem; }
.plate-chip-sm .plate-chip-body { padding: 0.4rem 0.6rem; }
.plate-chip-sm .plate-chip-number { font-size: 1.05rem; letter-spacing: 0.1em; }
.plate-chip-sm .plate-chip-model { font-size: 0.72rem; }

.plate-empty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--muted);
}

@media (min-width: 768px) {
    main.container {
        max-width: 960px;
        padding: 1.75rem 1.5rem calc(var(--tabbar-height) + 2rem);
    }

    .item-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .charge-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

@media (min-width: 860px) {
    body {
        display: flex;
        flex-direction: column;
    }

    main.container {
        order: 2;
    }

    .tabbar {
        order: 1;
        position: sticky;
        top: 0;
        left: auto;
        right: auto;
        border-top: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        justify-content: center;
        gap: 0.5rem;
        z-index: 19;
    }

    .tab-item,
    .tab-item-form {
        flex: none;
    }

    .tab-item {
        flex-direction: row;
        min-height: 44px;
        padding: 0.9rem 1rem;
    }

    main.container {
        padding-bottom: 2rem;
    }
}
