/* =========================================================================
   TMD Test Tool — "mission control" theme
   ========================================================================= */

.access-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.access-card { width: 100%; max-width: 460px; padding: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--panel-solid); box-shadow: var(--shadow); }
.access-card h1 { font-family: var(--font-display); font-size: 36px; margin: 12px 0; }
.access-card form { display: grid; gap: 14px; margin-top: 28px; }
.access-card label { font-weight: 600; }
.access-card input { width: 100%; min-width: 0; }
.access-help { color: var(--muted); font-size: 13px; margin: 0; }
.access-error { color: var(--bad); margin: 0; }

:root {
    color-scheme: dark;

    --bg: #060912;
    --bg-2: #0a0f1d;
    --panel: rgba(255, 255, 255, 0.035);
    --panel-2: rgba(255, 255, 255, 0.06);
    --panel-solid: #0d1324;
    --border: rgba(148, 163, 255, 0.12);
    --border-strong: rgba(148, 163, 255, 0.24);

    --text: #e7eaf6;
    --muted: #9099b8;
    --faint: #5e6787;

    --accent: #22d3ee;
    --accent-2: #8b5cf6;
    --grad: linear-gradient(120deg, var(--accent) 0%, #60a5fa 45%, var(--accent-2) 100%);

    --ok: #34d399;
    --bad: #fb7185;
    --warn: #fbbf24;
    --idle: #64748b;

    --ok-bg: rgba(52, 211, 153, 0.12);
    --bad-bg: rgba(251, 113, 133, 0.12);
    --warn-bg: rgba(251, 191, 36, 0.12);
    --idle-bg: rgba(100, 116, 139, 0.16);
    --accent-bg: rgba(34, 211, 238, 0.1);

    --radius: 18px;
    --radius-sm: 10px;
    --shadow: 0 20px 50px -24px rgba(0, 0, 0, 0.8);

    --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: "Space Grotesk", var(--font);
    --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

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

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

body {
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background:
        radial-gradient(1100px 600px at 12% -10%, rgba(34, 211, 238, 0.13), transparent 60%),
        radial-gradient(900px 600px at 95% 5%, rgba(139, 92, 246, 0.14), transparent 60%),
        radial-gradient(800px 500px at 50% 110%, rgba(52, 211, 153, 0.06), transparent 60%),
        var(--bg);
    background-attachment: fixed;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* faint engineering grid */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(148, 163, 255, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 255, 0.045) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 80%);
    z-index: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #67e8f9; }

h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: clamp(1.7rem, 2.6vw, 2.35rem); line-height: 1.15; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

h1:focus { outline: none; }

.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.82rem; }
.nowrap { white-space: nowrap; }
.grad-text {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

::selection { background: rgba(34, 211, 238, 0.3); }

/* ---------- Shell ---------- */

.shell {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding: 26px 18px;
    border-right: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(10, 15, 29, 0.85), rgba(6, 9, 18, 0.7));
    backdrop-filter: blur(14px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; color: var(--text); }
.brand:hover { color: var(--text); }
.brand-text { display: flex; flex-direction: column; gap: 2px; }
.brand-mark { width: 38px; height: 38px; filter: drop-shadow(0 0 12px rgba(34, 211, 238, 0.45)); }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; line-height: 1.1; }
.brand-sub { font-family: var(--font-mono); font-size: 0.68rem; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label {
    font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase;
    color: var(--faint); padding: 0 12px 8px;
}
.nav a {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active {
    color: var(--text);
    background: linear-gradient(90deg, rgba(34, 211, 238, 0.14), rgba(139, 92, 246, 0.06));
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.22);
}
.nav a.active::before {
    content: ""; position: absolute; left: -18px; top: 9px; bottom: 9px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--grad); box-shadow: 0 0 12px var(--accent);
}
.nav a svg { flex: none; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.status-line {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border);
    font-size: 0.8rem; color: var(--muted);
}
.status-line strong { color: var(--text); font-weight: 500; display: block; }

.main { min-width: 0; padding: 34px clamp(18px, 3.2vw, 48px) 80px; }
.page { max-width: 1440px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }

/* ---------- Page header ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; }
.page-head .lede { color: var(--muted); margin-top: 8px; max-width: 60ch; }
.eyebrow {
    font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.18em; text-transform: uppercase;
    color: var(--accent); margin-bottom: 8px; display: flex; align-items: center; gap: 8px;
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--faint); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

/* ---------- Panels & grids ---------- */

.panel {
    position: relative;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
}
.panel-glow::after {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
    padding: 1px; background: linear-gradient(140deg, rgba(34, 211, 238, 0.5), transparent 35%, transparent 65%, rgba(139, 92, 246, 0.5));
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h2 { display: flex; align-items: center; gap: 10px; }
.panel-head .sub { color: var(--muted); font-size: 0.82rem; }

.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-title h2 { font-size: 1.2rem; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- KPI tiles ---------- */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat {
    position: relative; overflow: hidden;
    padding: 18px 20px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
    color: var(--text);
    transition: transform 0.2s, border-color 0.2s;
}
a.stat:hover { transform: translateY(-2px); border-color: var(--border-strong); color: var(--text); }
.stat::before {
    content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle, var(--tone, var(--accent)) 0%, transparent 70%); opacity: 0.18;
}
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; }
.stat-label svg { color: var(--tone, var(--accent)); }
.stat-value { font-family: var(--font-display); font-size: 2.1rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 0.8rem; color: var(--faint); }
.stat.tone-ok { --tone: var(--ok); }
.stat.tone-bad { --tone: var(--bad); }
.stat.tone-warn { --tone: var(--warn); }
.stat.tone-violet { --tone: var(--accent-2); }
.stat.is-hot { border-color: rgba(251, 191, 36, 0.45); box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.15), 0 0 30px -10px rgba(251, 191, 36, 0.5); }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px; border-radius: 12px;
    font: 600 0.88rem/1 var(--font); letter-spacing: 0.01em;
    border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
    cursor: pointer; white-space: nowrap;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.09); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--grad); color: #04111a; border-color: transparent; box-shadow: 0 8px 26px -10px rgba(34, 211, 238, 0.7); }
