:root {
    --bg: #0f1420;
    --bg-soft: #161d2e;
    --card: #1b2334;
    --border: #2a354c;
    --text: #e7ecf5;
    --muted: #93a0b8;
    --primary: #3b82f6;
    --primary-600: #2563eb;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }

.container { width: 100%; max-width: 1100px; margin: 0 auto; padding: 0 1rem; }

/* ---------- Topbar ---------- */
.topbar {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 1rem; height: 60px; }
.brand { font-weight: 700; color: #0f1420; display: inline-flex; align-items: center; gap: .5rem; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px rgba(59,130,246,.2); }
.brand-center { display: flex; justify-content: center; font-size: 1.15rem; background: #f8fafc; padding: .55rem 1.1rem; border-radius: 14px; width: fit-content; margin: 0 auto; }
.nav { display: flex; gap: 1rem; margin-left: 1.5rem; flex: 1; }
.nav a { color: #475569; font-weight: 500; }
.nav a:hover { color: #0f1420; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: .75rem; font-size: .9rem; color: #475569; }
.userbox form { margin: 0; }
.userbox .btn-ghost { color: #0f1420; border-color: #cbd5e1; }
.userbox .btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.main { padding: 1.5rem 1rem 3rem; }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding: 1rem 0; text-align: center; }

/* ---------- Auth ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card {
    width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin: 1rem 0 .25rem; }
.auth-card .muted { text-align: center; margin-top: 0; }
.auth-foot { text-align: center; margin: 1rem 0 0; color: var(--muted); font-size: .9rem; }
.center { text-align: center; }

/* ---------- Cards / layout ---------- */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; }
.stat-num { font-size: 1.5rem; font-weight: 700; }
.stat-lbl { color: var(--muted); font-size: .85rem; }
.stat-ok .stat-num { color: var(--ok); }
.stat-warn .stat-num { color: var(--warn); }
.stat-danger .stat-num { color: var(--danger); }

/* ---------- Forms ---------- */
label { display: block; margin-bottom: .9rem; font-size: .9rem; color: var(--text); font-weight: 500; }
input, select, textarea {
    width: 100%; margin-top: .3rem; padding: .6rem .7rem; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text);
    font: inherit; font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(59,130,246,.4); border-color: var(--primary); }
textarea { resize: vertical; }
.mono, textarea.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .82rem; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; padding: 0 .4rem; }
.form-actions { display: flex; gap: .75rem; margin-top: .5rem; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    padding: .6rem 1rem; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; cursor: pointer; background: var(--bg-soft); color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary-600); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-whats { background: #25d366; color: #07300f; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
.table td { padding: .6rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table-sm td, .table-sm th { padding: .4rem .5rem; }
.table tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--bg-soft); color: var(--muted); }
.badge.ok { background: rgba(34,197,94,.15); color: var(--ok); }
.badge.warn { background: rgba(245,158,11,.15); color: var(--warn); }
.badge.danger { background: rgba(239,68,68,.15); color: var(--danger); }
.badge.muted { background: rgba(148,163,184,.15); color: var(--muted); }

.alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.alert-success { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.35); color: #86efac; }
.alert-error { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #fca5a5; }
.alert-info { background: rgba(59,130,246,.12); border-color: rgba(59,130,246,.35); color: #93c5fd; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.dl { display: grid; grid-template-columns: 130px 1fr; gap: .35rem 1rem; margin: 0; font-size: .9rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; }
.filters { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.filters input[type=text] { flex: 1; min-width: 220px; margin: 0; }
.filters select { width: auto; margin: 0; }
.code-block { display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; word-break: break-all; }
code { background: var(--bg); padding: .1rem .35rem; border-radius: 5px; font-size: .85em; }
