/* ==========================================================
   LapHar Usaha — Laporan Harian Usaha
   ========================================================== */

:root {
  --bg: #f2f5f4;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --surface-3: #eef3f1;
  --border: #e1e8e5;
  --border-strong: #cdd7d3;
  --text: #0f1a17;
  --muted: #5b6b66;
  --faint: #8b9994;

  --primary: #0e7a5f;
  --primary-hover: #0b6650;
  --primary-soft: #e1f2ec;
  --on-primary: #ffffff;

  --in: #0e7a5f;
  --in-soft: #e1f2ec;
  --out: #c4501f;
  --out-soft: #fbebe3;
  --danger: #cf3434;
  --danger-soft: #fdeaea;
  --ring: rgba(14, 122, 95, .28);

  --shadow-sm: 0 1px 2px rgba(16, 24, 22, .05);
  --shadow: 0 1px 2px rgba(16, 24, 22, .04), 0 10px 30px -18px rgba(16, 24, 22, .22);
  --shadow-lg: 0 30px 60px -20px rgba(10, 20, 17, .35);

  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a100e;
    --surface: #111916;
    --surface-2: #151f1c;
    --surface-3: #1a2622;
    --border: #22302b;
    --border-strong: #2f3f39;
    --text: #e7efec;
    --muted: #97a8a2;
    --faint: #6c7d77;
    --primary: #2fbf96;
    --primary-hover: #45d0a8;
    --primary-soft: #11322a;
    --on-primary: #04130e;
    --in: #39c79e;
    --in-soft: #11322a;
    --out: #ff8d5e;
    --out-soft: #3a2017;
    --danger: #ff6b6b;
    --danger-soft: #3a1717;
    --ring: rgba(47, 191, 150, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a100e;
  --surface: #111916;
  --surface-2: #151f1c;
  --surface-3: #1a2622;
  --border: #22302b;
  --border-strong: #2f3f39;
  --text: #e7efec;
  --muted: #97a8a2;
  --faint: #6c7d77;
  --primary: #2fbf96;
  --primary-hover: #45d0a8;
  --primary-soft: #11322a;
  --on-primary: #04130e;
  --in: #39c79e;
  --in-soft: #11322a;
  --out: #ff8d5e;
  --out-soft: #3a2017;
  --danger: #ff6b6b;
  --danger-soft: #3a1717;
  --ring: rgba(47, 191, 150, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
h1, h2, h3, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

/* ---------- Header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.brand-mark { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--primary); color: var(--on-primary); }
.brand-mark .i { width: 21px; height: 21px; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-tools { display: flex; align-items: center; gap: 6px; }

.tabs {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 12px;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 9px; font-weight: 600; font-size: 14px;
  transition: background .15s, color .15s;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-count { background: var(--primary-soft); color: var(--primary); font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }

.tab { white-space: nowrap; }
@media (max-width: 399px) { .hide-xs { display: none; } }
@media (max-width: 719px) {
  .header-inner { gap: 10px; }
  .card-head { flex-wrap: wrap; }
  .card-head > div { flex: 1; min-width: 0; }
  .chart-legend { width: 100%; }
  .tabs { order: 3; width: 100%; }
  .tab { flex: 1; justify-content: center; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 11px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible, .chip:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.05); background: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-3); }
.btn-ghost-danger { border-color: transparent; background: transparent; color: var(--danger); }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-lg { min-height: 50px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: 10px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 9px; }
.icon-btn.sm .i { width: 16px; height: 16px; }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Layout / Cards ---------- */
main.view { padding-top: 24px; padding-bottom: 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.page-head p { color: var(--muted); font-size: 14px; margin-top: 2px; }
@media (min-width: 768px) { .page-head h1 { font-size: 28px; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
@media (min-width: 768px) { .card { padding: 24px; } }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.card-head p { font-size: 13px; color: var(--muted); }
.card-head .spacer { flex: 1; }
.badge-icon {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--muted);
}
.badge-icon.in { background: var(--in-soft); color: var(--in); }
.badge-icon.out { background: var(--out-soft); color: var(--out); }
.badge-icon.primary { background: var(--primary-soft); color: var(--primary); }
.card-total { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.card-total.in { color: var(--in); }
.card-total.out { color: var(--out); }

/* ---------- Form ---------- */
.form-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .form-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
  .summary-col { position: sticky; top: calc(var(--header-h) + 24px); }
}
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; gap: 4px; align-items: baseline; }
.field .req { color: var(--danger); }
.field .opt { color: var(--faint); font-weight: 500; font-size: 12px; }
.input {
  width: 100%; min-height: 48px; padding: 11px 14px;
  border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface);
  font-size: 16px; /* cegah auto-zoom iOS */
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder { color: var(--faint); }
.input:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--border-strong)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type="date"].input { appearance: none; -webkit-appearance: none; }
.money { position: relative; }
.money .prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-weight: 700; font-size: 14px; color: var(--faint); pointer-events: none;
}
.money .input { padding-left: 44px; font-weight: 600; font-variant-numeric: tabular-nums; }
.field .err { display: none; font-size: 12.5px; color: var(--danger); font-weight: 500; }
.field.invalid .input { border-color: var(--danger); background: color-mix(in srgb, var(--danger-soft) 45%, var(--surface)); }
.field.invalid .input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 22%, transparent); }
.field.invalid .err { display: block; }

