/* ═══════════════════════════════════════════════════════════
   TIME IS MONEY — Complete Design System
   Premium Monochrome Personal Finance Application
   Font: Inter | Colors: Black/White + Green/Red numbers only
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,300;0,14..32,400;0,14..32,500;0,14..32,600;0,14..32,700;0,14..32,800&display=swap');

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  /* Monochrome Palette */
  --c-bg:          #F5F5F5;
  --c-surface:     #FFFFFF;
  --c-surface-2:   #F0F0F0;
  --c-border:      #E3E3E3;
  --c-border-2:    #CACACA;
  --c-muted:       #8A8A8A;
  --c-body:        #1A1A1A;
  --c-heading:     #000000;

  /* Accent — Used ONLY for numeric values */
  --c-positive:    #15803D;
  --c-positive-bg: #F0FDF4;
  --c-negative:    #DC2626;
  --c-negative-bg: #FEF2F2;

  /* Interactive Elements */
  --c-btn:         #0A0A0A;
  --c-btn-text:    #FFFFFF;
  --c-btn-hover:   #2D2D2D;
  --c-btn-sub:     #F0F0F0;
  --c-btn-sub-hover:#E3E3E3;
  --c-btn-danger:  #DC2626;

  /* Typography Scale */
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-2xs:      10px;
  --text-xs:       11px;
  --text-sm:       12px;
  --text-base:     13px;
  --text-md:       14px;
  --text-lg:       16px;
  --text-xl:       20px;
  --text-2xl:      26px;
  --text-3xl:      34px;

  /* Spacing */
  --sp-1:  4px;   --sp-2:  8px;   --sp-3:  12px;
  --sp-4:  16px;  --sp-5:  20px;  --sp-6:  24px;
  --sp-8:  32px;  --sp-10: 40px;  --sp-12: 48px;

  /* Shape */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  10px;
  --radius-xl:  14px;
  --radius-2xl: 20px;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.10);

  /* Motion */
  --t-fast: 100ms ease;
  --t-base: 180ms ease;
  --t-slow: 300ms ease;

  /* Layout Dimensions */
  --header-h:  56px;
  --left-w:    252px;
  --right-w:   336px;
}

/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  font-size: var(--text-md);
  color: var(--c-body);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Premium Animations ────────────────────────────────── */
@keyframes skeletonPulse {
  0% { opacity: 0.5; }
  50% { opacity: 1; }
  100% { opacity: 0.5; }
}

.skeleton {
  background: var(--c-border);
  border-radius: var(--radius-md);
  animation: skeletonPulse 1.5s ease-in-out infinite;
  color: transparent !important;
  pointer-events: none;
  min-height: 1em;
}

.fade-in {
  animation: fadeIn var(--t-base) ease forwards;
}

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

/* ═══════════════════════════════════════════════════════════
   LAYOUT SHELL
   ═══════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  gap: var(--sp-4);
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  text-decoration: none;
  flex-shrink: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--c-heading);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.5px;
}

.brand-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--c-heading);
  letter-spacing: -0.3px;
}

/* Cycle Picker in header center */
.cycle-picker {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-1) var(--sp-3);
}

.cycle-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--c-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.cycle-btn:hover { background: var(--c-border); color: var(--c-body); }

.cycle-label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-body);
  white-space: nowrap;
  min-width: 140px;
  text-align: center;
}

.cycle-current-badge {
  font-size: var(--text-2xs);
  background: var(--c-heading);
  color: white;
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
}

.cycle-future-badge {
  font-size: var(--text-2xs);
  background: transparent;
  color: var(--c-heading);
  border: 1px solid var(--c-heading);
  padding: 0 5px;
  border-radius: 99px;
  font-weight: 600;
}

.cycle-past-badge {
  font-size: var(--text-2xs);
  background: transparent;
  color: var(--c-muted);
  border: 1px solid var(--c-border-2);
  padding: 0 5px;
  border-radius: 99px;
  font-weight: 600;
}

/* Header Navigation */
.header-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-shrink: 0;
}

.nav-item {
  padding: 6px var(--sp-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-muted);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}
.nav-item:hover { color: var(--c-body); background: var(--c-surface-2); }
.nav-item.active {
  color: var(--c-heading);
  background: var(--c-surface-2);
  font-weight: 600;
}

/* ─── Main Body ─────────────────────────────────────────── */
.app-body {
  flex: 1;
  overflow: hidden;
}

