/* ==========================================================
   SATRIA CBT License — dashboard
   ========================================================== */
:root {
    --ink: #0f172a;
    --muted: #64748b;
    --subtle: #94a3b8;
    --line: #e8eaf1;
    --bg: #f6f7fb;
    --surface: #ffffff;
    --primary: #5b5bd6;
    --primary-2: #6366f1;
    --primary-soft: #eef0ff;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #f43f5e;
    --radius: 14px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -20px rgba(16, 24, 40, .40);
    --shadow-md: 0 1px 2px rgba(16, 24, 40, .04), 0 20px 44px -30px rgba(16, 24, 40, .48);
    --sidebar: 246px;
}

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

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; }
p { margin: 0; }
code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .86em;
    background: #f1f3fa;
    padding: 1px 5px;
    border-radius: 5px;
}
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ---------------- Shell ---------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex: none;
    background: #fff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.side-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid #f1f3fa;
}

.logo-mark {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 800;
    font-size: .78rem;
    letter-spacing: .02em;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px -10px rgba(99, 102, 241, .9);
}

.side-brand strong {
    display: block;
    font-size: .9rem;
    font-weight: 800;
    line-height: 1.2;
}

.side-brand small {
    display: block;
    font-size: .68rem;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 600;
}

.side-nav { padding: 14px 12px; display: grid; gap: 3px; }

.side-nav .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .13em;
    text-transform: uppercase;
    color: var(--subtle);
    padding: 10px 10px 6px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 500;
    color: #475569;
    transition: background .15s ease, color .15s ease;
}

