:root {
    /* Typography */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: var(--font-sans);

    /* Palette (hattatsu.pro) */
    --accent: #046bd2;
    --accent-dark: #045cb4;
    --accent-soft: rgba(4, 107, 210, 0.1);
    --accent-nav: #110f56;
    --primary-color: var(--accent);
    --primary-dark: var(--accent-dark);
    --primary-light: #3b8ee8;
    --secondary-color: #1e293b;
    --text-primary: #1e293b;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-primary: #ffffff;
    --bg-secondary: #f0f5fa;
    --bg-tertiary: #e8eef5;
    --success-color: #059669;
    --success-light: #d1fae5;
    --danger-color: #dc2626;
    --danger-light: #fee2e2;
    --warning-color: #d97706;
    --warning-light: #fef3c7;
    --info-color: #046bd2;
    --info-light: #dbeafe;
    --content-card: var(--bg-primary);

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Radius / shadow / layout */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --shadow-sm: 0 1px 2px rgba(30, 41, 59, 0.05);
    --shadow-md: 0 10px 30px rgba(30, 41, 59, 0.08);
    --shadow-lg: 0 16px 40px rgba(30, 41, 59, 0.12);
    --header-h: 64px;
    --content-max: 1280px;

    /* Atmosphere */
    --bg-glow: radial-gradient(ellipse 80% 50% at 10% -10%, rgba(4, 107, 210, 0.12), transparent 55%),
        radial-gradient(ellipse 60% 40% at 95% 5%, rgba(17, 15, 86, 0.08), transparent 50%),
        radial-gradient(ellipse 50% 35% at 70% 100%, rgba(4, 107, 210, 0.06), transparent 45%);

    /* Motion */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur-fast: 0.15s;
    --dur: 0.25s;
    --dur-slow: 0.4s;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    font-family: var(--font-sans);
    background-color: var(--bg-secondary);
    background-image: var(--bg-glow);
    background-attachment: fixed;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.5;
    min-height: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-dark);
    text-decoration: underline;
}

/* —— Page chrome —— */
.page-container {
    max-width: 100%;
    margin: 0 auto;
}

.page-kicker {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--border-color);
    gap: var(--space-4);
    flex-wrap: wrap;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 2.8vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.3;
}

.page-description {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin: 0.5rem 0 0;
    max-width: 42rem;
    line-height: 1.5;
}

/* —— Cards —— */
.content-card,
.card {
    background: var(--content-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem 1.75rem;
    margin-bottom: var(--space-5);
    transition: box-shadow var(--dur-fast) var(--ease);
}

.content-card:hover,
.card:hover {
    box-shadow: var(--shadow-md);
}

.content-card h2,
.content-card h3,
.card h2,
.card h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    line-height: 1.35;
    margin: 0 0 var(--space-4);
    color: var(--text-primary);
}

/* —— Stat tiles —— */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.stat-tile {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.35rem;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.stat-tile:hover {
    border-color: rgba(4, 107, 210, 0.35);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-tile-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
}

.stat-tile-value {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

/* —— Badges —— */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-online { background: var(--success-light); color: #065f46; }
.badge-offline { background: var(--bg-tertiary); color: var(--text-secondary); }
.badge-busy { background: var(--info-light); color: #1e40af; }
.badge-error { background: var(--danger-light); color: #991b1b; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-inactive { background: var(--bg-tertiary); color: var(--text-secondary); }

/* —— Device tabs (ops chrome, not pixel theme) —— */
.device-tabs-shell {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    margin-bottom: var(--space-4);
    background: var(--bg-primary);
}

.device-tabs-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0;
    min-height: 44px;
    padding: 0 6px;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 1px solid var(--border-color);
}

.device-tab {
    padding: 0.65rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
    font-family: inherit;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.device-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--accent-soft);
}

.device-tabs-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
    padding: 0.4rem;
}

.toolbar-actions,
.proxy-toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--space-4);
}

.proxy-toolbar {
    padding: 0.85rem 1.15rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

/* —— Buttons (hattatsu CTA: ~13×30, weight 500) —— */
.btn,
button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.8125rem 1.875rem;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-weight: 500;
    font-family: inherit;
    font-size: 0.95rem;
    text-decoration: none;
    line-height: 1.25;
    transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.btn:hover:not(:disabled),
button.btn:hover:not(:disabled) {
    background: var(--accent-dark);
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(4, 107, 210, 0.25);
}

.btn:disabled,
button.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-color: var(--border-color);
    transform: none;
    box-shadow: none;
}