.app-body.view-dashboard {
  display: grid;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
}

.app-body.view-planning,
.app-body.view-settings {
  display: block;
  overflow-y: auto;
}

/* ─── Panels ────────────────────────────────────────────── */
.panel {
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  height: 100%;
}
.panel:last-child { border-right: none; }

.panel-left  { background: var(--c-surface); }
.panel-center { background: var(--c-bg); border-right: 1px solid var(--c-border); }
.panel-right { background: var(--c-surface); }

/* ═══════════════════════════════════════════════════════════
   LEFT PANEL — METRICS & ACCOUNTS
   ═══════════════════════════════════════════════════════════ */
.left-inner {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: 100%;
}

.metrics-section { padding: var(--sp-5) var(--sp-5) var(--sp-3); }

.metric-card {
  padding: var(--sp-4) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  background: var(--c-surface);
  margin-bottom: var(--sp-3);
  transition: box-shadow var(--t-base);
}
.metric-card:hover { box-shadow: var(--shadow-sm); }
.metric-card:last-child { margin-bottom: 0; }

.metric-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: var(--sp-2);
}

.metric-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--c-heading);
  letter-spacing: -1px;
  line-height: 1;
  margin-bottom: var(--sp-1);
}
.metric-value.positive { color: var(--c-positive); }
.metric-value.negative { color: var(--c-negative); }

.metric-sub {
  font-size: var(--text-xs);
  color: var(--c-muted);
  font-weight: 400;
}

/* Divider */
.panel-divider {
  height: 1px;
  background: var(--c-border);
  margin: 0 var(--sp-5);
}

/* Accounts Section */
.accounts-section {
  padding: var(--sp-4) var(--sp-5);
  flex: 1;
}

.section-title {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: var(--sp-3);
}

.account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-md);
  transition: background var(--t-fast);
  margin-bottom: var(--sp-1);
}
.account-item:hover { background: var(--c-surface-2); }

.account-left { display: flex; align-items: center; gap: var(--sp-2); }

.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-border-2);
  flex-shrink: 0;
}
.account-dot.spending { background: var(--c-heading); }
.account-dot.cash     { background: #555; }
.account-dot.savings  { background: var(--c-positive); }
.account-dot.credit   { background: var(--c-negative); }

.account-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-body);
}

.account-balance {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: -0.3px;
}
.account-balance.positive { color: var(--c-positive); }
.account-balance.negative { color: var(--c-negative); }
.account-balance.neutral  { color: var(--c-body); }

/* Self-Tax Section */
.self-tax-section {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--c-border);
  background: var(--c-surface-2);
}

.self-tax-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-2);
}

.self-tax-label {
  font-size: var(--text-xs);
  color: var(--c-muted);
  font-weight: 500;
}

.self-tax-value {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-body);
}
.self-tax-value.highlight { color: var(--c-positive); }

.btn-self-tax {
  width: 100%;
  margin-top: var(--sp-3);
  font-size: var(--text-xs);
  padding: 10px var(--sp-3);
}

/* ═══════════════════════════════════════════════════════════
   CENTER PANEL — TRANSACTION FORM
   ═══════════════════════════════════════════════════════════ */
.center-inner {
  padding: var(--sp-6) var(--sp-6);
  max-width: 480px;
  margin: 0 auto;
}

.form-header {
  margin-bottom: var(--sp-5);
}

.form-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-heading);
  letter-spacing: -0.4px;
}

/* Type Selector (Income / Expense) */
.type-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
  background: var(--c-surface-2);
  border-radius: var(--radius-lg);
  padding: var(--sp-1);
}

.type-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-4);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-base);
  background: transparent;
  color: var(--c-muted);
}

.type-btn.active {
  background: var(--c-surface);
  color: var(--c-heading);
  box-shadow: var(--shadow-md);
}

.type-btn.income-btn.active { color: var(--c-positive); }
.type-btn.expense-btn.active { color: var(--c-negative); }

.type-btn-icon {
  font-size: var(--text-lg);
  font-weight: 400;
}

/* Transfer Link */
.transfer-link-row {
  text-align: center;
  margin-bottom: var(--sp-4);
}

.transfer-link {
  font-size: var(--text-xs);
  color: var(--c-muted);
  text-decoration: underline;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  transition: color var(--t-fast);
}
.transfer-link:hover { color: var(--c-body); }

