/* ==========================================================================
   LeadForge — a control desk, not a brochure.
   Dark ground so the data is the only thing emitting light.
   Mono for anything read character-by-character: selectors, hashes, +971 numbers.
   ========================================================================== */

:root {
    --ink:        #0D1520;
    --panel:      #141F2E;
    --panel-hi:   #1B2A3D;
    --line:       #22344A;
    --line-soft:  #1A2839;

    --sand:       #E0A458;   /* actions, focus, the one warm thing */
    --sand-dim:   #8A6435;
    --mint:       #4FD1A5;   /* running / succeeded */
    --coral:      #F0716D;   /* failed */

    --text:       #DCE6F2;
    --muted:      #788CA6;
    --faint:      #4A5C74;

    --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --r: 3px;
}

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

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

body {
    margin: 0;
    background: var(--ink);
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--sand); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: 2px solid var(--sand);
    outline-offset: 2px;
}

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

.shell { display: flex; min-height: 100vh; }

.rail {
    width: 216px;
    flex: 0 0 216px;
    background: #0A111A;
    border-right: 1px solid var(--line-soft);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 14px;
}

.brand__mark {
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
}
.brand__mark span { color: var(--sand); }

.brand__sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--faint);
    margin-top: 3px;
}

.nav { display: flex; flex-direction: column; gap: 1px; padding: 0 10px; flex: 1; }

.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    color: var(--muted);
    border-radius: var(--r);
    font-size: 13.5px;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.nav a:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--panel-hi); color: var(--text); box-shadow: inset 2px 0 0 var(--sand); }

.nav__count {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--faint);
}

.rail__foot {
    padding: 14px 20px 0;
    border-top: 1px solid var(--line-soft);
    font-size: 12px;
    color: var(--faint);
}
.rail__foot form { margin: 6px 0 0; }
.rail__foot button {
    background: none; border: 0; padding: 0;
    color: var(--muted); font: inherit; cursor: pointer;
}
.rail__foot button:hover { color: var(--coral); }

.main { flex: 1; min-width: 0; padding: 26px 30px 60px; }

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

.head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line-soft);
}

h1 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
}

.head__sub { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Stat strip ---------- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1px;
    background: var(--line-soft);
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    overflow: hidden;
    margin-bottom: 24px;
}

.stat { background: var(--panel); padding: 14px 16px; }

.stat__k {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--faint);
}

.stat__v {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -1px;
    margin-top: 4px;
}
.stat__v.is-warn { color: var(--coral); }
.stat__v.is-live { color: var(--mint); }

.stat__note { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Panels ---------- */

.grid-2 {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 18px;
}
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

.panel {
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    overflow: hidden;
}

.panel__head {
    padding: 11px 16px;
    border-bottom: 1px solid var(--line-soft);
    font-family: var(--mono);
    font-size: 10.5px;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    color: var(--faint);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel__body { padding: 16px; }

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

table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    padding: 9px 16px;
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--faint);
    font-weight: 500;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}

td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--line-soft);
    vertical-align: middle;
}

tbody tr:hover td { background: var(--panel-hi); }
tbody tr:last-child td { border-bottom: 0; }

.t-mono { font-family: var(--mono); font-size: 12.5px; }
.t-muted { color: var(--muted); }
.t-faint { color: var(--faint); }
.t-num { font-family: var(--mono); text-align: right; }

.truncate {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Status rail: the signature.
   State lives in a hairline on the left edge, not a coloured pill. ---------- */

.rowstate { box-shadow: inset 3px 0 0 var(--faint); }
.rowstate--run  { box-shadow: inset 3px 0 0 var(--mint); }
.rowstate--ok   { box-shadow: inset 3px 0 0 var(--sand-dim); }
.rowstate--fail { box-shadow: inset 3px 0 0 var(--coral); }
.rowstate--off  { box-shadow: inset 3px 0 0 transparent; opacity: .55; }

.dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--faint);
    margin-right: 7px;
    vertical-align: middle;
}
.dot--live {
    background: var(--mint);
    box-shadow: 0 0 0 0 rgba(79, 209, 165, .6);
    animation: pulse 1.8s infinite;
}
.dot--ok   { background: var(--sand); }
.dot--fail { background: var(--coral); }

