/* ============================================================
   TrackAnAgent — design tokens
   Palette anchored in radar/traffic-control tones, not generic
   SaaS blue. Same tokens power light and dark mode; only the
   surface/ink pair flips.
   ============================================================ */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    --paper: #F6F5F1;
    --ink: #14181F;
    --slate: #3D4552;
    --slate-light: #6B7280;
    --border-color: #D8D5CB;

    --signal-blue: #2B6CB0;
    --signal-blue-light: #E8F0F9;

    --go: #3D8F5B;
    --go-light: #E5F3EA;
    --caution: #C98A2E;
    --caution-light: #FBF0DF;
    --stop: #B4453A;
    --stop-light: #FBEAE8;
    --neutral-status: #6B7280;
    --neutral-status-light: #EEEEEC;

    --bg-page: var(--paper);
    --bg-surface: #FFFFFF;
    --bg-sidebar: #EDEBE3;
    --text-primary: var(--ink);
    --text-secondary: var(--slate);
    --text-muted: var(--slate-light);
    --border: var(--border-color);

    --radius: 8px;
    --radius-card: 12px;
}

[data-theme="dark"] {
    --bg-page: #14181F;
    --bg-surface: #1C212B;
    --bg-sidebar: #10141B;
    --text-primary: #EDEEF0;
    --text-secondary: #A7AFBC;
    --text-muted: #6E7684;
    --border: #2B313C;

    --signal-blue-light: #1C2C3C;
    --go-light: #17281E;
    --caution-light: #2E2312;
    --stop-light: #2E1815;
    --neutral-status-light: #23262C;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--signal-blue);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.mono {
    font-family: var(--font-mono);
}

/* ---------------- Layout shell ---------------- */

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

.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-brand {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    padding: 0 0.5rem 1.25rem;
    color: var(--text-primary);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 13px;
    letter-spacing: 0.03em;
    text-decoration: none;
}

.sidebar-link:hover {
    background: var(--bg-surface);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--signal-blue-light);
    color: var(--signal-blue);
    font-weight: 600;
}

.sidebar-link .badge-count {
    margin-left: auto;
    background: var(--stop);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    padding: 1px 6px;
    font-family: var(--font-mono);
}

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 56px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding: 0 1.5rem;
    background: var(--bg-surface);
}

.topbar-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
}

.topbar-icon-btn:hover {
    background: var(--bg-page);
}

.page-body {
    padding: 1.5rem;
    flex: 1;
}

/* ---------------- Cards & tables ---------------- */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1rem 1.25rem;
}

.metric-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 1rem;
}

.metric-card .metric-label {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.metric-card .metric-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
}

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

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table th {
    text-align: left;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

table.data-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tr:hover td {
    background: var(--bg-page);
}

.ref {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

/* ---------------- Status badges: dot + plate, not solid fill ---------------- */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 3px 9px 3px 7px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-surface);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.go { background: var(--go); }
.status-dot.caution { background: var(--caution); }
.status-dot.stop { background: var(--stop); }
.status-dot.neutral { background: var(--neutral-status); }

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

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

input, select, textarea {
    width: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
    color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--signal-blue);
    outline-offset: 1px;
}

.field-group {
    margin-bottom: 1rem;
}

.field-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.field-row > .field-group {
    flex: 1;
    min-width: 160px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-primary);
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-page);
    text-decoration: none;
}

.btn-primary {
    background: var(--signal-blue);
    border-color: var(--signal-blue);
    color: #fff;
}

.btn-primary:hover {
    background: #24568E;
}

.btn-danger {
    color: var(--stop);
    border-color: var(--stop);
}

.btn-danger:hover {
    background: var(--stop-light);
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 1rem;
    border: 1px solid;
}

.alert-danger {
    background: var(--stop-light);
    border-color: var(--stop);
    color: var(--stop);
}

.alert-success {
    background: var(--go-light);
    border-color: var(--go);
    color: var(--go);
}

.alert-info {
    background: var(--signal-blue-light);
    border-color: var(--signal-blue);
    color: var(--signal-blue);
}

/* ---------------- Utility ---------------- */

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