/* Form Groups */
.form-group { margin-bottom: var(--sp-4); }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-2);
}

.form-input, .form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--text-md);
  color: var(--c-body);
  background: var(--c-surface);
  outline: none;
  transition: all var(--t-base);
  appearance: none;
  -webkit-appearance: none;
}
.form-input::placeholder { color: var(--c-muted); transition: color var(--t-fast); }
.form-input:focus, .form-select:focus {
  border-color: var(--c-body);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
  transform: translateY(-1px);
}

.form-input.invalid, .form-select.invalid {
  border-color: var(--c-negative);
  background: var(--c-negative-bg);
}
.invalid-feedback {
  font-size: var(--text-xs);
  color: var(--c-negative);
  margin-top: 4px;
  display: block;
  animation: fadeIn var(--t-fast);
}

/* Amount Input — Large & prominent */
.amount-wrapper {
  position: relative;
}
.amount-prefix {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--c-muted);
  pointer-events: none;
  z-index: 1;
}
.form-input--amount {
  padding-left: 38px;
  font-size: var(--text-2xl);
  font-weight: 700;
  height: 64px;
  letter-spacing: -1px;
  color: var(--c-heading);
}
.form-input--amount::placeholder {
  font-weight: 300;
  color: var(--c-border-2);
}

/* Select arrow */
.select-wrapper { position: relative; }
.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--c-muted);
  font-size: var(--text-xs);
}
.select-wrapper .form-select { padding-right: 32px; }

/* Edit form in transaction list */
.tx-edit-form {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
  margin: var(--sp-2) 0;
}
.tx-edit-form .form-group { margin-bottom: var(--sp-3); }
.tx-edit-form .form-label { font-size: var(--text-2xs); }
.tx-edit-form .form-input, .tx-edit-form .form-select { padding: 7px 10px; font-size: var(--text-sm); }
.tx-edit-form .form-input--amount { height: 44px; font-size: var(--text-xl); }
.tx-edit-form .amount-prefix { font-size: var(--text-lg); }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px var(--sp-5);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--c-btn);
  color: var(--c-btn-text);
}
.btn-primary:hover:not(:disabled) { background: var(--c-btn-hover); }

.btn-secondary {
  background: var(--c-btn-sub);
  color: var(--c-body);
}
.btn-secondary:hover:not(:disabled) { background: var(--c-btn-sub-hover); }

.btn-ghost {
  background: transparent;
  color: var(--c-muted);
  padding: 6px var(--sp-3);
}
.btn-ghost:hover:not(:disabled) { background: var(--c-surface-2); color: var(--c-body); }

.btn-danger {
  background: var(--c-negative);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: #b91c1c; }

.btn-sm { padding: 6px var(--sp-3); font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { padding: 13px var(--sp-6); font-size: var(--text-md); }
.btn-full { width: 100%; }
.btn-full.btn-lg { padding: 14px; }

.form-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

/* ═══════════════════════════════════════════════════════════
   RIGHT PANEL — TRANSACTION LIST
   ═══════════════════════════════════════════════════════════ */
.panel-right-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 10;
}

.panel-right-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--c-heading);
  letter-spacing: -0.2px;
}

.tx-count-badge {
  font-size: var(--text-2xs);
  color: var(--c-muted);
  background: var(--c-surface-2);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}

/* Transaction list */
.tx-list { padding: var(--sp-2) var(--sp-1); }

.tx-date-group {
  padding: var(--sp-2) var(--sp-4) var(--sp-1);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tx-item {
  position: relative;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: 2px;
  transition: background var(--t-fast);
  cursor: default;
}
.tx-item:hover { background: var(--c-surface-2); }

.tx-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}

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