.btn-primary:hover { background: var(--grad); color: #04111a; box-shadow: 0 10px 34px -8px rgba(34, 211, 238, 0.85); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); }
.btn-ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 211, 153, 0.35); }
.btn-ok:hover { background: rgba(52, 211, 153, 0.2); color: #6ee7b7; }
.btn-bad { background: var(--bad-bg); color: var(--bad); border-color: rgba(251, 113, 133, 0.35); }
.btn-bad:hover { background: rgba(251, 113, 133, 0.2); color: #fda4af; }
.btn-danger { background: var(--bad); color: #1a0409; border-color: var(--bad); box-shadow: 0 8px 26px -12px rgba(251, 113, 133, 0.8); }
.btn-danger:hover { background: #fda4af; color: #1a0409; border-color: #fda4af; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 0.8rem; border-radius: 10px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 0.95rem; border-radius: 14px; }

/* ---------- Badges & chips ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 4px 10px 4px 9px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap;
    background: var(--idle-bg); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.2);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.badge.s-completed { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 211, 153, 0.3); }
.badge.s-rejected { background: var(--bad-bg); color: var(--bad); border-color: rgba(251, 113, 133, 0.3); }
.badge.s-pending { background: var(--warn-bg); color: var(--warn); border-color: rgba(251, 191, 36, 0.3); }
.badge.s-pending .dot { animation: pulse 1.6s ease-in-out infinite; }
.badge.s-progress { background: var(--accent-bg); color: var(--accent); border-color: rgba(34, 211, 238, 0.3); }
.badge.s-notrun { color: #94a3b8; }
.badge.s-notrun .dot { box-shadow: none; }

.tag {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
    font: 500 0.7rem/1.6 var(--font-mono); letter-spacing: 0.04em; text-transform: uppercase;
    color: var(--muted); background: var(--panel-2); border: 1px solid var(--border);
}
.tag.req { color: var(--accent); border-color: rgba(34, 211, 238, 0.25); background: var(--accent-bg); }

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px;
    border-radius: 999px; border: 1px solid var(--border); background: var(--panel);
    color: var(--muted); font: 500 0.82rem var(--font); cursor: pointer; transition: all 0.2s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip .count { font-family: var(--font-mono); font-size: 0.74rem; padding: 1px 7px; border-radius: 999px; background: var(--panel-2); color: var(--text); }
.chip.active { color: var(--text); border-color: rgba(34, 211, 238, 0.5); background: var(--accent-bg); box-shadow: 0 0 20px -8px var(--accent); }

.value-chip {
    display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 9px; border-radius: 8px;
    background: var(--panel-2); border: 1px solid var(--border); font-size: 0.78rem; white-space: nowrap;
}
.value-chip .k { color: var(--faint); }
.value-chip .v { font-family: var(--font-mono); color: var(--text); }
.value-chip.out { border-color: rgba(251, 113, 133, 0.4); background: var(--bad-bg); }
.value-chip.out .v { color: var(--bad); }
.value-chip.in .v { color: var(--ok); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 0.78rem; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

.input, .select, .textarea {
    width: 100%; height: 42px; padding: 0 14px;
    border-radius: 12px; border: 1px solid var(--border-strong);
    background: rgba(6, 9, 18, 0.6); color: var(--text);
    font: 500 0.92rem var(--font);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.textarea { height: auto; min-height: 84px; padding: 11px 14px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 36px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239099b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center; }
.select option { background: var(--panel-solid); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: rgba(34, 211, 238, 0.7); box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.14); }
.input.mono { font-family: var(--font-mono); font-size: 1.05rem; letter-spacing: 0.02em; }
.input.is-invalid, .textarea.is-invalid { border-color: rgba(251, 113, 133, 0.7); }
.input.is-out { border-color: rgba(251, 113, 133, 0.7); box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.12); }
.input.is-in { border-color: rgba(52, 211, 153, 0.6); box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.1); }
input[type="date"].input, input[type="datetime-local"].input { color-scheme: dark; }

.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search .input { padding-left: 40px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.filter-bar .search { flex: 1 1 240px; }
.filter-bar .select { width: auto; min-width: 150px; }

.error-text { color: var(--bad); font-size: 0.8rem; display: flex; align-items: center; gap: 6px; }

.alert {
    display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px;
    border: 1px solid rgba(251, 113, 133, 0.35); background: var(--bad-bg); color: #fecdd3;
}
.alert.warn { border-color: rgba(251, 191, 36, 0.35); background: var(--warn-bg); color: #fde68a; }
.alert.info { border-color: rgba(34, 211, 238, 0.3); background: var(--accent-bg); color: #a5f3fc; }

/* Yes/No segmented toggle */
.segmented { display: inline-flex; padding: 4px; gap: 4px; border-radius: 14px; background: rgba(6, 9, 18, 0.6); border: 1px solid var(--border-strong); }
.segmented button {
    display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 20px; border-radius: 10px;
    border: 0; background: transparent; color: var(--muted); font: 600 0.9rem var(--font); cursor: pointer; transition: all 0.2s;
}
.segmented button:hover { color: var(--text); }
.segmented button.on-yes { background: var(--ok-bg); color: var(--ok); box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.4); }
.segmented button.on-no { background: var(--bad-bg); color: var(--bad); box-shadow: inset 0 0 0 1px rgba(251, 113, 133, 0.4); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
    text-align: left; font: 600 0.7rem var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--faint); padding: 0 12px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 14px 12px; border-bottom: 1px solid rgba(148, 163, 255, 0.07); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background 0.15s; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .title { font-weight: 600; color: var(--text); min-width: 170px; }
.table .desc { color: var(--faint); font-size: 0.8rem; margin-top: 2px; max-width: 46ch; }

/* ---------- Bars ---------- */

.meter { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.meter-track { flex: 1; height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; display: flex; }
.meter-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--ok), #6ee7b7); box-shadow: 0 0 10px rgba(52, 211, 153, 0.6); }
.meter-fill.low { background: linear-gradient(90deg, var(--bad), #fda4af); box-shadow: 0 0 10px rgba(251, 113, 133, 0.6); }
.meter-fill.mid { background: linear-gradient(90deg, var(--warn), #fde68a); box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.meter-label { font: 600 0.8rem var(--font-mono); width: 42px; text-align: right; }

.stackbar { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.05); overflow: hidden; display: flex; gap: 2px; }
.stackbar span { height: 100%; }
.stackbar .ok { background: var(--ok); }
.stackbar .bad { background: var(--bad); }
.stackbar .warn { background: var(--warn); }

.breakdown { display: flex; flex-direction: column; gap: 14px; }
.breakdown-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.breakdown-row .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-row .counts { font: 500 0.78rem var(--font-mono); color: var(--muted); display: flex; gap: 10px; }
.breakdown-row .stackbar { grid-column: 1 / -1; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .ok { background: var(--ok); }
.legend .bad { background: var(--bad); }
.legend .warn { background: var(--warn); }

/* ---------- Charts ---------- */

.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gridline { stroke: rgba(148, 163, 255, 0.08); stroke-dasharray: 3 5; }
.chart .axis-label { fill: var(--faint); font: 500 10px var(--font-mono); }
.chart .bar { transition: opacity 0.2s; }
.chart .col:hover .bar { opacity: 0.8; }
.chart .col .hit { fill: transparent; }
.chart .col:hover .hit { fill: rgba(255, 255, 255, 0.03); }

.donut-wrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.donut { position: relative; width: 170px; height: 170px; flex: none; }
.donut svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center .big { font: 600 2rem/1 var(--font-display); }
.donut-center .cap { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; }
.donut-legend { display: flex; flex-direction: column; gap: 12px; flex: 1; min-width: 150px; }
.donut-legend .item { display: flex; align-items: center; gap: 10px; }
.donut-legend .item i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .item .n { margin-left: auto; font: 600 0.95rem var(--font-mono); }

/* ---------- Unit cards ---------- */

.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.unit-card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 16px;
    padding: 20px; border-radius: var(--radius);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
    border: 1px solid var(--border);
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.unit-card::before {
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
    background: var(--card-tone, var(--idle)); box-shadow: 0 0 18px var(--card-tone, var(--idle)); opacity: 0.9;
}
.unit-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: 0 24px 50px -24px rgba(34, 211, 238, 0.35); }
.unit-card.r-passed { --card-tone: var(--ok); }
.unit-card.r-failed { --card-tone: var(--bad); }
.unit-card.r-pending { --card-tone: var(--warn); }
.unit-card.r-progress { --card-tone: var(--accent); }
.unit-card.is-inactive { opacity: 0.55; }
.unit-card-top { display: flex; align-items: flex-start; gap: 14px; }
.unit-card-top .info { flex: 1; min-width: 0; }
.unit-card h3 { font-size: 1.08rem; }
.serial { font: 500 0.78rem var(--font-mono); color: var(--accent); letter-spacing: 0.04em; }
.unit-desc { color: var(--muted); font-size: 0.84rem; }

.test-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.test-list li {
    display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px;
    background: rgba(6, 9, 18, 0.45); border: 1px solid rgba(148, 163, 255, 0.06); font-size: 0.85rem;
}
.test-list .seq { font: 600 0.7rem var(--font-mono); color: var(--faint); width: 18px; }
.test-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-list .when { font: 500 0.72rem var(--font-mono); color: var(--faint); }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--idle); }
.sdot.s-completed { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.sdot.s-rejected { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.sdot.s-pending { background: var(--warn); box-shadow: 0 0 8px var(--warn); animation: pulse 1.6s ease-in-out infinite; }

.unit-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; padding-top: 4px; }

a.unit-card { color: var(--text); cursor: pointer; }
a.unit-card:hover { color: var(--text); }
.unit-card .go {
    display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.85rem; color: var(--accent);
    transition: gap 0.2s;
}
.unit-card:hover .go { gap: 10px; }

/* ---------- Feed ---------- */

.feed { display: flex; flex-direction: column; }
.feed-item {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
    padding: 12px 8px; border-bottom: 1px solid rgba(148, 163, 255, 0.07); color: var(--text);
    border-radius: 10px; transition: background 0.15s;
}
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: rgba(255, 255, 255, 0.03); color: var(--text); }
.feed-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--idle-bg); color: #cbd5e1; }
.feed-icon.s-completed { background: var(--ok-bg); color: var(--ok); }
.feed-icon.s-rejected { background: var(--bad-bg); color: var(--bad); }
.feed-icon.s-pending { background: var(--warn-bg); color: var(--warn); }
.feed-title { font-weight: 600; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-meta { font-size: 0.78rem; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed-when { font: 500 0.74rem var(--font-mono); color: var(--faint); text-align: right; }

/* ---------- Results list ---------- */

.result-list { display: flex; flex-direction: column; gap: 10px; }
.result-row {
    position: relative;
    display: grid;
    grid-template-columns: 150px minmax(0, 1.1fr) minmax(0, 1.5fr) minmax(0, 0.9fr) auto;
    gap: 18px; align-items: center;
    padding: 16px 18px 16px 22px; border-radius: 14px;
    background: var(--panel); border: 1px solid var(--border);
    color: var(--text); transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.result-row:hover { border-color: var(--border-strong); background: rgba(255, 255, 255, 0.05); color: var(--text); transform: translateX(2px); }
.result-row::before {
    content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 0 3px 3px 0;
    background: var(--row-tone, var(--idle)); box-shadow: 0 0 12px var(--row-tone, var(--idle));
}
.result-row.s-completed { --row-tone: var(--ok); }
.result-row.s-rejected { --row-tone: var(--bad); }
.result-row.s-pending { --row-tone: var(--warn); }
.result-row .when .d { font: 600 0.85rem var(--font-mono); }
.result-row .when .r { font-size: 0.75rem; color: var(--faint); }
.result-row .who { font-size: 0.8rem; color: var(--muted); }
.result-row .who b { color: var(--text); font-weight: 500; }
.result-row .values { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Stepper / run flow ---------- */

.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.step {
    display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--panel); color: var(--faint); font-size: 0.82rem; font-weight: 500;
}
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font: 600 0.72rem var(--font-mono); background: var(--panel-2); }
.step.done { color: var(--muted); }
.step.done .n { background: var(--ok-bg); color: var(--ok); }
.step.current { color: var(--text); border-color: rgba(34, 211, 238, 0.5); background: var(--accent-bg); box-shadow: 0 0 22px -10px var(--accent); }
.step.current .n { background: var(--grad); color: #04111a; }

.unit-strip {
    display: flex; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px 22px;
    border-radius: var(--radius); border: 1px solid var(--border);
    background: linear-gradient(100deg, rgba(34, 211, 238, 0.09), rgba(139, 92, 246, 0.07) 60%, transparent);
}
.unit-strip .glyph {
    width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
    background: rgba(6, 9, 18, 0.6); border: 1px solid rgba(34, 211, 238, 0.35); color: var(--accent);
    box-shadow: 0 0 24px -8px var(--accent);
}
.unit-strip h2 { font-size: 1.3rem; }

.pick-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.pick {
    position: relative; display: flex; gap: 14px; align-items: flex-start; text-align: left;
    padding: 16px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--border); background: var(--panel); color: var(--text); font: inherit;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.pick:hover { border-color: var(--border-strong); }
.pick.on { border-color: rgba(34, 211, 238, 0.55); background: var(--accent-bg); box-shadow: 0 0 26px -12px var(--accent); }
.checkbox {
    width: 22px; height: 22px; border-radius: 7px; flex: none; display: grid; place-items: center;
    border: 1.5px solid var(--border-strong); color: transparent; transition: all 0.2s; margin-top: 1px;
}
.pick.on .checkbox { background: var(--grad); border-color: transparent; color: #04111a; }
.pick .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pick .title { font-weight: 600; }
.pick .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.run-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 20px; align-items: start; }
.rail { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 6px; padding: 14px; }
.rail-item {
    display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px;
    border: 1px solid transparent; background: transparent; color: var(--muted); font: 500 0.88rem var(--font);
    cursor: pointer; text-align: left; width: 100%; transition: all 0.2s;
}
.rail-item:hover { background: var(--panel-2); color: var(--text); }
.rail-item.current { background: var(--accent-bg); border-color: rgba(34, 211, 238, 0.35); color: var(--text); }
.rail-item .n {
    width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none;
    font: 600 0.75rem var(--font-mono); background: var(--panel-2); border: 1px solid var(--border);
}
.rail-item.complete .n { background: var(--ok-bg); color: var(--ok); border-color: rgba(52, 211, 153, 0.35); }
.rail-item.warn .n { background: var(--bad-bg); color: var(--bad); border-color: rgba(251, 113, 133, 0.35); }
.rail-item.current .n { background: var(--grad); color: #04111a; border-color: transparent; }
.rail-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-progress { margin-top: 8px; padding: 12px 10px 4px; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }

.procedure {
    display: flex; gap: 14px; padding: 16px 18px; border-radius: 14px;
    background: rgba(6, 9, 18, 0.55); border: 1px dashed rgba(34, 211, 238, 0.3);
}
.procedure .ico { color: var(--accent); flex: none; margin-top: 2px; }
.procedure .lbl { font: 600 0.7rem var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.procedure p { white-space: pre-line; color: #cdd3ea; }

.capture-field {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 20px; align-items: start;
    padding: 18px; border-radius: 14px; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.02);
}
.capture-field .fname { font-weight: 600; font-size: 0.98rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.capture-field .fdesc { color: var(--muted); font-size: 0.84rem; margin-top: 4px; }
.capture-field .limits { margin-top: 8px; font: 500 0.78rem var(--font-mono); color: var(--faint); }
.capture-field .limits b { color: var(--accent); font-weight: 600; }
.input-uom { position: relative; }
.input-uom .uom { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font: 600 0.85rem var(--font-mono); color: var(--faint); pointer-events: none; }
.input-uom .input { padding-right: 52px; }

/* Range gauge */
.gauge { margin-top: 12px; }
.gauge-track {
    position: relative; height: 10px; border-radius: 99px;
    background: linear-gradient(90deg, rgba(251, 113, 133, 0.35), rgba(251, 113, 133, 0.12));
}
.gauge-band {
    position: absolute; top: 0; bottom: 0; border-radius: 99px;
    background: linear-gradient(90deg, rgba(52, 211, 153, 0.5), rgba(52, 211, 153, 0.8), rgba(52, 211, 153, 0.5));
    box-shadow: 0 0 14px rgba(52, 211, 153, 0.45);
}
.gauge-marker {
    position: absolute; top: 50%; width: 18px; height: 18px; margin-left: -9px; border-radius: 50%;
    transform: translateY(-50%); background: #fff; border: 3px solid var(--bg);
    box-shadow: 0 0 0 2px var(--marker, var(--accent)), 0 0 16px var(--marker, var(--accent));
    transition: left 0.35s cubic-bezier(.2, .8, .2, 1);
}
.gauge-marker.in { --marker: var(--ok); }
.gauge-marker.out { --marker: var(--bad); }
.gauge-scale { display: flex; justify-content: space-between; margin-top: 8px; font: 500 0.72rem var(--font-mono); color: var(--faint); }
.gauge-scale .mid { color: var(--muted); }
.gauge-verdict { margin-top: 8px; font-size: 0.8rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.gauge-verdict.in { color: var(--ok); }
.gauge-verdict.out { color: var(--bad); }

.capture-nav { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding-top: 6px; flex-wrap: wrap; }

/* Sign-off */
.signoff-card { display: flex; flex-direction: column; gap: 16px; }
.signoff-card.decided-ok { border-color: rgba(52, 211, 153, 0.45); box-shadow: 0 0 40px -22px var(--ok); }
.signoff-card.decided-bad { border-color: rgba(251, 113, 133, 0.45); box-shadow: 0 0 40px -22px var(--bad); }
.signoff-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.signoff-head .info { flex: 1; min-width: 200px; }
.verdict-toggle { display: flex; gap: 8px; }
.verdict-toggle .btn { min-width: 120px; }
.verdict-toggle .btn.sel-ok { background: var(--ok); color: #03140d; border-color: var(--ok); box-shadow: 0 0 24px -6px var(--ok); }
.verdict-toggle .btn.sel-bad { background: var(--bad); color: #1a0409; border-color: var(--bad); box-shadow: 0 0 24px -6px var(--bad); }
.suggest { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600; }
.suggest.ok { color: var(--ok); }
.suggest.bad { color: var(--bad); }

.values-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.values-table td { padding: 9px 10px; border-top: 1px solid rgba(148, 163, 255, 0.07); }
.values-table td:first-child { color: var(--muted); }
.values-table .v { font-family: var(--font-mono); font-weight: 600; }
.values-table .v.out { color: var(--bad); }
.values-table .v.in { color: var(--ok); }
.values-table .lim { font-family: var(--font-mono); color: var(--faint); font-size: 0.78rem; }

.sticky-bar {
    position: sticky; bottom: 16px; z-index: 5;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 14px 18px; border-radius: 16px;
    background: rgba(13, 19, 36, 0.88); border: 1px solid var(--border-strong);
    backdrop-filter: blur(16px); box-shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.9);
}
.sticky-bar .field { flex: 1 1 220px; }

/* Done */
.done-hero { text-align: center; padding: 44px 22px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.done-badge {
    width: 86px; height: 86px; border-radius: 50%; display: grid; place-items: center;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.25), rgba(52, 211, 153, 0.05));
    border: 1px solid rgba(52, 211, 153, 0.5); color: var(--ok);
    box-shadow: 0 0 60px -10px var(--ok); animation: pop 0.6s cubic-bezier(.2, 1.4, .4, 1) both;
}
.done-badge.bad {
    background: radial-gradient(circle, rgba(251, 113, 133, 0.25), rgba(251, 113, 133, 0.05));
    border-color: rgba(251, 113, 133, 0.5); color: var(--bad); box-shadow: 0 0 60px -10px var(--bad);
}
.done-stats { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* Detail meta */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.meta-item { padding: 14px 16px; border-radius: 12px; background: rgba(6, 9, 18, 0.45); border: 1px solid var(--border); }
.meta-item .k { font: 600 0.68rem var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.meta-item .v { margin-top: 4px; font-weight: 500; }

.comment { padding: 14px 16px; border-radius: 12px; background: rgba(6, 9, 18, 0.45); border-left: 3px solid var(--accent-2); color: #cdd3ea; }

/* Empty & loading */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; background: var(--panel-2); color: var(--faint); }

.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border: 1px solid var(--border); }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; }

/* ---------- Setup forms ---------- */

.alert.ok { border-color: rgba(52, 211, 153, 0.35); background: var(--ok-bg); color: #a7f3d0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.hint { font-size: 0.78rem; color: var(--faint); }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
    position: relative; width: 40px; height: 22px; border-radius: 99px; flex: none;
    background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border-strong); transition: all 0.2s;
}
.switch .thumb {
    position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--muted); transition: all 0.2s cubic-bezier(.2, .8, .2, 1);
}
.switch.on .track { background: var(--grad); border-color: transparent; box-shadow: 0 0 14px -4px var(--accent); }
.switch.on .thumb { left: 20px; background: #04111a; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-label { font-size: 0.86rem; color: var(--muted); font-weight: 500; }
.switch.on .switch-label { color: var(--text); }

.icon-btn {
    width: 32px; height: 32px; border-radius: 9px; display: inline-grid; place-items: center; flex: none;
    border: 1px solid var(--border); background: var(--panel); color: var(--muted); cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover:not([disabled]) { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.icon-btn.danger:hover:not([disabled]) { color: var(--bad); border-color: rgba(251, 113, 133, 0.4); background: var(--bad-bg); }
.icon-btn[disabled] { opacity: 0.3; cursor: not-allowed; }

.seq-list { display: flex; flex-direction: column; gap: 8px; }
.seq-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    background: rgba(6, 9, 18, 0.5); border: 1px solid var(--border);
}
.seq-row .n {
    width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none;
    font: 600 0.75rem var(--font-mono); background: var(--grad); color: #04111a;
}
.seq-row .t { flex: 1; min-width: 0; }
.seq-row .t .title { font-weight: 600; }
.seq-row .actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.field-editor {
    position: relative; display: flex; flex-direction: column; gap: 14px;
    padding: 18px; border-radius: 14px; background: rgba(6, 9, 18, 0.45); border: 1px solid var(--border);
}
.field-editor.has-error { border-color: rgba(251, 113, 133, 0.4); }
.field-editor-head { display: flex; align-items: center; gap: 10px; }
.field-editor-head .n { font: 600 0.72rem var(--font-mono); letter-spacing: 0.12em; color: var(--accent); text-transform: uppercase; }
.field-editor-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.type-note { font-size: 0.8rem; color: var(--faint); display: flex; align-items: center; gap: 8px; padding-top: 2px; }

.def-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 18px; }
.def-card { display: flex; flex-direction: column; gap: 14px; }
.def-card .fields { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.def-card .fields td { padding: 8px 6px; border-top: 1px solid rgba(148, 163, 255, 0.07); vertical-align: top; }
.def-card .fields td:first-child { font-weight: 500; }
.def-card .fields .lim { font-family: var(--font-mono); color: var(--faint); font-size: 0.76rem; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.new-flash { animation: flash 2.4s ease-out both; }
tr.new-flash { animation: none; }
tr.new-flash td { animation: flash-row 2.4s ease-out both; }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--ok), 0 0 40px -6px var(--ok); } 100% { box-shadow: var(--shadow); } }
@keyframes flash-row { 0% { background: rgba(52, 211, 153, 0.18); } 100% { background: transparent; } }

@media (max-width: 1080px) {
    .field-editor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-editor-grid > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .def-grid { grid-template-columns: minmax(0, 1fr); }
    .seq-row { flex-wrap: wrap; }
}

/* ---------- Motion ---------- */

.rise { animation: rise 0.55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes draw { from { stroke-dashoffset: var(--len); } }

.chart .bars { transform-origin: bottom; transform-box: fill-box; animation: grow-y 0.7s cubic-bezier(.2, .8, .2, 1) both; }
.arc { animation: draw 1s cubic-bezier(.2, .8, .2, 1) both; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Blazor bits ---------- */

.valid.modified:not([type=checkbox]) { outline: none; }
.validation-message { color: var(--bad); font-size: 0.8rem; }

/* Hidden until Blazor reports an error. Global (not scoped to a layout) so the runner and report layouts hide it too. */
#blazor-error-ui {
    display: none;
    position: fixed; left: 0; bottom: 0; z-index: 1000;
    width: 100%; box-sizing: border-box; padding: 0.7rem 1.25rem;
    background: #3b0d18; color: #fecdd3;
    border-top: 1px solid rgba(251, 113, 133, 0.5); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
}
#blazor-error-ui .reload { color: #fda4af; font-weight: 600; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.6rem; }

.blazor-error-boundary {
    background: var(--bad-bg); border: 1px solid rgba(251, 113, 133, 0.4); border-radius: 14px;
    padding: 1rem 1rem 1rem 1.2rem; color: #fecdd3;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
    .result-row { grid-template-columns: 130px minmax(0, 1fr) minmax(0, 1fr) auto; }
    .result-row .who { display: none; }
}

@media (max-width: 1080px) {
    .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
    .run-layout { grid-template-columns: minmax(0, 1fr); }
    .rail { position: static; flex-direction: row; overflow-x: auto; }
    .rail-item { width: auto; flex: none; }
    .rail-progress { display: none; }
}

@media (max-width: 860px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center;
        gap: 12px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto;
    }
    .brand-text, .nav-label, .sidebar-foot { display: none; }
    .nav { flex-direction: row; gap: 4px; }
    .nav a { padding: 8px 10px; white-space: nowrap; }
    .nav a.active::before { display: none; }
    .main { padding: 22px 16px 60px; }
    .capture-field { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .result-row { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; }
    .result-row .values { grid-column: 1 / -1; }
    .unit-grid, .pick-list { grid-template-columns: minmax(0, 1fr); }
    .verdict-toggle { width: 100%; }
    .verdict-toggle .btn { flex: 1; min-width: 0; }
}

@media (max-width: 520px) {
    .nav a span { display: none; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-value { font-size: 1.6rem; }
    .filter-bar .select { flex: 1 1 140px; }
}

/* =========================================================================
   Test sequences
   ========================================================================= */

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); border: 0; }

a.seq-link { color: var(--text); transition: border-color 0.2s, background 0.2s; }
a.seq-link:hover { color: var(--text); border-color: var(--border-strong); background: rgba(255, 255, 255, 0.04); }
.seq-row .go { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.85rem; color: var(--accent); }

/* Run tests: unit card */
.tests-done { display: flex; flex-direction: column; align-items: flex-end; text-align: right; flex: none; line-height: 1.15; }
.tests-done .v { font: 600 1.9rem var(--font-display); font-variant-numeric: tabular-nums; }
.tests-done .c { font-size: 0.7rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.08em; }
.last-result { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: rgba(6, 9, 18, 0.45); border: 1px solid var(--border); }

/* Test assignment editor */
.assign-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
.seq-row.assign { flex-wrap: wrap; }
.seq-row.assign .t { flex: 1 1 180px; }
.seq-row.assign .actions { margin-left: auto; }

/* Component list editor */
.component-table { display: flex; flex-direction: column; gap: 8px; }
.component-row { display: grid; grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: start; }
.component-table.with-serial .component-row { grid-template-columns: 28px minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1.2fr) auto; }
.component-row.head { font: 600 0.68rem var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); align-items: end; }
.component-row .n { width: 28px; height: 42px; display: grid; place-items: center; font: 600 0.75rem var(--font-mono); color: var(--faint); }
.component-row .actions { display: flex; gap: 6px; padding-top: 5px; }
.component-row .actions, .component-row.head > span:last-child { width: 108px; }
.component-row .error-text { margin-top: 4px; }

/* Confirmation checkbox (e.g. "I have done this") */
.confirm-check {
    display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 14px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--panel); font-weight: 600; font-size: 1rem;
    transition: border-color 0.2s, background 0.2s;
}
.confirm-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.confirm-check.on { border-color: rgba(52, 211, 153, 0.55); background: var(--ok-bg); }
.confirm-check.on .checkbox { background: var(--ok); border-color: transparent; color: #03140d; }
.confirm-check input:focus-visible + .checkbox { outline: 2px solid var(--accent); outline-offset: 2px; }
.confirm-check.compact { padding: 0; border: 0; background: transparent; font-weight: 500; font-size: 0.92rem; }
.setup-callout p { font-size: 1.15rem; line-height: 1.6; color: var(--text); }

/* Frameless runner */
.runner-shell { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }
.runner-bar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
    padding: 12px clamp(14px, 2.4vw, 32px);
    background: rgba(10, 15, 29, 0.92); border-bottom: 1px solid var(--border-strong); backdrop-filter: blur(14px);
}
.runner-brand .brand-mark { width: 34px; height: 34px; display: block; }
.runner-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.runner-label { font: 600 0.64rem var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.runner-value { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.serial-big { font-family: var(--font-mono); color: var(--accent); font-size: 1.2rem; letter-spacing: 0.04em; }
.runner-progress { display: flex; flex-direction: column; gap: 6px; min-width: 170px; }
.runner-main { flex: 1; padding: 22px clamp(14px, 2.4vw, 32px) 40px; }
.runner-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.runner-info { position: sticky; top: 86px; max-height: calc(100vh - 110px); overflow-y: auto; }
.runner-test-name { font-size: clamp(1.6rem, 2.4vw, 2.2rem); margin-top: 4px; }
.runner-entry .capture-field { grid-template-columns: minmax(0, 1fr); gap: 12px; }

.guidance { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: 14px; background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.3); }
.guidance .lbl { display: flex; align-items: center; gap: 6px; font: 600 0.7rem var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: #c4b5fd; }
.guidance p { white-space: pre-line; color: #ddd6fe; }
.guidance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.guidance-grid figure { margin: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: rgba(6, 9, 18, 0.6); }
.guidance-grid img { display: block; width: 100%; max-height: 320px; object-fit: contain; background: #fff; }
.guidance-grid figcaption { padding: 8px 10px; font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.runner-steps { border-top: 1px solid var(--border); padding-top: 12px; }
.runner-steps summary { cursor: pointer; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--muted); list-style: none; }
.runner-steps summary::-webkit-details-marker { display: none; }
.runner-steps[open] summary { margin-bottom: 10px; color: var(--text); }
.runner-steps ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.runner-steps li { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 8px; font-size: 0.86rem; }
.runner-steps li .name { flex: 1; }
.runner-steps li.current { background: var(--accent-bg); color: var(--text); }

.upload-box { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: 14px; border: 1px dashed var(--border-strong); background: rgba(255, 255, 255, 0.02); }
.upload-box.is-invalid { border-color: rgba(251, 113, 133, 0.6); }
.upload-box .fname { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.upload-box .fdesc { color: var(--muted); font-size: 0.84rem; margin-top: 2px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(6, 9, 18, 0.5); border: 1px solid var(--border); }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.86rem; }
label.btn { cursor: pointer; }

.verdict-box { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: 14px; background: rgba(6, 9, 18, 0.45); border: 1px solid var(--border); }
.verdict-toggle .btn[disabled] { opacity: 0.35; }
.runner-submit { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.choice {
    display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: left; padding: 20px; border-radius: 16px; cursor: pointer;
    border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font: inherit; transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.choice:hover { border-color: rgba(34, 211, 238, 0.55); background: var(--accent-bg); transform: translateY(-2px); }
.choice svg { color: var(--accent); }
.choice .title { font-family: var(--font-display); font-weight: 600; font-size: 1.1rem; }

.replace-row { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: rgba(6, 9, 18, 0.45); }
.replace-row.on { border-color: rgba(251, 191, 36, 0.5); background: var(--warn-bg); }

/* Dialog */
.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(2, 4, 10, 0.7); backdrop-filter: blur(4px); }
.modal {
    position: fixed; z-index: 41; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-x: hidden; overflow-y: auto;
    display: flex; flex-direction: column; gap: 16px; background: var(--panel-solid);
}
.modal h2 { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; }

@media (max-width: 1080px) {
    .assign-grid { grid-template-columns: minmax(0, 1fr); }
    .runner-grid { grid-template-columns: minmax(0, 1fr); }
    .runner-info { position: static; max-height: none; }
}

@media (max-width: 860px) {
    .component-row, .component-table.with-serial .component-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .component-row .n, .component-row.head { display: none; }
    .component-row > div:first-of-type { grid-column: 1 / -1; }
    .choice-grid { grid-template-columns: minmax(0, 1fr); }
    .runner-bar { gap: 12px; }
}

/* =========================================================================
   Printable reports (light theme)
   ========================================================================= */

.report-shell {
    position: relative; z-index: 1; min-height: 100vh; padding: 0 0 40px;
    background: #eef1f6; color: #111827; color-scheme: light; font-family: var(--font);
}
.report-shell a { color: #0e7490; }
.report-shell .muted { color: #4b5563; }
.report-shell .mono { font-family: var(--font-mono); }
.report-toolbar {
    position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 24px; background: #fff; border-bottom: 1px solid #d1d5db;
}
.report-toolbar .spacer { flex: 1; }
.report-toolbar button, .report-toolbar a.button {
    display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 8px; cursor: pointer;
    border: 1px solid #9ca3af; background: #fff; color: #111827; font: 600 0.85rem var(--font);
}
.report-toolbar button:hover, .report-toolbar a.button:hover { background: #f3f4f6; }
.report-search { display: flex; gap: 6px; }
.report-search input { height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid #9ca3af; font: 500 0.9rem var(--font-mono); }

.report-page {
    max-width: 960px; margin: 24px auto; padding: 40px 44px; background: #fff;
    border-radius: 6px; box-shadow: 0 6px 30px -12px rgba(0, 0, 0, 0.3); font-size: 13.5px;
}
.report-page h1 { font-family: var(--font-display); font-size: 1.8rem; color: #0f172a; }
.report-page h2 { font-size: 1.1rem; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 2px solid #0f172a; color: #0f172a; display: flex; align-items: center; gap: 10px; }
.report-page h3 { font-size: 0.98rem; margin: 18px 0 8px; color: #0f172a; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; flex-wrap: wrap; padding-bottom: 18px; border-bottom: 4px solid #0e7490; }
.report-brand { font: 700 0.75rem var(--font-mono); letter-spacing: 0.18em; text-transform: uppercase; color: #0e7490; margin-bottom: 6px; }
.report-ident { display: grid; grid-template-columns: auto auto; gap: 4px 16px; margin: 0; }
.report-ident dt { font: 600 0.7rem var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: #6b7280; align-self: center; }
.report-ident dd { margin: 0; font-weight: 600; font-size: 1rem; }
.report-warning { margin: 16px 0; padding: 12px 14px; border-radius: 6px; background: #fef3c7; border: 1px solid #f59e0b; color: #78350f; }
.report-table { width: 100%; border-collapse: collapse; margin: 6px 0; }
.report-table th, .report-table td { text-align: left; vertical-align: top; padding: 7px 9px; border-bottom: 1px solid #e5e7eb; }
.report-table tbody th { width: 160px; color: #374151; font-weight: 600; }
.report-table.grid th, .report-table.grid td { border: 1px solid #d1d5db; }
.report-table.grid thead th { background: #f3f4f6; font: 600 0.72rem var(--font); text-transform: uppercase; letter-spacing: 0.04em; color: #374151; }
.report-table .nowrap { white-space: nowrap; }
.report-table .small { font-size: 0.85em; }
.report-table .out { color: #b91c1c; font-weight: 600; }
.report-table tr.fail-row td { background: #fef2f2; }
.report-table tr.removed-row td { color: #9ca3af; text-decoration: line-through; }
.report-confirm { margin-top: 6px; font-weight: 600; }
.report-test { padding: 12px 0; border-bottom: 1px solid #e5e7eb; break-inside: avoid; }
.report-test-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.report-test-head h3 { margin: 0; }
.report-outcome { display: inline-block; padding: 2px 10px; border-radius: 4px; font: 700 0.75rem var(--font-mono); letter-spacing: 0.08em; }
.report-outcome.pass { background: #dcfce7; color: #166534; border: 1px solid #22c55e; }
.report-outcome.fail { background: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }
.report-outcome.none { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; }
.report-status { font: 600 0.7rem var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; background: #e0f2fe; color: #075985; }
.report-comment { margin-top: 8px; padding: 8px 12px; border-left: 3px solid #0e7490; background: #f9fafb; white-space: pre-line; }
.report-files { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.report-files figure { margin: 0; max-width: 260px; }
.report-files img { max-width: 100%; max-height: 220px; border: 1px solid #d1d5db; }
.report-files figcaption { font-size: 0.75rem; color: #6b7280; }
.report-foot { margin-top: 30px; padding-top: 10px; border-top: 1px solid #d1d5db; font-size: 0.75rem; color: #6b7280; text-align: center; }

@media print {
    @page { margin: 14mm; }
    body { background: #fff !important; }
    body::before, .no-print, #blazor-error-ui, #components-reconnect-modal { display: none !important; }
    .report-shell { background: #fff; padding: 0; }
    .report-page { margin: 0; padding: 0; max-width: none; box-shadow: none; border-radius: 0; }
    .report-shell a { color: inherit; text-decoration: none; }
}
