:root {
  --ink: #1c1410;
  --ink-dark: #0f0a08;
  --accent: #c2650a;
  --accent-dark: #9c4f08;
  --gold: #d9a441;
  --gold-dark: #b8842f;
  --bg: #f7f4ef;
  --card: #ffffff;
  --border: #e6ddd0;
  --text: #241a12;
  --muted: #7a6c5d;
  --danger: #c0392b;
  --warn: #b8860b;
  --ok: #1e7d32;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

/* LOGIN */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink); padding: 40px 16px;
}
.login-box { background: var(--card); padding: 0 0 30px; border-radius: 14px; width: 400px; max-width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,0.4); overflow: hidden; }
.login-back {
  display: block; width: 100%; padding: 12px; background: var(--accent); color: #fff; text-align: center;
  text-decoration: none; font-weight: 600; font-size: 14px; box-sizing: border-box;
}
.login-back:hover { background: var(--accent-dark); }
.login-box-inner { padding: 26px 32px 0; }
.login-box h1 { margin: 0 0 4px; font-size: 22px; color: var(--ink); text-align: center; }
.login-box .subtitle { margin: 0 0 20px; color: var(--muted); font-size: 13px; text-align: center; }
.login-box label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.login-box input { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-box input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(217,164,65,0.18); }
.login-box button {
  margin-top: 18px; width: 100%; padding: 11px; color: #fff; border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; letter-spacing: 0.01em;
  background: var(--accent); box-shadow: 0 6px 16px rgba(194,101,10,0.3); transition: filter 0.15s ease;
}
.login-box button:hover { filter: brightness(1.08); }
.login-box .hint { font-size: 12px; color: var(--muted); margin-top: 14px; text-align: center; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

.demo-accounts { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-accounts p { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.demo-accounts table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.demo-accounts td { padding: 6px 4px; border-bottom: 1px solid var(--border); cursor: pointer; }
.demo-accounts tr:last-child td { border-bottom: none; }
.demo-accounts tr:hover td { background: #faf3e8; }
.demo-accounts td:first-child { color: var(--accent); font-weight: 600; }
.demo-accounts code { background: transparent; color: var(--muted); font-size: 12px; padding: 0; }

/* APP */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 20px; background: var(--ink); color: #fff; padding: 10px 20px; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: baseline; gap: 10px; flex-shrink: 0; }
.brand-sub { font-weight: 400; font-size: 12px; color: #cbb89a; }
.topbar-search { flex: 1; min-width: 160px; max-width: 420px; }
.topbar-search input {
  width: 100%; padding: 8px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08); color: #fff; font-size: 13px;
}
.topbar-search input::placeholder { color: #b8ab98; }
.topbar-search input:focus { outline: none; background: rgba(255,255,255,0.14); border-color: var(--gold); }
.topbar-datetime { font-size: 12.5px; color: #cbb89a; white-space: nowrap; margin-left: auto; }
.topbar-bell { position: relative; background: none; border: none; color: #fff; font-size: 17px; cursor: pointer; padding: 2px 4px; }
.topbar-bell .bell-count {
  position: absolute; top: -4px; right: -4px; background: var(--gold); color: var(--ink-dark);
  font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 5px; min-width: 15px; text-align: center;
}
.user-box { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.link-btn { background: none; border: none; color: #fff; text-decoration: underline; cursor: pointer; font-size: 13px; padding: 0; }
.ai-badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: #3a2f27; color: #d8cabb; }
.ai-badge.on { background: #14532d; color: #86efac; }
.ai-badge.off { background: #3f3f46; color: #d4d4d8; }

.app-layout { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 230px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border);
  padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column;
}
.sidebar-links { flex: 1; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.sidebar-foot .side-link { color: var(--muted); font-size: 13px; }
.sidebar-foot .side-link:hover { color: var(--accent); background: #faf3e8; }
.side-module { margin-top: 2px; }
.side-module-title {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  font-size: 13.5px; color: var(--text); font-weight: 700; background: transparent;
  padding: 10px 12px; border: none; border-radius: 8px; cursor: pointer;
}
.side-module-title .chevron { transition: transform 0.2s ease; font-size: 11px; color: var(--muted); }
.side-module.collapsed .side-module-title .chevron { transform: rotate(-90deg); }
.side-module-title:hover { background: #faf3e8; }

.side-module-links {
  overflow: hidden; max-height: 500px; transition: max-height 0.25s ease, opacity 0.2s ease;
  opacity: 1; padding-top: 4px;
}
.side-module.collapsed .side-module-links { max-height: 0; opacity: 0; padding-top: 0; }

.side-link {
  display: block; width: 100%; text-align: left; background: transparent; border: none;
  color: var(--text); padding: 9px 10px 9px 18px; border-radius: 6px; cursor: pointer; font-size: 13.5px;
  margin-bottom: 2px;
}
.side-link:hover { background: #faf3e8; }
.side-link.active { background: var(--accent); color: #fff; font-weight: 600; }

.content { flex: 1; padding: 20px; overflow-y: auto; min-width: 0; }
.tab-panel h2 { margin-top: 0; }
.muted-note { color: var(--muted); font-size: 13px; line-height: 1.55; max-width: 900px; }
.inline-label { font-size: 13px; color: var(--muted); }
.wajib { color: var(--danger); font-size: 11px; }

@media (max-width: 800px) {
  .app-layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 4px; }
  .side-module { margin-top: 8px; width: 100%; }
}

/* KARTU */
.cards { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; min-width: 165px; flex: 1; }
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 21px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.card.danger { border-left: 4px solid var(--danger); }
.card.highlight { border-left: 4px solid var(--ok); background: #f4fbf5; }
.card.highlight .value { color: var(--ok); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.card-box { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 20px; }
.card-box.narrow { max-width: 620px; }
.card-box h3 { margin-top: 0; }
.card-box label { display: block; margin: 6px 0 4px; font-size: 12.5px; color: var(--muted); }
.card-box input, .card-box select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.card-box button, .primary-btn { margin-top: 14px; padding: 9px 18px; background: var(--accent); color: #fff; border: none; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; transition: filter 0.15s ease; }
.card-box button:hover, .primary-btn:hover { filter: brightness(1.1); }
.card-box button.small-btn { background: #fff; color: var(--text); }

.input-with-btn { display: flex; gap: 6px; align-items: stretch; }
.input-with-btn input { flex: 1; }
.input-with-btn .small-btn { margin-top: 0; white-space: nowrap; }

.msg { min-height: 18px; font-size: 13px; margin-bottom: 0; }
.msg.ok { color: var(--ok); }
.msg.error { color: var(--danger); }

.filter-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filter-row input, .filter-row select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; }
.filter-row button { padding: 7px 16px; background: var(--accent); color: #fff; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.filter-row button.small-btn { background: #fff; color: var(--text); border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 20px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #eef4f6; color: var(--ink); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; }

.small-btn { padding: 4px 8px; font-size: 12px; border: 1px solid var(--border); background: #fff; border-radius: 5px; cursor: pointer; }
.small-btn:hover { background: #f1f1f1; }

/* PIL STATUS & LEVEL */
.pill { padding: 3px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.pill-kritis { background: #fbe4e1; color: var(--danger); }
.pill-tinggi { background: #fdeadb; color: #b45309; }
.pill-sedang, .pill-perhatian { background: #fdf4d6; color: var(--warn); }
.pill-rendah, .pill-wajar, .pill-ok { background: #e2f3e4; color: var(--ok); }
.pill-netral { background: #eceff1; color: var(--muted); }

/* TEMUAN AI */
.insight { background: var(--card); border: 1px solid var(--border); border-left: 4px solid var(--muted); border-radius: 8px; padding: 12px 16px; margin-bottom: 10px; }
.insight.kritis { border-left-color: var(--danger); }
.insight.tinggi { border-left-color: #d97706; }
.insight.perhatian, .insight.sedang { border-left-color: var(--warn); }
.insight-head { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.insight-judul { font-weight: 600; font-size: 14px; }
.insight-nilai { font-weight: 700; color: var(--danger); white-space: nowrap; font-size: 14px; }
.insight-detail { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.insight-tindakan { font-size: 12.5px; margin-top: 6px; }
.insight-modul { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

.preview-box { background: #f6fafb; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 14px; margin-top: 12px; font-size: 13px; line-height: 1.6; }
.preview-box:empty { display: none; }
.preview-box strong { color: var(--ink); }

.ai-output { margin-top: 14px; background: #f8fafb; border: 1px solid var(--border); border-radius: 8px; padding: 14px 18px; font-size: 13.5px; line-height: 1.65; white-space: pre-wrap; }
.ai-output:empty { display: none; }
.ai-sumber { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; display: block; }

/* BAR SEDERHANA */
.bar-row { margin-bottom: 10px; }
.bar-label { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 3px; }
.bar-track { height: 16px; background: #eceff1; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); }
.bar-fill.danger { background: var(--danger); }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 130px; padding-top: 10px; }
.chart-bar { flex: 1; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 2px; }
.chart-bar:hover { background: var(--accent-dark); }

/* MODAL */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 10px; padding: 24px; width: 340px; }
.modal-box h3 { margin-top: 0; }
.modal-box label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.modal-box input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.modal-actions button { padding: 8px 18px; border-radius: 10px; cursor: pointer; border: none; background: var(--accent); color: #fff; font-weight: 600; }
.modal-actions .small-btn { background: #fff; color: var(--text); border: 1px solid var(--border); }
.pill-data-kurang { background: #eceff1; color: var(--muted); }

.ref-inline { width: 100%; min-width: 140px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 13px; }
.ref-inline:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
code { background: #eef4f6; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* MODE GELAP */
body.dark-mode {
  --bg: #1a1512;
  --card: #241d18;
  --border: #3a2f27;
  --text: #ece5db;
  --muted: #a89985;
}
body.dark-mode .sidebar { background: var(--card); }
body.dark-mode th { background: #2c241d; color: #ece5db; }
body.dark-mode .preview-box, body.dark-mode .ai-output { background: #2c241d; }
body.dark-mode code { background: #2c241d; }

/* PANDUAN & ALUR KERJA */
.panduan-list { margin: 0; padding-left: 20px; line-height: 1.7; font-size: 13.5px; }
.panduan-list li { margin-bottom: 10px; }
.panduan-list li:last-child { margin-bottom: 0; }

/* TOOLTIP */
.tip-icon {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 999px; background: var(--border); color: var(--muted); font-size: 12px; font-weight: 700;
  cursor: help; margin-left: 8px; vertical-align: middle; position: relative;
}
.tip-icon::after {
  content: attr(data-tip);
  position: absolute; left: 50%; top: 130%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 400; line-height: 1.5;
  padding: 8px 12px; border-radius: 8px; width: 260px; text-align: left;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25); z-index: 40;
  opacity: 0; visibility: hidden; transition: opacity 0.15s ease;
  pointer-events: none;
}
.tip-icon:hover::after, .tip-icon:focus::after { opacity: 1; visibility: visible; }
@media (max-width: 700px) {
  .tip-icon::after { left: 0; transform: none; width: 220px; }
}