.subhead { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }
.subhead .count { text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--primary); background: var(--primary-soft); border-radius: 99px; padding: 1px 8px; font-size: 12px; }
.subhead .count:empty { display: none; }

/* Uploader */
.dropzone {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px dashed var(--border-strong); border-radius: 14px; padding: 16px;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.dropzone .badge-icon { background: var(--surface); border: 1px solid var(--border); color: var(--primary); }
.dropzone strong { display: block; font-size: 14px; }
.dropzone small { color: var(--muted); font-size: 12.5px; }
.dropzone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.uploader.busy .dropzone { opacity: .6; pointer-events: none; }
.uploader.busy .dropzone strong::after { content: " — memproses…"; font-weight: 500; color: var(--muted); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 10px; margin-top: 12px; }
.thumbs:empty { display: none; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb-x {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 99px; border: 0;
  display: grid; place-items: center; background: rgba(10, 16, 14, .72); color: #fff;
}
.thumb-x .i { width: 14px; height: 14px; }
.thumb-x:hover { background: var(--danger); }

/* Edit banner */
.edit-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px; border-radius: 14px;
  background: color-mix(in srgb, #f2b33d 16%, var(--surface)); border: 1px solid color-mix(in srgb, #f2b33d 45%, var(--border));
}
.edit-banner .i { color: #b7791f; }
.edit-banner p { flex: 1; min-width: 200px; font-size: 14px; }

/* Summary panel */
.summary-card { padding: 20px; }
.summary-card h2 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; font-size: 14px; }
.sum-row span:first-child { color: var(--muted); }
.sum-row b { font-variant-numeric: tabular-nums; font-weight: 600; }
.sum-row.total { border-top: 1px dashed var(--border-strong); margin-top: 4px; padding-top: 11px; }
.sum-row.total b { font-weight: 800; }
.sum-group-label { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin-top: 10px; }
.sum-group-label.in { color: var(--in); }
.sum-group-label.out { color: var(--out); }
.saldo-box {
  margin: 16px 0; padding: 16px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #0b3d30));
  color: #fff;
}
.saldo-box span { font-size: 12.5px; opacity: .85; font-weight: 600; }
.saldo-box b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
:root[data-theme="dark"] .saldo-box { color: #04130e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .saldo-box { color: #04130e; } }
.saldo-box.neg { background: linear-gradient(135deg, #cf3434, #8f1f1f); color: #fff !important; }

.save-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.save-status .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--faint); flex: none; }
.save-status[data-state="saved"] .dot { background: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.save-status[data-state="saving"] .dot { background: #e0a526; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.summary-actions { display: grid; gap: 8px; margin-top: 14px; }
.kbd-hint { font-size: 12px; color: var(--faint); text-align: center; margin-top: 4px; }
.kbd-hint kbd { font-family: inherit; font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; background: var(--surface-2); }

/* Mobile action bar */
.mobile-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: none; align-items: center; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -10px 30px -20px rgba(0, 0, 0, .3);
}
.mobile-bar .mb-info { flex: 1; min-width: 0; }
.mobile-bar .mb-info small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.mobile-bar .mb-info b { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mobile-bar .mb-info b.neg { color: var(--danger); }
.mobile-bar .save-status { font-size: 11px; margin-top: 1px; }
@media (max-width: 1023px) {
  body[data-view="input"] .mobile-bar { display: flex; }
  body[data-view="input"] main.view { padding-bottom: 120px; }
  .summary-col .summary-actions, .summary-col .kbd-hint { display: none; }
}

/* ---------- Data view ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 16px; }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.stat { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); min-width: 0; }
@media (min-width: 768px) { .stat { padding: 18px 20px; } }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat-top .badge-icon { width: 30px; height: 30px; border-radius: 9px; }
.stat-top .badge-icon .i { width: 16px; height: 16px; }
.stat-val { font-size: 19px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 768px) { .stat-val { font-size: 23px; } }
.stat-val.in { color: var(--in); }
.stat-val.out { color: var(--out); }
.stat-val.neg { color: var(--danger); }
.stat-foot { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* Chart */
.chart-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.chart-legend i.in { background: var(--in); }
.chart-legend i.out { background: var(--out); }
.chart-area { position: relative; padding-left: 52px; }
.chart-axis { position: absolute; left: 0; top: 0; bottom: 22px; width: 48px; display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.bars {
  display: flex; align-items: stretch; gap: 4px; height: 190px; padding-bottom: 22px; position: relative;
  background-image: linear-gradient(var(--border) 1px, transparent 1px);
  background-size: 100% calc((100% - 22px) / 4);
  background-repeat: repeat-y;
  border-bottom: 1px solid var(--border-strong);
  overflow-x: auto; scrollbar-width: thin;
}
.bar-col { flex: 1 0 18px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: pointer; border-radius: 6px; }
.bar-col:hover, .bar-col.active { background: color-mix(in srgb, var(--primary) 7%, transparent); }
.bar-pair { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; justify-content: center; padding: 0 1px; }
.bar { width: 45%; max-width: 16px; min-height: 2px; border-radius: 4px 4px 1px 1px; transition: height .4s cubic-bezier(.2, .8, .2, 1); }
.bar.in { background: var(--in); }
.bar.out { background: var(--out); }
.bar-label { position: absolute; bottom: -20px; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chart-info { margin-top: 12px; font-size: 13px; color: var(--muted); min-height: 20px; }
.chart-info b { color: var(--text); }
.chart-empty { padding: 40px 0; text-align: center; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search .input { padding-left: 40px; min-height: 42px; font-size: 15px; }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; max-width: 100%; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--muted);
  padding: 8px 13px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap;
  transition: all .15s;
}
.chip:hover { color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.date-range { display: flex; align-items: center; gap: 6px; flex: 0 1 auto; }
.date-range .input { min-height: 42px; font-size: 14px; padding: 8px 10px; width: 150px; }
.date-range span { color: var(--faint); font-size: 13px; }
@media (max-width: 719px) {
  .date-range { width: 100%; }
  .date-range .input { flex: 1; width: auto; min-width: 0; }
}

/* Export menu */
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; width: 290px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px;
}
.menu-pop button {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 10px; border-radius: 10px;
}
.menu-pop button:hover { background: var(--surface-3); }
.menu-pop button b { display: block; font-size: 14px; font-weight: 600; }
.menu-pop button small { display: block; color: var(--muted); font-size: 12px; }
.menu-pop .badge-icon { width: 34px; height: 34px; }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 6px 4px; }

/* Spreadsheet table */
.table-card { padding: 16px; }
@media (min-width: 768px) { .table-card { padding: 20px; } }
.table-wrap {
  border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: 68vh;
  background: var(--surface);
}
.sheet { width: 100%; min-width: 1120px; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.sheet th, .sheet td { padding: 10px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); white-space: nowrap; }
.sheet th:last-child, .sheet td:last-child { border-right: 0; }
.sheet thead th {
  position: sticky; z-index: 2; background: var(--surface-2); font-size: 12px; font-weight: 700;
  color: var(--muted); text-align: left; text-transform: uppercase; letter-spacing: .04em;
}
.sheet thead tr:first-child th { top: 0; height: 37px; }
.sheet thead tr:nth-child(2) th { top: 37px; }
.sheet thead th.grp-in { background: var(--in-soft); color: var(--in); text-align: center; }
.sheet thead th.grp-out { background: var(--out-soft); color: var(--out); text-align: center; }
.sheet th.sortable { cursor: pointer; user-select: none; }
.sheet th.sortable:hover { color: var(--text); }
.sheet th .sort-ind { display: inline-block; width: 10px; margin-left: 4px; opacity: .35; }
.sheet th[aria-sort] .sort-ind { opacity: 1; color: var(--primary); }
.sheet td.num, .sheet th.num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet td.center, .sheet th.center { text-align: center; }
.sheet tbody tr { cursor: pointer; transition: background .1s; }
.sheet tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.sheet tbody tr:hover td { background: color-mix(in srgb, var(--primary) 6%, var(--surface)); }
.sheet tbody td { background: var(--surface); }
.sheet td.strong { font-weight: 700; }
.sheet td.in { color: var(--in); }
.sheet td.out { color: var(--out); }
.sheet td.neg { color: var(--danger); }
.sheet .sticky-col { position: sticky; left: 0; z-index: 1; }
.sheet thead .sticky-col { z-index: 3; }
.sheet tbody .sticky-col { box-shadow: 1px 0 0 var(--border); }
.sheet tfoot td {
  position: sticky; bottom: 0; z-index: 2; background: var(--surface-3); font-weight: 800; border-top: 2px solid var(--border-strong); border-bottom: 0;
}
.sheet tfoot td.sticky-col { z-index: 3; }
.cell-date b { display: block; font-weight: 700; }
.cell-date small { color: var(--muted); font-size: 12px; }
.sheet td.actions { padding: 4px 8px; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--muted); }
.pill .i { width: 13px; height: 13px; }

.cards-list { display: none; gap: 12px; }
.r-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; background: var(--surface); }
.r-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.r-card-head b { display: block; font-size: 15px; }
.r-card-head small { color: var(--muted); font-size: 12.5px; }
.r-card-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; padding: 10px; border-radius: 10px; background: var(--surface-2); }
.r-card-nums small { display: block; font-size: 11px; color: var(--muted); font-weight: 600; }
.r-card-nums b { font-size: 13.5px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.r-card-nums .in { color: var(--in); }
.r-card-nums .out { color: var(--out); }
.r-card-nums .neg { color: var(--danger); }
.r-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.r-card-foot .row-actions { gap: 4px; }
.cards-total { border-radius: 14px; padding: 14px; background: var(--surface-3); font-size: 13.5px; }
.cards-total div { display: flex; justify-content: space-between; padding: 3px 0; }
.cards-total b { font-variant-numeric: tabular-nums; }

@media (max-width: 719px) {
  .table-wrap { display: none; }
  .cards-list { display: grid; }
}

.empty { text-align: center; padding: 48px 16px; }
.empty .badge-icon { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; }
.empty .badge-icon .i { width: 26px; height: 26px; }
.empty h3 { font-size: 16px; margin-bottom: 4px; }
.empty p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }

/* ---------- Dialogs ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--text);
  width: calc(100% - 32px); max-width: 640px; max-height: calc(100dvh - 32px); overflow: visible;
}
dialog.sm { max-width: 420px; }
dialog.lg { max-width: 760px; }
dialog::backdrop { background: rgba(6, 12, 10, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
dialog[open] { animation: dlgIn .2s cubic-bezier(.2, .8, .2, 1); }
@keyframes dlgIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.dlg {
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; max-height: calc(100dvh - 32px); overflow: hidden;
}
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 20px; border-bottom: 1px solid var(--border); }
.dlg-head h2 { font-size: 17px; font-weight: 700; flex: 1; min-width: 0; }
.dlg-head p { font-size: 13px; color: var(--muted); }
.dlg-body { padding: 20px; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); }
.dlg-foot .spacer { flex: 1; }
.confirm-body { padding: 24px 22px 8px; }
.confirm-body h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.confirm-body p { color: var(--muted); font-size: 14.5px; }
.confirm-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 18px 22px 20px; }

@media (max-width: 639px) {
  dialog, dialog.sm, dialog.lg { width: 100%; max-width: 100%; margin: auto 0 0; max-height: 94dvh; }
  .dlg { border-radius: 22px 22px 0 0; max-height: 94dvh; border-bottom: 0; }
  dialog[open] { animation: sheetIn .25s cubic-bezier(.2, .8, .2, 1); }
  .dlg-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dlg-foot .btn { flex: 1; }
  .dlg-foot .spacer { display: none; }
  .confirm-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .confirm-foot .btn { flex: 1; }
}
@keyframes sheetIn { from { transform: translateY(40px); opacity: .5; } }

/* Detail */
.detail-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.detail-stats div { border-radius: 12px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.detail-stats small { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.detail-stats b { font-size: 15px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 560px) { .detail-stats b { font-size: 18px; } }
@media (max-width: 559px) {
  .detail-stats { grid-template-columns: 1fr; gap: 6px; }
  .detail-stats div { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
  .detail-stats small { font-size: 13px; }
  .detail-stats b { font-size: 16px; }
}
.detail-cols { display: grid; gap: 14px; }
@media (min-width: 560px) { .detail-cols { grid-template-columns: 1fr 1fr; } }
.detail-list { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.detail-list h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; font-weight: 700; }
.detail-list h3.in { background: var(--in-soft); color: var(--in); }
.detail-list h3.out { background: var(--out-soft); color: var(--out); }
.detail-list .sum-row { padding: 9px 14px; border-top: 1px solid var(--border); }
.detail-list .sum-row.total { margin: 0; border-top-style: solid; background: var(--surface-2); }
.detail-section { margin-top: 18px; }
.detail-section h3 { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }
.detail-note { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.detail-meta { font-size: 12px; color: var(--faint); margin-top: 18px; }

/* Lightbox */
dialog.lightbox { max-width: min(1000px, 100vw); width: auto; margin: auto; }
.lightbox .dlg { background: #0b0f0e; border: 0; }
.lightbox img { max-width: min(1000px, 100vw); max-height: calc(100dvh - 120px); display: block; margin: 0 auto; object-fit: contain; }
.lightbox .dlg-head { color: #fff; border-color: #222; }
.lightbox .icon-btn { color: #ccc; }
.lightbox .icon-btn:hover { background: #222; color: #fff; }
@media (max-width: 639px) { dialog.lightbox { margin: auto; } .lightbox .dlg { border-radius: 0; } }

/* Settings */
.settings-section + .settings-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.settings-section h3 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.settings-section > p { font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.settings-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.storage-info { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); padding: 10px 12px; border-radius: 10px; background: var(--surface-2); margin-bottom: 12px; }

/* ---------- Toast ---------- */
#toasts {
  position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 440px;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border: 0; background: transparent; overflow: visible;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; z-index: 100;
}
#toasts:not(:popover-open):empty { display: none; }
body[data-view="input"] #toasts { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
@media (min-width: 1024px) {
  body[data-view="input"] #toasts { padding-bottom: 24px; }
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  background: #13201c; color: #f0f6f4; border-radius: 13px; padding: 12px 12px 12px 14px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .45); font-size: 14px; font-weight: 500;
  animation: toastIn .25s cubic-bezier(.2, .8, .2, 1);
}
.toast span { flex: 1; }
.toast .i { color: #8fd9c0; }
.toast-error .i { color: #ff9b9b; }
.toast-action { border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-weight: 700; font-size: 13px; padding: 6px 12px; border-radius: 8px; }
.toast-action:hover { background: rgba(255, 255, 255, .2); }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- v2: item dinamis, sinkron online ---------- */
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-sm .i { width: 16px; height: 16px; }
.items-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); }
.date-field { max-width: 320px; }
.manage-btn { margin-top: 10px; color: var(--primary); padding-left: 8px; }
.field .old-tag { font-size: 11px; font-weight: 600; color: var(--faint); background: var(--surface-3); padding: 0 6px; border-radius: 99px; }

.item-editor { display: grid; gap: 8px; }
.item-row { display: flex; align-items: center; gap: 6px; }
.item-row .num-badge { width: 26px; flex: none; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--faint); }
.item-row .input { min-height: 44px; flex: 1; min-width: 0; }
.item-row .icon-btn[disabled] { opacity: .3; pointer-events: none; }
.add-item-btn { margin-top: 12px; border-style: dashed; color: var(--primary); }
.hint { display: flex; gap: 8px; align-items: flex-start; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.hint .i { width: 15px; height: 15px; margin-top: 2px; }

.sync-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; margin-right: 2px;
  border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.sync-chip .i { width: 16px; height: 16px; }
.sync-chip:hover { border-color: var(--border-strong); color: var(--text); }
.sync-chip[data-state="ok"] { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); background: var(--primary-soft); }
.sync-chip[data-state="syncing"] .i { animation: spin 1s linear infinite; }
.sync-chip[data-state="error"], .sync-chip[data-state="login"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: var(--danger-soft); }
.sync-chip[data-state="offline"] { color: #b7791f; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 719px) { .sync-chip .sync-text { display: none; } .sync-chip { width: 34px; padding: 0; justify-content: center; } }

.thumb .size { position: absolute; left: 6px; bottom: 6px; font-size: 10.5px; font-weight: 700; color: #fff; background: rgba(10, 16, 14, .65); padding: 1px 6px; border-radius: 99px; pointer-events: none; }
.thumb img:not([src]), .thumb img[src=""] { visibility: hidden; }
.thumb.loading { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Layar masuk ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--primary-soft), var(--bg));
  overflow: auto;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow-lg); padding: 28px 24px; display: grid; gap: 14px;
}
.login-card .brand-mark { width: 48px; height: 48px; border-radius: 14px; }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.login-card > p { color: var(--muted); font-size: 14px; margin-top: -8px; }
.login-err { color: var(--danger); font-size: 13.5px; font-weight: 500; background: var(--danger-soft); padding: 10px 12px; border-radius: 10px; }
.login-card .hint { margin-top: 0; }
body.locked .app-header, body.locked main.view, body.locked .mobile-bar { visibility: hidden; }

/* ---------- Multi-usaha ---------- */
button.brand { border: 0; background: transparent; padding: 4px 8px 4px 4px; margin-left: -4px; border-radius: 12px; text-align: left; color: inherit; flex: 0 1 auto; }
button.brand:hover { background: var(--surface-3); }
button.brand:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.brand-text { display: block; }
.brand-name { display: flex; align-items: center; gap: 4px; }
.brand-name #brandName { overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: block; }
.brand-caret { width: 16px; height: 16px; color: var(--muted); flex: none; }
.header-inner .brand { margin-right: auto; }
.header-inner .tabs { margin-left: auto; }
@media (max-width: 719px) { .header-inner .brand { flex: 1; } }

.biz-list { display: grid; gap: 8px; }
.biz-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: inherit;
}
.biz-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.biz-item[aria-current="true"] { border-color: var(--primary); background: var(--primary-soft); }
.biz-item .badge-icon { width: 34px; height: 34px; }
.biz-item b { display: block; font-size: 14.5px; }
.biz-item small { display: block; color: var(--muted); font-size: 12px; }
.biz-item .grow { flex: 1; min-width: 0; }
.biz-item .grow b, .biz-item .grow small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--surface-3); color: var(--muted); flex: none; }
.role-pill.owner { background: var(--primary-soft); color: var(--primary); }
.biz-add { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
.biz-add label { font-size: 13.5px; font-weight: 600; }
.biz-add-row, .member-add { display: flex; gap: 8px; }
.biz-add-row .input, .member-add .input { min-height: 44px; flex: 1; min-width: 0; }
.member-add select.input { flex: 0 0 110px; }
@media (max-width: 479px) { .member-add { flex-wrap: wrap; } .member-add .btn { flex: 1; } }
.member-list { display: grid; gap: 6px; margin-bottom: 12px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px solid var(--border); border-radius: 10px; font-size: 13.5px; }
.member-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-fields { display: grid; gap: 14px; }
.setup-fields[hidden] { display: none; }
body:not(.is-owner) .owner-only { display: none !important; }

/* ---------- Periode bulanan & penanda tanggal ---------- */
.period-bar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 16px; }
.month-nav, .month-range { display: flex; align-items: center; gap: 6px; }
.month-nav .icon-btn { border: 1px solid var(--border-strong); background: var(--surface); width: 42px; height: 42px; }
.month-select { min-height: 42px; padding: 8px 12px; font-size: 15px; font-weight: 700; width: auto; min-width: 170px; cursor: pointer; }
.month-range span { color: var(--faint); font-size: 13px; }
.month-range .month-select { min-width: 140px; font-weight: 600; }
.period-label { font-size: 13px; color: var(--muted); }
@media (max-width: 559px) {
  .month-nav { width: 100%; }
  .month-nav .month-select { flex: 1; min-width: 0; }
  .month-range { width: 100%; }
  .month-range .month-select { flex: 1; min-width: 0; }
}

@media (max-width: 719px) { .card-head > .chart-legend { flex: 0 0 100%; } }
.period-bar .chips { flex: 0 1 auto; }

/* Sakelar */
.switch-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.switch-row .grow { flex: 1; min-width: 0; }
.switch-row b { display: block; font-size: 14px; }
.switch-row small { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 46px; height: 28px; border-radius: 99px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }
.switch:disabled { opacity: .5; cursor: not-allowed; }