.btn-primary,
a.btn-primary {
    background: var(--accent);
    color: #fff !important;
    text-decoration: none;
}

.btn-primary:hover,
a.btn-primary:hover {
    background: var(--accent-dark);
    color: #fff !important;
    text-decoration: none;
}

.btn-secondary,
a.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color);
    text-decoration: none;
}

.btn-secondary:hover:not(:disabled),
a.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent) !important;
    background: var(--bg-primary);
    text-decoration: none;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: none;
}

.btn-danger {
    background: var(--danger-color);
    border-color: var(--danger-color);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
}

.muted,
.text-muted {
    color: var(--text-muted);
}

.detail-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

@media (max-width: 900px) {
    .detail-panel { grid-template-columns: 1fr; }
}

.tab-panel { padding: var(--space-4); background: var(--bg-primary); }

.checkbox-col { width: 2.5rem; }

.progress-bar {
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-nav));
}

/* —— Alerts —— */
.alert {
    padding: 0.9rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-light);
    color: #166534;
    border-color: #a7f3d0;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border-color: #fde68a;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border-color: #bfdbfe;
}

/* —— Forms —— */
.form-group {
    margin-bottom: var(--space-4);
}

.form-group label,
label.form-label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea,
.form-control {
    width: 100%;
    max-width: 420px;
    padding: 0.75rem 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.form-group textarea.form-control,
textarea.form-control {
    max-width: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-end;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* —— Tables —— */
table:not(.pixel-fleet-table) {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

table:not(.pixel-fleet-table) th,
table:not(.pixel-fleet-table) td {
    padding: 0.9rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

table:not(.pixel-fleet-table) th {
    background: transparent;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

table:not(.pixel-fleet-table) tbody tr {
    transition: background var(--dur-fast) var(--ease);
}

table:not(.pixel-fleet-table) tbody tr:hover {
    background: rgba(4, 107, 210, 0.04);
}

table:not(.pixel-fleet-table) tbody tr:last-child td {
    border-bottom: none;
}

.data-table-wrap {
    overflow-x: auto;
}

/* —— Public / login —— */
.public-layout {
    min-height: 100vh;
    background-color: var(--bg-secondary);
    background-image: var(--bg-glow);
    color: var(--text-primary);
}

.login-stage {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
}

.login-page {
    width: 100%;
    max-width: 440px;
    animation: login-enter var(--dur-slow) var(--ease) both;
}

@keyframes login-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent);
    border-radius: var(--radius-lg);
    padding: 2.25rem 2rem 2rem;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(1.75rem, 3vw, 2.15rem);
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--accent-nav);
    margin: 0 0 0.35rem;
}

.login-title {
    font-size: 1.05rem;
    font-weight: 500;
    margin: 0 0 0.35rem;
    color: var(--text-secondary);
}

.login-support {
    margin: 0 0 1.5rem;
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.login-form .form-group {
    margin-bottom: 1.15rem;
}

.login-form input {
    max-width: none;
    padding: 0.85rem 1rem;
}

.login-submit {
    width: 100%;
    margin-top: 0.65rem;
    padding: 0.9rem 1.5rem;
    font-weight: 500;
}

/* —— Agent download —— */
.agent-download-page .download-hero {
    display: flex;
    justify-content: space-between;
    gap: var(--space-8);
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 2rem 2rem;
}

.agent-download-page .version-tag {
    font-family: var(--font-display);
    font-size: clamp(1.75rem, 3vw, 2.25rem);
    font-weight: 700;
    margin: 0.35rem 0;
    letter-spacing: -0.03em;
    line-height: 1.2;
    color: var(--accent-nav);
}

.agent-download-page .summary {
    margin: 0.65rem 0 0.35rem;
    font-size: 1.05rem;
    line-height: 1.5;
    max-width: 36rem;
}

.download-actions {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 240px;
}

.install-steps {
    margin: 0;
    padding-left: 1.35rem;
    line-height: 1.65;
}

.install-steps pre {
    margin: 0.5rem 0 0.75rem;
    padding: 0.75rem 0.9rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.85rem;
}

.releases-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.releases-table th,
.releases-table td {
    text-align: left;
    padding: 0.85rem 0.65rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.releases-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.releases-table tbody tr:hover {
    background: rgba(4, 107, 210, 0.04);
}

/* —— Status / empty pages —— */
.status-page {
    max-width: 36rem;
}

.status-page .page-header {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--space-6);
}

.status-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: var(--space-2);
}

/* —— Proxies —— */
.proxy-file-row {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.proxy-file-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1.15rem;
    cursor: pointer;
    user-select: none;
    transition: background var(--dur-fast) var(--ease);
}

.proxy-file-header:hover {
    background: var(--bg-secondary);
}

.proxy-file-count {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* —— Modals —— */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(30, 41, 59, 0.45);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
}

.modal-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    border-top: 3px solid var(--accent);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
}

.modal-card .form-group input,
.modal-card .form-group select,
.modal-card .form-group textarea {
    max-width: none;
}

.buffer-multiselect {
    display: block;
    width: 100%;
    min-height: 7.5rem;
    margin-top: 0.35rem;
}

.buffer-checklist {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 10rem;
    overflow-y: auto;
    margin-top: 0.35rem;
    padding: 0.5rem 0.65rem;
    border: 1px solid var(--border-color, var(--pixel-border, #333));
    border-radius: var(--radius-md, 6px);
    background: var(--bg-tertiary, transparent);
}

.buffer-checklist .checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
}

.key-display {
    font-family: ui-monospace, monospace;
    background: var(--bg-tertiary);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    word-break: break-all;
    margin-top: 0.5rem;
}

code {
    font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
    font-size: 0.9em;
    background: var(--bg-tertiary);
    padding: 0.1em 0.35em;
    border-radius: var(--radius-sm);
}

.event-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.event-row:last-child {
    border-bottom: none;
}

.screenshot-preview {
    display: block;
    max-width: min(480px, 100%);
    margin-top: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.enroll-alert {
    margin-top: var(--space-4);
}

.live-status {
    color: var(--text-secondary);
    margin: 0 0 var(--space-4);
}

/* —— Blazor error UI (global) —— */
#blazor-error-ui {
    background: var(--danger-color);
    bottom: 0;
    box-shadow: var(--shadow-md);
    color: #fff;
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .reload {
    color: #fff;
    margin-left: 0.75rem;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1rem;
    top: 0.65rem;
}

/* —— Shared page surface (billing / devices / job-stats share it) —— */
.surface-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.surface-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.surface-card-head h2,
.surface-card-head h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 650;
    color: var(--text-primary);
}

.surface-card-body {
    padding: 1rem 1.25rem;
}

.page-toolbar {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    padding: 1.25rem 1.5rem 1rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.page-toolbar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6 55%, #2f9e6f);
}

.page-toolbar-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
}

.page-toolbar-title h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.page-toolbar-sub {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.page-toolbar-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    margin-top: 1.1rem;
}

.toolbar-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0;
}

