/* LochStudios Fleet — base styles.
 *
 * Ported from .claude/design-cache/status-fetch/lochstudios-status-page/project/styles.css
 * with the .ls-* class names preserved so future agent-design diffs land
 * trivially. Drop-in for the fleet home + server detail pages.
 */

:root {
    --bg-0: oklch(0.165 0.013 235);
    --bg-1: oklch(0.195 0.015 235);
    --bg-2: oklch(0.225 0.017 235);
    --bg-3: oklch(0.265 0.018 235);
    --line: oklch(0.305 0.018 235);
    --line-2: oklch(0.255 0.018 235);
    --line-soft: oklch(0.235 0.017 235);

    --ink-1: oklch(0.965 0.005 235);
    --ink-2: oklch(0.78 0.012 235);
    --ink-3: oklch(0.6 0.015 235);
    --ink-4: oklch(0.45 0.015 235);

    --loch: oklch(0.78 0.13 200);
    --loch-deep: oklch(0.58 0.14 220);
    --loch-soft: oklch(0.78 0.13 200 / 0.18);
    --loch-line: oklch(0.78 0.13 200 / 0.35);

    --ok: oklch(0.78 0.17 152);
    --ok-soft: oklch(0.78 0.17 152 / 0.16);
    --warn: oklch(0.82 0.16 78);
    --warn-soft: oklch(0.82 0.16 78 / 0.16);
    --bad: oklch(0.7 0.21 25);
    --bad-soft: oklch(0.7 0.21 25 / 0.18);

    --m-cpu: oklch(0.73 0.14 230);
    --m-iowait: oklch(0.72 0.2 25);
    --m-steal: oklch(0.85 0.16 95);
    --m-user: oklch(0.72 0.17 295);
    --m-system: oklch(0.78 0.13 200);

    --m-ram: oklch(0.76 0.16 152);
    --m-swap: oklch(0.74 0.16 350);
    --m-buf: oklch(0.7 0.16 285);
    --m-cached: oklch(0.66 0.15 165);

    --m-in: oklch(0.78 0.17 152);
    --m-out: oklch(0.78 0.16 60);

    --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'Geist Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;
}

.ls-root {
    font-family: var(--sans);
    color: var(--ink-1);
    background: var(--bg-0);
    font-feature-settings: 'ss01', 'cv11';
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
    min-height: 100vh;
}
.ls-root * { box-sizing: border-box; }
.ls-root a { color: inherit; }

.ls-root .mono { font-family: var(--mono); letter-spacing: -0.01em; }

/* ── Top app bar ───────────────────────────────────────────────────── */
.ls-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line-2);
    background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
    position: sticky; top: 0; z-index: 5;
}
.ls-topbar-left { display: flex; align-items: center; gap: 18px; }
.ls-brand {
    display: flex; align-items: center; gap: 10px;
    font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
    color: var(--ink-1); text-decoration: none;
}
.ls-brand-mark {
    width: 22px; height: 22px; position: relative;
    display: grid; place-items: center;
}
.ls-brand-mark svg { display: block; }
.ls-crumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 12.5px; color: var(--ink-3);
    font-family: var(--mono); letter-spacing: -0.01em;
}
.ls-crumb a { color: var(--ink-3); text-decoration: none; }
.ls-crumb a:hover { color: var(--ink-1); }
.ls-crumb .sep { color: var(--ink-4); }
.ls-crumb .cur { color: var(--ink-1); }

.ls-topbar-right { display: flex; align-items: center; gap: 12px; }

/* Centre nav — sits in the topbar alongside the brand. Subtle, mono,
   low-contrast so it doesn't fight the ops-dashboard density. */
.ls-topnav {
    display: flex; align-items: center; gap: 18px;
    font-family: var(--mono); font-size: 12px;
    letter-spacing: -0.005em;
}
.ls-topnav a {
    color: var(--ink-3); text-decoration: none;
    padding: 4px 0;
}
.ls-topnav a:hover { color: var(--ink-1); }

