/* Kubus Admin — gaya padat untuk dasbor. Tanpa langkah build: hosting tidak punya Node. */
:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-2: #f1f4f9;
    --text: #0f172a;
    --muted: #526077;
    --border: #e1e7ef;
    --primary: #2358d8;
    --primary-hover: #1b47b3;
    --on-primary: #ffffff;
    --primary-soft: #e6eefc;
    --danger: #c0282d;
    --danger-hover: #9d1f23;
    --ring: #2358d8;
    --ok-fg: #14653a;   --ok-bg: #dcf5e6;
    --warn-fg: #8a4a06; --warn-bg: #fdefd1;
    --bad-fg: #a8201f;  --bad-bg: #fde3e2;
    --info-fg: #1f4fb8; --info-bg: #e1ebfd;
    --muted-fg: #455167; --muted-bg: #e8edf4;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 248px;
    --control-h: 36px; /* tinggi tunggal tombol, isian, tab */
    --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1320;
        --surface: #151d2e;
        --surface-2: #1b2539;
        --text: #eef2f8;
        --muted: #a2afc4;
        --border: #2a364d;
        --primary: #5b8cff;
        --primary-hover: #7aa1ff;
        --on-primary: #0b1220;
        --primary-soft: #1c2a4a;
        --danger: #ff6b6b;
        --danger-hover: #ff8a8a;
        --ring: #8bacff;
        --ok-fg: #6fe3a1;   --ok-bg: #123524;
        --warn-fg: #f6c36b; --warn-bg: #3a2a0c;
        --bad-fg: #ff9a9a;  --bad-bg: #3d1717;
        --info-fg: #9dbbff; --info-bg: #172647;
        --muted-fg: #b3bfd2; --muted-bg: #243049;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 400 15px/1.55 var(--font);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .04em; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; }
tfoot th { background: var(--surface-2); }
.nowrap { white-space: nowrap; }
.link { font-weight: 600; }
.icon { flex: none; }

/* ---------- kerangka ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 16px 12px; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
    background: var(--primary); color: var(--on-primary); font-weight: 700; font-size: 1.1rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: .98rem; }
.brand-text small { color: var(--muted); font-size: .75rem; }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 1.3rem; }
.nav { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.nav-label { font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 10px 4px; }
.nav-link {
    display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 10px;
    border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; font-size: .92rem;
    transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--border); margin-top: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; }
.me-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.me-text strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text small { color: var(--muted); font-size: .75rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 600; }
.content { padding: 24px 28px 48px; max-width: 1400px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 22, .5); z-index: 30; }

.icon-btn {
    display: inline-grid; place-items: center; min-width: var(--control-h); height: var(--control-h); border: 0; background: transparent;
    color: var(--muted); border-radius: var(--radius-sm); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- halaman ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > :first-child { flex: 1 1 320px; min-width: 0; }
.page-head > :not(:first-child) { flex: none; }
.page-head p { margin-top: 4px; }
.page-head h2 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.section-title { margin-bottom: 10px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card-title { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat-link { text-decoration: none; color: inherit; transition: border-color .15s ease, transform .15s ease; }
.stat-link:hover { border-color: var(--primary); color: inherit; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; }
.has-work .stat-icon { background: var(--warn-bg); color: var(--warn-fg); }
.stat-body { display: flex; flex-direction: column; line-height: 1.2; }
.stat-num { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); padding: 20px 8px; text-align: center; }
.kv-list { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.kv-list li { display: flex; align-items: center; justify-content: space-between; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

pre.json { margin: 4px 0 8px; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font: .78rem/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-width: 520px; }

/* ---------- soal & meter ---------- */
.options { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.options legend { font-weight: 600; padding: 0 6px; }
.option-row { display: grid; grid-template-columns: 28px minmax(0, 2fr) 84px minmax(0, 1.4fr); gap: 8px; align-items: center; }
.option-row input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); }
.option-row input[type=file] { padding: 6px; font-size: .8rem; }
.meter { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0; }
.meter span { display: block; height: 100%; border-radius: 99px; }
.meter .ok { background: var(--ok-fg); }
.meter .warn { background: var(--warn-fg); }
@media (max-width: 640px) { .option-row { grid-template-columns: 28px 1fr; } .option-row .opt-pos, .option-row input[type=file] { grid-column: 2; } }

