/* ── System Health dashboard ────────────────────────────────────────
   Tokens alias `--st-*` from studio-theme.css so health follows the
   rust / dark-rust / dark-slate themes the cockpit uses. Aliasing is
   cheaper than a rename pass — every selector below already reads
   `--h-*`, and the studio-theme tokens flip per `body.light-theme`,
   `body.dark-theme`, and `body.dark-theme.dark-slate` for us.
   ──────────────────────────────────────────────────────────────── */

:root {
    --h-bg:          var(--st-bg);
    --h-surface:     var(--st-card-bg);
    --h-card:        var(--st-card-bg);
    --h-border:      var(--st-border);
    --h-text:        var(--st-text);
    --h-text-muted:  var(--st-text-muted);
    --h-text-dim:    var(--st-text-muted);

    --h-ok:          var(--st-success);
    --h-warning:     var(--st-warning);
    --h-error:       var(--st-danger);
    --h-unknown:     var(--st-text-muted);
    --h-primary:     var(--st-primary);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    background: var(--h-bg);
    color: var(--h-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────── */
.h-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    background: var(--h-surface);
    border-bottom: 1px solid var(--h-border);
    position: sticky; top: 0; z-index: 10;
}
.h-header h1 {
    margin: 0; font-size: 16px; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
}
.h-subtitle {
    opacity: 0.6; font-weight: 400; font-size: 12px; margin-left: 12px;
}
.h-header-actions {
    display: flex; align-items: center; gap: 16px;
}
.h-header-actions a {
    color: var(--h-text-muted); text-decoration: none; font-size: 13px;
}
.h-header-actions a:hover { color: var(--h-text); }
.h-connection {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    background: var(--h-card); border: 1px solid var(--h-border);
    font-size: 12px; color: var(--h-text-muted);
}
.h-connection[data-state="live"]        { color: var(--h-ok);      border-color: var(--h-ok); }
.h-connection[data-state="polling"]     { color: var(--h-warning); border-color: var(--h-warning); }
.h-connection[data-state="offline"]     { color: var(--h-error);   border-color: var(--h-error); }

/* ── Overall status banner ──────────────────────────────────────── */
.h-overall {
    display: flex; align-items: center; gap: 16px;
    margin: 18px 24px 8px;
    padding: 14px 18px;
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    border-left: 4px solid var(--h-unknown);
    border-radius: 8px;
}
.h-overall[data-status="ok"]        { border-left-color: var(--h-ok); }
.h-overall[data-status="warning"]   { border-left-color: var(--h-warning); }
.h-overall[data-status="error"]     { border-left-color: var(--h-error); }
.h-overall-badge {
    font-size: 24px; font-weight: 700; padding: 6px 16px; border-radius: 6px;
    background: var(--h-card); text-transform: uppercase; letter-spacing: 0.04em;
}
.h-overall[data-status="ok"]      .h-overall-badge { color: var(--h-ok);      background: rgba(34,197,94,0.10); }
.h-overall[data-status="warning"] .h-overall-badge { color: var(--h-warning); background: rgba(245,158,11,0.12); }
.h-overall[data-status="error"]   .h-overall-badge { color: var(--h-error);   background: rgba(239,68,68,0.12); }
.h-overall-label   { font-size: 12px; color: var(--h-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.h-overall-checked { font-size: 12px; color: var(--h-text-dim); margin-top: 2px; }

/* ── Card grid ──────────────────────────────────────────────────── */
.h-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 14px;
    padding: 8px 24px 28px;
}
.h-card-wide { grid-column: 1 / -1; }
@media (min-width: 1400px) {
    .h-card-wide { grid-column: span 2; }
}

.h-card {
    background: var(--h-card);
    border: 1px solid var(--h-border);
    border-radius: 8px;
    overflow: hidden;
    display: flex; flex-direction: column;
}
.h-card > header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--h-border);
}
.h-card > header i:first-child {
    color: var(--h-primary); font-size: 15px;
}
.h-card > header h2 {
    margin: 0; flex: 1; font-size: 14px; font-weight: 600;
}
.h-card-body {
    padding: 12px 14px 14px; flex: 1;
}
.h-card-body h3 {
    margin: 14px 0 6px; font-size: 12px; font-weight: 600;
    color: var(--h-text-muted); text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Status pills ───────────────────────────────────────────────── */
.h-status {
    display: inline-block; padding: 2px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.05em; background: var(--h-card); border: 1px solid var(--h-border);
    color: var(--h-text-muted);
}
.h-status[data-status="ok"]      { color: var(--h-ok);      border-color: var(--h-ok); }
.h-status[data-status="warning"] { color: var(--h-warning); border-color: var(--h-warning); }
.h-status[data-status="error"]   { color: var(--h-error);   border-color: var(--h-error); }

/* ── List / table utilities ─────────────────────────────────────── */
.h-list { list-style: none; padding: 0; margin: 0; }
.h-list li {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px dashed var(--h-border);
    font-size: 13px;
}
.h-list li:last-child { border-bottom: 0; }
.h-list .h-unit-state {
    font-family: 'SF Mono', Menlo, monospace; font-size: 11px;
    padding: 1px 8px; border-radius: 4px;
}
.h-list .h-unit-state[data-state="active"]   { color: var(--h-ok);      background: rgba(34,197,94,0.10); }
.h-list .h-unit-state[data-state="inactive"],
.h-list .h-unit-state[data-state="failed"]   { color: var(--h-error);   background: rgba(239,68,68,0.10); }

.h-kv {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 0; font-size: 13px;
}
.h-kv + .h-kv { border-top: 1px dashed var(--h-border); }

.h-table {
    width: 100%; border-collapse: collapse; margin-top: 6px;
    font-size: 12px;
}
.h-table th, .h-table td {
    padding: 5px 8px; text-align: left;
    border-bottom: 1px solid var(--h-border);
}
.h-table th {
    font-weight: 600; color: var(--h-text-muted); text-transform: uppercase;
    font-size: 10px; letter-spacing: 0.04em;
}
.h-table tr:last-child td { border-bottom: 0; }
.h-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.h-link { font-size: 12px; color: var(--h-primary); text-decoration: none; }
.h-link:hover { text-decoration: underline; }

/* ── Runs metrics ───────────────────────────────────────────────── */
.h-runs-summary {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
    margin-bottom: 8px;
}
.h-metric {
    background: var(--h-surface);
    border: 1px solid var(--h-border);
    border-radius: 6px;
    padding: 10px; text-align: center;
}
.h-metric-value { font-size: 22px; font-weight: 700; }
.h-metric-label {
    font-size: 11px; color: var(--h-text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px;
}

.h-cat-bars { display: flex; flex-direction: column; gap: 4px; }
.h-cat-row {
    display: grid; grid-template-columns: 120px 1fr 40px;
    align-items: center; gap: 8px; font-size: 12px;
}
.h-cat-label { color: var(--h-text-muted); }
.h-cat-bar {
    height: 6px; background: var(--h-surface); border-radius: 3px; overflow: hidden;
}
.h-cat-bar > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--h-warning), var(--h-error));
}
.h-cat-count { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Disk bar + hint banner (Phase 2 cards) ─────────────────────── */
.h-disk-bar {
    width: 100%; height: 8px; background: var(--h-surface);
    border-radius: 4px; overflow: hidden; margin-top: 8px;
    border: 1px solid var(--h-border);
}
.h-disk-fill {
    height: 100%; width: 0%;
    background: var(--h-ok);
    transition: width 0.3s ease, background 0.3s ease;
}
.h-disk-fill[data-status="warning"] { background: var(--h-warning); }
.h-disk-fill[data-status="error"]   { background: var(--h-error); }

.h-hint {
    display: none;
    margin-top: 8px; padding: 6px 10px;
    background: rgba(245,158,11,0.10);
    color: var(--h-warning);
    border-radius: 4px;
    font-size: 12px;
}

/* Drill-down target cell: becomes clickable-looking only when we've
   flagged it with h-drill-active (i.e. there's actually something
   to drill into). The dormant state stays unobtrusive. */
.h-drill               { cursor: default; }
.h-drill.h-drill-active {
    cursor: pointer;
    color: var(--h-warning);
    text-decoration: underline dotted;
    text-underline-offset: 3px;
}
.h-drill.h-drill-active:hover,
.h-drill.h-drill-active:focus {
    color: var(--h-error);
    outline: none;
}

/* ── Activity feed ──────────────────────────────────────────────── */
.h-activity { list-style: none; padding: 0; margin: 0; }
.h-activity li {
    display: grid; grid-template-columns: 90px 1fr auto;
    gap: 12px; align-items: center;
    padding: 8px 0; border-bottom: 1px solid var(--h-border);
    font-size: 13px;
}
.h-activity li:last-child { border-bottom: 0; }
.h-activity .h-time {
    font-size: 11px; color: var(--h-text-muted);
    font-variant-numeric: tabular-nums;
}
.h-activity .h-event-body strong { color: var(--h-text); }
.h-activity .h-event-body .h-art-type {
    font-size: 11px; color: var(--h-text-muted); margin-right: 4px;
}
.h-activity .h-event-action {
    font-size: 11px; padding: 2px 8px; border-radius: 999px;
    background: var(--h-surface); color: var(--h-text-muted);
}
.h-activity .h-event-action[data-event="run_failed"]    { color: var(--h-error);   background: rgba(239,68,68,0.10); cursor: pointer; }
.h-activity .h-event-action[data-event="run_completed"] { color: var(--h-ok);      background: rgba(34,197,94,0.10); }
.h-activity .h-event-action[data-event="run_started"]   { color: var(--h-primary); background: rgba(59,130,246,0.10); }

/* ── Debug report modal ─────────────────────────────────────────── */
.h-modal {
    position: fixed; inset: 0; display: grid; place-items: center; z-index: 100;
}
.h-modal[hidden] { display: none; }
.h-modal-backdrop {
    position: absolute; inset: 0; background: rgba(0,0,0,0.55);
}
.h-modal-panel {
    position: relative; z-index: 1;
    width: min(680px, 92vw); max-height: 86vh; overflow: auto;
    background: var(--h-card); border: 1px solid var(--h-border);
    border-radius: 8px;
}
.h-modal-panel header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--h-border);
}
.h-modal-panel header h3 { margin: 0; font-size: 15px; }
.h-modal-close {
    background: transparent; border: 0; color: var(--h-text-muted); cursor: pointer;
    font-size: 16px;
}
.h-debug-body { padding: 14px 16px 18px; }
.h-debug-body h4 {
    margin: 12px 0 4px; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--h-text-muted);
}
.h-debug-body pre {
    background: var(--h-surface); border: 1px solid var(--h-border);
    padding: 8px; border-radius: 4px; overflow: auto; max-height: 220px;
    font-size: 11px; line-height: 1.4;
}
.h-debug-cat {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    font-weight: 600; text-transform: uppercase; font-size: 11px;
    background: rgba(239,68,68,0.10); color: var(--h-error);
}
.h-debug-cat[data-cat="unknown"] { background: var(--h-surface); color: var(--h-text-muted); }
.h-debug-cat[data-cat="timeout"] { background: rgba(245,158,11,0.12); color: var(--h-warning); }