/* Portal CTA — loch-accented to stand out without leaving the palette. */
.ls-cta {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    background: var(--loch-soft);
    border: 1px solid var(--loch-line);
    color: var(--loch);
    font-family: var(--mono); font-size: 12px;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.ls-cta:hover { background: var(--loch); color: var(--bg-0); border-color: var(--loch); }
.ls-cta .arrow { font-size: 11px; }

@media (max-width: 860px) {
    /* Collapse the mid-nav on narrow screens; brand + cta still fit. */
    .ls-topnav { display: none; }
    .ls-crumb  { display: none; }
}
.ls-live {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 5px 10px 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-1);
    font-size: 11.5px; color: var(--ink-2);
    font-family: var(--mono);
}
.ls-live-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
    box-shadow: 0 0 0 0 var(--ok);
    animation: ls-pulse 2s ease-in-out infinite;
}
@keyframes ls-pulse {
    0% { box-shadow: 0 0 0 0 oklch(0.78 0.17 152 / 0.6); }
    70% { box-shadow: 0 0 0 8px oklch(0.78 0.17 152 / 0); }
    100% { box-shadow: 0 0 0 0 oklch(0.78 0.17 152 / 0); }
}

.ls-iconbtn {
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--line-2); background: var(--bg-1);
    color: var(--ink-2);
    display: grid; place-items: center;
    cursor: pointer;
}
.ls-iconbtn:hover { background: var(--bg-2); color: var(--ink-1); }

/* ── Page + sections ───────────────────────────────────────────────── */
.ls-page { padding: 24px 28px 80px; }

.ls-section-head {
    display: flex; align-items: baseline; gap: 14px;
    margin: 0 0 12px;
}
.ls-section-head h2 {
    margin: 0; font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-3);
    font-family: var(--mono);
}
.ls-section-head .sub {
    font-size: 12px; color: var(--ink-4);
    font-family: var(--mono);
}

.ls-card {
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: 12px;
}
.ls-card-h {
    padding: 14px 16px;
    border-bottom: 1px solid var(--line-2);
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
}
.ls-card-h h3 {
    margin: 0; font-size: 13px; font-weight: 600; color: var(--ink-1);
    letter-spacing: -0.01em;
}
.ls-card-h .meta {
    font-family: var(--mono); font-size: 11px; color: var(--ink-4);
}

/* ── Pills / badges ────────────────────────────────────────────────── */
.pill {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 11px; font-family: var(--mono);
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--ink-2);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.pill.ok { color: var(--ok); border-color: oklch(0.78 0.17 152 / 0.35); background: var(--ok-soft); }
.pill.ok .dot { background: var(--ok); }
.pill.warn { color: var(--warn); border-color: oklch(0.82 0.16 78 / 0.35); background: var(--warn-soft); }
.pill.warn .dot { background: var(--warn); }
.pill.bad { color: var(--bad); border-color: oklch(0.7 0.21 25 / 0.4); background: var(--bad-soft); }
.pill.bad .dot { background: var(--bad); }
.pill.loch { color: var(--loch); border-color: var(--loch-line); background: var(--loch-soft); }
.pill.loch .dot { background: var(--loch); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11.5px; font-family: var(--mono);
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--ink-2);
}
.badge .b-name { color: var(--ink-1); }
.badge .b-val { color: var(--ink-3); }
.badge.ok { color: var(--ok); border-color: oklch(0.78 0.17 152 / 0.35); background: var(--ok-soft); }
.badge.ok .b-name { color: var(--ok); }
.badge.warn { color: var(--warn); border-color: oklch(0.82 0.16 78 / 0.35); background: var(--warn-soft); }
.badge.warn .b-name { color: var(--warn); }
.badge.bad { color: var(--bad); border-color: oklch(0.7 0.21 25 / 0.4); background: var(--bad-soft); }
.badge.bad .b-name { color: var(--bad); }

