:root {
    --ink-950: #021820;
    --ink-900: #04222E;
    --ink-850: #062B39;
    --ink-800: #0A3646;
    --brand: #004158;
    --accent: #1C93B0;
    --accent-2: #7FC4D2;
    --teal-500: #12809B;
    --teal-600: #0A6076;
    --fg: #E7EEEF;
    --muted: #A9C0C4;
    --border: rgba(127, 196, 210, 0.16);
    --surface: #0A3646;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow-md: 0 8px 24px rgba(2, 24, 32, 0.35);
    --shadow-accent: 0 12px 34px rgba(0, 65, 88, 0.4);
    --font-body: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--ink-950);
    background-image: radial-gradient(circle at 15% 0%, rgba(28, 147, 176, 0.12), transparent 45%);
    color: var(--fg);
}
a { color: var(--accent-2); }
h1, h2 { font-family: var(--font-body); font-weight: 700; color: #fff; margin: 0 0 16px; }
.text-accent { color: var(--accent-2); }

/* One consistent gap between every top-level block on a page (dashboard
   cards, page header, action row, each server-detail section) — so
   spacing never has to be re-tuned per element as sections get added. */
.content > * + * { margin-top: 28px; }
.page-section > * + * { margin-top: 20px; }

.topnav {
    display: flex;
    align-items: center;
    padding: 16px 28px;
    background: rgba(4, 34, 46, 0.85);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}
.topnav .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { height: 28px; width: auto; display: block; }
.brand-sub { font-size: 12px; color: var(--muted); text-transform: lowercase; }
.topnav .spacer { flex: 1; }
.topnav .username { margin-right: 14px; color: var(--muted); font-size: 14px; }
.nav-link { margin-right: 14px; color: var(--muted); font-size: 14px; text-decoration: none; }
.nav-link:hover { color: var(--accent-2); }

.content { padding: 32px; max-width: 1180px; margin: 0 auto; }

.eyebrow {
    display: inline-block; color: var(--accent-2); font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em; margin: 0 0 6px;
}
h1 { font-size: 32px; margin-bottom: 6px; }
.meta { color: var(--muted); font-size: 14px; }

.inline-form { display: inline; }
.link-button {
    background: none; border: none; color: var(--accent-2); cursor: pointer; padding: 0; font: inherit;
}

button, .btn-ghost, .btn-accent {
    padding: 9px 18px; border-radius: 10px; cursor: pointer; font-weight: 600;
    font-family: var(--font-body); text-decoration: none; display: inline-block; border: none; font-size: 14px;
}
button, .btn-accent {
    background: var(--accent); color: #fff; box-shadow: var(--shadow-accent);
}
button:hover, .btn-accent:hover { background: var(--teal-500); }
.btn-ghost {
    background: transparent; color: var(--accent-2); border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent-2); }
