:root {
  --primary: #0f766e;
  --primary-dark: #0d5e58;
  --primary-light: #ccfbf1;
  --ink: #0f172a;
  --muted: #475569;
  --muted-light: #64748b;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --good: #15803d;
  --bad: #b91c1c;
  --accent: #b45309;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 8px 30px rgba(15, 23, 42, 0.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
  line-height: 1.6;
  overflow: hidden;
}

.app { display: flex; height: 100vh; }
.hidden { display: none !important; }

/* ——— SIDEBAR ——— */
.sidebar {
  width: 264px; flex: none;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  display: flex; flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 3px; }

.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 22px; border-bottom: 1px solid rgba(255,255,255,.10); margin-bottom: 18px; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  font-weight: 800; font-size: 22px; color: #fff;
  flex-shrink: 0;
}
.brand-name { font-size: 18px; color: #fff; font-weight: 700; letter-spacing: -.01em; }
.brand-name b { color: #5eead4; }
.brand-sub { font-size: 12px; color: #94a3b8; margin-top: 2px; letter-spacing: .02em; }

.side-nav { display: grid; gap: 6px; }
.side-nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 13px 14px;
  background: transparent; border: none; border-radius: 12px;
  color: #cbd5e1; font-size: 15px; font-weight: 500; cursor: pointer; text-align: left;
  transition: background .15s, color .15s, transform .1s;
  min-height: 44px;
}
.side-nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav button.active { background: var(--primary); color: #fff; font-weight: 700; box-shadow: 0 2px 10px rgba(15,118,110,.35); }
.side-nav button span { font-size: 18px; flex-shrink: 0; }
.side-nav button:focus-visible { outline: 2px solid #5eead4; outline-offset: 2px; }

.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.10); }
.env { font-size: 12px; color: #94a3b8; line-height: 1.5; }
.btn-ghost-sm {
  background: rgba(255,255,255,.08); color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.15); border-radius: 10px;
  padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
  min-height: 40px;
}
.btn-ghost-sm:hover { background: rgba(255,255,255,.15); }
.btn-ghost-sm:focus-visible { outline: 2px solid #5eead4; outline-offset: 2px; }

/* ——— MAIN ——— */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  padding: 28px 32px 20px; gap: 16px;
  background: var(--bg);
}
.topbar h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.topbar p { color: var(--muted); font-size: 15px; margin-top: 4px; }
.period {
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--muted);
  box-shadow: var(--shadow); white-space: nowrap;
}

.content { flex: 1; overflow-y: auto; padding: 0 32px 32px; }
.content::-webkit-scrollbar { width: 8px; }
.content::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }
.view { animation: fade .3s ease; }
.view.hidden { display: none; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ——— CARDS ——— */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 20px; box-shadow: var(--shadow);
  transition: box-shadow .2s, transform .15s;
  position: relative; overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--line); border-radius: var(--radius) var(--radius) 0 0;
}
.card.accent::before { background: var(--primary); }
.card.pos::before { background: var(--good); }
.card.neg::before { background: var(--bad); }
.card .c-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; letter-spacing: .02em; text-transform: uppercase; }
.card .c-value { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.card .c-note { font-size: 12px; color: var(--muted-light); margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.card.pos .c-value { color: var(--good); }
.card.neg .c-value { color: var(--bad); }
.card.accent .c-value { color: var(--primary); }
.card-icon {
  position: absolute; top: 18px; right: 18px;
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 18px;
  background: #f8fafc; border: 1px solid var(--line);
}
.card.pos .card-icon { background: #f0fdf4; border-color: #bbf7d0; }
.card.neg .card-icon { background: #fef2f2; border-color: #fecaca; }
.card.accent .card-icon { background: #f0fdfa; border-color: #99f6e4; }

/* ——— CHARTS ——— */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.chart-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.chart-head h3 { font-size: 16px; font-weight: 700; }
.chart-head span { font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); padding: 4px 10px; border-radius: 999px; }
.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ——— SUMMARY STRIP ——— */
.summary-strip {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px;
}
.summary-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
}
.summary-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.summary-icon.green { background: #f0fdf4; border: 1px solid #bbf7d0; }
.summary-icon.blue { background: #eff6ff; border: 1px solid #bfdbfe; }
.summary-icon.amber { background: #fffbeb; border: 1px solid #fde68a; }
.summary-text label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: block; }
.summary-text strong { font-size: 18px; font-weight: 800; }

/* ——— PANEL & TABLES ——— */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.panel-head h2 { font-size: 17px; font-weight: 700; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line);
}
.table td { padding: 13px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; font-size: 14px; }
.table tbody tr:hover { background: #f8fafc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table .del {
  border: none; background: transparent; color: var(--bad); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 8px;
  min-width: 32px; min-height: 32px;
}
.table .del:hover { background: #fee2e2; }
.table .del:focus-visible { outline: 2px solid var(--bad); outline-offset: 2px; }
.badge { font-size: 12px; font-weight: 700; padding: 5px 12px; border-radius: 999px; letter-spacing: .02em; }
.badge.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge.bad { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.empty { text-align: center; color: var(--muted); padding: 24px !important; font-size: 14px; }

/* ——— TOOLBAR / BUTTONS ——— */
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.btn {
  background: var(--primary); color: #fff; border: none;
  padding: 12px 18px; border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 2px 8px rgba(15,118,110,.2);
}
.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 14px rgba(15,118,110,.3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid #99f6e4; outline-offset: 2px; }
.btn-ghost {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; gap: 8px;
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); background: #f0fdfa; }
.btn-ghost:focus-visible { outline: 3px solid #99f6e4; outline-offset: 2px; }
.btn-block { width: 100%; padding: 14px; font-size: 16px; }

/* ——— LOGIN ——— */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: radial-gradient(900px 500px at 70% -10%, #134e4a, #0f172a 70%);
  padding: 20px;
}
.login-card {
  width: 420px; max-width: 92vw; background: #fff; border-radius: 20px;
  padding: 36px 32px; box-shadow: 0 30px 80px rgba(0,0,0,.4);
  display: grid; gap: 18px;
}
.login-brand { text-align: center; margin-bottom: 6px; }
.login-brand .brand-mark.big { width: 56px; height: 56px; font-size: 28px; margin: 0 auto 14px; border-radius: 16px; }
.login-brand h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.login-brand h1 b { color: var(--primary); }
.login-brand p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-card label { display: grid; gap: 7px; font-size: 13px; color: var(--ink); font-weight: 600; }
.login-card input {
  padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #ccfbf1; }
.login-error { color: var(--bad); font-size: 13px; min-height: 18px; font-weight: 600; }
.login-hint { text-align: center; font-size: 13px; color: var(--muted); margin-top: 2px; }
.login-hint b { color: var(--ink); }

/* ——— ACTION BUTTONS ——— */
.act { border: none; background: transparent; cursor: pointer; padding: 6px 10px; font-size: 13px; font-weight: 600; border-radius: 8px; min-height: 32px; }
.act.edit { color: var(--primary); }
.act.edit:hover { background: #ccfbf1; }
.act.del { color: var(--bad); }
.act.del:hover { background: #fee2e2; }
.act:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.status-badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; }
.status-badge.on { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.status-badge.off { background: #f1f5f9; color: var(--muted); border-color: var(--line); }

/* ——— SELECT ——— */
.select {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 14px; min-width: 260px; color: var(--ink);
  min-height: 44px;
}
.select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #ccfbf1; }
.ledger-saldo { margin-bottom: 14px; font-size: 14px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.ledger-saldo b { color: var(--ink); }

/* ——— TABS & REPORT ——— */
.tabs { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.tabs button {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-height: 44px;
}
.tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; box-shadow: 0 2px 8px rgba(15,118,110,.2); }
.tabs button:focus-visible { outline: 3px solid #99f6e4; outline-offset: 2px; }
.tabs .spacer { flex: 1; }

.report {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 36px; max-width: 760px;
}
.report .r-head { text-align: center; margin-bottom: 26px; }
.report .r-head h2 { font-size: 20px; font-weight: 800; }
.report .r-head p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.report table { width: 100%; border-collapse: collapse; }
.report th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--ink);
}
.report td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; }
.report .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.report .grp td { font-weight: 700; background: #f8fafc; }
.report .tot td { font-weight: 800; border-top: 2px solid var(--ink); font-size: 15px; }
.report .indent { padding-left: 28px !important; }
.report .r-note { font-size: 13px; color: var(--muted); margin-top: 22px; line-height: 1.7; }
.report .r-calk h3 { font-size: 15px; margin: 18px 0 8px; }
.report .r-calk p { font-size: 14px; color: var(--muted); margin-bottom: 8px; line-height: 1.6; }
.report .r-calk li { margin-left: 18px; font-size: 14px; color: var(--muted); margin-bottom: 5px; }

/* ——— MODAL ——— */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: #fff; border-radius: 16px; width: 560px; max-width: 94vw;
  box-shadow: 0 24px 60px rgba(15,23,42,.3); overflow: hidden; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.close { border: none; background: transparent; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px; border-radius: 8px; min-width: 36px; min-height: 36px; }
.close:hover { background: #f1f5f9; }
.modal form { padding: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label { display: grid; gap: 7px; font-size: 13px; color: var(--ink); font-weight: 600; }
.form-grid input, .form-grid select {
  padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; color: var(--ink); background: #fff;
  min-height: 44px;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px #ccfbf1; }
.form-hint { margin-top: 14px; font-size: 13px; color: var(--muted); background: #f0fdfa; border: 1px solid #99f6e4; border-radius: 10px; padding: 12px 14px; line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ——— RESPONSIVE ——— */
@media (max-width: 1200px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .chart-grid { grid-template-columns: 1fr; }
  .summary-strip { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { width: 72px; padding: 16px 8px; }
  .brand-name, .brand-sub, .side-nav button span + text, .sidebar-foot .env { display: none; }
  .side-nav button { justify-content: center; padding: 12px; }
  .content { padding: 0 16px 20px; }
  .topbar { padding: 20px 16px 16px; flex-direction: column; align-items: flex-start; }
  .cards { grid-template-columns: 1fr; }
}

/* ——— DOKUMEN ——— */
.doc-items { display: grid; gap: 10px; margin-top: 12px; }
.doc-item-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
}
.doc-item-row select, .doc-item-row input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; min-height: 38px;
}
.doc-item-row .li-prod { flex: 1; min-width: 140px; }
.doc-total { margin-top: 14px; text-align: right; font-size: 16px; font-weight: 700; color: var(--ink); }
.act.send { color: var(--primary); }
.act.send:hover { background: #ccfbf1; }
.act.approve { color: var(--good); }
.act.approve:hover { background: #dcfce7; }
.act.convert { color: #2563eb; }
.act.convert:hover { background: #dbeafe; }
.act.pay { color: var(--accent); }
.act.pay:hover { background: #fef3c7; }
.status-badge.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.status-badge.bad { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

/* ——— PRINT ——— */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .tabs, .toolbar { display: none !important; }
  .content { overflow: visible; padding: 0; }
  .view.hidden { display: none; }
  .view { display: none; }
  #view-laporan { display: block !important; }
  .report { box-shadow: none; border: none; padding: 0; max-width: 100%; }
  .chart-grid, .cards, .summary-strip { break-inside: avoid; }
}
