/*
 * Customer Portal Status - stylesheet
 *
 * Design tokens are defined once on :root and redefined per theme, so components only ever
 * reference tokens. The viewer's OS preference drives prefers-color-scheme; an explicit
 * data-theme on <html> (the in-page toggle) overrides it in both directions.
 *
 * ICT #5773.
 */

@font-face {
    font-family: 'Plex Sans';
    font-weight: 400 700;
    font-style: normal;
    font-display: swap;
    src: url('assets/fonts/plexsans-var.woff2') format('woff2');
}

@font-face {
    font-family: 'Plex Mono';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: url('assets/fonts/plexmono-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Plex Mono';
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    src: url('assets/fonts/plexmono-600.woff2') format('woff2');
}

:root {
    --ink: #14181c;
    --ink-soft: #4e5850;
    --ink-faint: #7c877e;
    --paper: #eef1ec;
    --surface: #ffffff;
    --surface-2: #f5f7f3;
    --line: #d9ded4;
    --line-strong: #b9c2b3;
    --accent: #a3571f;
    --accent-soft: #f3e4d4;
    --accent-ink: #7a3f14;

    --status-live: #256a41;
    --status-live-bg: #e2f2e6;
    --status-frozen: #92640c;
    --status-frozen-bg: #f6ecd7;
    --status-degraded: #a83629;
    --status-degraded-bg: #fbe6e2;
    --status-provisioned: #5f4a9c;
    --status-provisioned-bg: #ece6f8;
    --status-defunct: #626c60;
    --status-defunct-bg: #e6e9e2;
    --status-unknown-ink: #5a6357;
    --status-unknown-bg: #eef0eb;
    --status-unknown-hatch: rgba(20, 24, 28, 0.07);

    --shadow-card: 0 1px 2px rgba(20, 24, 28, 0.05), 0 1px 1px rgba(20, 24, 28, 0.03);
    --radius: 3px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --ink: #eef1ec;
        --ink-soft: #adb6a8;
        --ink-faint: #7c877e;
        --paper: #14171a;
        --surface: #1b1f21;
        --surface-2: #21262a;
        --line: #343b39;
        --line-strong: #47504c;
        --accent: #e08a4f;
        --accent-soft: #3a2c1e;
        --accent-ink: #f0b083;

        --status-live: #55c184;
        --status-live-bg: #172c1f;
        --status-frozen: #e0ac4d;
        --status-frozen-bg: #332705;
        --status-degraded: #e5786a;
        --status-degraded-bg: #3a1a15;
        --status-provisioned: #ab8ee0;
        --status-provisioned-bg: #251c3a;
        --status-defunct: #a3ac9f;
        --status-defunct-bg: #292d27;
        --status-unknown-ink: #a3ac9f;
        --status-unknown-bg: #21262a;
        --status-unknown-hatch: rgba(238, 241, 236, 0.06);

        --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
    }
}

:root[data-theme="dark"] {
    --ink: #eef1ec;
    --ink-soft: #adb6a8;
    --ink-faint: #7c877e;
    --paper: #14171a;
    --surface: #1b1f21;
    --surface-2: #21262a;
    --line: #343b39;
    --line-strong: #47504c;
    --accent: #e08a4f;
    --accent-soft: #3a2c1e;
    --accent-ink: #f0b083;
    --status-live: #55c184;
    --status-live-bg: #172c1f;
    --status-frozen: #e0ac4d;
    --status-frozen-bg: #332705;
    --status-degraded: #e5786a;
    --status-degraded-bg: #3a1a15;
    --status-provisioned: #ab8ee0;
    --status-provisioned-bg: #251c3a;
    --status-defunct: #a3ac9f;
    --status-defunct-bg: #292d27;
    --status-unknown-ink: #a3ac9f;
    --status-unknown-bg: #21262a;
    --status-unknown-hatch: rgba(238, 241, 236, 0.06);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 1px rgba(0, 0, 0, 0.2);
}

