:root {
    --bg: #0f1115;
    --bg-elev: #161a22;
    --bg-elev-2: #1d222c;
    --border: #262c38;
    --text: #e6e9ef;
    --text-dim: #9aa3b2;
    --accent: #6ea8fe;
    --accent-strong: #4a8df0;
    --ok: #2fbf71;
    --warn: #f5a524;
    --err: #f06464;
    --unknown: #6b7180;
    --idle: #4cc9c4;
    --radius: 8px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.45;
}

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

.muted { color: var(--text-dim); }

/* ---------- Top bar (dashboard) ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--bg-elev);
    border-bottom: 1px solid var(--border);
}
.topbar__brand {
    font-weight: 600;
    letter-spacing: 0.02em;
}
.topbar__meta {
    display: flex;
    gap: 16px;
    align-items: center;
    color: var(--text-dim);
    font-size: 13px;
}
.topbar__meta strong { color: var(--text); font-weight: 600; }
.topbar__logout {
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: var(--radius);
    color: var(--text-dim);
}
.topbar__logout:hover { color: var(--text); border-color: var(--accent); text-decoration: none; }

/* ---------- Page / VPC sections ---------- */

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.vpc {
    margin-bottom: 32px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.vpc__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-elev-2);
    border-bottom: 1px solid var(--border);
}
.vpc__header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* ---------- Fleet table ---------- */

.table-wrap { overflow-x: auto; }

table.fleet {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.fleet th, table.fleet td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.fleet thead th {
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    background: var(--bg-elev-2);
}
table.fleet tbody tr:last-child td,
table.fleet tbody tr:last-child th { border-bottom: none; }
table.fleet tbody tr:hover { background: rgba(110, 168, 254, 0.04); }

.cell-service { font-weight: 600; color: var(--text); }
.cell-mono { font-family: var(--font-mono); }
.cell-docker { color: var(--text-dim); }
.cell-docker .docker-stat { display: inline-block; margin-right: 12px; }
.cell-docker em { color: var(--text); font-style: normal; }

/* ---------- Badges ---------- */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border: 1px solid transparent;
}
.badge--ok      { color: var(--ok);      background: rgba(47, 191, 113, 0.10); border-color: rgba(47, 191, 113, 0.35); }
.badge--idle    { color: var(--idle);    background: rgba(76, 201, 196, 0.10); border-color: rgba(76, 201, 196, 0.35); }
.badge--warn    { color: var(--warn);    background: rgba(245, 165, 36, 0.10); border-color: rgba(245, 165, 36, 0.35); }
.badge--err     { color: var(--err);     background: rgba(240, 100, 100, 0.10); border-color: rgba(240, 100, 100, 0.35); }
.badge--unknown { color: var(--unknown); background: rgba(107, 113, 128, 0.12); border-color: rgba(107, 113, 128, 0.40); }
.badge--public  { color: var(--accent);  background: rgba(110, 168, 254, 0.10); border-color: rgba(110, 168, 254, 0.35); }
.badge--private { color: var(--text-dim); background: rgba(154, 163, 178, 0.10); border-color: rgba(154, 163, 178, 0.30); }

/* ---------- Freshness pill (topbar) ---------- */

.freshness {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-dim);
    background: rgba(110, 168, 254, 0.08);
    border: 1px solid rgba(110, 168, 254, 0.30);
}
.freshness::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.6);
    animation: freshness-pulse 2s infinite;
}
.freshness.is-stale {
    color: var(--warn);
    background: rgba(245, 165, 36, 0.10);
    border-color: rgba(245, 165, 36, 0.40);
}
.freshness.is-stale::before { background: var(--warn); animation: none; }

@keyframes freshness-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0.50); }
    70%  { box-shadow: 0 0 0 6px rgba(47, 191, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(47, 191, 113, 0); }
}

/* ---------- Clickable rows + chevron + detail rows ---------- */

table.fleet .cell-toggle {
    width: 22px;
    padding-left: 14px;
    padding-right: 0;
    color: var(--text-dim);
    user-select: none;
}
.row-host {
    cursor: pointer;
    transition: background 0.08s ease-in-out;
}
.row-host:focus { outline: none; }
.row-host:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.row-host .chevron {
    display: inline-block;
    transition: transform 0.12s ease-in-out;
    font-size: 14px;
    line-height: 1;
}
.row-host.is-open .chevron { transform: rotate(90deg); }

.row-detail > td {
    padding: 12px 18px 18px;
    background: var(--bg);
    border-top: none;
}
.row-detail[hidden] { display: none; }

.detail-error {
    background: rgba(240, 100, 100, 0.08);
    border: 1px solid rgba(240, 100, 100, 0.35);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 10px;
}
.detail-error code {
    display: block;
    margin-top: 4px;
    color: var(--err);
    font-family: var(--font-mono);
    font-size: 12px;
    word-break: break-all;
}
.detail-empty {
    padding: 6px 4px;
    font-size: 13px;
}

/* ---------- Sub-table: per-container detail ---------- */

table.containers {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
table.containers th, table.containers td {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
table.containers thead th {
    background: var(--bg-elev-2);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
    font-weight: 600;
}
table.containers tbody tr:last-child td { border-bottom: none; }
table.containers .cell-status-text {
    color: var(--text-dim);
}

/* ---------- Summary cell ---------- */

.cell-summary { white-space: nowrap; }
.cell-probe   { font-size: 11px; margin-left: 6px; }

/* ---------- Footnote ---------- */

.footnote {
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
}
.footnote code {
    font-family: var(--font-mono);
    background: var(--bg-elev);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
}

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

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
}
.login-card h1 {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.01em;
}
.login-card p { margin: 0 0 18px; }
.login-card label {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
    margin: 12px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 9px 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
}
.login-card input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(110, 168, 254, 0.15);
}
.login-card button {
    margin-top: 18px;
    width: 100%;
    padding: 10px 14px;
    background: var(--accent-strong);
    border: 1px solid var(--accent-strong);
    color: #0b1220;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
}
.login-card button:hover { background: var(--accent); border-color: var(--accent); }

.alert {
    padding: 9px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 6px;
}
.alert--error {
    color: var(--err);
    background: rgba(240, 100, 100, 0.08);
    border: 1px solid rgba(240, 100, 100, 0.35);
}
