:root {
    --bg: #1a1a2e;
    --bg-card: #16213e;
    --bg-input: #0f3460;
    --text: #e0e0e0;
    --text-muted: #8a8a9a;
    --accent: #e94560;
    --accent-hover: #ff6b81;
    --success: #4ecca3;
    --warning: #f0c040;
    --danger: #e94560;
    --border: #2a2a4a;
    --radius: 6px;
}

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

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

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

/* Navigation */
nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
nav .brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
nav .links { display: flex; gap: 1rem; flex: 1; }
nav .links a { color: var(--text-muted); font-size: 0.9rem; display: flex; align-items: center; gap: 0.35rem; text-decoration: none; }
nav .links a:hover, nav .links a.active { color: var(--text); text-decoration: none; }
nav .user-info { font-size: 0.85rem; color: var(--text-muted); }

/* Layout */
main { max-width: 960px; margin: 2rem auto; padding: 0 1.5rem; }

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid rgba(42,42,74,0.6); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
tr:hover { background: rgba(255,255,255,0.05); }

/* Forms — scoped to .card to avoid breaking inline table forms */
.card > form, .auth-card form {
    display: flex; flex-direction: column; gap: 0.75rem; max-width: 400px;
}
label { font-size: 0.85rem; color: var(--text-muted); }
input, select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.85rem;
    cursor: pointer;
    color: white;
    background: var(--accent);
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-success { background: var(--success); color: #0d1117; }
.btn-warning { background: var(--warning); color: #0d1117; }
.btn-danger { background: var(--danger); }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--text); color: var(--text); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: rgba(78,204,163,0.15); color: var(--success); border: 1px solid rgba(78,204,163,0.3); }
.badge-warning { background: rgba(240,192,64,0.15); color: var(--warning); border: 1px solid rgba(240,192,64,0.3); }
.badge-danger { background: rgba(233,69,96,0.15); color: var(--danger); border: 1px solid rgba(233,69,96,0.3); }
.badge-muted { background: rgba(42,42,74,0.4); color: var(--text-muted); border: 1px solid rgba(42,42,74,0.6); }

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: rgba(233,69,96,0.15); border: 1px solid var(--danger); color: var(--danger); }
.alert-success { background: rgba(78,204,163,0.15); border: 1px solid var(--success); color: var(--success); }
.alert-warning { background: rgba(240,192,64,0.15); border: 1px solid var(--warning); color: var(--warning); }
.alert-info { background: rgba(100,149,237,0.15); border: 1px solid var(--accent); color: var(--accent); }

/* Status indicators */
.status-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
}
.status-dot.up { background: var(--success); }
.status-dot.down { background: var(--danger); }
.status-dot.glow { box-shadow: 0 0 6px rgba(78,204,163,0.5); }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
h1 { font-size: 1.4rem; margin-bottom: 1.25rem; padding-bottom: 0.5rem; }
.flex-between h1 { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
main > h1 { border-bottom: 1px solid var(--border); }

/* Stat cards (dashboard, status) */
.stat-card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-left: 3px solid var(--border);
    padding: 1rem 1.25rem;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.stat-card:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 0.15rem; }
.stat-detail { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Hero card (status page) */
.hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hero-card.up { background: rgba(78,204,163,0.06); border-color: rgba(78,204,163,0.3); }
.hero-card.down { background: rgba(233,69,96,0.06); border-color: rgba(233,69,96,0.3); }
.hero-status { font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 0.5rem; }
.hero-meta { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* Status grid (2-column) */
.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Empty states */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}
.empty-state .icon { margin-bottom: 0.5rem; }

/* Toast notifications */
.toast {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    animation: toast-in 0.3s ease, toast-out 0.3s ease 3s forwards;
}
.toast-success { background: rgba(78,204,163,0.15); border: 1px solid rgba(78,204,163,0.3); color: var(--success); }
.toast-error { background: rgba(233,69,96,0.15); border: 1px solid rgba(233,69,96,0.3); color: var(--danger); }
.toast-warning { background: rgba(240,192,64,0.15); border: 1px solid rgba(240,192,64,0.3); color: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; height: 0; margin: 0; padding: 0; overflow: hidden; } }

/* Auth page centering */
.auth-center { max-width: 400px; margin: 4rem auto; }

/* Inline SVG icon sizing */
.icon { display: inline-block; width: 16px; height: 16px; vertical-align: middle; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }

/* Table footer row */
.tfoot-row td {
    border-top: 1px solid var(--border);
    font-style: italic;
}

/* HTMX loading indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; }
.htmx-request .btn { pointer-events: none; opacity: 0.6; }

/* Loading pulse */
@keyframes pulse { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
.loading-pulse { animation: pulse 1.5s ease-in-out infinite; }

/* Log viewer */
.log-tab-bar { display: flex; gap: 0.25rem; margin-bottom: 1rem; }
.tab-btn { padding: 0.5rem 1rem; border: 1px solid var(--border); background: transparent; cursor: pointer; border-radius: 4px 4px 0 0; color: var(--text-muted); }
.tab-btn.active { background: var(--bg-card); border-bottom-color: var(--bg-card); color: var(--text); }

.log-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 0.5rem; }
.log-controls-left, .log-controls-right { display: flex; align-items: center; gap: 0.25rem; }
.log-search { padding: 0.25rem 0.5rem; border: 1px solid var(--border); background: var(--bg); border-radius: 4px; font-size: 0.85rem; color: var(--text); }

.log-filter-group { display: flex; gap: 2px; }
.log-level-btn { padding: 0.2rem 0.5rem; border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: 0.75rem; border-radius: 3px; color: var(--text-muted); }
.log-level-btn.active { background: var(--bg-card); font-weight: bold; color: var(--text); }

.log-container { font-family: monospace; font-size: 0.85rem; max-height: 70vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem; background: var(--bg); }
.log-entry { white-space: pre-wrap; word-break: break-all; padding: 1px 0; }
.log-ts { color: var(--text-muted); }
.log-level { font-weight: bold; min-width: 5ch; display: inline-block; }
.log-target { color: var(--text-muted); }
.log-fields { color: var(--text-muted); font-size: 0.8em; }
.log-error { color: #e74c3c; }
.log-warn { color: #f39c12; }
.log-debug, .log-trace { color: var(--text-muted); }

/* Admin panel */
.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.tab-bar .tab { padding: 0.5rem 1.25rem; background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; cursor: pointer; color: var(--text-muted); font-size: 0.95rem; }
.tab-bar .tab.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.tab-bar .tab:hover { color: var(--text); }

.profile-card { line-height: 1.5; }
.action-buttons { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.reset-link-display { display: flex; gap: 0.25rem; align-items: center; }
.reset-link-display input { font-family: monospace; font-size: 0.85rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-weight: 500; }
.form-group input { width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); }

.current-user td { opacity: 0.7; }

@keyframes highlight { from { background: var(--warning-bg, rgba(255,193,7,0.2)); } to { background: transparent; } }
.highlight-flash { animation: highlight 2s ease-out; }

.badge-info { background: var(--info, #17a2b8); color: #fff; }

/* Mod requests */
.request-card { position: relative; }
.request-card .vote-buttons .btn-sm { min-width: 2rem; justify-content: center; }
.vote-score { font-size: 1.1rem; }

.search-card { transition: border-color 0.15s; }
.search-card:hover { border-color: var(--accent); }
.search-card.selected { border-color: var(--accent); }

.status-filter { display: flex; gap: 0.25rem; }
.status-filter .btn.active { border-color: var(--accent); color: var(--text); }

.resolve-form input[type="text"] {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
}
