:root {
    --fv-bg: #0c1322;
    --fv-bg-deep: #070e1d;
    --fv-surface: #191f2f;
    --fv-surface-2: #222a3d;
    --fv-line: #2e3545;
    --fv-line-soft: #232a3a;
    --fv-line-faint: #1c2333;
    --fv-text: #ffffff;
    --fv-muted: #9fb1bc;
    --fv-muted-dim: #6b7a86;
    --fv-muted-deep: #4b5563;
    --fv-primary: #f83812;
    --fv-primary-deep: #c42e0e;
    --fv-primary-lite: #ff6b4a;
    --fv-primary-glow: rgba(248, 56, 18, 0.18);
    --fv-primary-soft: rgba(248, 56, 18, 0.10);
    --fv-primary-border: rgba(248, 56, 18, 0.30);
    --fv-amber: #ffae03;
    --fv-info: #3b82f6;
    --fv-success: #10b981;
    --fv-warning: #f59e0b;
    --fv-error: #ef4444;
    --fv-font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --fv-font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
    --fv-eyebrow-spacing: 1.4px;
}

* {
    scrollbar-color: var(--fv-line) var(--fv-bg);
    scrollbar-width: thin;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--fv-bg); }
::-webkit-scrollbar-thumb { background: var(--fv-line); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #374151; }

html,
body {
    min-height: 100%;
    color-scheme: dark;
}

body {
    margin: 0;
    color: var(--fv-text);
    background: var(--fv-bg);
    font-family: var(--fv-font);
}

button {
    font: inherit;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 32px;
}

.top-band {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 0 22px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--fv-primary);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fv-eyebrow-spacing);
}

h1,
h2 {
    margin: 0;
    color: var(--fv-text);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 28px;
    font-weight: 800;
    line-height: 1.12;
}

h2 {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.25;
}

.panel > h2 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel > h2::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 18px;
    background: var(--fv-primary);
    border-radius: 2px;
    flex-shrink: 0;
}

.status-cluster,
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 5px 10px;
    border: 1px solid rgba(159, 177, 188, 0.28);
    border-radius: 999px;
    background: rgba(159, 177, 188, 0.10);
    color: var(--fv-muted);
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.status-pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.status-pill.ready {
    background: rgba(16, 185, 129, 0.14);
    border-color: rgba(16, 185, 129, 0.28);
    color: #34d8a3;
}

.status-pill.busy {
    background: rgba(248, 56, 18, 0.16);
    border-color: var(--fv-primary-border);
    color: #ff8a6e;
}

.status-pill.pending {
    background: rgba(245, 158, 11, 0.14);
    border-color: rgba(245, 158, 11, 0.28);
    color: #fbbf24;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) repeat(3, minmax(220px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.panel {
    border: 1px solid var(--fv-line-soft);
    border-radius: 14px;
    background: var(--fv-surface);
    padding: 18px;
    transition: border-color .15s ease, background .15s ease;
}

.action-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.bluetooth-box {
    display: grid;
    gap: 10px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--fv-line-faint);
}

.bluetooth-box span,
.bluetooth-box small {
    display: block;
    color: var(--fv-muted-dim);
}

.bluetooth-box span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fv-eyebrow-spacing);
}

.bluetooth-box strong {
    display: block;
    margin-top: 3px;
    overflow-wrap: anywhere;
    color: var(--fv-text);
    font-size: 0.98rem;
}

.bluetooth-box small {
    margin-top: 3px;
    line-height: 1.35;
}

.device-button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.button-row {
    flex-direction: column;
}

.category-read-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.category-read-row select {
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--fv-line);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--fv-bg);
    color: var(--fv-text);
    font: inherit;
    font-weight: 650;
    color-scheme: dark;
}

.category-read-row select:focus {
    outline: none;
    border-color: var(--fv-primary);
    box-shadow: 0 0 0 2px var(--fv-primary-glow);
}

.category-button-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.category-button-row .secondary-action {
    width: 100%;
    white-space: nowrap;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    color: var(--fv-text);
    font-weight: 650;
}

.option-row input {
    width: 18px;
    height: 18px;
    accent-color: var(--fv-primary);
}

.primary-action,
.secondary-action {
    min-height: 42px;
    width: 100%;
    border-radius: 10px;
    padding: 9px 12px;
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .1s ease, box-shadow .2s ease, border-color .15s ease, background .15s ease;
}

