/* ============================================================================
   PEMBUKUAN MAKLON — EYE-COMFORT FINTECH SPREADSHEET DESIGN SYSTEM
   3 Mode Nyaman Mata: Terang (Soft Cool) · Nyaman Mata (Warm Paper) · Malam
   ============================================================================ */

:root {
  /* Palette: Soft Cool-White (Anti-Silau) */
  --bg-app: #f3f6fa;
  --bg-card: #ffffff;
  --bg-card-head: #f8fafd;
  --header-bg: linear-gradient(135deg, #10253a 0%, #173a56 58%, #115e59 100%);
  --ribbon-bg: #ffffff;
  --ribbon-border: #dce4ee;

  --border: #d7e0ec;
  --border-light: #e7edf5;

  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Table surfaces */
  --th-bg: linear-gradient(180deg, #f3f7fc 0%, #e8eff8 100%);
  --th-text: #1e3a5f;
  --th-border: #cdd9e8;
  --th-rownum-bg: #e2ebf6;
  --td-bg: #ffffff;
  --td-zebra: #f9fbfd;
  --td-hover: #edf5ff;
  --td-border: #e3eaf3;
  --rownum-bg: #f4f7fb;
  --rownum-text: #64748b;

  /* Quick-Add & Edit rows */
  --add-bg: #eef6ff;
  --add-border-top: #3b82f6;
  --add-border-bot: #93c5fd;
  --add-plus-bg: linear-gradient(135deg, #2563eb, #0d9488);
  --edit-bg: #fffbeb;
  --edit-border: #f59e0b;

  /* Footer totals */
  --tfoot-bg: #e9f2fc;
  --tfoot-text: #0f2942;
  --tfoot-border: #93c5fd;
  --tfoot-top: #3b82f6;

  /* Inputs */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: #2563eb;

  /* Semantic financial colors (balanced & calm) */
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --blue-border: #bfdbfe;
  --emerald: #047857;
  --emerald-soft: #ecfdf5;
  --emerald-border: #a7f3d0;
  --amber: #b45309;
  --amber-soft: #fffbeb;
  --amber-border: #fde68a;
  --rose: #be123c;
  --rose-soft: #fff1f2;
  --rose-border: #fecdd3;
  --purple: #6d28d9;
  --purple-soft: #f5f3ff;
  --purple-border: #ddd6fe;
  --slate-soft: #f1f5f9;
  --slate-text: #475569;

  --calc-text: #1d4ed8;
  --hint-bg: #e0f2fe;
  --hint-text: #0369a1;
  --fin-sec-bg: #e8eff8;
  --fin-sec-text: #1e3a5f;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 4px rgba(15, 35, 65, 0.055), 0 1px 2px rgba(15, 35, 65, 0.03);
  --shadow-md: 0 6px 18px rgba(15, 35, 65, 0.08);
  --shadow-lg: 0 22px 48px rgba(15, 23, 42, 0.22);
}

/* ============================================================================
   MODE 2: NYAMAN MATA (WARM PAPER / ANTI-RADIASI CAHAYA BIRU)
   ============================================================================ */
[data-theme="warm"] {
  --bg-app: #f3eee4;
  --bg-card: #fcfaf5;
  --bg-card-head: #f6f1e7;
  --header-bg: linear-gradient(135deg, #2d261e 0%, #3d3528 58%, #264a42 100%);
  --ribbon-bg: #faf7f0;
  --ribbon-border: #dfd6c5;

  --border: #dcd2c0;
  --border-light: #eae2d4;

  --text-primary: #2c241b;
  --text-secondary: #574b3d;
  --text-muted: #7d6f5d;

  --th-bg: linear-gradient(180deg, #f2ece0 0%, #e8dfd0 100%);
  --th-text: #3b3022;
  --th-border: #d5c9b5;
  --th-rownum-bg: #e2d8c6;
  --td-bg: #fdfbf6;
  --td-zebra: #f7f3ea;
  --td-hover: #efe8d8;
  --td-border: #e5dccb;
  --rownum-bg: #f1ebe0;
  --rownum-text: #7a6b58;

  --add-bg: #eef5f0;
  --add-border-top: #15803d;
  --add-border-bot: #86efac;
  --add-plus-bg: linear-gradient(135deg, #0f766e, #15803d);
  --edit-bg: #fef7dc;
  --edit-border: #d97706;

  --tfoot-bg: #eae4d6;
  --tfoot-text: #2c241b;
  --tfoot-border: #c9bca5;
  --tfoot-top: #0f766e;

  --input-bg: #ffffff;
  --input-border: #cbbda6;
  --input-focus: #0f766e;

  --blue: #0f766e;
  --blue-dark: #115e59;
  --blue-soft: #ecfdf5;
  --blue-border: #99f6e4;
  --emerald: #15803d;
  --emerald-soft: #eef9f1;
  --emerald-border: #bbf7d0;
  --amber: #b45309;
  --amber-soft: #fdf6e3;
  --amber-border: #f3d799;
  --rose: #b91c1c;
  --rose-soft: #fdf2f2;
  --rose-border: #f8c8c8;
  --purple: #6d28d9;
  --purple-soft: #f5f0fb;
  --purple-border: #d8c7f2;
  --slate-soft: #eee8dc;
  --slate-text: #574b3d;

  --calc-text: #0f766e;
  --hint-bg: #e8f1eb;
  --hint-text: #166534;
  --fin-sec-bg: #e8dfd0;
  --fin-sec-text: #3b3022;
}

/* ============================================================================
   MODE 3: MODE MALAM (CALM DARK SLATE — NYAMAN UNTUK MALAM HARI)
   ============================================================================ */
[data-theme="dark"] {
  --bg-app: #0d1522;
  --bg-card: #152033;
  --bg-card-head: #19263c;
  --header-bg: linear-gradient(135deg, #09101d 0%, #111f36 60%, #0d3538 100%);
  --ribbon-bg: #121c2e;
  --ribbon-border: #25344d;

  --border: #283852;
  --border-light: #202e45;

  --text-primary: #e6edf7;
  --text-secondary: #b6c5da;
  --text-muted: #889bb5;

  --th-bg: linear-gradient(180deg, #1d2c45 0%, #17243a 100%);
  --th-text: #dbeafe;
  --th-border: #2b3e5c;
  --th-rownum-bg: #142034;
  --td-bg: #152033;
  --td-zebra: #18253b;
  --td-hover: #1f304d;
  --td-border: #24344d;
  --rownum-bg: #121c2d;
  --rownum-text: #7e92ad;

  --add-bg: #142842;
  --add-border-top: #38bdf8;
  --add-border-bot: #1d4ed8;
  --add-plus-bg: linear-gradient(135deg, #0ea5e9, #10b981);
  --edit-bg: #2e2614;
  --edit-border: #f59e0b;

  --tfoot-bg: #1a2d49;
  --tfoot-text: #f1f5f9;
  --tfoot-border: #2f4b73;
  --tfoot-top: #38bdf8;

  --input-bg: #0f1727;
  --input-border: #364b6e;
  --input-focus: #38bdf8;

  --blue: #38bdf8;
  --blue-dark: #0ea5e9;
  --blue-soft: rgba(56, 189, 248, 0.14);
  --blue-border: rgba(56, 189, 248, 0.35);
  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.14);
  --emerald-border: rgba(52, 211, 153, 0.35);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.14);
  --amber-border: rgba(251, 191, 36, 0.35);
  --rose: #fb7185;
  --rose-soft: rgba(251, 113, 133, 0.15);
  --rose-border: rgba(251, 113, 133, 0.35);
  --purple: #c084fc;
  --purple-soft: rgba(192, 132, 252, 0.15);
  --purple-border: rgba(192, 132, 252, 0.35);
  --slate-soft: #1f2e46;
  --slate-text: #cbd5e1;

  --calc-text: #7dd3fc;
  --hint-bg: rgba(56, 189, 248, 0.14);
  --hint-text: #7dd3fc;
  --fin-sec-bg: #1f314d;
  --fin-sec-text: #dbeafe;
}

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

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.num, td.num, th.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Custom Subtle Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.35); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.55); }

/* Full-width Web Spreadsheet Shell */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Brand & Action Header */
.top-header {
  background: var(--header-bg);
  color: #f8fafc;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.16);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #14b8a6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.brand-text h1 {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: #f8fafc;
}

.brand-text span {
  font-size: 11.5px;
  color: #b6c8dc;
  display: block;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.38);
}

.balance-badge.unbalanced {
  background: rgba(244, 63, 94, 0.24);
  color: #fda4af;
  border-color: rgba(251, 113, 133, 0.45);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.4);
  cursor: pointer;
  transition: background 0.15s ease;
}

.live-pill:hover {
  background: rgba(16, 185, 129, 0.3);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
  animation: pulseDot 2.2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.empty-row td {
  text-align: center !important;
  padding: 28px 16px !important;
  color: var(--text-muted) !important;
  font-size: 13px;
  background: var(--td-bg) !important;
}

.danger-zone-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border-radius: 10px;
  background: var(--bg-card-head);
  border: 1px solid var(--border);
}

.period-select {
  padding: 6px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.period-select option {
  background: #1e293b;
  color: #f8fafc;
}

.btn-theme {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 99px;
}

.btn-theme:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Excel/Spreadsheet Sheet Tab Ribbon */
.sheet-ribbon {
  position: sticky;
  top: 0;
  z-index: 35;
  background: var(--ribbon-bg);
  border-bottom: 1.5px solid var(--ribbon-border);
  padding: 7px 16px 0;
  display: flex;
  align-items: flex-end;
  gap: 5px;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.045);
}

.sheet-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px 9px;
  border: 1px solid transparent;
  border-bottom: 3px solid transparent;
  border-radius: 9px 9px 0 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.8px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  margin-bottom: -1.5px;
}

.sheet-tab:hover {
  background: var(--td-hover);
  color: var(--text-primary);
}

.sheet-tab.active {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: var(--ribbon-border);
  border-bottom: 3px solid var(--blue);
  font-weight: 700;
}

.tab-count {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--slate-soft);
  color: var(--slate-text);
}