/* ── Time-range selector ───────────────────────────────────────────── */
.ls-range {
    display: inline-flex; align-items: center; padding: 3px;
    background: var(--bg-2); border: 1px solid var(--line-2);
    border-radius: 8px;
    gap: 0;
}
.ls-range button, .ls-range a {
    border: 0; background: transparent; color: var(--ink-3);
    font-family: var(--mono); font-size: 11px;
    padding: 5px 9px; border-radius: 6px; cursor: pointer;
    min-width: 32px; letter-spacing: -0.005em;
    text-decoration: none;
    display: inline-flex; align-items: center; justify-content: center;
}
.ls-range button:hover, .ls-range a:hover { color: var(--ink-1); }
.ls-range button.active, .ls-range a.active {
    background: var(--bg-3);
    color: var(--ink-1);
    box-shadow: 0 0 0 1px var(--line) inset, 0 1px 0 oklch(1 0 0 / 0.04);
}

/* ── Status dot ────────────────────────────────────────────────────── */
.ls-status-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    position: relative;
}
.ls-status-dot.ok { background: var(--ok); box-shadow: 0 0 0 3px oklch(0.78 0.17 152 / 0.2); }
.ls-status-dot.warn { background: var(--warn); box-shadow: 0 0 0 3px oklch(0.82 0.16 78 / 0.2); }
.ls-status-dot.bad { background: var(--bad); box-shadow: 0 0 0 3px oklch(0.7 0.21 25 / 0.2); }