.primary-action {
    color: #ffffff;
    background: linear-gradient(135deg, #f83812 0%, #ff5635 100%);
    box-shadow: 0 6px 20px -8px rgba(248, 56, 18, 0.5);
}

.primary-action:not(:disabled):hover {
    background: linear-gradient(135deg, #ff5635 0%, #f83812 100%);
    box-shadow: 0 0 24px rgba(248, 56, 18, 0.4);
    transform: translateY(-1px);
}

.primary-action:disabled {
    background: linear-gradient(135deg, #2a3146, #1f2638);
    color: var(--fv-muted-dim);
    box-shadow: none;
}

.secondary-action {
    color: var(--fv-text);
    background: transparent;
    border-color: var(--fv-line);
}

.secondary-action:not(:disabled):hover {
    border-color: var(--fv-primary);
    background: var(--fv-primary-soft);
}

.secondary-action:disabled {
    color: var(--fv-muted-dim);
}

.snapshot-list {
    display: grid;
    gap: 12px;
    margin: 16px 0 0;
}

.snapshot-list div {
    min-width: 0;
}

.snapshot-list dt {
    color: var(--fv-muted-dim);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--fv-eyebrow-spacing);
}

.snapshot-list .did-code {
    color: var(--fv-muted-dim);
    font-weight: 650;
    text-transform: none;
    letter-spacing: 0;
}

.metric-label {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 6px;
}

.metric-label > span:first-child {
    min-width: 100%;
}

.tooltip-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    outline: none;
}

.tooltip-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: 1px solid var(--fv-line);
    border-radius: 50%;
    background: var(--fv-surface-2);
    color: var(--fv-muted);
    font-size: 0.72rem;
    font-weight: 800;
    line-height: 1;
    text-transform: none;
    cursor: help;
    transition: border-color .15s ease, background .15s ease;
}

.tooltip-panel {
    position: absolute;
    z-index: 20;
    left: 0;
    top: calc(100% + 8px);
    display: none;
    width: min(300px, calc(100vw - 40px));
    padding: 10px 12px;
    border: 1px solid var(--fv-line);
    border-radius: 10px;
    background: var(--fv-surface-2);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
    color: var(--fv-muted);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.45;
    text-transform: none;
}

.tooltip-panel span {
    display: block;
}

.tooltip-panel span + span {
    margin-top: 6px;
}

.tooltip-title {
    color: var(--fv-text);
    font-weight: 800;
}

.tooltip-wrap:hover .tooltip-panel,
.tooltip-wrap:focus .tooltip-panel,
.tooltip-wrap:focus-within .tooltip-panel {
    display: block;
}

.tooltip-wrap:hover .tooltip-trigger,
.tooltip-wrap:focus .tooltip-trigger,
.tooltip-wrap:focus-within .tooltip-trigger {
    border-color: var(--fv-primary);
    background: var(--fv-primary-soft);
}

.snapshot-list dd {
    margin: 2px 0 0;
    overflow-wrap: anywhere;
    color: var(--fv-text);
    font-size: 15px;
    font-weight: 600;
}

.snapshot-list .hash {
    font-family: var(--fv-font-mono);
    font-size: 0.82rem;
    line-height: 1.45;
}

.snapshot-list .field-check-value {
    color: var(--fv-amber);
}

.snapshot-list .field-check-source {
    color: var(--fv-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.snapshot-list .version-ok {
    color: var(--fv-success);
}

.snapshot-list .version-warn {
    color: var(--fv-warning);
}

.snapshot-list .version-unknown {
    color: var(--fv-muted-dim);
}

.version-did-list {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--fv-line-faint);
}

.version-did-list dd {
    font-size: 13px;
}

.snapshot-list .unavailable dd {
    color: var(--fv-muted-dim);
}

.snapshot-list .unavailable .field-check-value {
    color: var(--fv-amber);
}

.empty-state {
    margin-top: 16px;
    color: var(--fv-muted-dim);
}

.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

.driver-hours-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
    align-items: start;
}

.compact-list {
    gap: 10px;
}

.compact-list div {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(92px, auto);
    gap: 10px;
    align-items: baseline;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--fv-line-faint);
}

.compact-list div:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.compact-list dd {
    margin-top: 0;
    text-align: right;
    white-space: nowrap;
    font-family: var(--fv-font-mono);
    font-variant-numeric: tabular-nums;
}

.guess-row dt::after {
    content: " field check";
    color: var(--fv-amber);
    font-size: 0.68rem;
    font-weight: 800;
}

