/* ═══════════════════════════════════════════════════════════════════════════
   Sentiment Early Warning — app.css
   Tanpa dependensi eksternal. Semua warna lewat token (mode malam & siang).
     1. Token            6. Filter bar           11. Artikel & drawer
     2. Dasar            7. Konten & kartu       12. Chat
     3. Tombol & form    8. KPI & banner         13. Tab, keyword, alur proses
     4. Login            9. Badge & tabel        14. Toast, modal, skeleton
     5. Kerangka app    10. Chart & daftar       15. Responsif
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── 1. Token ──────────────────────────────────────────────────────────────── */
:root {
  --bg:            #0b0f16;
  --surface:       #121823;
  --surface-2:     #171f2c;
  --surface-3:     #202a3a;
  --border:        #273142;
  --border-soft:   #1d2533;

  --text:          #e6ebf2;
  --text-strong:   #ffffff;
  --muted:         #8d99ab;

  --accent:        #4c8dff;
  --accent-hover:  #6a9fff;
  --accent-soft:   rgba(76, 141, 255, .14);
  --accent-ring:   rgba(76, 141, 255, .38);
  --on-accent:     #ffffff;

  --positif:       #2fb35a;
  --positif-soft:  rgba(47, 179, 90, .15);
  --positif-text:  #7fe0a0;
  --negatif:       #ec4d4d;
  --negatif-soft:  rgba(236, 77, 77, .15);
  --negatif-text:  #ff9d9d;
  --netral:        #8b95a5;
  --netral-soft:   rgba(139, 149, 165, .15);
  --netral-text:   #c5ccd8;
  --warn:          #e0a43a;
  --warn-soft:     rgba(224, 164, 58, .15);
  --warn-text:     #f2cd88;

  --radius:        14px;
  --radius-sm:     9px;
  --radius-pill:   999px;
  --shadow:        0 16px 40px rgba(0, 0, 0, .45);
  --shadow-sm:     0 1px 3px rgba(0, 0, 0, .35);

  --topbar-bg:     rgba(11, 15, 22, .86);
  --backdrop:      rgba(3, 6, 12, .6);

  --sidebar-w:     252px;
  --rail-w:        72px;
  --topbar-h:      64px;
  /* Tinggi navigasi bawah di HP: tombol 52px + padding 8px + garis 1px + area aman (poni/bilah home iPhone). */
  --bottomnav-h:   calc(61px + env(safe-area-inset-bottom, 0px));
  --page-max:      1440px;
  --page-pad:      max(clamp(1rem, 2.2vw, 1.75rem), calc((100% - var(--page-max)) / 2));

  --fs-xs: .75rem;
  --fs-sm: .8125rem;
  --fs-md: .9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.45rem;

  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg:            #f3f6fb;
  --surface:       #ffffff;
  --surface-2:     #f6f8fc;
  --surface-3:     #e8eef7;
  --border:        #d7e0ec;
  --border-soft:   #e6ecf4;

  --text:          #172335;
  --text-strong:   #0b1626;
  --muted:         #5d6d84;

  --accent:        #1d5fd1;
  --accent-hover:  #174fb0;
  --accent-soft:   rgba(29, 95, 209, .09);
  --accent-ring:   rgba(29, 95, 209, .28);

  --positif:       #16803f;
  --positif-soft:  rgba(22, 128, 63, .10);
  --positif-text:  #10693a;
  --negatif:       #c8342b;
  --negatif-soft:  rgba(200, 52, 43, .09);
  --negatif-text:  #9c2b20;
  --netral:        #64748b;
  --netral-soft:   rgba(100, 116, 139, .11);
  --netral-text:   #47566b;
  --warn:          #b8740f;
  --warn-soft:     rgba(184, 116, 15, .11);
  --warn-text:     #85560e;

  --shadow:        0 16px 36px rgba(17, 42, 82, .13);
  --shadow-sm:     0 1px 3px rgba(17, 42, 82, .08);
  --topbar-bg:     rgba(255, 255, 255, .9);
  --backdrop:      rgba(15, 25, 45, .38);

  color-scheme: light;
}