.tx-desc {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.tx-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.tx-meta-tag {
  font-size: var(--text-2xs);
  color: var(--c-muted);
  font-weight: 400;
}
.tx-meta-dot { color: var(--c-border-2); font-size: 8px; }

.tx-item-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

.tx-amount {
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: -0.3px;
  min-width: 70px;
  text-align: right;
}
.tx-amount.positive { color: var(--c-positive); }
.tx-amount.negative { color: var(--c-negative); }
.tx-amount.transfer { color: var(--c-muted); }

.tx-self-tax-badge {
  font-size: var(--text-2xs);
  background: var(--c-positive-bg);
  color: var(--c-positive);
  padding: 1px 6px;
  border-radius: 99px;
  font-weight: 600;
}

/* Transaction Action Buttons */
.tx-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.tx-item:hover .tx-actions { opacity: 1; }

.tx-action-btn {
  width: 26px;
  height: 26px;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--c-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.tx-action-btn:hover { background: var(--c-border); color: var(--c-body); }
.tx-action-btn.delete:hover { background: var(--c-negative-bg); color: var(--c-negative); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  gap: var(--sp-2);
}
.empty-icon { font-size: 32px; opacity: 0.3; }
.empty-title { font-size: var(--text-sm); font-weight: 600; color: var(--c-muted); }
.empty-sub { font-size: var(--text-xs); color: var(--c-muted); }

/* ═══════════════════════════════════════════════════════════
   PLANNING PAGE
   ═══════════════════════════════════════════════════════════ */
.planning-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-8);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--c-heading);
  letter-spacing: -0.5px;
}

/* Safe-to-Spend Summary Bar */
.planning-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.summary-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-5);
}
.summary-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--sp-2);
}
.summary-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -1px;
}
.summary-value.positive { color: var(--c-positive); }
.summary-value.negative { color: var(--c-negative); }
.summary-value.neutral  { color: var(--c-heading); }

/* Planning Grid */
.planning-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

.planning-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 2px solid var(--c-border);
}

.planning-col-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--c-heading);
  letter-spacing: -0.3px;
}

.planning-col-total {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.5px;
}
.planning-col-total.income  { color: var(--c-positive); }
.planning-col-total.expense { color: var(--c-negative); }

/* Planned Item Card */
.planned-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-2);
  transition: box-shadow var(--t-fast), opacity var(--t-fast);
}
.planned-item:hover { box-shadow: var(--shadow-sm); }
.planned-item.done  { opacity: 0.5; }

.planned-item.paynext-rollover {
  border-left: 3px solid var(--c-negative);
  background: var(--c-negative-bg);
}

.planned-status-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--c-border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--c-muted);
}
.planned-status-icon.done {
  background: var(--c-positive);
  border-color: var(--c-positive);
  color: white;
}

.planned-item-info { flex: 1; min-width: 0; }
.planned-item-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-body);
  margin-bottom: 2px;
}
.planned-item-meta { font-size: var(--text-2xs); color: var(--c-muted); }

.planned-item-amount {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.3px;
  flex-shrink: 0;
}
.planned-item-amount.income  { color: var(--c-positive); }
.planned-item-amount.expense { color: var(--c-negative); }

.planned-item-actions {
  display: flex;
  gap: var(--sp-1);
  flex-shrink: 0;
}

.planned-execute-btn {
  padding: 5px var(--sp-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Add Planned Item inline form */
.add-planned-form {
  background: var(--c-surface-2);
  border: 1px dashed var(--c-border-2);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  margin-top: var(--sp-3);
}

/* ═══════════════════════════════════════════════════════════
   SETTINGS PAGE
   ═══════════════════════════════════════════════════════════ */
.settings-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-8);
}

.settings-tabs {
  display: flex;
  gap: var(--sp-1);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--sp-6);
}

.settings-tab {
  padding: var(--sp-2) var(--sp-4);
  border: none;
  background: none;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.settings-tab:hover { color: var(--c-body); }
.settings-tab.active { color: var(--c-heading); border-bottom-color: var(--c-heading); font-weight: 600; }

.settings-content { display: none; }
.settings-content.active { display: block; }

.settings-section {
  margin-bottom: var(--sp-8);
}

.settings-section-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--c-heading);
  margin-bottom: var(--sp-4);
  letter-spacing: -0.3px;
}

/* Accounts Table */
.settings-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.settings-table th {
  background: var(--c-surface-2);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--c-border);
}
.settings-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--text-sm);
  color: var(--c-body);
  vertical-align: middle;
}
.settings-table tr:last-child td { border-bottom: none; }
.settings-table tr:hover td { background: var(--c-surface-2); }

.settings-table .balance-input {
  width: 140px;
  padding: 6px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--text-sm);
  color: var(--c-body);
  font-weight: 600;
  text-align: right;
}
.settings-table .balance-input:focus {
  border-color: var(--c-body);
  outline: none;
}

/* Account type badge */
.account-type-badge {
  font-size: var(--text-2xs);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 600;
  background: var(--c-surface-2);
  color: var(--c-muted);
}