.guess-row small {
    grid-column: 1 / -1;
    color: var(--fv-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.metric-note {
    margin: 12px 0 0;
    color: var(--fv-muted);
    font-size: 0.82rem;
    line-height: 1.4;
}

.diagnostics-panel {
    min-width: 0;
}

.diagnostics-list {
    gap: 10px;
}

.guide-panel {
    margin-bottom: 16px;
    border: 1px solid var(--fv-line-soft);
    border-radius: 14px;
    background: var(--fv-surface);
    overflow: hidden;
}

.guide-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--fv-text);
    transition: background .15s ease;
}

.guide-toggle:hover {
    background: var(--fv-surface-2);
}

.guide-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    font-family: var(--fv-font-mono);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.guide-toggle-label {
    flex: 1;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.guide-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--fv-surface-2);
    color: var(--fv-muted-dim);
    flex-shrink: 0;
    transition: transform .2s ease, background .15s ease;
}

.guide-chevron::after {
    content: '';
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-top: -2px;
}

.guide-chevron.open {
    transform: rotate(180deg);
    background: var(--fv-primary-soft);
    color: var(--fv-primary-lite);
}

.guide-toggle:hover .guide-chevron {
    background: var(--fv-line);
}

.guide-toggle:hover .guide-chevron.open {
    background: var(--fv-primary-glow);
}

.guide-body {
    border-top: 1px solid var(--fv-line-faint);
}

.guide-steps {
    margin: 0;
    padding: 16px 18px 16px 42px;
    display: grid;
    gap: 10px;
    color: var(--fv-muted);
    font-size: 14px;
    line-height: 1.5;
}

.guide-steps li::marker {
    color: var(--fv-primary);
    font-weight: 700;
}

.guide-steps strong {
    color: var(--fv-text);
}

.guide-notes {
    display: grid;
    gap: 0;
}

.guide-note {
    margin: 0;
    padding: 12px 18px;
    border-top: 1px solid var(--fv-line-faint);
    font-size: 13px;
    line-height: 1.5;
}

.guide-note--warning {
    color: var(--fv-warning);
}

.guide-note--warning strong {
    color: var(--fv-warning);
}

.guide-note--tip {
    color: var(--fv-info);
}

.guide-note--tip strong {
    color: #93c5fd;
}

.log-panel {
    margin-top: 16px;
    padding: 0;
    overflow: hidden;
}

.log-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--fv-line-soft);
}

.log-heading span {
    color: var(--fv-muted-dim);
    font-size: 0.88rem;
}

.log-list {
    max-height: 460px;
    overflow: auto;
}

.log-row {
    display: grid;
    grid-template-columns: 76px 68px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 10px 18px;
    border-bottom: 1px solid var(--fv-line-faint);
    position: relative;
    padding-left: 22px;
}

.log-row::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--fv-line-faint);
}

.log-row.ok::before { background: var(--fv-success); }
.log-row.warn::before { background: var(--fv-warning); }
.log-row.error::before { background: var(--fv-error); }
.log-row.trace::before { background: var(--fv-muted-dim); }

.log-row time {
    color: var(--fv-muted-dim);
    font-family: var(--fv-font-mono);
    font-variant-numeric: tabular-nums;
}

.log-row span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.log-row p {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    color: var(--fv-muted);
}

.log-row.ok span { color: #34d8a3; }
.log-row.warn span { color: #fbbf24; }
.log-row.error span { color: #fca5a5; }
.log-row.trace span { color: var(--fv-muted-dim); }

#blazor-error-ui {
    color-scheme: dark only;
    background: var(--fv-surface);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    color: var(--fv-error);
    border-top: 2px solid var(--fv-error);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--fv-surface);
    stroke-width: 0.6rem;
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
}

.loading-progress circle:last-child {
    stroke: var(--fv-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    inset: calc(20vh + 3.25rem) 0 auto 0;
    color: var(--fv-muted);
    font-weight: 700;
    text-align: center;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

@media (max-width: 1120px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .driver-hours-grid {
        grid-template-columns: 1fr;
    }

    .action-panel {
        grid-column: 1 / -1;
    }
}

@media (max-width: 700px) {
    .app-shell {
        width: min(100% - 20px, 1180px);
        padding-top: 16px;
    }

    .top-band {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .log-row {
        grid-template-columns: 64px 58px minmax(0, 1fr);
        padding: 10px 12px;
        padding-left: 16px;
    }

    .compact-list div {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .compact-list dd {
        text-align: left;
        white-space: normal;
    }
}