@keyframes pulse {
    to { box-shadow: 0 0 0 7px rgba(79, 209, 165, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .dot--live { animation: none; }
    * { transition: none !important; }
}

/* ---------- Confidence meter ---------- */

.meter {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11.5px;
}
.meter__bar {
    width: 44px; height: 3px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
}
.meter__fill { height: 100%; background: var(--sand); }
.meter__fill.is-low { background: var(--sand-dim); }

/* ---------- Coverage bars ---------- */

.cov { margin-bottom: 14px; }
.cov:last-child { margin-bottom: 0; }
.cov__top {
    display: flex; justify-content: space-between;
    font-size: 12.5px; margin-bottom: 5px;
}
.cov__pct { font-family: var(--mono); color: var(--muted); }
.cov__track { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.cov__fill { height: 100%; background: var(--sand); }
.cov__fill--alt { background: var(--mint); }

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

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--panel-hi);
    color: var(--text);
    font: 500 13px var(--sans);
    cursor: pointer;
    text-decoration: none;
    transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--sand-dim); text-decoration: none; }

.btn--primary {
    background: var(--sand);
    border-color: var(--sand);
    color: #1A1207;
    font-weight: 600;
}
.btn--primary:hover { background: #EFB56C; border-color: #EFB56C; }

.btn--ghost { background: transparent; }
.btn--danger:hover { border-color: var(--coral); color: var(--coral); }
.btn--sm { padding: 4px 9px; font-size: 12px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

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

.field { margin-bottom: 15px; }

label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.hint {
    font-size: 11.5px;
    color: var(--faint);
    margin-top: 4px;
    line-height: 1.45;
}

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=url], select, textarea {
    width: 100%;
    padding: 8px 10px;
    background: var(--ink);
    border: 1px solid var(--line);
    border-radius: var(--r);
    color: var(--text);
    font: 400 13px var(--sans);
}

input.mono, textarea.mono, select.mono { font-family: var(--mono); font-size: 12.5px; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--sand);
}

textarea { resize: vertical; min-height: 72px; }

.check { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.check input { width: auto; margin: 0; accent-color: var(--sand); }
.check label { margin: 0; color: var(--text); font-size: 13px; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 0 16px;
}

fieldset {
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    padding: 16px;
    margin: 0 0 18px;
}
legend {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--sand);
    padding: 0 7px;
}

/* ---------- Filter bar ---------- */

.filters {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: var(--r);
    padding: 13px 16px;
    margin-bottom: 16px;
}
.filters .field { margin: 0; min-width: 130px; }
.filters .field--grow { flex: 1; min-width: 200px; }

/* ---------- Flash + empty ---------- */

.flash {
    background: rgba(224, 164, 88, .09);
    border: 1px solid var(--sand-dim);
    border-left-width: 3px;
    border-radius: var(--r);
    padding: 10px 14px;
    margin-bottom: 18px;
    font-size: 13px;
}

.empty { padding: 44px 24px; text-align: center; }
.empty__t { font-size: 15px; margin-bottom: 5px; }
.empty__d { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.errors {
    background: rgba(240, 113, 109, .08);
    border: 1px solid var(--coral);
    border-radius: var(--r);
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--coral);
}
.errors ul { margin: 0; padding-left: 16px; }
.field-error { color: var(--coral); font-size: 11.5px; margin-top: 4px; display: block; }

/* ---------- Sparkline ---------- */

.spark { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.spark__bar {
    flex: 1;
    background: var(--sand-dim);
    border-radius: 1px 1px 0 0;
    min-height: 2px;
    transition: background .12s;
}
.spark__bar:hover { background: var(--sand); }

/* ---------- Pager ---------- */

.pager {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    font-size: 12.5px;
    color: var(--muted);
}
.pager__n { font-family: var(--mono); }

/* ---------- Login ---------- */

.gate {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
        radial-gradient(circle at 50% 0%, rgba(224, 164, 88, .06), transparent 55%),
        var(--ink);
}

.gate__card {
    width: 100%;
    max-width: 340px;
    background: var(--panel);
    border: 1px solid var(--line-soft);
    border-radius: 5px;
    padding: 30px 28px;
}

.gate__mark {
    font-family: var(--mono);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 3px;
}
.gate__mark span { color: var(--sand); }

.gate__sub {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: var(--faint);
    margin-bottom: 24px;
}

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

@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .rail { width: 100%; flex: none; }
    .nav { flex-direction: row; overflow-x: auto; flex: none; }
    .rail__foot { display: none; }
    .main { padding: 18px 14px 40px; }
    .head { flex-direction: column; align-items: flex-start; }
    table { font-size: 12.5px; }
    th, td { padding: 8px 10px; }
}