/* ── 2. Dasar ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
/* Layar HP tetap "diam": tanpa zoom ketuk-dua-kali, dan tanpa gerak sapuan horizontal pada halaman. */
html { touch-action: manipulation; overscroll-behavior-x: none; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0 0 .35rem; color: var(--text-strong); line-height: 1.25; font-weight: 700; }
h1 { font-size: var(--fs-xl); letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p  { margin: 0 0 .6rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; display: inline-block; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted   { color: var(--muted); }
.small   { font-size: var(--fs-sm); }
.tiny    { font-size: var(--fs-xs); }
.strong  { font-weight: 700; color: var(--text-strong); }
.nowrap  { white-space: nowrap; }
.num     { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row     { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.stack   { display: grid; gap: .75rem; }
.spacer  { flex: 1 1 auto; }
.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;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; flex: 0 0 8px; }
.dot-positif, .dot-ok { background: var(--positif); }
.dot-negatif, .dot-bad { background: var(--negatif); }
.dot-netral { background: var(--netral); }
.dot-warn { background: var(--warn); }

/* ── 3. Tombol & form ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 36px;
  padding: .45rem .85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-outline { background: transparent; }
.btn-danger { background: var(--negatif); border-color: var(--negatif); color: #fff; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--negatif-text); }
.btn-danger-ghost:hover { background: var(--negatif-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 30px; padding: .3rem .6rem; font-size: var(--fs-xs); }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; min-height: 30px; }

.input, input[type="email"], input[type="password"], input[type="date"], input[type="number"],
input[type="text"], input[type="search"], select, textarea {
  width: 100%;
  min-height: 38px;
  padding: .5rem .7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.input:focus, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field { margin-bottom: .85rem; }
.field > label, .field-label { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: .3rem; color: var(--text); }
.field-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: .25rem; }
.field-row { display: flex; gap: .5rem; align-items: center; }
.field-row > input { flex: 1 1 auto; }
.form-grid { display: grid; gap: .75rem 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); align-items: start; }
.form-grid > .field { margin-bottom: 0; }
.form-grid > .form-actions { align-self: end; }
.form-grid > .form-actions .btn { width: 100%; min-height: 40px; }
.modal .form-grid { margin-bottom: .85rem; }
.form-section { display: grid; gap: .85rem; }
.form-section > .field { margin-bottom: 0; }
.form-section-title { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: .3rem 0 -.2rem; }
.secret-box { display: grid; gap: .35rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .85rem; font-size: var(--fs-sm); }
.secret-box code { font-family: var(--font-num); font-size: .85rem; color: var(--text-strong); user-select: all; }
.check { display: inline-flex; align-items: center; gap: .5rem; font-size: var(--fs-sm); color: var(--muted); cursor: pointer; }
.check input { width: auto; min-height: 0; accent-color: var(--accent); }
.status { min-height: 1.2rem; font-size: var(--fs-sm); margin: .5rem 0 0; }
.status.is-error { color: var(--negatif-text); }
.status.is-ok { color: var(--positif-text); }

.switch { position: relative; display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 36px; height: 20px; border-radius: var(--radius-pill); background: var(--surface-3);
  border: 1px solid var(--border); position: relative; transition: background .15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── 4. Login ──────────────────────────────────────────────────────────────── */
.auth-body {
  min-height: 100%;
  display: grid; place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
  padding-top: max(clamp(1rem, 4vw, 3rem), env(safe-area-inset-top));
  padding-bottom: max(clamp(1rem, 4vw, 3rem), env(safe-area-inset-bottom));
  background:
    radial-gradient(1000px 520px at 12% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(800px 480px at 100% 0%, rgba(47, 179, 90, .07), transparent 55%),
    var(--bg);
}
.auth-shell {
  width: 100%; max-width: 960px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem;
}
.auth-card, .auth-aside {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
  min-width: 0;                 /* item grid boleh menyusut; tanpa ini kartu melebar melewati layar HP */
}
.auth-card .brand-text small { white-space: normal; }   /* di layar sempit tagline turun baris, bukan memaksa kartu melebar */
.auth-card { box-shadow: var(--shadow); }
.auth-aside { background: linear-gradient(160deg, var(--surface-2), var(--surface)); display: flex; flex-direction: column; justify-content: center; }
.auth-points { list-style: none; margin: .8rem 0 1rem; padding: 0; display: grid; gap: .6rem; }
.auth-points li { display: flex; align-items: flex-start; gap: .6rem; font-size: var(--fs-sm); }
.auth-points .icon { color: var(--accent); margin-top: 2px; }
.auth-head h1 { font-size: clamp(1.35rem, 3vw, 1.65rem); margin-top: 1.1rem; }
.auth-foot { margin-top: 1rem; border-top: 1px solid var(--border-soft); padding-top: .8rem; }

.brand { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), #2f6fe0);
  color: #fff;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text strong { font-size: var(--fs-md); color: var(--text-strong); }
.brand-text small { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 5. Kerangka aplikasi ──────────────────────────────────────────────────── */
.boot-screen { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: var(--bg); }
.boot-card { display: grid; place-items: center; gap: .75rem; color: var(--muted); max-width: 560px; padding: 1rem; text-align: center; }
.spinner {
  width: 28px; height: 28px; display: inline-block;
  border: 3px solid var(--surface-3); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh; min-height: 100dvh;
  transition: grid-template-columns .2s ease;
}
/* Poni/sudut layar (iPhone landscape): isi tidak boleh tertutup. Bernilai 0 di layar biasa. */
@supports (padding: env(safe-area-inset-left)) {
  .app-shell { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}
.app-shell.is-collapsed { grid-template-columns: var(--rail-w) minmax(0, 1fr); }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; gap: .25rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: .9rem .75rem;
  overflow-y: auto; overflow-x: hidden;
  z-index: 50;
}
.sidebar-head { display: flex; align-items: center; gap: .6rem; padding: .15rem .25rem .9rem; min-height: 52px; }
.nav { display: grid; gap: .1rem; }
.nav-section {
  margin: .9rem .6rem .3rem;
  font-size: .6875rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: .7rem;
  width: 100%;
  min-height: 40px;
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  border: 0; background: transparent;
  color: var(--muted);
  cursor: pointer; text-align: left;
  font-size: var(--fs-sm); font-weight: 600;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--text-strong); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -.75rem; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-label { overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  margin-left: auto;
  min-width: 20px; padding: 0 .4rem;
  border-radius: var(--radius-pill);
  background: var(--negatif); color: #fff;
  font-size: .6875rem; font-weight: 700; line-height: 20px; text-align: center;
  font-family: var(--font-num);
}
.sidebar-foot {
  margin-top: auto; padding: .75rem .45rem .2rem;
  border-top: 1px solid var(--border-soft);
  display: grid; gap: .35rem;
  font-size: var(--fs-xs); color: var(--muted);
}
.db-status { display: flex; align-items: center; gap: .45rem; white-space: nowrap; }

/* Rail (desktop, sidebar diciutkan) */
.app-shell.is-collapsed .sidebar { padding-inline: .55rem; }
.app-shell.is-collapsed .brand-text,
.app-shell.is-collapsed .nav-label,
.app-shell.is-collapsed .nav-section,
.app-shell.is-collapsed .db-text,
.app-shell.is-collapsed .foot-text { display: none; }
.app-shell.is-collapsed .sidebar-head { justify-content: center; padding-inline: 0; }
.app-shell.is-collapsed .nav-item { justify-content: center; padding-inline: 0; }
.app-shell.is-collapsed .nav-item[aria-current="page"]::before { left: -.55rem; }
.app-shell.is-collapsed .nav-badge {
  position: absolute; top: 3px; right: 6px; min-width: 16px; line-height: 16px; font-size: .625rem; padding: 0 .25rem;
}
.app-shell.is-collapsed .nav-group + .nav-group { border-top: 1px solid var(--border-soft); margin-top: .5rem; padding-top: .5rem; }
.app-shell.is-collapsed .db-status { justify-content: center; }

.backdrop { position: fixed; inset: 0; z-index: 55; background: var(--backdrop); }

.main { display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .75rem;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  /* Mode "aplikasi" iOS (status bar transparan): topbar harus turun di bawah jam/baterai. */
  padding: calc(.55rem + env(safe-area-inset-top, 0px)) var(--page-pad) .55rem;
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { min-width: 0; flex: 1 1 auto; }
.topbar-title h1 { font-size: var(--fs-lg); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { margin: 0; font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; }

/* Menu profil */
.menu-wrap { position: relative; }
.profile-btn {
  display: flex; align-items: center; gap: .55rem;
  min-height: 40px;
  padding: .25rem .55rem .25rem .3rem;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface-2); cursor: pointer;
}
.profile-btn:hover, .profile-btn[aria-expanded="true"] { background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #2f6fe0);
  color: #fff; font-weight: 700; font-size: var(--fs-xs);
}
.avatar-lg { width: 44px; height: 44px; flex-basis: 44px; font-size: var(--fs-md); }
.avatar-xl { width: 64px; height: 64px; flex-basis: 64px; font-size: 1.3rem; }
.profile-text { display: flex; flex-direction: column; line-height: 1.15; text-align: left; max-width: 170px; }
.profile-text strong { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text small { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 70;
  width: 300px; max-width: calc(100vw - 1.5rem);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .4rem; animation: pop .12s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu-head { display: flex; gap: .7rem; align-items: center; padding: .7rem .65rem .8rem; }
.menu-head-text { min-width: 0; display: grid; gap: .1rem; }
.menu-head-text strong { color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head-text span { font-size: var(--fs-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-sep { height: 1px; background: var(--border-soft); margin: .3rem .2rem; }
.menu-item {
  width: 100%;
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem .65rem; min-height: 38px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text);
  font-size: var(--fs-sm); font-weight: 500; text-align: left; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item .icon { color: var(--muted); }
.menu-item .menu-hint { margin-left: auto; font-size: var(--fs-xs); color: var(--muted); }
.menu-item.is-danger { color: var(--negatif-text); }
.menu-item.is-danger .icon { color: var(--negatif-text); }
.menu-item.is-danger:hover { background: var(--negatif-soft); }

/* ── 6. Filter bar ─────────────────────────────────────────────────────────── */
.filterbar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top, 0px)); z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: .6rem var(--page-pad);
}
.filter-toggle { display: none; }
.filter-fields { display: flex; align-items: flex-end; gap: .65rem; flex-wrap: wrap; }
.filter-group { display: flex; flex-direction: column; gap: .2rem; min-width: 130px; }
.filter-group .input { min-height: 36px; padding: .35rem .6rem; font-size: var(--fs-sm); }
.filter-label { font-size: .6875rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.filter-dates { display: flex; gap: .4rem; }
#keyword-select { min-width: 200px; }

.picker { position: relative; min-width: 180px; }
.picker-toggle { width: 100%; justify-content: flex-start; min-height: 36px; background: var(--surface-2); font-weight: 500; }
.picker-toggle .icon:last-child { margin-left: auto; color: var(--muted); }
.picker-panel {
  position: absolute; z-index: 45; top: calc(100% + 4px); left: 0;
  width: 280px; max-width: 86vw; max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: .5rem;
}
.picker-panel label {
  display: flex; align-items: center; gap: .55rem;
  padding: .35rem .45rem; border-radius: 6px; font-size: var(--fs-sm); cursor: pointer;
}
.picker-panel label:hover { background: var(--surface-2); }
.picker-panel input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
.picker-search { margin-bottom: .4rem; }
.picker-actions { display: flex; gap: .4rem; padding-top: .45rem; margin-top: .45rem; border-top: 1px solid var(--border-soft); }

/* ── 7. Konten & kartu ─────────────────────────────────────────────────────── */
.content {
  flex: 1 1 auto;
  padding: clamp(1rem, 2vw, 1.5rem) var(--page-pad) 2rem;
  /* Satu kolom yang BOLEH menyusut: tanpa minmax(0,…) kolom implisit melebar mengikuti isi terlebar
     (tabel, URL panjang, grafik) lalu halaman bisa digeser ke samping di HP. */
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; align-content: start;
}
.content:focus { outline: none; }
/* Banner ajakan di atas konten (tetap terlihat saat pindah halaman). */
.notice-host { padding: .9rem var(--page-pad) 0; }
.content-foot {
  padding: 0 var(--page-pad) 1.5rem;
  display: flex; gap: .5rem; flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--muted);
}
.page-head { display: flex; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--muted); font-size: var(--fs-sm); max-width: 760px; }
.page-head .page-actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1rem, 1.8vw, 1.25rem);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 1rem; }
.card-head p { margin: .15rem 0 0; font-size: var(--fs-sm); color: var(--muted); }
.card-head .card-actions { margin-left: auto; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; min-width: 0; max-width: 100%; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .card-head { padding: 1rem 1.1rem 0; }

.grid { display: grid; gap: 1rem; align-items: start; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-wide { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ── 8. KPI & banner ───────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .95rem 1rem;
  display: grid; gap: .3rem; min-width: 0; position: relative;
}
.kpi-top { display: flex; align-items: center; gap: .45rem; }
.kpi-top .icon { color: var(--muted); }
.kpi-label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; color: var(--text-strong); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-value.is-text { font-size: 1.15rem; padding-top: .3rem; }
.kpi-sub { font-size: var(--fs-xs); color: var(--muted); display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.kpi-bar { height: 3px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-top: .2rem; }
.kpi-bar > span { display: block; height: 100%; border-radius: 3px; }
.kpi.tone-positif .kpi-top .icon { color: var(--positif); }
.kpi.tone-negatif .kpi-top .icon { color: var(--negatif); }
.kpi.tone-netral .kpi-top .icon { color: var(--netral); }
.kpi.tone-accent .kpi-top .icon { color: var(--accent); }

.delta { display: inline-flex; align-items: center; gap: .2rem; font-weight: 700; font-size: var(--fs-xs); border-radius: var(--radius-pill); padding: .05rem .45rem; }
.delta.is-good { background: var(--positif-soft); color: var(--positif-text); }
.delta.is-bad  { background: var(--negatif-soft); color: var(--negatif-text); }
.delta.is-flat { background: var(--netral-soft);  color: var(--netral-text); }

.banner {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;
  border-radius: var(--radius); border: 1px solid var(--border);
  padding: 1rem 1.15rem; background: var(--surface);
  border-left-width: 4px;
}
.banner-icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; display: grid; place-items: center; }
.banner-body { flex: 1 1 320px; min-width: 0; }
.banner-body strong { display: block; color: var(--text-strong); font-size: var(--fs-md); }
.banner-body span { color: var(--muted); font-size: var(--fs-sm); }
.banner.is-ok     { border-left-color: var(--positif); }
.banner.is-ok .banner-icon { background: var(--positif-soft); color: var(--positif); }
.banner.is-warn   { border-left-color: var(--warn); }
.banner.is-warn .banner-icon { background: var(--warn-soft); color: var(--warn); }
.banner.is-danger { border-left-color: var(--negatif); }
.banner.is-danger .banner-icon { background: var(--negatif-soft); color: var(--negatif); }
.banner.is-info   { border-left-color: var(--accent); }
.banner.is-info .banner-icon { background: var(--accent-soft); color: var(--accent); }

.alert {
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: .7rem .85rem; font-size: var(--fs-sm);
  display: flex; gap: .6rem; align-items: flex-start; background: var(--surface-2);
}
.alert .icon { margin-top: 1px; }
.alert-info    { background: var(--accent-soft);  border-color: var(--accent-ring); }
.alert-info .icon { color: var(--accent); }
.alert-ok      { background: var(--positif-soft); border-color: rgba(47, 179, 90, .35); }
.alert-ok .icon { color: var(--positif); }
.alert-warning { background: var(--warn-soft);    border-color: rgba(224, 164, 58, .4); }
.alert-warning .icon { color: var(--warn); }
.alert-danger  { background: var(--negatif-soft); border-color: rgba(236, 77, 77, .4); }
.alert-danger .icon { color: var(--negatif); }
.alert code, .code {
  font-family: var(--font-num); font-size: .8em; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: 5px; padding: .05rem .35rem; word-break: break-all;
}
pre.code { display: block; padding: .6rem .75rem; white-space: pre-wrap; margin: .4rem 0 0; }

/* ── 9. Badge & tabel ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: var(--radius-pill); padding: .1rem .55rem;
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
  border: 1px solid transparent; line-height: 1.5;
}
.badge-positif { background: var(--positif-soft); color: var(--positif-text); }
.badge-negatif { background: var(--negatif-soft); color: var(--negatif-text); }
.badge-netral  { background: var(--netral-soft);  color: var(--netral-text); }
.badge-info    { background: var(--accent-soft);  color: var(--accent); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn-text); }
.badge-crit    { background: var(--negatif-soft); color: var(--negatif-text); }
.badge-outline { border-color: var(--border); color: var(--muted); }
.risk-tinggi { background: var(--negatif); color: #fff; }
.risk-sedang { background: var(--warn-soft); color: var(--warn-text); }
.risk-rendah { background: var(--netral-soft); color: var(--netral-text); }

.table-tools { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.data thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-num); white-space: nowrap; }
table.data tr.is-clickable { cursor: pointer; }
table.data.is-compact th, table.data.is-compact td { padding: .5rem .5rem; }
.kw-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: .25rem; }
table.data.is-compact .cell-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: .15rem; }

/* ── 10. Chart & daftar ────────────────────────────────────────────────────── */
.chart { width: 100%; min-height: 280px; }
.chart-sm { min-height: 240px; }
.chart-note { font-size: var(--fs-xs); color: var(--muted); margin: 0 0 .5rem; }
.chart-fallback { max-height: 360px; overflow: auto; }
/* Grafik dengan aksi klik (mis. treemap media): tunjukkan kursor pointer. */
.chart-clickable, .chart-clickable .slice { cursor: pointer; }

/* max-width + overflow-x: pilihan yang banyak (Semua/Tinggi/Sedang/…) bisa digulir, tidak melebarkan kartu di HP 320px. */
.segmented {
  display: inline-flex; max-width: 100%; overflow-x: auto; scrollbar-width: none;
  border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--surface-2);
}
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  flex: 0 0 auto;
  border: 0; background: transparent; color: var(--muted);
  padding: .35rem .8rem; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text-strong); box-shadow: inset 0 0 0 1px var(--border); border-radius: var(--radius-pill); }

.pill-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-pill); padding: .25rem .7rem; font-size: var(--fs-sm); cursor: pointer; color: var(--text);
}
.pill:hover { border-color: var(--accent-ring); }
.pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--text-strong); }
.pill .count { font-family: var(--font-num); font-size: var(--fs-xs); color: var(--muted); }