:root[data-theme="light"] {
    --ink: #14181c;
    --ink-soft: #4e5850;
    --ink-faint: #7c877e;
    --paper: #eef1ec;
    --surface: #ffffff;
    --surface-2: #f5f7f3;
    --line: #d9ded4;
    --line-strong: #b9c2b3;
    --accent: #a3571f;
    --accent-soft: #f3e4d4;
    --accent-ink: #7a3f14;
    --status-live: #256a41;
    --status-live-bg: #e2f2e6;
    --status-frozen: #92640c;
    --status-frozen-bg: #f6ecd7;
    --status-degraded: #a83629;
    --status-degraded-bg: #fbe6e2;
    --status-provisioned: #5f4a9c;
    --status-provisioned-bg: #ece6f8;
    --status-defunct: #626c60;
    --status-defunct-bg: #e6e9e2;
    --status-unknown-ink: #5a6357;
    --status-unknown-bg: #eef0eb;
    --status-unknown-hatch: rgba(20, 24, 28, 0.07);
    --shadow-card: 0 1px 2px rgba(20, 24, 28, 0.05), 0 1px 1px rgba(20, 24, 28, 0.03);
}

* {
    box-sizing: border-box;
}

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

html,
body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: 'Plex Sans', 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.page {
    max-width: 1440px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

/* ---------- Gate (pre sign-in) ---------- */

.gate {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.gate-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 32px;
    max-width: 460px;
    width: 100%;
}

.gate-card h1 {
    font-size: 22px;
    margin: 0 0 8px;
}

.gate-card p {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0 0 20px;
}

.btn {
    font-family: 'Plex Sans', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--surface);
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 9px 18px;
    cursor: pointer;
}

.btn:hover {
    background: var(--accent-ink);
    border-color: var(--accent-ink);
}

.btn:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.btn--quiet {
    color: var(--ink);
    background: var(--surface-2);
    border-color: var(--line);
}

.btn--quiet:hover {
    background: var(--line);
    border-color: var(--line-strong);
}

/* ---------- Header ---------- */

.hub-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.hub-title-block {
    position: relative;
    z-index: 1;
    max-width: 640px;
    padding: 16px 22px;
    border-radius: var(--radius);
    overflow: hidden;
}

/* A quiet echo of the portal login pages this page tracks - the same diagonal-cut
   composition (text panel / colour panel), spent in exactly one place rather than
   repeated, so it reads as this page's own identity instead of decoration. */
.hub-title-block::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, var(--surface) 0%, var(--surface) 62%, var(--accent-soft) 62%, var(--accent-soft) 100%);
    z-index: -1;
}

.eyebrow {
    font-family: 'Plex Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent-ink);
    margin: 0 0 6px;
}

h1 {
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
    text-wrap: balance;
}

.hub-subtitle {
    color: var(--ink-soft);
    font-size: 14px;
    margin: 0;
    max-width: 60ch;
}

.header-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.stat-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-tile {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 16px;
    min-width: 112px;
}

.stat-num {
    font-family: 'Plex Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.1;
}

.stat-tile--flag .stat-num {
    color: var(--accent-ink);
}

.stat-label {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin-top: 3px;
}

.session-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--ink-faint);
}

.session-bar button {
    font-family: 'Plex Sans', sans-serif;
    font-size: 12px;
    background: none;
    border: 0;
    padding: 0;
    color: var(--accent-ink);
    text-decoration: underline;
    cursor: pointer;
}

/* ---------- Legend ---------- */

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin: 18px 0 26px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.legend-title {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-faint);
    align-self: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ink-soft);
}

.legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-dot--unknown {
    background-color: var(--status-unknown-bg);
    background-image: repeating-linear-gradient(-45deg, var(--status-unknown-hatch), var(--status-unknown-hatch) 3px, transparent 3px, transparent 6px);
}

/* ---------- Grid ---------- */

.section-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-faint);
    margin: 30px 0 10px;
}

.fleet-grid {
    display: grid;
    grid-template-columns: 108px repeat(4, minmax(240px, 1fr));
    gap: 10px;
}

.grid-col-head {
    font-family: 'Plex Mono', monospace;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    align-self: end;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--line-strong);
}

.grid-row-head {
    font-family: 'Plex Mono', monospace;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    align-self: center;
    text-align: center;
    padding: 5px 4px;
    border-radius: var(--radius);
}

.grid-cell {
    min-width: 0;
}

.cell-empty {
    height: 100%;
    min-height: 120px;
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-faint);
    font-family: 'Plex Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.04em;
}

