:root {
  --bg: #0b0f19;
  --surface: #131b2e;
  --surface-hover: #1b253d;
  --border: #23304d;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.14);
  --rose: #f43f5e;
  --rose-bg: rgba(244, 63, 94, 0.14);
  --amber: #f59e0b;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* Auth View */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.45);
}

.brand-badge {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.auth-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.input-group input {
  width: 100%;
  padding: 13px 16px;
  font-size: 1.05rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
  margin-bottom: 14px;
  text-align: center;
}

.input-group input:focus {
  border-color: var(--primary);
}

.error-msg {
  color: var(--rose);
  font-size: 0.85rem;
  margin-bottom: 12px;
}

/* Main App Container */
.app-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 18px 16px 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

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

.brand-icon {
  font-size: 1.75rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--primary);
}

/* Summary Cards */
.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card.under-budget {
  border-color: rgba(16, 185, 129, 0.35);
}

.stat-card.over-budget {
  border-color: rgba(244, 63, 94, 0.38);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.stat-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
}

.stat-pill.positive {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.stat-pill.negative {
  background: var(--rose-bg);
  color: var(--rose);
}

.stat-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.stat-value.positive {
  color: var(--emerald);
}

.stat-value.negative {
  color: var(--rose);
}

.stat-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--emerald);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-bar-fill.danger {
  background: var(--rose);
}

/* Add Expense Card */
.add-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

.quick-form-row {
  display: grid;
  grid-template-columns: 145px 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 480px) {
  .quick-form-row {
    grid-template-columns: 125px 1fr;
  }
}

.amount-field {
  position: relative;
  display: flex;
  align-items: center;
}

.currency-prefix {
  position: absolute;
  left: 12px;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 1.05rem;
  pointer-events: none;
}

.amount-field input {
  width: 100%;
  padding: 11px 10px 11px 28px;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}

.note-field input {
  width: 100%;
  padding: 11px 13px;
  font-size: 0.98rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  outline: none;
}

.amount-field input:focus,
.note-field input:focus {
  border-color: var(--primary);
}

.quick-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.date-picker-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.date-picker-wrap input[type='date'] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  outline: none;
  color-scheme: dark;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 9px 15px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
}

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 9px 15px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}

.full-width {
  width: 100%;
}

/* History & Day Cards */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.section-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.days-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
}

.day-title {
  font-weight: 600;
  font-size: 0.93rem;
}

.day-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
}

.day-total {
  font-weight: 700;
}

.day-diff {
  font-size: 0.76rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.day-diff.positive {
  background: var(--emerald-bg);
  color: var(--emerald);
}

.day-diff.negative {
  background: var(--rose-bg);
  color: var(--rose);
}

.expense-items {
  divide-y: 1px solid var(--border);
}

.expense-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: background 0.12s ease;
}

.expense-row:last-child {
  border-bottom: none;
}

.expense-row:hover {
  background: var(--surface-hover);
}

.expense-note-text {
  font-size: 0.92rem;
  color: var(--text);
}

.expense-note-text.empty {
  color: var(--text-muted);
  font-style: italic;
}

.expense-amount-text {
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  padding: 36px 20px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 15, 0.76);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h3 {
  font-size: 1.1rem;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  color-scheme: dark;
}

.form-field small {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions.split {
  justify-content: space-between;
}

.right-actions {
  display: flex;
  gap: 8px;
}