/* ── Tables ────────────────────────────────────────────────────────── */
.ls-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.ls-table th, .ls-table td {
    text-align: left; padding: 9px 12px;
    border-bottom: 1px solid var(--line-soft);
    font-family: var(--mono);
    color: var(--ink-2);
}
.ls-table th {
    position: sticky; top: 0;
    background: var(--bg-1);
    font-weight: 500;
    font-size: 11px;
    color: var(--ink-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.ls-table tbody tr:hover { background: oklch(1 0 0 / 0.015); }
.ls-table td.num { text-align: right; }
.ls-table td.name { color: var(--ink-1); }

.bar-mini {
    position: relative; height: 5px; border-radius: 3px;
    background: var(--bg-3); overflow: hidden; min-width: 80px;
}
.bar-mini > span {
    position: absolute; inset: 0 auto 0 0;
    background: var(--loch);
    border-radius: 3px;
}
.bar-mini.warn > span { background: var(--warn); }
.bar-mini.bad > span { background: var(--bad); }

/* ── Layout helpers ────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }

.kv {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: 18px; row-gap: 8px;
    font-size: 12.5px; font-family: var(--mono);
}
.kv dt { color: var(--ink-3); margin: 0; }
.kv dd { margin: 0; color: var(--ink-1); }

.stat {
    display: flex; flex-direction: column; gap: 4px;
    padding: 12px 14px;
    border: 1px solid var(--line-2); background: var(--bg-1);
    border-radius: 10px;
}
.stat .label {
    font-family: var(--mono); font-size: 10.5px;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-3);
}
.stat .val {
    font-family: var(--mono); font-size: 22px; color: var(--ink-1);
    letter-spacing: -0.02em;
    display: flex; align-items: baseline; gap: 4px;
}
.stat .val .u {
    font-size: 12px; color: var(--ink-3); font-weight: 400;
}
.stat .sub {
    font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}

/* ── Chart panel ───────────────────────────────────────────────────── */
.chart-panel { display: flex; flex-direction: column; }
.chart-panel .legend {
    display: flex; flex-wrap: wrap; gap: 12px; padding: 10px 16px;
    border-bottom: 1px solid var(--line-2);
    font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.chart-panel .legend .li {
    display: inline-flex; align-items: center; gap: 6px;
}
.chart-panel .legend .sw {
    width: 9px; height: 9px; border-radius: 2px;
}
.chart-panel .legend .val { color: var(--ink-1); }
.chart-panel .body { padding: 12px 12px 8px; }
.chart-panel .summary {
    display: grid; grid-template-columns: repeat(4, 1fr);
    border-top: 1px solid var(--line-2);
}
.chart-panel .summary > div {
    padding: 10px 16px;
    border-right: 1px solid var(--line-soft);
}
.chart-panel .summary > div:last-child { border-right: 0; }
.chart-panel .summary .label {
    font-family: var(--mono); font-size: 10.5px;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--ink-3); margin-bottom: 3px;
}
.chart-panel .summary .v { font-family: var(--mono); font-size: 14px; color: var(--ink-1); }

/* Sparkline wrapper (home page) */
.sparkline-wrap {
    position: relative;
    height: 56px;
}

/* ── Filter chips ──────────────────────────────────────────────────── */
.ls-chip {
    height: 30px; padding: 0 12px;
    border: 1px solid var(--line-2);
    background: var(--bg-1);
    color: var(--ink-2);
    border-radius: 8px;
    font-family: var(--mono); font-size: 12px;
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; text-decoration: none;
}
.ls-chip .count { color: var(--ink-4); }
.ls-chip.active {
    border-color: var(--loch-line);
    background: var(--loch-soft);
    color: var(--loch);
}
.ls-chip.active .count { color: var(--loch); }

/* ── Form bits ─────────────────────────────────────────────────────── */
.input {
    height: 30px; padding: 0 10px;
    background: var(--bg-2); border: 1px solid var(--line-2);
    border-radius: 7px; color: var(--ink-1);
    font-family: var(--mono); font-size: 12px;
    min-width: 200px;
    outline: none;
}
.input:focus { border-color: var(--loch-line); box-shadow: 0 0 0 3px var(--loch-soft); }
.select {
    height: 30px; padding: 0 28px 0 10px;
    background: var(--bg-2) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M3 5l3 3 3-3' stroke='%2399a' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat right 8px center;
    border: 1px solid var(--line-2);
    border-radius: 7px; color: var(--ink-1);
    font-family: var(--mono); font-size: 12px;
    appearance: none;
    cursor: pointer;
}

.scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.scroll::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; border: 2px solid var(--bg-0); }
.scroll::-webkit-scrollbar-track { background: transparent; }

/* ── Server card (home page) ───────────────────────────────────────── */
.ls-server-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--bg-1);
    border: 1px solid var(--line-2);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color .15s, transform .15s;
}
.ls-server-card:hover { border-color: var(--line); transform: translateY(-1px); }
.ls-server-card .hdr {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line-soft);
}
.ls-server-card .hdr-top {
    display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.ls-server-card .hdr-top .name {
    color: var(--ink-1); font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
}
.ls-server-card .hdr-bottom {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--mono); font-size: 11px; color: var(--ink-3);
}
.ls-server-card .hdr-bottom .sep { color: var(--ink-4); }
.ls-server-card .body-section { padding: 10px 14px 0; }
.ls-server-card .body-section .label-row {
    display: flex; align-items: center; justify-content: space-between;
    font-family: var(--mono); font-size: 10.5px; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;
}
.ls-server-card .body-section .label-row .v {
    font-size: 13px; text-transform: none; letter-spacing: 0;
    color: var(--loch);
}
.ls-server-card .body-section .v.warn { color: var(--warn); }
.ls-server-card .body-section .v.bad  { color: var(--bad); }
.ls-server-card .body-section + .body-section { padding-top: 8px; }
.ls-server-card .body-section:last-of-type { padding-bottom: 14px; }
.ls-server-card .footer-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr;
    border-top: 1px solid var(--line-soft);
    background: oklch(1 0 0 / 0.01);
}
.ls-server-card .footer-grid > div {
    padding: 8px 12px; border-right: 1px solid var(--line-soft);
}
.ls-server-card .footer-grid > div:last-child { border-right: 0; }
.ls-server-card .footer-grid .k {
    font-family: var(--mono); font-size: 9.5px; color: var(--ink-4);
    text-transform: uppercase; letter-spacing: 0.08em;
}
.ls-server-card .footer-grid .v {
    font-family: var(--mono); font-size: 12px; color: var(--ink-1); margin-top: 2px;
}
.ls-server-card .bad-state {
    padding: 24px 16px; display: flex; flex-direction: column; gap: 6px;
    color: var(--ink-3); font-family: var(--mono); font-size: 12px;
    align-items: center; text-align: center;
}
.ls-server-card .bad-state .small {
    color: var(--ink-4); font-size: 11px;
}

