:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d37;
    --text: #e4e4e7;
    --text-muted: #71717a;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --positive: #22c55e;
    --negative: #ef4444;
    --warning: #eab308;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
}

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

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

/* ── Nav ── */
nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 56px;
}

nav .brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text);
    text-decoration: none;
}

nav .nav-links {
    display: flex;
    gap: 0;
    list-style: none;
}

nav .nav-links a {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
}

nav .nav-links a:hover,
nav .nav-links a.active {
    color: var(--text);
    background: var(--border);
}

nav .nav-spacer {
    flex: 1;
}

nav .nav-right a {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Layout ── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* ── Card ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
}

.card-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* ── Stats grid ── */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 768px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

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

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ── Table ── */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

/* ── Utility classes ── */
.positive { color: var(--positive); }
.negative { color: var(--negative); }
.warning  { color: var(--warning); }
.muted    { color: var(--text-muted); }

.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 0.9em; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 0.15em 0.55em;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-ok      { background: rgba(34,197,94,0.15); color: var(--positive); }
.badge-warn    { background: rgba(234,179,8,0.15);  color: var(--warning); }
.badge-err     { background: rgba(239,68,68,0.15);  color: var(--negative); }
.badge-neutral { background: var(--border); color: var(--text-muted); }

/* ── Login box ── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-box .subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
}

/* ── Forms ── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.55rem 0.75rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    width: 100%;
}

.btn-primary:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover { background: #3a3d4a; }

.btn-danger {
    background: rgba(239,68,68,0.15);
    color: var(--negative);
}

.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm {
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
}

/* ── Alert messages ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: var(--negative); }
.alert-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: var(--positive); }
.alert-warning { background: rgba(234,179,8,0.1);  border: 1px solid rgba(234,179,8,0.3);  color: var(--warning); }

/* ── Advisory box ── */
.advisory-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    white-space: pre-wrap;
    font-size: 0.875rem;
    line-height: 1.7;
    max-height: 300px;
    overflow-y: auto;
}

/* ── Section spacing ── */
.section {
    margin-bottom: 2rem;
}

/* ── HTMX loading indicator ── */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}
.htmx-request .htmx-indicator {
    opacity: 1;
}

/* ── Posture checks ── */
.posture-list {
    list-style: none;
}

.posture-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.posture-item:last-child { border-bottom: none; }

.posture-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.1rem;
}

.posture-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.posture-detail {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* ── Responsive utilities ── */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