/* ---------- Card ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.thumb-wrap {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    padding: 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    cursor: zoom-in;
    background: var(--surface-2);
    overflow: hidden;
}

.thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
    transition: transform 0.2s ease;
}

.thumb-wrap:hover img {
    transform: scale(1.03);
}

.thumb-wrap:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--ink-faint);
    font-family: 'Plex Mono', monospace;
    font-size: 12px;
}

.status-chip {
    position: absolute;
    top: 8px;
    right: 8px;
    font-family: 'Plex Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 3px 7px;
    border-radius: 2px;
    color: var(--status-unknown-ink);
    background-color: var(--status-unknown-bg);
    background-image: repeating-linear-gradient(-45deg, var(--status-unknown-hatch), var(--status-unknown-hatch) 4px, transparent 4px, transparent 8px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.status-chip--live {
    color: var(--status-live);
    background-color: var(--status-live-bg);
    background-image: none;
}

.status-chip--frozen {
    color: var(--status-frozen);
    background-color: var(--status-frozen-bg);
    background-image: none;
}

.status-chip--degraded {
    color: var(--status-degraded);
    background-color: var(--status-degraded-bg);
    background-image: none;
}

.status-chip--provisioned {
    color: var(--status-provisioned);
    background-color: var(--status-provisioned-bg);
    background-image: none;
}

.status-chip--defunct {
    color: var(--status-defunct);
    background-color: var(--status-defunct-bg);
    background-image: none;
}

.card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.card-title {
    font-family: 'Plex Mono', monospace;
    font-size: 14.5px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
}

.card-meta {
    font-size: 11.5px;
    color: var(--ink-faint);
    white-space: nowrap;
}

.field-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    row-gap: 5px;
    column-gap: 10px;
    font-size: 12.5px;
}

.field-label {
    color: var(--ink-faint);
    white-space: nowrap;
}

.field-value {
    color: var(--ink);
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-value--mono {
    font-family: 'Plex Mono', monospace;
}

.field-value--empty {
    color: var(--ink-faint);
    font-style: italic;
}

.field-value--warn {
    color: var(--status-degraded);
    font-size: 11.5px;
    white-space: normal;
}

.field-value a {
    color: var(--accent-ink);
    text-decoration: none;
    border-bottom: 1px solid var(--accent-soft);
}

.field-value a:hover {
    border-bottom-color: var(--accent-ink);
}

.field-rel {
    color: var(--ink-faint);
    font-family: 'Plex Sans', sans-serif;
}

.card-flag {
    margin-top: 2px;
    padding: 10px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-left-width: 4px;
    border-radius: 2px;
    font-size: 12.5px;
    color: var(--ink);
    line-height: 1.5;
}

.card-flag-label {
    display: block;
    width: fit-content;
    font-family: 'Plex Mono', monospace;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--surface);
    background: var(--accent-ink);
    padding: 2px 7px;
    border-radius: 2px;
    margin-bottom: 6px;
}

/* ---------- Unplaced ---------- */

#unplaced-section {
    margin-top: 44px;
    padding: 20px;
    background: var(--surface-2);
    border: 1px dashed var(--line-strong);
    border-radius: var(--radius);
}

#unplaced-section .section-label {
    margin: 0 0 14px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--accent-ink);
}

.unplaced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 340px));
    gap: 10px;
}

/* ---------- Footer / states ---------- */

.hub-footer {
    margin-top: 40px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    color: var(--ink-faint);
    font-size: 12px;
    line-height: 1.6;
    max-width: 80ch;
}

.hub-footer code {
    font-family: 'Plex Mono', monospace;
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 2px;
}

.notice {
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    font-size: 13.5px;
    color: var(--ink-soft);
}

.notice--error {
    border-left: 3px solid var(--status-degraded);
    color: var(--ink);
}

.notice strong {
    color: var(--ink);
}

.notice code {
    font-family: 'Plex Mono', monospace;
    font-size: 12px;
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 2px;
    word-break: break-all;
}

.hidden {
    display: none !important;
}

/* ---------- Lightbox ---------- */

dialog.lightbox {
    padding: 0;
    border: 0;
    border-radius: 4px;
    max-width: min(90vw, 900px);
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

dialog.lightbox::backdrop {
    background: rgba(10, 12, 10, 0.6);
}

dialog.lightbox img {
    width: 100%;
    display: block;
}

.lightbox-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}

.lightbox-head span {
    font-family: 'Plex Mono', monospace;
    font-size: 13px;
    font-weight: 600;
}

@media (max-width: 860px) {
    .fleet-grid {
        grid-template-columns: 84px repeat(4, minmax(200px, 1fr));
    }

    .hub-header {
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .fleet-grid {
        display: flex;
        flex-direction: column;
    }

    .grid-corner,
    .grid-col-head,
    .grid-row-head {
        display: none;
    }

    .header-side {
        align-items: flex-start;
    }
}
