/* =========================================================
   DASHBOARD SPENDING & ARUS KAS (CUT-OFF TGL 22) - MOBILE FIRST
   ========================================================= */

:root {
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-muted: #f8fafc;
  --bg-header: #0f172a;
  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --green: #059669;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

[data-theme="dark"] {
  --bg-body: #0b1120;
  --bg-card: #1e293b;
  --bg-muted: #0f172a;
  --bg-header: #020617;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --primary: #3b82f6;
  --primary-soft: rgba(59, 130, 246, 0.18);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.18);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.18);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.18);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.45;
  padding-bottom: 84px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
.app-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  color: #ffffff;
  padding: 16px 16px 14px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.22);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.badge-cutoff {
  display: inline-block;
  background: rgba(56, 189, 248, 0.2);
  color: #7dd3fc;
  border: 1px solid rgba(125, 211, 252, 0.35);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}

.app-header h1 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.app-header .subtitle {
  font-size: 11.5px;
  color: #cbd5e1;
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn-primary-sm {
  background: #10b981;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.btn-primary-sm:active {
  transform: scale(0.97);
}

/* Filter Bar */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.filter-group label {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.filter-bar .form-select {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 10px;
}

.filter-bar .form-select option {
  background: #0f172a;
  color: #ffffff;
}

/* Main Container */
.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 14px 12px;
}

.tab-panel {
  display: none;
  animation: fadeIn 0.2s ease;
}

.tab-panel.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

@media (min-width: 680px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.kpi-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}

.kpi-income::before { background: var(--green); }
.kpi-expense::before { background: var(--red); }
.kpi-balance::before { background: var(--primary); }
.kpi-avg::before { background: var(--amber); }

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  word-break: break-word;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.card-header h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.card-desc {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.text-accent { color: var(--primary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.mt-12 { margin-top: 12px; }

/* Status Pills */
.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-surplus {
  background: var(--green-soft);
  color: var(--green);
}

.status-defisit {
  background: var(--red-soft);
  color: var(--red);
}

.status-seimbang {
  background: var(--primary-soft);
  color: var(--primary);
}

.status-empty {
  background: var(--bg-muted);
  color: var(--text-muted);
}

/* Period Summary Strip */
.period-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--bg-muted);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.strip-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.strip-item span {
  font-size: 10.5px;
  color: var(--text-muted);
}

.strip-item strong {
  font-size: 12.5px;
  font-weight: 700;
}

/* Charts */
.chart-wrapper {
  position: relative;
  width: 100%;
}

.chart-doughnut {
  height: 270px;
}

.chart-bar {
  height: 250px;
}

.chart-bar-tall {
  height: 310px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.data-table th {
  background: var(--bg-muted);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:hover {
  background: var(--bg-muted);
}

.data-table tfoot td {
  background: var(--bg-muted);
  font-weight: 800;
  border-top: 2px solid var(--border-color);
  border-bottom: none;
}

/* Sticky First Column for Horizontal Tables */
.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 2;
  font-weight: 600;
  border-right: 1px solid var(--border-color);
}

.data-table th:first-child,
.data-table tfoot td:first-child {
  background: var(--bg-muted);
}

/* Category Highlight Box */
.category-highlight-box {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

@media (min-width: 600px) {
  .category-highlight-box {
    grid-template-columns: repeat(4, 1fr);
  }
}

.cat-stat-mini {
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.cat-stat-mini span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}

.cat-stat-mini strong {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
}

/* Toggle Checkbox */
.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

/* Forms & Inputs */
.form-select,
.form-input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-muted);
  color: var(--text-main);
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.form-select:focus,
.form-input:focus {
  border-color: var(--primary);
}

.search-filter-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Transaction List Cards (Mobile Friendly) */
.tx-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.tx-main {
  min-width: 0;
  flex: 1;
}

.tx-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tx-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
}

.tx-cat-badge {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 600;
}

.tx-right {
  text-align: right;
  flex-shrink: 0;
}

.tx-amount {
  font-weight: 700;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

.tx-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 4px;
}

.tx-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: 11px;
  cursor: pointer;
}

.tx-btn.del {
  color: var(--red);
}

/* Input Form */
.tx-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.hint-text {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.radio-pill-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-pill {
  cursor: pointer;
}

.radio-pill input {
  display: none;
}

.radio-pill span {
  display: block;
  text-align: center;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-muted);
  font-weight: 600;
  font-size: 13px;
}

.radio-pill input:checked + span {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-primary {
  flex: 1;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-danger-outline {
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* Sync Section */
.sync-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.inline-input-btn {
  display: flex;
  gap: 8px;
}

.divider {
  border: none;
  border-top: 1px solid var(--border-color);
}

.sync-box h3 {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 3px;
}

.file-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.file-upload-btn input {
  display: none;
}

.btn-group-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 50;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.06);
}

.nav-item {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  cursor: pointer;
  font-family: inherit;
}

.nav-item.active {
  color: var(--primary);
  font-weight: 700;
}

.nav-icon {
  font-size: 18px;
  line-height: 1;
}

.nav-label {
  font-size: 10.5px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #ffffff;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 60;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Login */
.login-screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

body.locked { padding-bottom: 0; }
body.locked .login-screen { display: flex; }
body.locked > .app-header,
body.locked > .app-container,
body.locked > .bottom-nav,
body.locked > .toast { display: none; }

.login-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px 20px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-card .form-row { text-align: left; }
.login-card .form-input { font-size: 16px; }
.login-card .btn-primary { flex: none; }
.login-icon { font-size: 32px; }
.login-error { color: var(--red); font-size: 12px; min-height: 18px; }