.toolbar-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.toolbar-field select,
.toolbar-field input {
    height: 2.25rem;
    padding: 0 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.9rem;
}

.toolbar-field select:focus,
.toolbar-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.segmented {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 10px;
    background: var(--bg-tertiary);
}

.segmented button {
    height: 1.9rem;
    padding: 0 0.8rem;
    border: 0;
    border-radius: 7px;
    background: none;
    color: var(--text-secondary);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.segmented button:hover {
    color: var(--text-primary);
}

.segmented button.is-active {
    background: var(--bg-primary);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.14);
}

/* Compact data table: one line per row, scrolls sideways instead of wrapping. */
.table-scroll {
    overflow-x: auto;
}

table.data-compact th,
table.data-compact td {
    padding: 0.5rem 0.75rem;
    white-space: nowrap;
    font-size: 0.85rem;
}

table.data-compact th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-primary);
    font-size: 0.7rem;
}

table.data-compact td.cell-wrap {
    white-space: normal;
    min-width: 14rem;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.pill-ok { background: var(--success-light); color: var(--success-text); }
.pill-bad { background: var(--danger-light); color: var(--danger-text); }
.pill-warn { background: var(--warning-light); color: var(--warning-text); }
.pill-info { background: var(--info-light); color: var(--info-text); }
.pill-muted { background: var(--bg-tertiary); color: var(--text-secondary); }

.mono {
    font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
    font-size: 0.8rem;
}

/* —— Light: text tones for tinted backgrounds —— */
:root {
    --success-text: #065f46;
    --danger-text: #991b1b;
    --warning-text: #92400e;
    --info-text: #1e40af;
    --nav-glass: rgba(255, 255, 255, 0.78);
    color-scheme: light;
}

/* —— Night mode: dark pastel surfaces, light text (WCAG AA on every surface) —— */
:root[data-theme="dark"] {
    color-scheme: dark;
    --accent: #8ab4ff;
    --accent-dark: #b3cdff;
    --accent-soft: rgba(138, 180, 255, 0.16);
    --accent-nav: #c7d7ff;
    --primary-color: var(--accent);
    --primary-dark: var(--accent-dark);
    --primary-light: #a9c6ff;
    --secondary-color: #d6dcec;
    --text-primary: #e8ebf4;
    --text-secondary: #c4cadb;
    --text-muted: #949db3;
    --border-color: #2f3548;
    --bg-primary: #1f2331;
    --bg-secondary: #161924;
    --bg-tertiary: #2a2f40;
    --success-color: #7ddbb0;
    --success-light: rgba(125, 219, 176, 0.16);
    --success-text: #a6ecc9;
    --danger-color: #f4a3a3;
    --danger-light: rgba(244, 163, 163, 0.16);
    --danger-text: #f9c0c0;
    --warning-color: #f2c98a;
    --warning-light: rgba(242, 201, 138, 0.16);
    --warning-text: #f6dbae;
    --info-color: #8ab4ff;
    --info-light: rgba(138, 180, 255, 0.16);
    --info-text: #bcd2ff;
    --content-card: var(--bg-primary);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --nav-glass: rgba(26, 29, 41, 0.78);
    --bg-glow: radial-gradient(ellipse 80% 50% at 10% -10%, rgba(138, 180, 255, 0.10), transparent 55%),
        radial-gradient(ellipse 60% 40% at 95% 5%, rgba(180, 150, 255, 0.07), transparent 50%),
        radial-gradient(ellipse 50% 35% at 70% 100%, rgba(125, 219, 176, 0.05), transparent 45%);
}

:root[data-theme="dark"] .btn,
:root[data-theme="dark"] button.btn,
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] a.btn-primary {
    color: #10131c !important;
}