.sheet-tab.active .tab-count {
  background: var(--blue);
  color: #fff;
}

.tab-count.warn {
  background: #f59e0b;
  color: #fff;
}

/* Main Sheet Workspace */
.workspace {
  padding: 18px 20px 48px;
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  flex: 1;
}

/* Compact KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--kpi-accent, var(--blue));
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.kpi-label {
  font-size: 11.8px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.kpi-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 4px 0 2px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Toolbar & Filter Bar */
.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sheet-hint {
  font-size: 12px;
  background: var(--hint-bg);
  color: var(--hint-text);
  padding: 5px 11px;
  border-radius: 99px;
  font-weight: 600;
}

.search-input {
  padding: 7px 12px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 215px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* Spreadsheet Table Container */
.sheet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}

.sheet-card-header {
  padding: 12px 16px;
  background: var(--bg-card-head);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.sheet-card-header h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-card-header p {
  font-size: 12px;
  color: var(--text-muted);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  max-height: 72vh;
  -webkit-overflow-scrolling: touch;
}

/* Refined Eye-Friendly Spreadsheet Table */
table.sheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

table.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--th-bg);
  color: var(--th-text);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 11px 11px;
  border-right: 1px solid var(--th-border);
  border-bottom: 2px solid var(--th-border);
  text-align: left;
  white-space: nowrap;
}