/* ---------- alur program ---------- */
.flow { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 12px; counter-reset: step; }
.flow li { counter-increment: step; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .8rem; font-weight: 500; }
.flow li::before { content: counter(step); width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--border); color: var(--text); font-size: .7rem; font-weight: 700; }
.flow li.done { color: var(--ok-fg); background: var(--ok-bg); }
.flow li.done::before { background: var(--ok-fg); color: var(--ok-bg); content: "✓"; }
.flow li.now { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.flow li.now::before { background: var(--on-primary); color: var(--primary); }

/* ---------- grafik ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bar-fill { width: 100%; max-width: 28px; background: var(--primary); border-radius: 5px 5px 2px 2px; min-height: 3px; }
.bar-x { font-size: .7rem; color: var(--muted); white-space: nowrap; height: 1em; line-height: 1; overflow: visible; }
.data-details { margin-top: 12px; }
.data-details summary { cursor: pointer; color: var(--primary); font-weight: 500; font-size: .88rem; }

/* ---------- tabel ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card .table-wrap { border: 0; border-radius: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; white-space: nowrap; position: sticky; top: 0; }
.table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
/* Sel aksi: semua tombol/formulir sebaris, sejajar tengah, jarak 8px. font-size 0 membuang celah spasi antar elemen. */
.table th.num, .table td.num { text-align: right; }
.table th.actions { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; font-size: 0; }
.table td.actions > * { display: inline-flex; align-items: center; vertical-align: middle; margin: 0 0 0 8px; }
.table td.actions > :first-child { margin-left: 0; }
.table td.actions form { margin-bottom: 0; }
.cell-title { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: .82rem; }
.cell-sub.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-foot { padding: 10px 14px; color: var(--muted); font-size: .82rem; border-top: 1px solid var(--border); }

/* ---------- alat ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar-inline { display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; background: var(--surface-2); border-radius: 10px; width: fit-content; max-width: 100%; }
.tab { padding: 0 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: .88rem; height: calc(var(--control-h) - 8px); display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.search { position: relative; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; min-width: 240px; }

/* ---------- tombol & formulir ---------- */
/* Satu tinggi untuk semua kontrol (tombol, isian, pilihan, tab): --control-h. Tidak ada tombol "besar" dan "kecil". */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--control-h); padding: 0 14px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
    font: 600 .88rem/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; vertical-align: middle;
    transition: background-color .15s ease, border-color .15s ease;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 0 12px; } /* hanya lebih rapat ke samping; tinggi tetap sama */
.btn-block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; font-weight: 500; }
.field > span { color: var(--muted); }
.field .hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
.input {
    width: 100%; height: var(--control-h); padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: 400 .9rem/1.4 var(--font);
}
select.input { padding-right: 28px; }
textarea.input { height: auto; padding: 8px 12px; resize: vertical; min-height: 84px; }
input[type=file].input { height: auto; min-height: var(--control-h); padding: 6px 10px; line-height: 1.5; }
.input:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--border)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }

/* ---------- lencana & peringatan ---------- */
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px; font-size: .76rem; font-weight: 600; line-height: 1; white-space: nowrap; vertical-align: middle; }
.badge-ok { color: var(--ok-fg); background: var(--ok-bg); }
.badge-warn { color: var(--warn-fg); background: var(--warn-bg); }
.badge-bad { color: var(--bad-fg); background: var(--bad-bg); }
.badge-info { color: var(--info-fg); background: var(--info-bg); }
.badge-muted { color: var(--muted-fg); background: var(--muted-bg); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .92rem; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.alert-ok { color: var(--ok-fg); background: var(--ok-bg); }
.alert-bad { color: var(--bad-fg); background: var(--bad-bg); }
.alert-warn { color: var(--warn-fg); background: var(--warn-bg); }
.alert-info { color: var(--info-fg); background: var(--info-bg); }

/* ---------- dialog ---------- */
.dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(8, 12, 22, .55); }
.dialog-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- media moderasi ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.media-card { display: flex; flex-direction: column; gap: 10px; }
.media-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.media-card audio { width: 100%; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { padding: 0 0 4px; }

/* ---------- responsif ---------- */
@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
    .app { grid-template-columns: 1fr; }
    .topbar { display: flex; }
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(290px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .2s ease; }
    body.nav-open .sidebar { transform: none; }
    .content { padding: 16px 16px 40px; }
    .grid-2 { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .search .input { min-width: 0; width: 100%; }
    .search { flex: 1 1 100%; }
}
/* Layar sentuh: kontrol lebih tinggi agar mudah ditekan */
@media (pointer: coarse) { :root { --control-h: 44px; } }
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
@media print {
    .sidebar, .topbar, .btn, .toolbar { display: none !important; }
    .app { display: block; }
}