:root[data-theme="dark"] .btn:hover:not(:disabled),
:root[data-theme="dark"] .btn-primary:hover {
    color: #10131c !important;
    box-shadow: 0 4px 14px rgba(138, 180, 255, 0.25);
}

:root[data-theme="dark"] .btn-secondary,
:root[data-theme="dark"] .btn-outline {
    color: var(--text-primary) !important;
}

:root[data-theme="dark"] .btn-danger {
    color: #2a0f12 !important;
}

:root[data-theme="dark"] .btn:disabled {
    color: var(--text-muted) !important;
}

:root[data-theme="dark"] .badge-online,
:root[data-theme="dark"] .alert-success { color: var(--success-text); border-color: transparent; }
:root[data-theme="dark"] .badge-busy,
:root[data-theme="dark"] .alert-info { color: var(--info-text); border-color: transparent; }
:root[data-theme="dark"] .badge-error { color: var(--danger-text); }
:root[data-theme="dark"] .badge-warning,
:root[data-theme="dark"] .alert-warning { color: var(--warning-text); border-color: transparent; }

:root[data-theme="dark"] table:not(.pixel-fleet-table) tbody tr:hover {
    background: rgba(138, 180, 255, 0.06);
}

:root[data-theme="dark"] .modal-backdrop {
    background: rgba(5, 7, 12, 0.6);
}

:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
}

html {
    transition: background-color var(--dur) var(--ease);
}

/* —— Day / night toggle in the header —— */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur) var(--ease);
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: rotate(-15deg);
}

.theme-toggle svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-icon-sun {
    display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
    display: block;
}

:root[data-theme="dark"] .theme-icon-moon {
    display: none;
}
