/* Admin-only overrides. The public site is light-by-default with a
 * dark theme toggle; the admin is a tool, so it stays dark always.
 * We scope via `body.admin` so the admin's palette is independent of
 * whatever the public site's theme is set to.
 */
body.admin {
    --bg:        #0a0a0a;
    --bg-2:      #18181b;
    --bg-3:      #1c1c20;
    --surface:   #18181b;
    --surface-2: #232328;
    --line:      #27272a;
    --line-soft: rgba(255, 255, 255, 0.06);
    --text:      #fafafa;
    --text-soft: #d4d4d8;
    --muted:     #a1a1aa;
    --footer-bg: #050229;

    background: var(--bg); color: var(--text);
}
body.admin .nav { background: rgba(10, 10, 10, 0.92); border-bottom: 1px solid var(--line); }
body.admin .nav-cta, body.admin .theme-toggle { display: none; }  /* No CTA inside admin */

.admin-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 70px);
}
.admin-side {
    background: var(--bg-2);
    border-right: 1px solid var(--line);
    padding: 22px 0;
    position: sticky; top: 70px;
    height: calc(100vh - 70px);
    overflow-y: auto;
}
.admin-side h6 {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.14em;
    color: var(--muted); margin: 22px 22px 6px; font-weight: 700;
}
.admin-side a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 22px; color: var(--text-soft);
    font-size: 14px; text-decoration: none;
    border-left: 3px solid transparent;
}
.admin-side a:hover { background: var(--surface-2); color: var(--text); }
.admin-side a.active {
    background: var(--surface-2);
    color: var(--accent);
    border-left-color: var(--accent);
}
.admin-side a .ico { width: 16px; opacity: .8; }
.admin-side a.sub { padding-left: 50px; font-size: 13px; }

.admin-main {
    padding: 36px 40px;
    max-width: 100%; overflow-x: auto;
}
.admin-main h1 { font-size: 28px; margin-bottom: 6px; color: var(--text); }
.admin-main h2, .admin-main h3 { color: var(--text); }
.admin-main .subtitle { color: var(--muted); margin-bottom: 28px; }
.admin-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}

@media (max-width: 720px) {
    .admin-shell { grid-template-columns: 1fr; }
    .admin-side { position: static; height: auto; padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .admin-main { padding: 24px 18px; }
}

/* Stat cards */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px; margin-bottom: 28px;
}
.kpi {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; padding: 18px;
}
.kpi .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.kpi .val { font-size: 30px; font-weight: 800; color: var(--accent); margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .val small { font-size: 14px; color: var(--text-soft); font-weight: 500; margin-left: 6px; }

/* Tables */
.adm-table {
    width: 100%; border-collapse: collapse;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 12px; overflow: hidden;
}
.adm-table th, .adm-table td {
    padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line);
    font-size: 14px; color: var(--text-soft);
}
.adm-table td { color: var(--text); }
.adm-table th {
    font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--muted);
    background: var(--surface-2);
}
.adm-table tr:last-child td { border-bottom: 0; }
.adm-table td.right { text-align: right; }
.adm-table td.mono { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.adm-table .pid { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.adm-table button { background: var(--red); color: white; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.adm-table button:hover { background: #ff7872; }

/* Event log */
.evlog {
    background: #0a1812; border: 1px solid var(--line); border-radius: 10px;
    padding: 12px; max-height: 480px; overflow-y: auto;
    font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
}
.evlog .row { padding: 1px 4px; color: var(--text-soft); }
.evlog .ts { color: var(--gold-deep); margin-right: 8px; }
.evlog .row.peer { color: #b3c89c; }
.evlog .row.created { color: var(--gold); }
.evlog .row.expired { color: var(--muted); }
.evlog .row.config { color: #9cb6c8; }
.evlog .row.coin { color: var(--accent); }

/* Login screen */
.admin-login {
    max-width: 400px; margin: 80px auto;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: 16px; padding: 40px;
}
.admin-login h1 { font-size: 24px; margin-bottom: 6px; color: var(--text); }
.admin-login p { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.admin-login button { width: 100%; }

/* Markdown editor */
.md-editor textarea {
    min-height: 420px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55;
}
.md-meta-row { display: grid; grid-template-columns: 1fr 180px; gap: 14px; }
@media (max-width: 600px) { .md-meta-row { grid-template-columns: 1fr; } }

.danger-zone {
    border: 1px solid var(--red); border-radius: 12px;
    padding: 22px; margin-top: 30px;
}
.danger-zone h3 { color: var(--red); margin: 0 0 6px; font-size: 16px; }
.danger-zone p { color: var(--text-soft); font-size: 13px; margin: 0 0 12px; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #ff7872; color: white; }

.flash-ok  { background: rgba(34, 212, 123, 0.12); border: 1px solid rgba(34, 212, 123, 0.4); color: var(--green);
             padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }
.flash-err { background: rgba(255, 91, 91, 0.12); border: 1px solid rgba(255, 91, 91, 0.4); color: var(--red);
             padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; }

.repeater-row label { color: var(--muted); }