/* Region tags (compact). */
.ls-region {
    display: inline-flex; align-items: center; gap: 5px;
    font-family: var(--mono); font-size: 10px;
    color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em;
}
.ls-region .dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--loch);
}
.ls-region.syd .dot { background: oklch(0.78 0.13 200); }
.ls-region.fra .dot { background: oklch(0.74 0.16 295); }
.ls-region.iad .dot { background: oklch(0.78 0.17 152); }

/* ============================================================
   Light theme — opt-in via <html data-theme="light"> (cookie-driven
   from views/layout.php). Swaps every dark surface to its light
   counterpart and inverts the ink scale; accent colours (loch, ok,
   warn, bad and the chart series) are kept on the OKL scale but
   nudged darker so AA contrast holds against white.
   ============================================================ */
:root[data-theme="light"] {
    --bg-0: oklch(0.985 0.003 235);
    --bg-1: oklch(0.97 0.004 235);
    --bg-2: oklch(0.94 0.005 235);
    --bg-3: oklch(0.91 0.006 235);
    --line: oklch(0.83 0.008 235);
    --line-2: oklch(0.88 0.007 235);
    --line-soft: oklch(0.93 0.005 235);

    --ink-1: oklch(0.18 0.02 235);
    --ink-2: oklch(0.32 0.02 235);
    --ink-3: oklch(0.48 0.015 235);
    --ink-4: oklch(0.62 0.012 235);

    --loch: oklch(0.55 0.14 220);
    --loch-deep: oklch(0.45 0.16 220);
    --loch-soft: oklch(0.55 0.14 220 / 0.10);
    --loch-line: oklch(0.55 0.14 220 / 0.30);

    --ok: oklch(0.52 0.17 152);
    --ok-soft: oklch(0.52 0.17 152 / 0.10);
    --warn: oklch(0.58 0.16 78);
    --warn-soft: oklch(0.58 0.16 78 / 0.10);
    --bad: oklch(0.52 0.21 25);
    --bad-soft: oklch(0.52 0.21 25 / 0.10);

    --m-cpu: oklch(0.5 0.16 230);
    --m-iowait: oklch(0.5 0.2 25);
    --m-steal: oklch(0.6 0.16 95);
    --m-user: oklch(0.48 0.17 295);
    --m-system: oklch(0.5 0.14 200);

    --m-ram: oklch(0.5 0.16 152);
    --m-swap: oklch(0.5 0.16 350);
    --m-buf: oklch(0.5 0.16 285);
    --m-cached: oklch(0.45 0.15 165);

    --m-in: oklch(0.5 0.17 152);
    --m-out: oklch(0.55 0.16 60);
}
/* The .ls-topbar gradient + ::after fade rely on the bg-0/1 contrast
   working in both directions; force a hairline shadow in light mode
   so the sticky topbar still has a visual edge against the page. */
:root[data-theme="light"] .ls-topbar {
    background: linear-gradient(180deg, #FFFFFF, var(--bg-1));
    box-shadow: 0 1px 0 var(--line-2);
}

/* Theme-toggle button — show moon by default (dark mode), sun in
   light mode. The shared theme-toggle.js flips the cookie and the
   html data-theme attribute; CSS below decides which icon is
   visible. */
.ls-theme-toggle:hover { background: var(--bg-2) !important; }
:root[data-theme="light"] .ls-theme-toggle .ic-moon { display: none; }
:root[data-theme="light"] .ls-theme-toggle .ic-sun  { display: inline; }