/* Category Tree */
.category-tree { margin-top: var(--sp-4); }

.cat-main-item {
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-2);
  overflow: hidden;
}

.cat-main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  cursor: pointer;
  user-select: none;
}
.cat-main-header:hover { background: var(--c-surface-2); }

.cat-main-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-body);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.cat-chevron {
  font-size: var(--text-xs);
  color: var(--c-muted);
  transition: transform var(--t-fast);
}
.cat-main-item.open .cat-chevron { transform: rotate(180deg); }

.cat-sub-list {
  display: none;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
}
.cat-main-item.open .cat-sub-list { display: block; }

.cat-sub-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-4) var(--sp-2) var(--sp-8);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--text-sm);
  color: var(--c-body);
}
.cat-sub-item:last-child { border-bottom: none; }

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-3);
}
.toggle-info { flex: 1; }
.toggle-title { font-size: var(--text-sm); font-weight: 600; color: var(--c-body); }
.toggle-desc  { font-size: var(--text-xs); color: var(--c-muted); margin-top: 2px; }

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--c-border-2);
  border-radius: 99px;
  cursor: pointer;
  transition: background var(--t-base);
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: var(--shadow-sm);
}
.toggle-switch input:checked + .toggle-track { background: var(--c-heading); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(20px); }

/* ═══════════════════════════════════════════════════════════
   MODALS
   ═══════════════════════════════════════════════════════════ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  animation: backdrop-in 200ms ease forwards;
}
.modal-backdrop.exiting {
  animation: backdrop-out 200ms ease forwards;
}
@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes backdrop-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

.modal {
  background: var(--c-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-8);
  max-width: 400px;
  width: calc(100% - 48px);
  animation: modal-in 200ms ease forwards;
}
.modal-backdrop.exiting .modal {
  animation: modal-out 200ms ease forwards;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes modal-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(12px) scale(0.98); }
}

.modal-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto var(--sp-4);
}
.modal-icon.confirm { background: var(--c-surface-2); }
.modal-icon.danger  { background: var(--c-negative-bg); }

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--c-heading);
  text-align: center;
  margin-bottom: var(--sp-2);
  letter-spacing: -0.3px;
}
.modal-body {
  font-size: var(--text-sm);
  color: var(--c-muted);
  text-align: center;
  margin-bottom: var(--sp-6);
  line-height: 1.5;
}
.modal-amount {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--c-heading);
  text-align: center;
  margin-bottom: var(--sp-2);
  letter-spacing: -1px;
}
.modal-footer {
  display: flex;
  gap: var(--sp-2);
}
.modal-footer .btn { flex: 1; }

/* Execute modal account selector */
.modal-select-group { margin-bottom: var(--sp-4); }
.modal-select-label { font-size: var(--text-xs); font-weight: 600; color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: var(--sp-2); }

/* ═══════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 13px var(--sp-5) 13px var(--sp-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  pointer-events: auto;
  animation: toast-in 0.3s var(--t-slow);
}
.toast.exiting { animation: toast-out 0.3s ease forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(calc(100% + 24px)); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(calc(100% + 24px)); }
}

.toast-icon-wrap {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}
.toast-icon-wrap.success { background: var(--c-positive); color: white; }
.toast-icon-wrap.error   { background: var(--c-negative); color: white; }

.toast-text {
  flex: 1;
}
.toast-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-heading);
}
.toast-sub {
  font-size: var(--text-xs);
  color: var(--c-muted);
  margin-top: 1px;
}

.toast-close {
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--t-fast);
  pointer-events: auto;
}
.toast-close:hover { background: var(--c-surface-2); }

/* ═══════════════════════════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════════════════════════ */
.positive { color: var(--c-positive) !important; }
.negative { color: var(--c-negative) !important; }
.muted    { color: var(--c-muted)    !important; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

.hidden { display: none !important; }

.loading-shimmer {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, var(--c-border) 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-muted); }

.dashboard-mobile-tabs { display: none; }

/* ─── Responsive ────────────────────────────────────────── */
@media (max-width: 1200px) {
  :root { --left-w: 220px; --right-w: 290px; }
}

