:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --ink: #16202a;
    --muted: #667085;
    --line: #d7dde5;
    --primary: #1769aa;
    --primary-dark: #0f4f82;
    --ok: #147a4d;
    --danger: #b42318;
    --warn: #9a6700;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: #101820;
    color: #fff;
    border-bottom: 1px solid #26323d;
}
.header-inner {
    max-width: 1480px;
    margin: 0 auto;
    padding: 14px 24px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 22px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
}
.brand:hover { color: #fff; }
.brand small, .account small { display: block; color: #a7b0ba; }
.mark {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: #2f80ed;
    font-weight: 800;
}
.top-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: thin;
}
.top-nav a {
    color: #dce4ec;
    padding: 9px 12px;
    border-radius: 8px;
    font-weight: 650;
    white-space: nowrap;
}
.top-nav a:hover, .top-nav a.active { background: #1e2b36; color: #fff; }
.account {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}
.account img { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; }
.ghost { color: #dce4ec; font-size: 14px; }
.main {
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px;
}
.topbar {
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
h2 { margin: 0 0 14px; font-size: 19px; letter-spacing: 0; }
h3 { margin: 0 0 10px; font-size: 16px; letter-spacing: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
}
.stat strong { display: block; font-size: 28px; }
.stat small { color: var(--muted); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline-flex; gap: 8px; align-items: center; }
label { display: grid; gap: 6px; font-weight: 650; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 11px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}
textarea { min-height: 120px; resize: vertical; }
button, .button {
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    padding: 10px 13px;
    font: inherit;
    font-weight: 750;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}
button:hover, .button:hover { background: var(--primary-dark); color: #fff; }
.button.secondary, button.secondary { background: #e7edf3; color: #14212c; }
.button.danger, button.danger { background: var(--danger); }
.button.warn, button.warn { background: var(--warn); }
.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e7edf3;
    color: #243447;
    font-weight: 750;
    font-size: 12px;
}
.badge.ok { background: #dff3e9; color: var(--ok); }
.badge.danger { background: #fde4e1; color: var(--danger); }
.badge.warn { background: #fff3cd; color: var(--warn); }
.empty { background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: 22px; color: var(--muted); }
.flash { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-weight: 650; }
.flash.ok { background: #dff3e9; color: var(--ok); }
.flash.error { background: #fde4e1; color: var(--danger); }
.login {
    min-height: calc(100vh - 48px);
    display: grid;
    place-items: center;
}
.login-box { width: min(440px, 100%); }
.muted { color: var(--muted); }
.thread-post { border-top: 1px solid var(--line); padding: 16px 0; }
.thread-post:first-child { border-top: 0; padding-top: 0; }

@media (max-width: 860px) {
    .header-inner {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 12px;
        padding: 14px 18px;
    }
    .top-nav {
        padding-bottom: 2px;
    }
    .account {
        justify-content: flex-start;
    }
    .main { padding: 18px; }
    .cols-2, .cols-3 { grid-template-columns: 1fr; }
    h1 { font-size: 24px; }
}