table.sheet-table thead th:last-child { border-right: none; }
table.sheet-table thead th.num { text-align: right; }

table.sheet-table thead th.row-num-col {
  position: sticky;
  left: 0;
  z-index: 15;
  width: 40px;
  min-width: 40px;
  text-align: center;
  background: var(--th-rownum-bg);
  box-shadow: 2px 0 4px rgba(15, 23, 42, 0.05);
}

table.sheet-table tbody td {
  padding: 9px 11px;
  border-right: 1px solid var(--td-border);
  border-bottom: 1px solid var(--td-border);
  color: var(--text-primary);
  vertical-align: middle;
  background: var(--td-bg);
  transition: background-color 0.1s ease;
}

table.sheet-table tbody td:last-child { border-right: none; }

table.sheet-table tbody tr:nth-child(even) td {
  background: var(--td-zebra);
}

table.sheet-table tbody tr:hover td {
  background: var(--td-hover);
}

table.sheet-table tbody td.row-num {
  position: sticky;
  left: 0;
  z-index: 5;
  text-align: center;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--rownum-text);
  background: var(--rownum-bg) !important;
  user-select: none;
  box-shadow: 2px 0 4px rgba(15, 23, 42, 0.04);
}

/* Inline Quick-Add Row (Serene Spreadsheet Entry Bar) */
table.sheet-table tbody tr.inline-add-row td {
  background: var(--add-bg) !important;
  border-top: 2px solid var(--add-border-top);
  border-bottom: 2px solid var(--add-border-bot);
  padding: 8px 6px;
}