.side-nav a:hover { background: #f6f7fc; color: var(--ink); }

.side-nav a.active {
    background: linear-gradient(90deg, #eef0ff, #f7f8ff);
    color: #4f46e5;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary-2);
}

.side-nav a i { width: 18px; text-align: center; color: var(--subtle); font-size: .9rem; }
.side-nav a.active i { color: #4f46e5; }

.side-foot {
    margin-top: auto;
    padding: 14px;
    border-top: 1px solid #f1f3fa;
    font-size: .76rem;
    color: var(--subtle);
}

.side-foot strong { display: block; color: #334155; font-size: .82rem; }

/* ---------------- Main ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    height: 62px;
    padding: 0 26px;
    background: rgba(255, 255, 255, .9);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 1.05rem; font-weight: 800; }
.topbar .spacer { margin-left: auto; }

.topbar .who { font-size: .82rem; color: var(--muted); text-align: right; line-height: 1.3; }
.topbar .who strong { display: block; color: var(--ink); font-size: .86rem; }

.content { padding: 24px 26px 48px; }
.content > * { max-width: 1280px; }

/* ---------------- Cards & stats ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f1f3fa;
}

.card-head h2 { font-size: .95rem; font-weight: 700; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 20px; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
}

.stat .k {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--subtle);
}

.stat b {
    display: block;
    margin-top: 6px;
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -.03em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat .sub { margin-top: 3px; font-size: .76rem; color: var(--muted); }
.stat.c-primary b { color: var(--primary); }
.stat.c-ok b { color: #059669; }
.stat.c-warn b { color: #b45309; }
.stat.c-danger b { color: #be123c; }

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

table.data {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table.data th {
    padding: 10px 16px;
    background: #fbfcfe;
    border-bottom: 1px solid #eef1f7;
    color: var(--subtle);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
}

table.data td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f5fa;
    color: #334155;
    vertical-align: middle;
}

table.data tbody tr:hover { background: #fafbff; }
table.data tbody tr:last-child td { border-bottom: 0; }

.key-chip {
    display: inline-block;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .02em;
    color: #3730a3;
    background: var(--primary-soft);
    border: 1px solid #dfe2ff;
    padding: 3px 8px;
    border-radius: 7px;
    white-space: nowrap;
}

/* ---------------- Badges ---------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
}

.badge.ok { background: #ecfdf5; color: #047857; }
.badge.warn { background: #fffbeb; color: #b45309; }
.badge.off { background: #f1f5f9; color: #64748b; }
.badge.danger { background: #fff1f2; color: #be123c; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.2;
    padding: 9px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: transform .15s ease, filter .15s ease, box-shadow .15s ease,
                border-color .15s ease, color .15s ease, background .15s ease;
}

.btn-primary {
    background: linear-gradient(180deg, #6366f1, #5557d8);
    color: #fff;
    box-shadow: 0 10px 20px -12px rgba(99, 102, 241, .85);
}

.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.06); }

.btn-ghost {
    background: #fff;
    color: #3f4254;
    border-color: var(--line);
}

.btn-ghost:hover { border-color: #c9cdf0; color: var(--primary); }

.btn-danger { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.btn-danger:hover { background: #ffe4e6; }

.btn-sm { padding: 6px 10px; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }

.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------------- Forms ---------------- */
.stack { display: grid; gap: 14px; }

label.field { display: block; font-size: .8rem; font-weight: 600; color: #475569; }
label.field span.hint { display: block; font-weight: 400; color: var(--subtle); font-size: .74rem; margin-top: 2px; }

input[type=text], input[type=password], input[type=date], input[type=number],
input[type=email], input[type=search], select, textarea {
    width: 100%;
    margin-top: 6px;
    font-family: inherit;
    font-size: .88rem;
    color: var(--ink);
    background: #fff;
    border: 1px solid #e2e5ee;
    border-radius: 10px;
    padding: 9px 11px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea { min-height: 74px; resize: vertical; }

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #a5a8f0;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    padding-top: 6px;
    border-top: 1px solid #f1f3fa;
    margin-top: 4px;
    padding-top: 16px;
}

.form-actions .spacer { margin-left: auto; }

/* ---------------- Alerts ---------------- */
.alert {
    border-radius: 11px;
    padding: 11px 14px;
    font-size: .85rem;
    line-height: 1.55;
    border: 1px solid;
}

.alert-ok { background: #ecfdf5; border-color: #d1fae5; color: #047857; }
.alert-error { background: #fff1f2; border-color: #fecdd3; color: #be123c; }
.alert-warn { background: #fffbeb; border-color: #fef3c7; color: #b45309; }
.alert-info { background: #eef2ff; border-color: #e0e7ff; color: #4338ca; }

/* ---------------- Auth pages ---------------- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 12% -10%, rgba(99, 102, 241, .16), transparent 62%),
        radial-gradient(760px 380px at 100% 0%, rgba(139, 92, 246, .12), transparent 58%),
        var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    padding: 28px;
}

.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand strong { display: block; font-size: .95rem; font-weight: 800; line-height: 1.2; }
.auth-brand small { display: block; font-size: .7rem; color: var(--subtle); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

.auth-card h1 { font-size: 1.3rem; font-weight: 800; margin-bottom: 6px; }
.auth-card > p.muted { margin-bottom: 20px; font-size: .87rem; line-height: 1.6; }
.auth-card .btn-block { margin-top: 6px; }

/* ---------------- Detail page ---------------- */
.detail-grid {
    display: grid;
    grid-template-columns: 1.35fr .65fr;
    gap: 16px;
    align-items: start;
}

.kv { display: grid; gap: 0; }
.kv-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f3f5fa;
    font-size: .87rem;
}
.kv-row:last-child { border-bottom: 0; }
.kv-row dt { color: var(--muted); }
.kv-row dd { margin: 0; color: var(--ink); font-weight: 500; word-break: break-word; }

.quota-bar {
    height: 8px;
    border-radius: 999px;
    background: #eef0f6;
    overflow: hidden;
    margin-top: 10px;
}

.quota-bar > span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.quota-bar.is-over > span { background: linear-gradient(90deg, #f59e0b, #f43f5e); }

.big-key {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--primary-soft);
    border: 1px dashed #c7caff;
    border-radius: 12px;
    padding: 14px 16px;
}

.big-key code {
    background: transparent;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: .06em;
    color: #3730a3;
    padding: 0;
}

/* ---------------- Empty state ---------------- */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .ico {
    width: 52px; height: 52px; margin: 0 auto 14px;
    border-radius: 14px; background: var(--primary-soft);
    color: var(--primary); display: grid; place-items: center; font-size: 1.1rem;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1080px) {
    .detail-grid { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .side-nav { display: flex; overflow-x: auto; gap: 6px; padding: 10px 12px; }
    .side-nav .label { display: none; }
    .side-nav a { white-space: nowrap; }
    .side-foot { display: none; }
    .content { padding: 16px 14px 40px; }
    .topbar { padding: 0 14px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .kv-row { grid-template-columns: 120px 1fr; }
}

@media (max-width: 560px) {
    .stats { grid-template-columns: 1fr; }
    .topbar .who { display: none; }
}