.rank-list { display: grid; gap: .55rem; }
.rank-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .75rem; align-items: center; font-size: var(--fs-sm); }
.rank-item .rank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item .rank-val { font-family: var(--font-num); color: var(--muted); font-size: var(--fs-xs); }
.stackbar { grid-column: 1 / -1; display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: var(--surface-3); }
.stackbar > span { display: block; height: 100%; }
.stackbar .s-positif { background: var(--positif); }
.stackbar .s-netral  { background: var(--netral); opacity: .7; }
.stackbar .s-negatif { background: var(--negatif); }

.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }

.empty {
  text-align: center; padding: 2rem 1rem; color: var(--muted);
  display: grid; justify-items: center; gap: .4rem;
}
.empty .empty-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.empty h3 { margin: .3rem 0 0; }
.empty p { max-width: 560px; margin: 0; font-size: var(--fs-sm); }
.diag { display: grid; gap: .3rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .7rem .85rem; font-size: var(--fs-sm); text-align: left; width: min(560px, 100%); }
.diag-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.diag-key { color: var(--muted); min-width: 140px; }
.diag-val { font-family: var(--font-num); color: var(--text); }

/* ── 11. Artikel & drawer ──────────────────────────────────────────────────── */
.article-list { display: grid; }
.article-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .35rem 1rem;
  padding: .95rem 1.1rem; border-bottom: 1px solid var(--border-soft);
  cursor: pointer; transition: background .12s;
}
.article-item:last-child { border-bottom: 0; }
.article-item:hover { background: var(--surface-2); }
.article-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.article-title { font-weight: 600; color: var(--text-strong); line-height: 1.35; }
/* Teks dari luar (judul berita, jawaban AI, URL) tanpa spasi tidak boleh mendorong layout melewati layar. */
.article-title, .article-reason, .article-meta, .msg-bubble, .rec-body, .quote, .ai-box, .alert, .banner-body,
.drawer-head h2, .card-head p, .page-head p, .kpi-sub { overflow-wrap: anywhere; }
.article-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: var(--fs-xs); color: var(--muted); align-items: center; }
.article-meta span { display: inline-flex; align-items: center; gap: .3rem; }
.article-meta .icon { width: 13px; height: 13px; }
.article-reason { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--text); opacity: .9; display: flex; gap: .45rem; }
.article-reason .icon { color: var(--accent); margin-top: 2px; }
.article-side { display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.list-more { padding: .8rem 1.1rem; border-top: 1px solid var(--border-soft); display: flex; justify-content: center; }

.drawer-host { position: fixed; inset: 0; z-index: 100; }
.drawer-host .backdrop { z-index: 0; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(620px, 100%);
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slide .2s ease-out;
}
@keyframes slide { from { transform: translateX(24px); opacity: .4; } }
.drawer-head { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 1.05rem; line-height: 1.35; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 1.1rem 1.2rem 2rem; display: grid; gap: 1.1rem; align-content: start; }
.section-title { font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 .45rem; display: flex; align-items: center; gap: .4rem; }
.quote { border-left: 3px solid var(--border); padding: .2rem 0 .2rem .85rem; color: var(--text); font-size: var(--fs-sm); }
.ai-box { border: 1px solid var(--accent-ring); background: var(--accent-soft); border-radius: var(--radius-sm); padding: .8rem .9rem; font-size: var(--fs-sm); }
.ai-box.is-negative { border-color: rgba(236, 77, 77, .35); background: var(--negatif-soft); }
.ai-box ul { margin: .35rem 0 0; padding-left: 1.1rem; }
.ai-box li { margin-bottom: .2rem; }
.rec-list { display: grid; gap: .6rem; }
.rec {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .85rem;
  background: var(--surface-2); display: grid; gap: .35rem; font-size: var(--fs-sm);
}
.rec-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--muted); }
.rec-head strong { color: var(--text-strong); font-size: var(--fs-sm); }
.rec-body { white-space: pre-wrap; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; }
.meta-grid div { display: grid; gap: .1rem; font-size: var(--fs-sm); }
.meta-grid dt, .meta-grid .k { font-size: var(--fs-xs); color: var(--muted); }