table.sheet-table tbody tr.inline-add-row td.row-num {
  background: var(--add-plus-bg) !important;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
}

/* Inline Editing Row */
table.sheet-table tbody tr.editing-row td {
  background: var(--edit-bg) !important;
  border-top: 2px solid var(--edit-border);
  border-bottom: 2px solid var(--edit-border);
  padding: 7px 6px;
}

/* Spreadsheet Cell Inputs (Comfortable & Tactile) */
.cell-input, select.cell-input {
  width: 100%;
  min-width: 72px;
  padding: 7px 9px;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  background: var(--input-bg);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.cell-input:focus, select.cell-input:focus {
  outline: none;
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.cell-input::placeholder {
  color: var(--text-muted);
  opacity: 0.78;
}

.cell-input.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-calc {
  font-weight: 800;
  color: var(--calc-text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-size: 13px;
}

/* Sticky Total Footer */
table.sheet-table tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 8;
  padding: 10px 11px;
  background: var(--tfoot-bg);
  color: var(--tfoot-text);
  font-weight: 800;
  border-right: 1px solid var(--tfoot-border);
  border-top: 2px solid var(--tfoot-top);
}

table.sheet-table tfoot td:last-child { border-right: none; }
table.sheet-table tfoot td.row-num {
  position: sticky;
  left: 0;
  z-index: 10;
  text-align: center;
  background: var(--tfoot-bg);
}

/* Buttons & Actions */
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); color: #fff; box-shadow: 0 1px 3px rgba(37, 99, 235, 0.28); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-emerald { background: linear-gradient(135deg, #059669, #047857); color: #fff; box-shadow: 0 1px 3px rgba(5, 150, 105, 0.28); }
.btn-emerald:hover { filter: brightness(1.07); }
.btn-amber { background: linear-gradient(135deg, #d97706, #b45309); color: #fff; }
.btn-amber:hover { filter: brightness(1.07); }
.btn-rose { background: linear-gradient(135deg, #e11d48, #be123c); color: #fff; }
.btn-rose:hover { filter: brightness(1.07); }
.btn-outline { background: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
.btn-outline:hover { background: var(--td-hover); }
.btn-dark { background: rgba(255, 255, 255, 0.11); color: #e2e8f0; border-color: rgba(255, 255, 255, 0.2); }
.btn-dark:hover { background: rgba(255, 255, 255, 0.2); }

.btn-xs { padding: 4px 9px; font-size: 11.8px; border-radius: 6px; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }

.btn-icon {
  padding: 5px 8px;
  font-size: 12.5px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}
.btn-icon:hover { background: var(--td-hover); border-color: var(--blue); color: var(--blue); }
.btn-icon.del:hover { background: var(--rose-soft); color: var(--rose); border-color: var(--rose-border); }
.btn-icon.save { background: #059669; color: #fff; border-color: #059669; }

/* Subtabs */
.subtabs {
  display: flex;
  gap: 7px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.subtab {
  padding: 7px 14px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.14s ease;
}

.subtab:hover { border-color: var(--blue); color: var(--blue); }

.subtab.active {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

/* Soft Crisp Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-emerald { background: var(--emerald-soft); color: var(--emerald); border-color: var(--emerald-border); }
.badge-blue { background: var(--blue-soft); color: var(--blue); border-color: var(--blue-border); }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-border); }
.badge-rose { background: var(--rose-soft); color: var(--rose); border-color: var(--rose-border); }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: var(--purple-border); }
.badge-slate { background: var(--slate-soft); color: var(--slate-text); border-color: var(--border-light); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.grid-main-side { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; margin-bottom: 16px; }

.bank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow-sm);
}
.bank-card .bank-code { font-size: 11px; font-weight: 700; color: var(--blue); }
.bank-card .bank-name { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.bank-card .bank-bal { font-size: 19px; font-weight: 800; color: var(--text-primary); font-variant-numeric: tabular-nums; margin-top: 2px; }

.card-body { padding: 16px; }

/* Alerts & Financial Report Statements */
.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  margin-bottom: 8px;
  background: var(--bg-card);
}
.alert-item.warn { background: var(--amber-soft); border-color: var(--amber-border); }
.alert-item.info { background: var(--blue-soft); border-color: var(--blue-border); }

.fin-row { display: flex; justify-content: space-between; padding: 8px 11px; border-bottom: 1px solid var(--border-light); font-size: 13px; color: var(--text-primary); }
.fin-section { background: var(--fin-sec-bg); color: var(--fin-sec-text); font-weight: 800; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 11px; margin-top: 12px; border-radius: 7px; }
.fin-subtotal { display: flex; justify-content: space-between; padding: 9px 11px; font-weight: 700; background: var(--blue-soft); color: var(--text-primary); border: 1px solid var(--blue-border); border-radius: 6px; margin-top: 4px; }
.fin-total { display: flex; justify-content: space-between; padding: 12px 14px; font-weight: 800; font-size: 14.5px; background: var(--emerald-soft); color: var(--emerald); border: 1.5px solid var(--emerald-border); border-radius: 8px; margin-top: 10px; }

/* Charts */
.legend-list { display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; gap: 10px; color: var(--text-primary); }
.legend-left { display: flex; align-items: center; gap: 7px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.modal-box.wide { max-width: 880px; }
.modal-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: var(--bg-card-head); }
.modal-header h3 { font-size: 15.5px; font-weight: 700; color: var(--text-primary); }
.modal-close { border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary); width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--bg-card-head); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.input, select.input { padding: 8px 11px; border: 1px solid var(--input-border); border-radius: 7px; font-size: 13px; background: var(--input-bg); color: var(--text-primary); width: 100%; }
.input:focus, select.input:focus { outline: none; border-color: var(--input-focus); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14); }

/* Printable Slip / Invoice (Always crisp white paper) */
.print-doc { border: 1px solid #cbd5e1; border-radius: 8px; padding: 20px; background: #fff; color: #0f172a; }
.print-doc-header { display: flex; justify-content: space-between; border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 14px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.22s ease;
  max-width: 440px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #047857; }
.toast.error { background: #be123c; }

.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-amber { color: var(--amber); }
.text-muted { color: var(--text-muted); }
.fw-700 { font-weight: 700; }

/* ============================================================================
   LOGIN OVERLAY, USER PILL & AUDIT TRAIL
   ============================================================================ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: linear-gradient(135deg, #10253a 0%, #173a56 50%, #115e59 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  color: #1e293b;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.login-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #2563eb);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.login-brand h2 { font-size: 16.5px; font-weight: 800; color: #0f172a; margin: 0; }
.login-brand p { font-size: 12.5px; color: #64748b; margin: 2px 0 0; }

.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field label { font-size: 12.5px; font-weight: 700; color: #334155; }
.login-field input {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  background: #f8fafc;
  color: #0f172a;
}
.login-field input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.pwd-wrap { position: relative; display: flex; align-items: center; }
.pwd-wrap input { padding-right: 42px; }
.pwd-toggle { position: absolute; right: 9px; border: none; background: transparent; cursor: pointer; font-size: 16px; padding: 4px 6px; opacity: 0.7; }
.pwd-toggle:hover { opacity: 1; }

.login-error { padding: 10px 12px; border-radius: 8px; background: #fff1f2; border: 1px solid #fecdd3; color: #be123c; font-size: 12.5px; font-weight: 600; }
.login-submit { width: 100%; padding: 12px 16px; font-size: 14px; font-weight: 700; justify-content: center; margin-top: 4px; border-radius: 9px; }

.login-accounts-box { margin-top: 18px; padding-top: 14px; border-top: 1px dashed #cbd5e1; }
.login-accounts-title { font-size: 12px; font-weight: 700; color: #475569; margin-bottom: 9px; }
.quick-user-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-user-btn {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 9px;
  padding: 9px 6px;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.15s;
}
.quick-user-btn:hover { border-color: #2563eb; background: #eff6ff; transform: translateY(-1px); }
.quick-user-btn strong { font-size: 12.5px; color: #0f172a; }
.quick-user-btn span { font-size: 10.5px; color: #64748b; }
.login-accounts-note { margin-top: 10px; font-size: 11.5px; color: #475569; line-height: 1.5; background: #f1f5f9; padding: 9px 11px; border-radius: 8px; }

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.18);
  color: #e0f2fe;
  border: 1px solid rgba(125, 211, 252, 0.35);
}

.btn-logout {
  background: rgba(244, 63, 94, 0.2);
  color: #fecdd3;
  border: 1px solid rgba(251, 113, 133, 0.38);
  font-size: 12px;
  padding: 5px 10px;
}
.btn-logout:hover { background: rgba(244, 63, 94, 0.38); color: #fff; }

.btn-amber-soft {
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
  border: 1px solid rgba(251, 191, 36, 0.42);
  font-size: 12px;
  padding: 5px 10px;
}
.btn-amber-soft:hover { background: rgba(245, 158, 11, 0.4); color: #fff; }

.author-tag {
  display: inline-block;
  margin-top: 2px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--slate-soft);
  color: var(--slate-text);
  white-space: nowrap;
}
.author-tag.owner { background: var(--amber-soft); color: var(--amber); }
.author-tag.irwan { background: var(--blue-soft); color: var(--blue); }
.author-tag.istri { background: var(--rose-soft); color: var(--rose); }

.cf-guide-box {
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12.5px;
  color: var(--text-primary);
  line-height: 1.6;
}
.cf-guide-box code {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 700;
  color: var(--blue);
}

/* ============================================================================
   RESPONSIVE MOBILE POLISH (COMFORTABLE ON ANDROID & IPHONE SCREENS)
   ============================================================================ */
@media (max-width: 1020px) {
  .grid-2, .grid-3, .grid-main-side { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .top-header { padding: 9px 11px; gap: 7px; }
  .brand-logo { width: 32px; height: 32px; font-size: 13px; border-radius: 8px; }
  .brand-text h1 { font-size: 13.5px; }
  .brand-text span { display: none; }
  .header-controls { width: 100%; gap: 5px; }
  .header-controls .btn, .header-controls .period-select, .user-pill, .balance-badge {
    font-size: 11.5px;
    padding: 4px 8px;
  }
  .sheet-ribbon { padding: 5px 8px 0; gap: 3px; }
  .sheet-tab { padding: 7px 10px; font-size: 12.2px; }
  .workspace { padding: 12px 9px 32px; }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .kpi-card { padding: 10px 11px; }
  .kpi-value { font-size: 15.5px; }
  .sheet-title { font-size: 14.5px; }
  .sheet-hint { font-size: 11.2px; padding: 4px 9px; }
  .search-input { min-width: 100%; width: 100%; }
  table.sheet-table { font-size: 12.8px; }
  table.sheet-table tbody td { padding: 8px 9px; }
  .form-grid { grid-template-columns: 1fr; }
  .login-card { padding: 22px 18px; }
  .quick-user-grid { grid-template-columns: 1fr; }
}

@media print {
  .login-overlay, .top-header, .sheet-ribbon, .no-print, .modal-header, .modal-footer, .toast, .inline-add-row {
    display: none !important;
  }
  .modal-backdrop.open { position: static !important; background: none !important; padding: 0 !important; }
  .modal-box { box-shadow: none !important; max-width: 100% !important; max-height: none !important; }
}