.btn-danger { background: #ef5a6f; color: var(--ink-950); box-shadow: none; }
.btn-danger:hover { background: #ff7a8c; }

.copyable {
    cursor: pointer; border-bottom: 1px dashed var(--muted); transition: color 0.15s;
}
.copyable:hover { color: var(--accent-2); }
.copyable.copied { color: #35d08a; border-bottom-color: #35d08a; }

.login-box {
    max-width: 340px; margin: 80px auto; padding: 28px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.login-box label { display: block; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
.login-box input {
    display: block; width: 100%; margin-top: 6px; padding: 10px 12px;
    background: var(--ink-900); border: 1px solid var(--border); color: var(--fg); border-radius: var(--radius-sm);
    font-family: var(--font-body);
}
.error { color: #ff9d9d; }

.server-card-list { display: flex; flex-direction: column; gap: 18px; }
.server-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow-md);
}
.server-card[draggable="true"] { cursor: grab; }
.server-card.dragging { opacity: 0.5; cursor: grabbing; }
.drag-handle { color: var(--muted); margin-right: 6px; cursor: grab; letter-spacing: -2px; }
.server-card-header { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.server-card-title { font-size: 20px; font-weight: 700; color: #fff; text-decoration: none; }
.server-card-title:hover { color: var(--accent-2); }
.server-card-host { color: var(--muted); font-size: 13px; margin-left: 10px; }
.server-card-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.last-checked { color: var(--muted); font-size: 13px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile-grid-wide { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.tile {
    background: var(--ink-900); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.tile-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.tile-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.tile-summary { font-size: 13px; color: var(--fg); }
.tile-time { font-size: 11px; color: var(--muted); margin-top: 8px; }
.tile-wide { grid-column: span 2; }

.sparkline { display: flex; align-items: flex-end; gap: 2px; height: 36px; margin-top: 10px; }
.sparkline-bar { flex: 1; background: var(--accent-2); border-radius: 2px 2px 0 0; min-height: 2px; }

.stat-block { display: flex; flex-direction: column; gap: 4px; }
.stat-block-label { font-size: 12px; color: var(--muted); }
.stat-block-value { font-family: var(--font-body); font-weight: 800; font-size: 34px; line-height: 1.1; color: #35d08a; }
.stat-block-value.stat-warning { color: #f0b93d; }
.stat-block-value.stat-error { color: #ef5a6f; }
.stat-block-value.stat-none { color: var(--muted); }
.stat-block-sub { font-size: 12px; color: var(--muted); }

.gauge-load { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.gauge-section-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--accent-2); margin: 12px 0 6px;
}
.gauge-section-label:first-of-type { margin-top: 0; }
.gauge { margin-bottom: 10px; }
.gauge:last-child { margin-bottom: 0; }
.gauge-top { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg); margin-bottom: 4px; }
.gauge-track {
    height: 6px; border-radius: 3px; background: rgba(169, 192, 196, 0.15); overflow: hidden;
}
.gauge-fill { height: 100%; border-radius: 3px; background: #35d08a; transition: width 0.3s var(--ease, ease); }
.gauge-fill.gauge-mid { background: #f0b93d; }
.gauge-fill.gauge-warn { background: #ef5a6f; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot-ok { background: #35d08a; box-shadow: 0 0 8px rgba(53, 208, 138, 0.6); }
.dot-warning { background: #f0b93d; box-shadow: 0 0 8px rgba(240, 185, 61, 0.6); }
.dot-error, .dot-unreachable { background: #ef5a6f; box-shadow: 0 0 8px rgba(239, 90, 111, 0.6); }
.dot-none { background: var(--muted); }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.badge-ok { background: rgba(53, 208, 138, 0.16); color: #35d08a; }
.badge-warning { background: rgba(240, 185, 61, 0.16); color: #f0b93d; }
.badge-error { background: rgba(239, 90, 111, 0.16); color: #ef5a6f; }
.badge-none { background: rgba(169, 192, 196, 0.16); color: var(--muted); }

.console-overlay {
    position: fixed; inset: 0; background: rgba(2, 24, 32, 0.75); backdrop-filter: blur(2px);
    align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
/* [hidden] is an author-vs-UA specificity tie with .console-overlay alone —
   without this compound selector, our own display:flex below would win over
   the browser's built-in "[hidden] { display: none }" and the overlay would
   show up immediately on page load instead of only after JS un-hides it. */
.console-overlay:not([hidden]) { display: flex; }
.console-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-md); width: min(760px, 100%); max-height: 80vh; display: flex; flex-direction: column;
}
.console-header {
    display: flex; align-items: center; justify-content: space-between; padding: 14px 18px;
    border-bottom: 1px solid var(--border); font-weight: 600; color: #fff;
}
.console-output {
    flex: 1; margin: 0; padding: 14px 18px; overflow-y: auto; font-family: "Courier New", monospace;
    font-size: 12px; line-height: 1.5; color: var(--fg); white-space: pre-wrap; word-break: break-word;
}
.console-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

.plain-list { padding-left: 20px; color: var(--fg); }

.danger-zone {
    background: rgba(239, 90, 111, 0.06); border: 1px solid rgba(239, 90, 111, 0.35);
    border-radius: var(--radius); padding: 20px;
}
.danger-zone-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.danger-zone-title { font-weight: 600; color: #fff; }

.settings-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; max-width: 520px;
}
.settings-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.settings-card-title { font-weight: 600; color: #fff; }
.settings-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.settings-form input {
    flex: 1; min-width: 120px; padding: 9px 12px; background: var(--ink-900); border: 1px solid var(--border);
    color: var(--fg); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 14px;
}
select {
    padding: 9px 12px; background: var(--ink-900); border: 1px solid var(--border);
    color: var(--fg); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 14px;
}
.checkbox-label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--fg); white-space: nowrap; }
.checkbox-label input { flex: none; width: auto; }

/* A real on/off switch instead of a browser checkbox that all but
   disappears against the dark background — the track/thumb makes the
   current state and the clickable area obvious at a glance. */
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-track {
    width: 42px; height: 24px; background: var(--ink-900); border: 1px solid var(--border);
    border-radius: 999px; transition: background 0.15s, border-color 0.15s; flex-shrink: 0;
}
.toggle-thumb {
    display: block; width: 16px; height: 16px; margin: 3px; background: var(--muted);
    border-radius: 50%; transition: transform 0.15s, background 0.15s;
}
.toggle input:checked ~ .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked ~ .toggle-track .toggle-thumb { transform: translateX(18px); background: #fff; }
.toggle input:focus-visible ~ .toggle-track { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* A row pairing a title+description with a toggle on the right — the
   settings-list pattern used for per-user notification preferences. */
.option-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-top: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.option-title { font-weight: 600; color: #fff; font-size: 14px; }
.option-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* A labeled grid form — each field gets its own caption above it, instead
   of a flat row of same-looking, unlabeled inputs where it's unclear what
   each box is for or where the actual "on/off" control even is. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-top: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.form-field input, .form-field select {
    width: 100%; padding: 9px 12px; background: var(--ink-900); border: 1px solid var(--border);
    color: var(--fg); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 14px;
}
.form-field-toggle { display: flex; align-items: center; gap: 10px; }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; margin-top: 2px; }

.test-mail-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.test-mail-row input { flex: 1; min-width: 200px; }
.test-mail-status { font-size: 13px; color: var(--muted); }
.test-mail-status.test-mail-ok { color: #35d08a; }
.test-mail-status.test-mail-error { color: #ff9d9d; }

.actions-row { display: flex; gap: 10px; margin: 16px 0; }
.fleet-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.fleet-table th, .fleet-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.fleet-table th { color: var(--muted); font-weight: 500; font-size: 13px; }

.agent-layout { display: flex; gap: 20px; height: calc(100vh - 160px); }
.agent-sidebar { width: 220px; flex-shrink: 0; }
.agent-sidebar form button { width: 100%; margin-bottom: 12px; }
.conversation-list { list-style: none; padding: 0; margin: 0; }
.conversation-list li { margin-bottom: 4px; }
.conversation-list li a {
    display: block; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none;
    color: var(--fg); font-size: 14px;
}
.conversation-list li.active a { background: var(--ink-900); color: var(--accent-2); }

.agent-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-log {
    flex: 1; overflow-y: auto; padding: 16px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
}
.bubble {
    max-width: 80%; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 10px; white-space: pre-wrap;
}
.bubble-user { background: var(--ink-900); margin-left: auto; }
.bubble-assistant { background: rgba(28, 147, 176, 0.14); border: 1px solid var(--border); }
.bubble-error { background: rgba(239, 90, 111, 0.14); color: #ff9d9d; border: 1px solid rgba(239, 90, 111, 0.3); }

.tool-card {
    background: var(--ink-900); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 14px; margin-bottom: 10px;
}
.tool-card-command code {
    display: block; padding: 8px 10px; background: var(--ink-950); border-radius: 8px; font-size: 13px; overflow-x: auto;
}
.tool-card-purpose { font-size: 13px; color: var(--muted); margin-top: 6px; }
.tool-card-actions { margin-top: 10px; display: flex; gap: 8px; }
.tool-card-actions .approve-btn { background: #35d08a; color: var(--ink-950); box-shadow: none; }
.tool-card-actions .deny-btn { background: #ef5a6f; color: var(--ink-950); box-shadow: none; }
.tool-card-status {
    display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.status-executed_ok { background: rgba(53, 208, 138, 0.16); color: #35d08a; }
.status-executed_failed { background: rgba(239, 90, 111, 0.16); color: #ef5a6f; }
.status-denied { background: rgba(169, 192, 196, 0.16); color: var(--muted); }
.tool-card-output {
    margin-top: 8px; padding: 10px; background: var(--ink-950); border-radius: 8px; font-size: 12px;
    max-height: 200px; overflow: auto; white-space: pre-wrap;
}

.message-form {
    display: flex; gap: 10px; padding: 14px; background: var(--surface);
    border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
}
.message-form textarea {
    flex: 1; resize: vertical; min-height: 44px; padding: 10px 12px; background: var(--ink-900);
    border: 1px solid var(--border); color: var(--fg); border-radius: var(--radius-sm); font: inherit;
}
