:root {
    --brand: #0072BB;
    --state: #0072BB;
    font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: #f1f5f9;
    color: #1e293b;
    min-height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--brand);
    color: #fff;
    padding: .6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.app-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.2px;
}
.app-name em {
    font-style: normal;
    font-weight: 400;
    opacity: .75;
}

.header-right {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    transition: background .4s;
}
.status-dot.live  { background: #4ade80; }
.status-dot.error { background: #f87171; }

.refresh-btn {
    background: rgba(255,255,255,.2);
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: .4rem;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.refresh-btn:active { background: rgba(255,255,255,.35); }

/* ── Stale banner ──────────────────────────────────────────────────────────── */
.stale-banner {
    background: #fef3c7;
    color: #92400e;
    padding: .4rem 1rem;
    font-size: .75rem;
    font-weight: 600;
    text-align: center;
    border-bottom: 1px solid #fde68a;
    display: none;
}
.stale-banner.visible { display: block; }

/* ── Search bar ────────────────────────────────────────────────────────────── */
.search-bar {
    background: #fff;
    padding: .55rem .65rem;
    display: flex;
    gap: .45rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.search-bar input {
    flex: 1;
    min-width: 0;
    padding: .55rem .75rem;
    border: 1.5px solid #cbd5e1;
    border-radius: .45rem;
    font-size: .82rem;
    font-family: 'Consolas', 'Courier New', monospace;
    letter-spacing: .04em;
    outline: none;
    transition: border-color .2s;
}
.search-bar input:focus { border-color: var(--brand); }

.search-bar button {
    padding: .55rem 1.1rem;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: .45rem;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.search-bar button:active { filter: brightness(.9); }

/* ── State banner ──────────────────────────────────────────────────────────── */
.state-banner {
    background: var(--state);
    color: #fff;
    padding: .5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
}
.state-badge {
    font-size: 1rem;
    font-weight: 700;
}
.driver-name {
    font-size: .8rem;
    opacity: .9;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Dashboard wrapper ─────────────────────────────────────────────────────── */
.dashboard {
    padding: .7rem;
    max-width: 620px;
    margin: 0 auto;
}

/* ── Hero card ─────────────────────────────────────────────────────────────── */
.hero-card {
    background: #fff;
    border-radius: 1rem;
    padding: 1.2rem 1rem 1rem;
    margin-bottom: .6rem;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hero-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #94a3b8;
    margin-bottom: .8rem;
}

.arc-wrap {
    position: relative;
    width: 164px;
    height: 164px;
}
.arc-wrap svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}
.arc-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
.arc-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: var(--state);
}
.arc-sub {
    font-size: .65rem;
    color: #94a3b8;
    margin-top: .2rem;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-top: .75rem;
    justify-content: center;
}
.pill {
    padding: .22rem .65rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 600;
    background: #dcfce7;
    color: #166534;
}

.warn-banner {
    margin-top: .65rem;
    width: 100%;
    padding: .4rem .75rem;
    border-radius: .5rem;
    font-size: .8rem;
    font-weight: 700;
    text-align: center;
    background: #fef3c7;
    color: #92400e;
}
.warn-banner.danger {
    background: #fee2e2;
    color: #991b1b;
}

/* ── Section title ─────────────────────────────────────────────────────────── */
.section-title {
    font-size: .64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #94a3b8;
    margin: .65rem 0 .35rem .1rem;
}

/* ── Cards grid ────────────────────────────────────────────────────────────── */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .45rem;
    margin-bottom: .45rem;
}

.card {
    background: #fff;
    border-radius: .7rem;
    padding: .65rem .7rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-label {
    font-size: .59rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    margin-bottom: .18rem;
}
.card-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
}
/* Deadline strings can be longer — scale down slightly so they fit */
.card-value.deadline {
    font-size: .88rem;
    font-weight: 700;
    color: #1e293b;
}
.card-value.warn   { color: #d97706; }
.card-value.danger { color: #dc2626; }
.card-sub {
    font-size: .62rem;
    color: #94a3b8;
    margin-top: .1rem;
}

/* ── Rest info card (Next Daily Rest / Next Weekly Rest) ───────────────────── */
/* ── Next Stop Required card ───────────────────────────────────────────────── */
.next-stop-card {
    background: #fff;
    border-radius: .9rem;
    padding: .75rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    margin-bottom: .65rem;
    border-left: 4px solid #0072BB;
}
.next-stop-type {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .55rem;
}
.next-stop-icon {
    font-size: 2.2rem;
    line-height: 1;
}
.next-stop-type-text { flex: 1; }
.next-stop-label {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.2;
}
.next-stop-hint {
    font-size: .72rem;
    color: #64748b;
    margin-top: .2rem;
    line-height: 1.3;
}
.next-stop-when {
    font-size: 1.35rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: .45rem;
    line-height: 1.2;
}
.next-stop-when.warn   { color: #d97706; }
.next-stop-when.danger { color: #dc2626; }
.next-stop-at { display: block; }
.next-stop-in {
    font-size: .8rem;
    font-weight: 500;
    color: #64748b;
}
.next-stop-rows {
    border-top: 1px solid #f1f5f9;
    padding-top: .4rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.next-stop-row {
    display: flex;
    justify-content: space-between;
    font-size: .8rem;
    color: #475569;
    padding: .15rem 0;
}
.next-stop-row span:last-child {
    font-weight: 700;
    color: #1e293b;
}
.next-stop-row--highlight {
    font-size: .88rem;
    padding: .3rem 0;
    border-bottom: 1px solid #f1f5f9;
}
.next-stop-row--highlight span:first-child {
    font-weight: 600;
    color: #334155;
}
.next-stop-row--highlight span:last-child {
    font-size: .95rem;
}

.rest-info-card {
    background: #fff;
    border-radius: .7rem;
    padding: .55rem .75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: .45rem;
}
.rest-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .3rem 0;
    border-bottom: 1px solid #f1f5f9;
    gap: .5rem;
}
.rest-row:last-child { border-bottom: none; }
.rest-lbl {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    flex-shrink: 0;
}
.rest-val {
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
}
.rest-val.warn   { color: #d97706; }
.rest-val.danger { color: #dc2626; }
.rest-sub {
    font-size: .65rem;
    font-weight: 400;
    color: #94a3b8;
    margin-left: .3rem;
}

/* ── Dates card ────────────────────────────────────────────────────────────── */
.dates-card {
    background: #fff;
    border-radius: .7rem;
    padding: .6rem .75rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    margin-bottom: .65rem;
}
.date-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .28rem 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: .75rem;
    gap: .5rem;
}
.date-row:last-child { border-bottom: none; }
.date-row .lbl { color: #64748b; flex-shrink: 0; }
.date-row .val { font-weight: 600; color: #334155; text-align: right; font-size: .72rem; }

/* ── Infringement card ─────────────────────────────────────────────────────── */
.infring-card {
    background: #fef9c3;
    border: 1.5px solid #eab308;
    border-radius: .7rem;
    padding: .6rem .75rem;
    margin-bottom: .65rem;
}
.infring-card.danger {
    background: #fee2e2;
    border-color: #dc2626;
}
.infring-title {
    font-size: .72rem;
    font-weight: 700;
    color: #78350f;
    margin-bottom: .3rem;
}
.infring-card.danger .infring-title { color: #7f1d1d; }
.infring-row {
    display: flex;
    justify-content: space-between;
    font-size: .76rem;
    padding: .15rem 0;
    color: #78350f;
}
.infring-card.danger .infring-row { color: #7f1d1d; }
.infring-count { font-weight: 700; }

/* ── Data footer ───────────────────────────────────────────────────────────── */
/* ── Raw Data Panel ────────────────────────────────────────────────────────── */
.raw-data-panel {
    background: #fff;
    border-radius: .7rem;
    margin-bottom: .65rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    overflow: hidden;
}
.raw-data-panel summary {
    padding: .55rem .85rem;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
}
.raw-data-panel summary:hover { color: #475569; }
.raw-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
}
.raw-table tr { border-top: 1px solid #f1f5f9; }
.raw-field {
    padding: .3rem .85rem;
    color: #64748b;
    font-family: 'Cascadia Code', 'Fira Mono', monospace;
    width: 55%;
}
.raw-value {
    padding: .3rem .5rem;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
    white-space: nowrap;
}
.raw-fmt {
    padding: .3rem .85rem .3rem .4rem;
    color: #94a3b8;
    font-size: .72rem;
    text-align: right;
    white-space: nowrap;
}
.raw-null { color: #cbd5e1; font-weight: 400; }

.data-footer {
    text-align: center;
    font-size: .64rem;
    color: #94a3b8;
    padding: .4rem .5rem 2.5rem;
    line-height: 1.7;
}

/* ── Empty / loading states ────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: #64748b;
}
.empty-icon  { font-size: 2.8rem; margin-bottom: .6rem; }
.empty-title { font-size: 1.1rem; font-weight: 700; color: #334155; margin-bottom: .4rem; }
.empty-sub   { font-size: .85rem; }

/* ── Tablet: 3-column cards ────────────────────────────────────────────────── */
@media (min-width: 480px) {
    .cards-grid { grid-template-columns: 1fr 1fr 1fr; }
}
