/* ═══════════════════════════════════════════════════════════
   BASE — reset, typography, focus, utilities
   ═══════════════════════════════════════════════════════════ */

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

html, body {
    height: 100%;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-base);
    font-weight: var(--weight-regular);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-variant-numeric: tabular-nums;
}

/* On a desktop the app shell scrolls inside its content column, so the document itself never
   does (layouts.css). Below 900px the document scrolls under a sticky top bar. */
@media (min-width: 900px) {
    body.app-body {
        overflow: hidden;
    }
}

button, input, select, textarea {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
}

button, [role="button"], select, label[for] {
    cursor: pointer;
}

button:disabled, input:disabled, select:disabled, textarea:disabled {
    cursor: not-allowed;
}

img, svg {
    vertical-align: middle;
    flex-shrink: 0;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

a:hover {
    color: var(--accent-hover);
}

h1, h2, h3, h4 {
    font-size: inherit;
    font-weight: var(--weight-semibold);
    line-height: inherit;
}

ul[role="list"], ol[role="list"] {
    list-style: none;
}

code, kbd, samp, .mono {
    font-family: var(--font-mono);
    font-variant-numeric: normal;
}

::placeholder {
    color: var(--text-placeholder);
    opacity: 1;
}

::selection {
    background: var(--accent-tint);
    color: var(--text);
}

[hidden] {
    display: none !important;
}

/* ── Focus ────────────────────────────────────────────────────
   Keyboard users always see where they are (WCAG 2.4.7); mouse clicks don't
   draw it. Inputs add a soft accent halo on top (see components.css). */

:focus {
    outline: none;
}

:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

/* A heading or region that receives focus only programmatically (a pane title, the content
   area after "Skip to content") is a reading position, not a control: no ring. */
[tabindex="-1"]:focus-visible {
    outline: none;
}

/* Skip straight past the sidebar and the top bar to the page. */
.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--text);
    color: var(--surface);
    font-weight: var(--weight-medium);
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus-visible {
    transform: none;
    color: var(--surface);
}

/* Accessible-but-invisible, for labelling icon-only controls. */
.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Text helpers ─────────────────────────────────────────── */

.num { font-variant-numeric: tabular-nums; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.text-warn { color: var(--warn); }
.text-danger { color: var(--danger); }
.caps {
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
    letter-spacing: var(--tracking-caps);
    text-transform: uppercase;
    color: var(--text-3);
}
.truncate {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════
   LEGACY UTILITIES — the prototype's shorthand set. Still used by
   the screens that keep their old markup; do not use in new markup.
   ═══════════════════════════════════════════════════════════ */

.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.ir2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ir3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* A grid cell may shrink below its content's width, so a long chassis number or a wide table
   inside scrolls within its column instead of pushing the column off-screen. */
.g2 > *, .g3 > *, .g4 > *, .ir2 > *, .ir3 > * { min-width: 0; }

.mb4  { margin-bottom: 4px; }
.mb8  { margin-bottom: 8px; }
.mb12 { margin-bottom: 12px; }
.mb14 { margin-bottom: 14px; }
.mb16 { margin-bottom: 16px; }
.mb20 { margin-bottom: 20px; }
.mt8  { margin-top: 8px; }
.mt12 { margin-top: 12px; }
.mt16 { margin-top: 16px; }

.flex { display: flex; }
.fac  { align-items: center; }
.g8   { gap: 8px; }
.g12  { gap: 12px; }

.fw6 { font-weight: var(--weight-semibold); }
.fw7 { font-weight: var(--weight-semibold); }
.fw8 { font-weight: var(--weight-semibold); }

.fs9  { font-size: var(--text-xs); }
.fs10 { font-size: var(--text-xs); }
.fs11 { font-size: var(--text-xs); }
.fs12 { font-size: var(--text-sm); }

.tcr  { color: var(--danger); }
.tcg  { color: var(--ok); }
.tca  { color: var(--warn); }
.tcb  { color: var(--info); }
.tct2 { color: var(--text-2); }
.tct3 { color: var(--text-3); }
.tct4 { color: var(--text-disabled); }

.nowrap { white-space: nowrap; }

.sep {
    height: 1px;
    background: var(--line);
    margin: 16px 0;
}

.last-upd {
    font-size: var(--text-sm);
    color: var(--text-3);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

@media (max-width: 899.98px) {
    .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
    .ir3 { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