@media (max-width: 960px) {
  /* Mobile Dashboard Sub-Tabs */
  .dashboard-mobile-tabs {
    display: flex;
    justify-content: space-around;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: var(--sp-1) var(--sp-3);
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .db-tab-btn {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--c-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--t-fast);
  }
  
  .db-tab-btn.active {
    color: var(--c-heading);
    border-bottom-color: var(--c-heading);
  }

  .app-body.view-dashboard {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  
  .app-body.view-dashboard .panel {
    display: none !important;
    height: 100% !important;
    overflow-y: auto !important;
    border-right: none;
    border-bottom: none;
    flex: 1;
    background: var(--c-bg);
  }
  
  .app-body.view-dashboard .panel.active-mobile-panel {
    display: block !important;
  }

  /* Make panels look clean on mobile */
  .panel-left { background: var(--c-surface) !important; }
  .panel-right { background: var(--c-surface) !important; }
}

@media (max-width: 600px) {
  /* Bottom navigation bar */
  .header-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0;
    z-index: 1000;
  }
  
  .nav-item {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border-radius: 0;
    padding: 4px 0;
    background: none;
    border: none;
    color: var(--c-muted);
    gap: 2px;
  }
  
  .nav-item .nav-icon {
    font-size: 16px;
    margin-bottom: 2px;
  }

  .nav-item .nav-text {
    font-size: 10px;
    font-weight: 500;
  }
  
  .nav-item.active {
    background: transparent;
    color: var(--c-heading);
    font-weight: 700;
  }
  
  /* Make room for bottom nav */
  .app-shell {
    padding-bottom: 56px;
  }
  
  /* Hide the brand name text, leaving only the logo */
  .brand-name {
    display: none;
  }
  
  /* Compact cycle picker */
  .cycle-picker {
    padding: var(--sp-1) var(--sp-2);
  }
  
  .cycle-label {
    min-width: 100px;
    font-size: var(--text-xs);
  }
  
  /* Compact app-header padding */
  .app-header {
    padding: 0 var(--sp-3);
  }

  /* Center inner adjustments on mobile */
  .center-inner {
    padding: var(--sp-4) var(--sp-4);
  }

  /* Compact amount input */
  .form-input--amount {
    height: 52px;
    font-size: var(--text-xl);
  }
  .amount-prefix {
    font-size: var(--text-lg);
  }

  /* Mobile Modals as Bottom Sheets */
  .modal-backdrop {
    align-items: flex-end;
  }
  .modal {
    max-width: 100%;
    width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: var(--sp-6) var(--sp-6) calc(var(--sp-6) + env(safe-area-inset-bottom, 16px));
    box-shadow: 0 -8px 24px rgba(0,0,0,0.15);
    animation: modal-sheet-in 200ms cubic-bezier(0.1, 0.76, 0.55, 0.94) forwards;
  }
  .modal-backdrop.exiting .modal {
    animation: modal-sheet-out 200ms cubic-bezier(0.1, 0.76, 0.55, 0.94) forwards;
  }
  @keyframes modal-sheet-in {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  @keyframes modal-sheet-out {
    from { transform: translateY(0); }
    to   { transform: translateY(100%); }
  }

  /* Active tap feedback */
  .tx-item:active { background: var(--c-surface-2) !important; }
  .nav-item:active { background: var(--c-surface-2) !important; }
  .type-btn:active { background: var(--c-border) !important; }
  .planned-item:active { background: var(--c-surface-2) !important; }
}

/* Progress Bar */
.progress-bar-container { width: 100%; height: 4px; background-color: var(--c-surface-2); border-radius: 2px; margin-top: var(--sp-1); overflow: hidden; }
.progress-bar-fill { height: 100%; background-color: var(--c-heading); border-radius: 2px; transition: width var(--t-base), background-color var(--t-base); }
.progress-bar-fill.danger { background-color: var(--c-negative); }
.progress-bar-fill.warning { background-color: #F59E0B; }

/* Success Center Overlay */
.success-center-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.12);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  animation: backdrop-in 150ms ease forwards;
}
.success-center-backdrop.exiting {
  animation: backdrop-out 150ms ease forwards;
}
.success-center-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--sp-6) var(--sp-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  max-width: 280px;
  width: calc(100% - 48px);
  animation: modal-in 180ms cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
.success-center-backdrop.exiting .success-center-card {
  animation: modal-out 150ms ease forwards;
}
.success-center-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--c-positive-bg);
  color: var(--c-positive);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
}
.success-center-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--c-heading);
  text-align: center;
  letter-spacing: -0.2px;
}
