:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --ink: #12202f;
  --muted: #5b6b7a;
  --line: #dfe6e2;
  --navy: #0b2a4a;
  --navy-2: #133d68;
  --gold: #f2b705;
  --gold-ink: #3a2a00;
  --focus: #1f6feb;
  --danger: #b42318;
  --ok: #157f3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 47, .06), 0 4px 14px rgba(16, 32, 47, .05);

  --c-akademik: #2f5fd0;
  --c-keuangan: #0f8a5f;
  --c-administrasi: #8a4fd0;
  --c-aset: #c46a12;
  --c-layanan: #0e7c90;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141c;
    --surface: #151f2a;
    --ink: #e6edf3;
    --muted: #93a3b3;
    --line: #243241;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --ok: #4cc994;
    --c-akademik: #7ea2ff;
    --c-keuangan: #4cc994;
    --c-administrasi: #be96f5;
    --c-aset: #f0a35a;
    --c-layanan: #5ccbdc;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Splash & error */
.splash, .fatal {
  min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 16px;
  text-align: center; padding: 24px; color: var(--muted);
}
.splash-ring {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.fatal h1 { color: var(--ink); font-size: 1.25rem; margin: 0; }
.fatal p { max-width: 42ch; margin: 0; }
.btn {
  background: var(--gold); color: var(--gold-ink); border: 0; border-radius: 10px;
  padding: 10px 18px; font-weight: 700;
}

/* Shell */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(16px, 4vw, 40px);
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img, .logo-fallback {
  width: 36px; height: 36px; border-radius: 8px; object-fit: contain; background: #fff; padding: 3px; flex: none;
}
.logo-fallback { display: grid; place-items: center; color: var(--navy); font-weight: 800; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .98rem; }
.brand-text small { font-size: .74rem; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 999px; padding: 4px 10px 4px 4px; color: #fff;
}
.user-btn:hover { background: rgba(255, 255, 255, .14); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: var(--gold-ink); font-weight: 800; font-size: .8rem;
}
.chev { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: min(280px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 6px; display: grid;
}
.pop-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: grid; }
.pop-head span { color: var(--muted); font-size: .85rem; word-break: break-all; }
.user-pop a, .user-pop button {
  text-align: left; text-decoration: none; background: none; border: 0;
  padding: 10px 12px; border-radius: 8px; font-size: .92rem;
}
.user-pop a:hover, .user-pop button:hover { background: var(--bg); }
.user-pop .danger { color: var(--danger); font-weight: 600; }

.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 48px; }

/* Hero */
.hero {
  margin: 0 calc(-1 * clamp(16px, 4vw, 40px)); padding: 28px clamp(16px, 4vw, 40px) 32px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff;
  display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; justify-content: space-between;
  border-radius: 0 0 22px 22px;
}
.eyebrow { margin: 0 0 4px; font-size: .82rem; opacity: .8; }
.hero h1 { margin: 0; font-size: clamp(1.45rem, 3.4vw, 2.1rem); font-weight: 800; letter-spacing: -.01em; }
.hero h1 #first-name { color: var(--gold); }
.hero-sub { margin: 6px 0 0; opacity: .85; max-width: 52ch; }
.identity {
  margin: 0; display: grid; grid-template-columns: auto auto; gap: 4px 20px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 12px; padding: 12px 16px; font-size: .85rem;
}
.identity div { display: contents; }
.identity dt { opacity: .7; }
.identity dd { margin: 0; font-weight: 600; word-break: break-word; }

/* Toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  margin: 24px 0 8px;
}
.search {
  flex: 1 1 280px; max-width: 420px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px;
}
.search:focus-within { border-color: var(--focus); }
.search svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; background: none; padding: 11px 0; font: inherit; color: var(--ink); outline: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; max-width: 100%; }
.chip {
  white-space: nowrap; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 14px; font-size: .86rem; font-weight: 600; color: var(--muted);
}
.chip[aria-selected="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
@media (prefers-color-scheme: dark) {
  .chip[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
}

/* Grid */
.group h2 { font-size: 1rem; margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.count {
  font-size: .75rem; font-weight: 700; background: var(--line); color: var(--muted);
  border-radius: 999px; padding: 1px 8px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); box-shadow: 0 10px 24px rgba(16, 32, 47, .1); }
.card-link { display: flex; gap: 14px; padding: 16px 44px 16px 16px; text-decoration: none; height: 100%; }
.card-ico {
  --c: var(--navy-2);
  flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 12%, transparent); color: var(--c);
}
.card-ico .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card-ico img { width: 30px; height: 30px; object-fit: contain; }
.cat-akademik { --c: var(--c-akademik); }
.cat-keuangan { --c: var(--c-keuangan); }
.cat-administrasi { --c: var(--c-administrasi); }
.cat-aset { --c: var(--c-aset); }
.cat-layanan { --c: var(--c-layanan); }
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-title { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-desc { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.card-meta { color: var(--muted); font-size: .76rem; margin-top: auto; padding-top: 8px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-radius: 999px; padding: 1px 7px;
}
.pin {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; border-radius: 8px;
  border: 0; background: none; color: var(--muted); display: grid; place-items: center; opacity: .5;
}
.card:hover .pin, .pin:focus-visible, .pin[aria-pressed="true"] { opacity: 1; }
.pin:hover { background: var(--bg); }
.pin .ico { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.pin[aria-pressed="true"] { color: var(--gold); }
.pin[aria-pressed="true"] .ico { fill: currentColor; }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted);
}
.empty p { margin: 4px 0; }

.foot {
  display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px); color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line);
}
.demo-flag { background: var(--gold); color: var(--gold-ink); border-radius: 999px; padding: 1px 10px; font-weight: 700; }

@media (max-width: 560px) {
  .user-btn-name { display: none; }
  .identity { width: 100%; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .splash-ring { transition: none; animation: none; }
}
