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

html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: #f2f4f8;
  color: #111827;
  -webkit-font-smoothing: antialiased;
}

a, button { font-family: inherit; }

/* Shell */
.shell-header {
  background: #0f172a;
  color: #fff;
  padding: 12px 16px 6px;
}
.shell-title { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; }
.shell-user { font-size: 0.8125rem; color: #94a3b8; margin-top: 2px; }

.bottom-nav {
  display: flex;
  position: fixed;
  bottom: env(safe-area-inset-bottom, 0);
  left: 0; right: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  height: 68px;
  padding-top: env(safe-area-inset-bottom, 0) ? 0 : 6px;
  z-index: 50;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  border: none;
  background: none;
  color: #94a3b8;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  padding: 6px 4px 2px;
}
.nav-item.active { color: #2563eb; }

.shell-content {
  padding: 12px 14px;
  padding-bottom: 90px;
}
.shell-section { display: none; }
.shell-section.active { display: block; }

/* Components */
.kpi-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.kpi-card {
  flex: 1;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 12px 12px 10px;
}
.kpi-label { font-size: 0.75rem; color: #64748b; margin-bottom: 4px; }
.kpi-value { font-size: 1.25rem; font-weight: 700; color: #111827; letter-spacing: -0.01em; }
.kpi-value.warn { color: #dc2626; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.9375rem; font-weight: 700; margin: 6px 0 8px;
}
.small-btn {
  background: #eff6ff; color: #2563eb; border: none; border-radius: 10px;
  padding: 6px 12px; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
}
.small-btn:hover { background: #dbeafe; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 300px; color: #64748b; font-size: 0.9375rem;
  border: 1px dashed #cbd5e1; border-radius: 16px; background: #fafafa;
}

/* Expenses */
.expense-toolbar {
  display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; align-items: flex-end;
}
.expense-toolbar input {
  flex: 1; min-width: 150px; padding: 10px 12px; border: 1px solid #cbd5e1;
  border-radius: 12px; font-size: 0.9375rem; background: #fff;
}
.expense-toolbar select {
  min-width: 170px; padding: 10px 12px; border: 1px solid #cbd5e1;
  border-radius: 12px; font-size: 0.9375rem; background: #fff;
}
.primary-btn {
  background: #2563eb; color: #fff; border: none; border-radius: 12px;
  padding: 10px 18px; font-size: 0.9375rem; font-weight: 600; cursor: pointer;
}
.primary-btn:hover { background: #1d4ed8; }
.primary-btn.full { width: 100%; }
.outline-btn {
  background: #fff; color: #2563eb; border: 1px solid #cbd5e1; border-radius: 12px;
  padding: 10px 16px; font-size: 0.9375rem; font-weight: 600; cursor: pointer;
}
.outline-btn:hover { background: #f1f5f9; }
.outline-btn.full { width: 100%; }
.danger-btn {
  background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; border-radius: 12px;
  padding: 10px 16px; font-size: 0.9375rem; font-weight: 600; cursor: pointer;
}
.danger-btn:hover { background: #fecaca; }

.filter-chips { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; border-radius: 20px;
  padding: 6px 14px; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
}
.chip.active { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }

.list-wrap { border: 1px solid #e2e8f0; border-radius: 14px; background: #fff; overflow: hidden; }
.exp-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.exp-table th {
  background: #f8fafc; color: #64748b; font-weight: 600; text-align: left;
  padding: 10px 14px; border-bottom: 1px solid #e2e8f0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.exp-table td { padding: 12px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.exp-table tr:last-child td { border-bottom: none; }
.exp-duedate { font-weight: 700; color: #111827; }
.exp-name { font-weight: 600; color: #111827; }
.exp-category { font-size: 0.875rem; color: #475569; }
.exp-amount { font-weight: 700; color: #111827; text-align: right; }
.exp-amount.blank { color: #94a3b8; font-style: italic; }
.status-badge {
  display: inline-block; padding: 4px 10px; border-radius: 12px; font-size: 0.7875rem; font-weight: 700;
}
.status-paid { background: #dcfce7; color: #166534; }
.status-unpaid { background: #fef2f2; color: #b91c1c; }
.action-btns { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn {
  background: transparent; border: none; border-radius: 10px; width: 36px; height: 36px;
  color: #64748b; font-size: 1.125rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f1f5f9; }

.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#cal-month { font-weight: 700; font-size: 1.125rem; }
.calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
}
.cal-day {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; height: 64px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.875rem; color: #475569; position: relative;
}
.cal-day.today { background: #eff6ff; border-color: #2563eb; color: #2563eb; font-weight: 700; }
.cal-dot {
  position: absolute; bottom: 8px; width: 8px; height: 8px; background: #2563eb; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

/* Settings */
.settings-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 16px; margin-bottom: 12px;
}
.settings-title { font-weight: 700; font-size: 1rem; margin-bottom: 4px; color: #111827; }
.settings-note { font-size: 0.875rem; color: #64748b; margin-bottom: 12px; line-height: 1.5; }
.divider { height: 1px; background: #e2e8f0; margin: 12px 0; }

/* Form */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 0.875rem; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-row input, .form-row select {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 12px;
  font-size: 0.9375rem; background: #fff;
}
.form-row .hint { font-size: 0.7875rem; color: #64748b; margin-top: 4px; display: block; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* Modal */
.overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px); z-index: 100; display: none;
}
.modal {
  position: fixed; inset: 0; z-index: 110; display: none; align-items: center; justify-content: center;
  padding: 24px 14px; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}
.modal-panel {
  background: #fff; border-radius: 20px; width: 100%; max-width: 420px;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 40px -10px rgba(15,23,42,0.25);
}
.modal-header { display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 12px; border-bottom: 1px solid #f1f5f9; }
.modal-header span { font-weight: 700; font-size: 1.0625rem; color: #111827; }
.close-btn { background: none; border: none; font-size: 1.75rem; line-height: 1; color: #94a3b8; cursor: pointer; padding: 0; }
.modal-panel.narrow { max-width: 320px; text-align: center; }
.modal-panel.narrow p { color: #475569; margin: 16px 0; }

/* Safe area tweaks */
@supports (padding: max(0px)) {
  .shell-content { padding-bottom: calc(90px + env(safe-area-inset-bottom, 0)); }
}

/* Print-friendly not needed */