:root {
  --teal-900: #0B4A40;
  --teal-700: #0F6B5C;
  --teal-500: #16876F;
  --amber-500: #E8A33D;
  --amber-600: #CC8A28;
  --paper: #F7F5F0;
  --card: #FFFFFF;
  --ink: #1D2A26;
  --ink-soft: #5B6B65;
  --line: #E4E1D8;
  --danger: #C0392B;
  --success: #2F855A;
  --radius: 10px;
  --font-display: "Poppins", sans-serif;
  --font-body: "Inter", system-ui, sans-serif;
  --base-font-size: 16px;
}

/* Tema gelap - diaktifkan lewat [data-theme="dark"] pada <html> */
html[data-theme="dark"] {
  --teal-900: #0A2E28;
  --teal-700: #14806D;
  --teal-500: #1FA085;
  --paper: #101815;
  --card: #1A2521;
  --ink: #EDEFEC;
  --ink-soft: #9AA8A2;
  --line: #2C3833;
}

html { font-size: var(--base-font-size); }
html[data-font-size="small"] { --base-font-size: 14px; }
html[data-font-size="medium"] { --base-font-size: 16px; }
html[data-font-size="large"] { --base-font-size: 18px; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); color: var(--teal-900); margin: 0; }

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, var(--teal-700), var(--teal-900));
  padding: 24px;
}
.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(11,74,64,0.35);
}
.login-mark {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--amber-500); color: var(--teal-900);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 24px;
  margin: 0 auto 16px;
}
.login-logo { max-width: 120px; max-height: 80px; margin: 0 auto 16px; display: block; object-fit: contain; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.tagline { font-size: 14px; font-weight: 600; color: var(--teal-700); margin: 0 0 10px; }
.muted { color: var(--ink-soft); font-size: 14px; margin: 0 0 20px; }
.login-card input {
  width: 100%; padding: 14px; margin-bottom: 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 20px; text-align: center; letter-spacing: 4px;
}
.link-button {
  border: none; background: transparent; color: var(--teal-700); font-weight: 600;
  font-size: 13px; margin-top: 6px; text-decoration: underline;
}
.recovery-reveal {
  margin-top: 14px; padding: 14px; border-radius: var(--radius);
  background: #FDF1DC; border: 1px solid var(--amber-500);
}
html[data-theme="dark"] .recovery-reveal { background: #3A2C12; }
.recovery-code {
  font-family: monospace; font-size: 20px; font-weight: 700; letter-spacing: 2px;
  color: var(--teal-900); text-align: center; padding: 10px; margin-bottom: 10px;
  background: var(--card); border-radius: 6px;
}

/* ---------- App shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: var(--teal-900); color: var(--header-text-color, white);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--amber-500);
  color: var(--teal-900); display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700;
}
.brand-logo { height: 32px; max-width: 140px; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--header-text-color, white); }
.brand-tagline { font-size: 11px; color: var(--header-text-color, white); opacity: 0.75; font-weight: 500; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.btn.icon-only { padding: 8px 12px; font-size: 16px; line-height: 1; }
.badge {
  background: rgba(255,255,255,0.15); color: white; padding: 4px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: 0.5px;
}

.tabs {
  display: flex; gap: 4px; padding: 8px 16px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 58px; z-index: 9;
  overflow-x: auto;
}
.tab {
  border: none; background: transparent; padding: 10px 16px; border-radius: 999px;
  font-weight: 600; color: var(--ink-soft); white-space: nowrap;
}
.tab.active { background: var(--teal-700); color: white; }

.app-main { flex: 1; max-width: 980px; width: 100%; margin: 0 auto; padding: 20px; }

.app-footer {
  text-align: center; padding: 16px; font-size: 12px; color: var(--footer-text-color, var(--ink-soft));
  border-top: 1px solid var(--line);
}

.checkbox-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-label input { width: auto; }

.page { display: none; }
.page.active { display: block; }

/* ---------- Cards & forms ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; margin-bottom: 18px;
}
.section-title { font-size: 16px; margin: 18px 0 10px; }
.section-title:first-child { margin-top: 0; }

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 6px;
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.form-grid .span-2 { grid-column: span 2; }
input, select {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 14px; color: var(--ink); background: white;
}
input:focus, select:focus { outline: 2px solid var(--amber-500); outline-offset: 1px; }

.item-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: #FCFBF8;
}
.item-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.item-title { font-weight: 700; color: var(--teal-700); font-size: 14px; }
.item-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.item-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-soft); font-weight: 600; }
.item-name, .item-description { grid-column: span 2; }

.hint { font-size: 12px; color: var(--ink-soft); margin: 6px 0 0; }

.form-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; gap: 10px; }
.total-line { font-size: 15px; color: var(--ink-soft); }
.total-line strong { color: var(--teal-900); font-size: 18px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.inline-form input, .inline-form select { flex: 1; min-width: 120px; }

/* ---------- Buttons ---------- */
.btn {
  border: none; border-radius: 999px; padding: 12px 22px; font-weight: 700; font-size: 14px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.btn.small { padding: 8px 16px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.primary { background: var(--teal-700); color: white; }
.btn.primary:hover { background: var(--teal-500); }
.btn.secondary { background: var(--amber-500); color: var(--teal-900); }
.btn.secondary:hover { background: var(--amber-600); }
.btn.ghost { background: transparent; color: var(--teal-700); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--teal-500); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #F1D4D0; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---------- Report ---------- */
.filter-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.metric-card span { display: block; font-size: 12px; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; }
.metric-card strong { font-size: 20px; color: var(--teal-900); }

.bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-track { background: #EFECE3; border-radius: 999px; height: 8px; overflow: hidden; margin-bottom: 12px; }
.bar-fill { background: linear-gradient(90deg, var(--teal-700), var(--amber-500)); height: 100%; border-radius: 999px; }

.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #FCFBF8; color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
html[data-theme="dark"] th { background: #16211D; }
.empty-cell { text-align: center; color: var(--ink-soft); padding: 30px; }
.row-actions { display: flex; gap: 6px; }
#reportStatus { padding: 10px 14px; }

.status-badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.status-badge.edited { background: #FDF1DC; color: var(--amber-600); }
.status-badge.original { background: #EFF6F3; color: var(--teal-700); }
html[data-theme="dark"] .status-badge.edited { background: #3A2C12; color: var(--amber-500); }
html[data-theme="dark"] .status-badge.original { background: #12241D; color: var(--teal-500); }

.pagination-bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--line);
}
.page-size-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.page-size-label select { padding: 6px 10px; }
.pagination-controls { display: flex; align-items: center; gap: 10px; }
.page-indicator { font-size: 13px; color: var(--ink-soft); font-weight: 600; white-space: nowrap; }

.detail-body dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; }
.detail-body dt { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.detail-body dd { margin: 0; font-size: 14px; }

/* ---------- Settings ---------- */
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.chip {
  display: flex; align-items: center; gap: 6px; background: #EFF6F3; color: var(--teal-700);
  border-radius: 999px; padding: 6px 10px 6px 14px; font-size: 13px; font-weight: 600;
}
.chip button { border: none; background: transparent; color: var(--danger); font-size: 14px; line-height: 1; padding: 2px; }
.reference-manager { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.reference-group h3 { font-size: 13px; margin-bottom: 8px; color: var(--ink-soft); }

.list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.list-row { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.list-row .name { font-weight: 600; }
.list-row .role { font-size: 12px; color: var(--ink-soft); margin-left: 8px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(11,74,64,0.5); display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal.show { display: flex; }
.modal-dialog { background: white; border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-footer { margin-top: 16px; }
.icon-button { border: none; background: transparent; font-size: 22px; color: var(--ink-soft); }

/* ---------- Status & toast ---------- */
.status { font-size: 13px; margin-top: 10px; min-height: 16px; }
.status.error { color: var(--danger); }
.status.success { color: var(--success); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--teal-900); color: white; padding: 12px 20px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

@media (max-width: 640px) {
  .app-main { padding: 14px; }
  .item-name, .item-description { grid-column: span 1; }
}

/* ---------- Dark mode overrides untuk warna yang tidak lewat CSS variable ---------- */
html[data-theme="dark"] .item-card { background: #141F1B; }
html[data-theme="dark"] .btn.danger { border-color: #4A2A24; }
html[data-theme="dark"] .bar-track { background: #22302B; }
html[data-theme="dark"] .chip { background: #12241D; }
html[data-theme="dark"] .login-card { background: var(--card); }
html[data-theme="dark"] input, html[data-theme="dark"] select { background: #141F1B; color: var(--ink); border-color: var(--line); }
html[data-theme="dark"] .modal-dialog { background: var(--card); }
