/* ============================================================
   Uangnesia PHP Edition - UI 2.0 (shadcn-inspired, no build)
   ============================================================ */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e4e7ec;
  --muted: #64748b;
  --text: #0f172a;
  --primary: #0f172a;
  --primary-fg: #ffffff;
  --ring: #94a3b8;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #e11d48;
  --red-bg: #fff1f2;
  --amber: #d97706;
  --blue: #0284c7;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .22);
  --tr: .18s cubic-bezier(.4, 0, .2, 1);
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.5rem; letter-spacing: -.02em; font-weight: 600; }
h2 { font-size: 1.1rem; } h3 { font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .75rem; }
.center { text-align: center; }
.right { text-align: right; }
.ml-auto { margin-left: auto; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.income { color: var(--green); }
.expense { color: var(--red); }
.uppercase { text-transform: uppercase; letter-spacing: .06em; font-size: .68rem; color: var(--muted); font-weight: 600; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 256px; flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfe 100%);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; z-index: 10;
}
.sidebar-brand {
  display: flex; gap: 11px; align-items: center;
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.brand-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: var(--primary-fg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.brand-icon.sm { width: 28px; height: 28px; font-size: .78rem; border-radius: 8px; }
.sidebar-brand strong { display: block; font-size: .92rem; letter-spacing: -.01em; }
.sidebar-brand small { color: var(--muted); font-size: .72rem; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 9px; color: #52627a; font-weight: 500; font-size: .86rem;
  transition: background var(--tr), color var(--tr), transform var(--tr);
}
.sidebar-nav a:hover { background: #eef1f6; color: var(--text); transform: translateX(2px); }
.sidebar-nav a.active {
  background: #eef1f6; color: var(--text); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.nav-ico { width: 17px; height: 17px; flex-shrink: 0; opacity: .75; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
.user-email { color: var(--muted); font-size: .74rem; padding: 0 8px 8px; overflow: hidden; text-overflow: ellipsis; }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: none; gap: 4px; align-items: center;
  padding: 10px 12px; background: rgba(255,255,255,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; overflow-x: auto;
}
.topbar a { padding: 6px 10px; border-radius: 7px; font-size: .78rem; white-space: nowrap; color: #52627a; }
.topbar a.active { background: #eef1f6; font-weight: 600; color: var(--text); }
.main { padding: 28px; max-width: 1160px; width: 100%; margin: 0 auto; }
@media (max-width: 768px) {
  .sidebar { display: none; }
  .topbar { display: flex; }
  .main { padding: 16px; }
}

/* ---------- Page ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.page-head h1 { font-size: 1.45rem; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 700px) { .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Card ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  transition: box-shadow var(--tr);
}
.card:hover { box-shadow: var(--shadow); }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: .95rem; }
.card-body { padding: 18px; }
.stat { padding: 18px; position: relative; overflow: hidden; }
.stat::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: linear-gradient(180deg, var(--primary), #475569); opacity: .85;
}
.stat.income::after { background: var(--green); }
.stat.expense::after { background: var(--red); }
.stat-title { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid transparent; background: #eef1f6; color: var(--text);
  font-size: .84rem; font-weight: 550; cursor: pointer; font-family: inherit;
  transition: background var(--tr), color var(--tr), border-color var(--tr), transform var(--tr); text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #e2e8f0; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: var(--primary-fg); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #1e293b; }
.btn-outline { background: #fff; border-color: var(--border); }
.btn-outline:hover { border-color: #cbd5e1; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: #f1f5f9; box-shadow: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #be123c; }
.danger { color: var(--red) !important; }
.btn-sm { padding: 6px 11px; font-size: .78rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ring); outline-offset: 2px;
}

/* ---------- Forms ---------- */
label { display: block; font-size: .82rem; font-weight: 550; margin-bottom: 12px; color: #334155; }
input, select, textarea {
  width: 100%; padding: 9px 12px; margin-top: 5px;
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; background: #fff; color: var(--text);
  transition: border-color var(--tr), box-shadow var(--tr);
}
input:hover, select:hover, textarea:hover { border-color: #cbd5e1; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, .25);
}
input[type="checkbox"] { width: auto; margin: 0 6px 0 0; accent-color: var(--primary); cursor: pointer; }
input[type="file"] { padding: 8px; background: #f8fafc; }
textarea { resize: vertical; }
.inline { display: inline-block; }
.inline-check { display: flex; align-items: center; font-weight: 450; }
.form-grid { display: flex; flex-direction: column; gap: 4px; }
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.filter-bar label { margin: 0; font-size: .74rem; color: var(--muted); }
.filter-bar input, .filter-bar select { width: auto; min-width: 128px; margin-top: 3px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.chip { font-size: .78rem; color: var(--muted); padding: 4px 12px; border-radius: 999px; background: #f1f5f9; border: 1px solid var(--border); }
.chip.income { color: #047857; font-weight: 650; background: var(--green-bg); border-color: #a7f3d0; }
.chip.expense { color: #be123c; font-weight: 650; background: var(--red-bg); border-color: #fecdd3; }

/* ---------- Alerts & toasts ---------- */
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 12px; font-size: .85rem; }
.alert-danger { background: var(--red-bg); color: #be123c; border: 1px solid #fecdd3; }
.alert-ok { background: var(--green-bg); color: #047857; border: 1px solid #a7f3d0; }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #0f172a; color: #fff; padding: 11px 16px;
  border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: .84rem; max-width: 340px;
  animation: toast-in .28s cubic-bezier(.21, 1.02, .73, 1);
}
.toast.ok { background: #065f46; }
.toast.err { background: #9f1239; }
.toast.out { animation: toast-out .25s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); animation: fade-in .18s ease; }
.modal-card {
  position: relative; z-index: 110; width: 100%; max-width: 560px;
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  animation: modal-in .22s cubic-bezier(.21, 1.02, .73, 1);
  max-height: 88vh; overflow-y: auto;
}
.modal-card.wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; border-radius: 16px 16px 0 0; }
.modal-head h3 { font-size: 1rem; }
.modal-body { padding: 20px; }
.modal-x { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; font-size: 1.15rem; cursor: pointer; color: var(--muted); line-height: 1; transition: background var(--tr); }
.modal-x:hover { background: #f1f5f9; color: var(--text); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Confirm modal */
.confirm-body { font-size: .88rem; color: #334155; }
.confirm-body strong { color: var(--red); }

/* ---------- Icons ---------- */
.ico { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: -3px; }
.btn .ico { width: 15px; height: 15px; }
.btn-sm .ico { width: 14px; height: 14px; }
.stat small .ico { width: 14px; height: 14px; vertical-align: -3px; }
.modal-head h3 .ico { vertical-align: -3px; }
.sidebar-foot .ico { vertical-align: -3px; }

/* ---------- Detail modal ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.detail-grid dt {
  font-size: .7rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
}
.detail-grid dd { margin: 3px 0 0; font-weight: 550; overflow-wrap: anywhere; }
.detail-grid .span2 { grid-column: 1 / -1; }
.view-items { margin: 4px 0 0; padding-left: 18px; }
.view-items li { margin: 2px 0; }
@media (max-width: 500px) { .detail-grid { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; padding: 11px 12px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
tbody tr { transition: background var(--tr); }
tbody tr:hover td { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
td.right, th.right { text-align: right; }
.strong { font-weight: 600; }
.w40 { width: 40px; }
.link { font-weight: 600; }
.link:hover { text-decoration: underline; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .72rem; font-weight: 600; }
.badge-green { background: #d1fae5; color: #047857; }
.badge-red { background: #ffe4e6; color: #be123c; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-blue { background: #e0f2fe; color: #0369a1; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 15px; border-radius: 9px 9px 0 0; font-size: .85rem; font-weight: 500; color: var(--muted); transition: all var(--tr); }
.tab:hover { color: var(--text); background: #f1f5f9; }
.tab.active { color: var(--text); border-bottom: 2px solid var(--primary); font-weight: 600; background: transparent; }

/* ---------- Bulk & pager ---------- */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--red-bg); border: 1px solid #fecdd3; border-radius: var(--radius);
  padding: 11px 16px; margin-top: 12px;
  animation: toast-in .2s ease;
}
.pager { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-top: 14px; font-size: .82rem; color: var(--muted); }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.chart-grid { margin-bottom: 16px; }
@media (max-width: 800px) { .stat-grid { grid-template-columns: 1fr; } }
.chart-wrap { max-width: 250px; margin: 0 auto; }
.legend { margin-top: 16px; display: flex; flex-direction: column; gap: 7px; font-size: .8rem; }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.legend-item.total { border-top: 1px solid var(--border); padding-top: 9px; margin-top: 4px; justify-content: space-between; }

/* ---------- Auth & wizard ---------- */
.center-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: radial-gradient(1200px 600px at 50% -10%, #e8edf5 0%, var(--bg) 60%); }
.auth-box { width: 100%; max-width: 410px; text-align: center; }
.auth-box h1 { margin-bottom: 4px; }
.auth-box .muted { margin-bottom: 20px; font-size: .85rem; }
.auth-box .card { text-align: left; }
.auth-box .card h2 { text-align: center; margin-bottom: 16px; }
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.step-dot { width: 32px; height: 5px; border-radius: 999px; background: #e2e8f0; transition: background var(--tr); }
.step-dot.on { background: var(--primary); }

/* ---------- Kategori ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-top: 16px; }
.cat-item { display: flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; transition: all var(--tr); }
.cat-item:hover { border-color: #cbd5e1; box-shadow: var(--shadow-sm); }
.cat-item .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-item .dot.income { background: var(--green); }
.cat-item .dot.expense { background: var(--red); }
.cat-item .dot.bank { background: #0ea5e9; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form input { margin: 0; }

/* ---------- Pengguna ---------- */
.user-card { display: flex; align-items: center; gap: 13px; padding: 13px 15px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #eef1f6; display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.user-card select { width: auto; margin: 0; }

/* ---------- Faktur items ---------- */
.items-box { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: #fbfcfe; }
.item-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; animation: fade-in .15s ease; }
.item-row input { margin: 0; }
.item-row .w80 { width: 78px; flex-shrink: 0; }
.item-row .w150 { width: 140px; flex-shrink: 0; }
.items-box { overflow-x: auto; }
.w150 { width: 150px; }

/* ---------- Print dokumen ---------- */
.print-page { background: #f1f5f9; padding: 16px; }
.print-toolbar { max-width: 820px; margin: 0 auto 14px; display: flex; justify-content: space-between; align-items: center; }
.doc { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--border); padding: 42px; color: #0f172a; box-shadow: var(--shadow); }
.doc h1 { font-size: 1.5rem; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--border); padding-bottom: 20px; gap: 16px; }
.doc-brand { display: flex; gap: 14px; align-items: center; }
.doc-logo { max-height: 64px; max-width: 120px; object-fit: contain; }
.doc-brand p, .doc-brand small { color: var(--muted); font-size: .85rem; }
.doc-meta { text-align: right; }
.doc-meta.right { text-align: right; }
.doc-title { font-size: 1.1rem; font-weight: 700; }
.doc-meta-grid { display: flex; justify-content: space-between; padding: 20px 0; gap: 16px; }
.doc-meta-grid p { margin: 4px 0 10px; }
.doc-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; padding: 16px 0; }
.doc-summary > div { border: 1px solid var(--border); padding: 11px 13px; border-radius: 8px; }
.doc-summary small { color: var(--muted); font-weight: 600; font-size: .68rem; }
.doc-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: .85rem; }
.doc-table th { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: #f8fafc; padding: 9px 11px; text-align: left; }
.doc-table td { padding: 9px 11px; border-bottom: 1px solid #f1f5f9; }
.doc-table tfoot td { border-bottom: none; padding-top: 4px; }
.doc-sign { margin-top: 56px; display: flex; justify-content: flex-end; text-align: center; font-size: .85rem; }
.sign-space { height: 60px; }
.sign-name { border-top: 1px solid var(--border); padding: 4px 16px 0; font-weight: 600; }
@media print {
  body { background: #fff; padding: 0; }
  .print-toolbar { display: none; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  @page { size: A4; margin: 14mm; }
}

/* ---- v1.1: thumbnail logo, logo sidebar, versi, tema warna ---- */
.logo-preview { display: flex; align-items: center; justify-content: center; background: var(--bg-subtle, #f1f5f9); border: 1px dashed var(--border); border-radius: 10px; min-width: 120px; min-height: 64px; padding: 6px; }
.logo-preview img { max-height: 72px; max-width: 140px; width: auto; height: auto; object-fit: contain; border-radius: 6px; display: block; }
.brand-logo img { max-height: 34px; max-width: 34px; width: auto; height: auto; object-fit: contain; border-radius: 8px; display: block; }
.brand-icon.sm.brand-logo img { max-height: 26px; max-width: 26px; border-radius: 6px; }
.sidebar-ver { text-align: center; font-size: .68rem; color: var(--muted); margin-top: 8px; opacity: .8; }
.theme-swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.theme-swatch { position: relative; }
.theme-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.theme-swatch span { display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; padding: 8px 10px; border: 2px solid var(--border); border-radius: 10px; font-size: .7rem; font-weight: 500; background: var(--card, #fff); }
.theme-swatch span:hover { border-color: var(--muted); }
.theme-swatch input:checked + span { border-color: var(--text); box-shadow: 0 0 0 2px var(--border); }
.theme-swatch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-dot { width: 26px; height: 26px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* ---- v1.1.1: header tabel bertema, margin antar section ---- */
:root { --primary-soft: #0f172a14; }
table thead th { background: var(--primary-soft); border-bottom: 2px solid var(--primary); }
.main > * + * { margin-top: 18px; }
.page-head { margin-bottom: 0; }
.grid-3.stat-grid { margin-bottom: 0; }
.card + .card { margin-top: 18px; }
.pager { margin-top: 12px; }
.stack .card + .card { margin-top: 0; }

/* ---- v1.1.4: analitik dashboard (perbandingan, proyeksi, porsi) ---- */
.compare-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.compare-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; background: var(--card, #fff); }
.compare-title { font-size: .78rem; color: var(--muted); font-weight: 500; }
.compare-value { font-size: 1.25rem; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.compare-delta { font-size: .78rem; font-weight: 650; margin-top: 4px; }
.compare-prev { font-size: .72rem; color: var(--muted); margin-top: 2px; }
@media (max-width: 800px) { .compare-grid { grid-template-columns: 1fr; } }
