/* ===== Token warna ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #1a1e24;
  --text-2: #475161;
  --muted: #6b7482;
  --primary: #1f4fc9;
  --primary-hover: #1a43ab;
  --primary-ink: #ffffff;
  --primary-soft: #e7edfb;
  --bar: #3f6fe0;
  --ok: #17703a;      --ok-soft: #e5f4ea;
  --warn: #8a5a00;    --warn-soft: #fbf3df;
  --danger: #b42318;  --danger-soft: #fdecea;
  --info: #1f4fc9;    --info-soft: #e7edfb;
  --done: #0e6b63;    --done-soft: #def3f0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1f242c;
    --border: #2c323c;
    --text: #e7e9ed;
    --text-2: #b5bcc7;
    --muted: #8c95a3;
    --primary: #7d9bff;
    --primary-hover: #97afff;
    --primary-ink: #0c1324;
    --primary-soft: #1c2640;
    --bar: #6d8ef5;
    --ok: #6fd394;      --ok-soft: #14291c;
    --warn: #f0c060;    --warn-soft: #2d2412;
    --danger: #ff8f84;  --danger-soft: #331a18;
    --info: #7d9bff;    --info-soft: #1c2640;
    --done: #5fd3c6;    --done-soft: #12292a;
    --shadow: none;
    color-scheme: dark;
  }
}

/* ===== Dasar ===== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow: auto; max-height: 420px; margin: .5rem 0 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ===== Header ===== */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav a { color: var(--text-2); padding: 6px 10px; border-radius: 7px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.aktif { background: var(--primary-soft); color: var(--primary); }
.user-box { display: flex; align-items: center; gap: 10px; font-size: .9rem; color: var(--text-2); }
.user-box form { margin: 0; }

.mode-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--border); font-size: .85rem; }
.mode-banner div { max-width: 1180px; margin: 0 auto; padding: 6px 16px; }

/* ===== Layout ===== */
.container { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.layout-detail { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 960px) { .layout-detail { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.stack > * + * { margin-top: 16px; }

/* ===== Tile statistik ===== */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); color: var(--text); display: block; }
a.tile:hover { border-color: var(--primary); text-decoration: none; }
.tile-label { font-size: .82rem; color: var(--text-2); }
.tile-value { font-size: 1.75rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 2px; }
.tile-note { font-size: .78rem; color: var(--muted); }

/* ===== Batang horizontal (satu seri) ===== */
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 150px minmax(0, 1fr) 36px; gap: 10px; align-items: center; padding: 5px 0; }
.bars .bar-label { font-size: .88rem; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .bar-track { height: 12px; border-radius: 0 4px 4px 0; position: relative; }
.bars .bar-fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .bar-fill.kosong { background: var(--border); }
.bars .bar-n { font-variant-numeric: tabular-nums; text-align: right; font-size: .88rem; }
.bars li:hover .bar-fill:not(.kosong) { filter: brightness(1.1); }
@media (max-width: 480px) { .bars li { grid-template-columns: 110px minmax(0, 1fr) 30px; } }

/* ===== Tabel ===== */
.table-wrap { overflow-x: auto; margin: 0 -2px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface); }
tbody tr:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 10px; }

dl.kv { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } dl.kv dd { margin-bottom: 8px; } }

/* ===== Badge status (selalu dengan teks) ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.done { background: var(--done-soft); color: var(--done); }
.badge.muted, .badge.plain { background: var(--surface-2); color: var(--text-2); }
.badge.plain::before { display: none; }

/* ===== Tombol ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-warn { color: var(--warn); }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-link { background: none; border: none; color: var(--primary); padding: 0; font: inherit; cursor: pointer; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-ok { color: #0d1f14; } }

/* ===== Alert & pesan ===== */
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); }
.alert.success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.alert.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.alert.warning { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.alert.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.messages { margin-bottom: 16px; }

/* ===== Form ===== */
form.form .section { margin-bottom: 16px; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.field .req { color: var(--danger); }
.field small { display: block; margin-top: 3px; }
.field .help { color: var(--muted); }
.field .err { color: var(--danger); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-size: .92rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }

.jenis-pilih { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.jenis-pilih label { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 10px; padding: 12px; cursor: pointer; background: var(--surface); }
.jenis-pilih label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.jenis-pilih input { margin-top: 3px; }
.jenis-pilih strong { display: block; }
.jenis-pilih span { font-size: .82rem; color: var(--muted); }

.row-form { display: grid; gap: 10px; grid-template-columns: 160px minmax(0, 1fr) auto; align-items: start; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.row-form.dosen { grid-template-columns: 160px minmax(0, 1fr) minmax(0, 1fr) auto; }
.row-form.is-deleted { display: none; }
.row-form .del-box { display: none; }
.row-form .err { color: var(--danger); font-size: .8rem; }
@media (max-width: 640px) { .row-form, .row-form.dosen { grid-template-columns: minmax(0, 1fr); } }

.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filterbar select, .filterbar input { width: auto; min-width: 140px; }
.filterbar input[type=search] { flex: 1; min-width: 200px; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ===== Riwayat ===== */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--border); margin-left: 5px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--primary); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: .78rem; color: var(--muted); }

/* ===== Auth ===== */
.auth-wrap { max-width: 420px; margin: 40px auto; }
.auth-wrap.lebar { max-width: 640px; }
.auth-wrap .card { padding: 24px; }

[hidden] { display: none !important; }
.isi-langsung { display: contents; }
.captcha-baris { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.captcha-baris img { border: 1px solid var(--border); border-radius: 8px; background: #f6f8fb; display: block; max-width: 100%; height: auto; }
.cek { display: flex; gap: 8px; align-items: center; font-weight: 500; font-size: .9rem; }
.cek input { width: auto; }
.kelompok-fakultas { margin-top: 16px; }
.kelompok-fakultas:first-child { margin-top: 0; }
tr.nonaktif td { color: var(--muted); }

details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .88rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