.alert-card { display: grid; gap: .7rem; }
.alert-card + .alert-card { border-top: 1px solid var(--border-soft); padding-top: 1rem; }
.alert-card-head { display: flex; gap: .75rem; align-items: flex-start; }
.alert-card-head .article-title { flex: 1 1 auto; }

/* ── 12. Chat ──────────────────────────────────────────────────────────────── */
.chat {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100dvh - var(--topbar-h) - 190px); min-height: 460px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.chat-head { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-log {
  overflow-y: auto; padding: 1.1rem; display: grid; gap: 1rem; align-content: start;
  grid-template-columns: minmax(0, 1fr);         /* balon dengan teks/URL panjang tidak melebarkan log */
  overscroll-behavior: contain;                  /* gulir di dalam log tidak "menembus" ke halaman */
}
.chat-wait { display: block; margin-top: .45rem; }
.msg { display: flex; gap: .65rem; max-width: 880px; }
.msg-user { margin-left: auto; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.msg-bot .msg-avatar { background: var(--accent-soft); color: var(--accent); }
.msg-bubble { padding: .7rem .9rem; border-radius: 14px; font-size: var(--fs-sm); line-height: 1.55; min-width: 0; }
.msg-user .msg-bubble { background: var(--accent); color: var(--on-accent); border-top-right-radius: 4px; }
.msg-bot .msg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg-bubble p { margin: 0 0 .5rem; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { margin: .2rem 0 .5rem; padding-left: 1.2rem; }
.msg-sources { margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--border-soft); display: grid; gap: .3rem; font-size: var(--fs-xs); }
.msg-sources a { display: inline-flex; gap: .35rem; align-items: baseline; }
.msg-sources .src-n { font-family: var(--font-num); color: var(--muted); }
.chat-input { display: flex; gap: .5rem; padding: .75rem; border-top: 1px solid var(--border); align-items: flex-end; }
.chat-input textarea { min-height: 44px; max-height: 160px; resize: none; }
.chat-suggest { display: flex; flex-wrap: wrap; gap: .45rem; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ── 13. Tab, keyword, alur proses ─────────────────────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .65rem .9rem; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text-strong); border-bottom-color: var(--accent); }
.tab[aria-selected="true"] .icon { color: var(--accent); }
.settings { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.settings-nav { display: grid; gap: .15rem; position: sticky; top: calc(var(--topbar-h) + 1rem); }
.settings-nav .tab { border: 0; border-radius: var(--radius-sm); margin: 0; justify-content: flex-start; padding: .6rem .75rem; }
.settings-nav .tab[aria-selected="true"] { background: var(--accent-soft); }
.profile-hero { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: .55rem 1rem; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.quota { display: grid; gap: .4rem; }
.quota-bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.quota-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 8px; }
.quota-bar.is-full > span { background: var(--warn); }

.kw-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem;
  background: var(--surface); display: grid; gap: .55rem; position: relative;
}
.kw-card.is-current { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kw-card-head { display: flex; align-items: flex-start; gap: .5rem; }
.kw-card-head strong { color: var(--text-strong); font-size: 1rem; }
.kw-card .kw-count { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.kw-slot-empty { border-style: dashed; color: var(--muted); display: grid; place-items: center; text-align: center; min-height: 150px; font-size: var(--fs-sm); }

.flow { display: grid; gap: 1rem; }
.flow-lane { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1rem; background: var(--surface); }
.flow-lane-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin-bottom: .75rem; }
.flow-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.flow-step {
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  padding: .8rem .85rem; display: grid; gap: .3rem; position: relative;
}
.flow-step-head { display: flex; align-items: center; gap: .45rem; font-weight: 700; font-size: var(--fs-sm); color: var(--text-strong); }
.flow-step-head .icon { color: var(--accent); }
.flow-step .big { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-strong); }
.flow-step .sub { font-size: var(--fs-xs); color: var(--muted); }
.flow-step.is-warn { border-color: rgba(224, 164, 58, .5); }
.flow-step.is-bad { border-color: rgba(236, 77, 77, .5); }

/* ── 14. Toast, modal, skeleton, bottom nav ────────────────────────────────── */
.toast-host { position: fixed; z-index: 130; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm); padding: .7rem .85rem; box-shadow: var(--shadow);
  font-size: var(--fs-sm); animation: pop .18s ease-out;
}
.toast.is-ok    { border-left-color: var(--positif); }
.toast.is-warn  { border-left-color: var(--warn); }
.toast.is-error { border-left-color: var(--negatif); }
.toast strong { display: block; margin-bottom: .15rem; color: var(--text-strong); }

.modal-host { position: fixed; inset: 0; z-index: 120; background: var(--backdrop); display: grid; place-items: center; padding: 1rem; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); width: min(520px, 100%); max-height: 88vh; max-height: 88dvh; overflow: auto; padding: 1.15rem;
  animation: pop .15s ease-out;
}
.modal-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .7rem; }
.modal-head h2 { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite linear; border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 14px; margin-bottom: .5rem; }
.sk-block { height: 280px; }

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
  display: none;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: .25rem .35rem calc(.25rem + env(safe-area-inset-bottom));
}
.bottomnav-item {
  flex: 1 1 0; position: relative;
  display: grid; place-items: center; gap: .1rem;
  padding: .35rem .2rem; min-height: 52px;
  border: 0; background: transparent; color: var(--muted);
  border-radius: var(--radius-sm);
  font-size: .6875rem; font-weight: 600; cursor: pointer;
}
.bottomnav-item[aria-current="page"] { color: var(--accent); }
.bottomnav-item .nav-badge { position: absolute; top: 2px; right: 18%; margin: 0; min-width: 16px; line-height: 16px; font-size: .625rem; }

/* ── 15. Responsif ─────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .grid-2, .grid-wide { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; }
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }

  .app-shell, .app-shell.is-collapsed { grid-template-columns: minmax(0, 1fr); }
  /* Sidebar menjadi laci (drawer) yang dibuka tombol ☰ */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; height: auto;
    width: min(84vw, 300px);
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: var(--shadow);
    z-index: 60;
    padding-top: calc(.9rem + env(safe-area-inset-top, 0px));
    padding-left: calc(.75rem + env(safe-area-inset-left, 0px));
  }
  .app-shell.is-drawer-open .sidebar { transform: translateX(0); }
  /* Di mobile, rail tidak dipakai: tampilkan label lengkap di laci */
  .app-shell.is-collapsed .brand-text,
  .app-shell.is-collapsed .nav-label,
  .app-shell.is-collapsed .nav-section,
  .app-shell.is-collapsed .db-text,
  .app-shell.is-collapsed .foot-text { display: initial; }
  .app-shell.is-collapsed .nav-item { justify-content: flex-start; padding-inline: .7rem; }
  .app-shell.is-collapsed .sidebar-head { justify-content: flex-start; }
  .app-shell.is-collapsed .nav-badge { position: static; }

  .bottomnav { display: flex; }
  .content { padding-bottom: calc(var(--bottomnav-h) + 1.5rem); }
  .content-foot { padding-bottom: calc(var(--bottomnav-h) + 1.5rem); }
  .toast-host { bottom: calc(var(--bottomnav-h) + .75rem); }

  .topbar { gap: .5rem; padding-inline: .75rem; }
  .profile-text { display: none; }
  .profile-btn { padding-right: .3rem; }
  .hide-sm { display: none !important; }

  .filterbar { position: static; padding: .5rem .75rem; }
  .filter-toggle { display: flex; width: 100%; justify-content: flex-start; }
  .filter-toggle .icon:last-child { margin-left: auto; }
  .filter-fields { display: none; margin-top: .6rem; }
  .filterbar.is-open .filter-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .filter-group { min-width: 0; }
  .filter-group.is-wide, .filterbar .btn-reset { grid-column: 1 / -1; }
  #keyword-select { min-width: 0; }
  .picker { min-width: 0; }

  .kv { grid-template-columns: minmax(0, 1fr); gap: .1rem; }
  .kv dd { margin-bottom: .5rem; }
  .article-item { grid-template-columns: minmax(0, 1fr); }
  .article-side { flex-direction: row; align-items: center; justify-content: flex-start; flex-wrap: wrap; }
  table.data .hide-sm-col { display: none; }

  /* Asisten AI di HP: judul halaman sudah ada di topbar, jadi kepala halaman disembunyikan dan kotak chat
     diukur persis sebesar sisa layar (topbar + filter + navigasi bawah). Kolom ketik harus selalu terlihat
     tanpa menggulung halaman. `svh` (tinggi layar saat bilah alamat Safari tampil) dipakai agar ukuran
     tidak berubah-ubah saat bilah alamat naik-turun ketika menggulir. */
  .chat-page-head { display: none; }
  .chat {
    height: calc(100vh - var(--topbar-h) - env(safe-area-inset-top, 0px) - 5.6rem - var(--bottomnav-h));
    height: calc(100svh - var(--topbar-h) - env(safe-area-inset-top, 0px) - 5.6rem - var(--bottomnav-h));
    min-height: 300px;
  }
  .chat-head { padding: .6rem .75rem; }
  .chat-log { padding: .8rem; }
  .chat-input { padding: .6rem; }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .kpi { padding: .8rem; }
  .kpi-value { font-size: 1.4rem; }
  .grid-3, .grid-auto { grid-template-columns: minmax(0, 1fr); }
  .filterbar.is-open .filter-fields { grid-template-columns: minmax(0, 1fr); }
  .page-head .page-actions { margin-left: 0; }
  .drawer-head, .drawer-body { padding-inline: 1rem; }
  .topbar-title p { display: none; }
}

/* iOS Safari memperbesar (zoom) seluruh halaman setiap kali kolom isian berfont < 16px diketuk, lalu tidak
   kembali sendiri — layar jadi "bergeser" dan tidak pas lagi. Di layar sentuh/HP kolom isian dibuat 16px. */
@media (max-width: 900px), (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea,
  .input, .filter-group .input, .picker-search {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
