:root {
  --bg-primary: #0b0f19;
  --bg-surface: #141c2c;
  --bg-surface-elevated: #1b253b;
  --border-color: #232f48;
  --border-subtle: #192338;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #0a84ff;
  --accent-blue-hover: #0070e0;
  --color-success: #30d158;
  --color-danger: #ff453a;
  --color-warning: #ffd60a;
  --color-warning-bg: rgba(255, 214, 10, 0.12);

  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --tab-bar-height: 70px;
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-bar-height) + env(safe-area-inset-bottom, 20px));
}

/* App Container */
.app-container {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px 16px;
}

.app-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

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

.app-logo {
  font-size: 24px;
}

.app-brand h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.app-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Account Switcher */
.account-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(20, 28, 44, 0.7);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
}

.account-pill {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: 9px;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.account-pill.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(10, 132, 255, 0.35);
}

.account-pill-name {
  font-size: 13px;
  font-weight: 600;
}

.account-pill-limit {
  font-size: 10px;
  opacity: 0.85;
}

/* Viewport */
.main-viewport {
  flex: 1;
  padding: 16px;
}

/* Cards & Surfaces */
.balance-card {
  background: linear-gradient(135deg, #182236 0%, #121929 100%);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.balance-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.balance-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.checkpoint-date {
  font-size: 11px;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 10px;
}

.balance-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  margin-bottom: 6px;
}

.balance-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

/* Overdraft Gauge */
.overdraft-gauge {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.overdraft-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.gauge-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  background: var(--color-warning);
  border-radius: 3px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent-blue);
  color: #ffffff;
}

.btn-primary:active {
  background: var(--accent-blue-hover);
  transform: scale(0.98);
}

.btn-success {
  background: var(--color-success);
  color: #0b0f19;
  font-weight: 700;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.btn-danger-outline {
  background: transparent;
  border: 1px solid rgba(255, 69, 58, 0.5);
  color: var(--color-danger);
}

.btn-outline-warning {
  background: transparent;
  border: 1px solid var(--color-warning);
  color: var(--color-warning);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 14px 20px;
  font-size: 16px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-blue);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

/* Alert Cards */
.alert-card {
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border-color);
}

.alert-warning {
  border-color: rgba(255, 214, 10, 0.4);
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.08) 0%, var(--bg-surface) 100%);
}

.alert-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.alert-title h3 {
  font-size: 15px;
  color: var(--color-warning);
  font-weight: 700;
}

.alert-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.uncertain-preview-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.uncertain-preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 8px 12px;
  border-radius: 10px;
}

.item-name {
  font-size: 13px;
  font-weight: 600;
  display: block;
}

.item-date {
  font-size: 11px;
  color: var(--text-muted);
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

/* Preview Card */
.preview-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 16px;
}

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

.preview-header h3 {
  font-size: 15px;
  font-weight: 700;
}

.timeline-preview-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.preview-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.preview-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-item-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 48px;
  text-align: center;
}

.preview-item-name {
  font-size: 13px;
  font-weight: 500;
}

.preview-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.preview-item-amount {
  font-size: 14px;
  font-weight: 700;
}

.preview-item-balance {
  font-size: 11px;
  color: var(--text-muted);
}

/* Colors */
.text-income {
  color: var(--color-success);
}

.text-expense {
  color: var(--color-danger);
}

.text-success {
  color: var(--color-success);
}

.text-danger {
  color: var(--color-danger);
}

.text-muted {
  color: var(--text-muted);
}

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

.wizard-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.wizard-account-badge {
  background: rgba(10, 132, 255, 0.2);
  color: var(--accent-blue);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.wizard-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 20px;
}

.wizard-instructions {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-input {
  width: 100%;
  background: #0f1624;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 14px;
  color: #ffffff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--accent-blue);
}

.form-input-lg {
  font-size: 24px;
  font-weight: 700;
  padding: 14px 16px;
}

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

.review-summary-box {
  background: rgba(10, 132, 255, 0.1);
  border: 1px solid rgba(10, 132, 255, 0.3);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.review-summary-box strong {
  font-size: 20px;
  color: #ffffff;
}

.review-intro {
  margin-bottom: 16px;
}

.review-intro h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-warning);
  margin-bottom: 4px;
}

.review-intro p {
  font-size: 12px;
  color: var(--text-secondary);
}

.decision-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.decision-card {
  background: #0f1624;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
  transition: all 0.2s ease;
}

.decision-card.decision-yes {
  border-color: rgba(48, 209, 88, 0.4);
}

.decision-card.decision-no {
  border-color: rgba(255, 214, 10, 0.4);
}

.decision-card-info {
  margin-bottom: 12px;
}

.decision-item-name {
  font-size: 15px;
  font-weight: 700;
}

.decision-item-instance {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 6px;
}

.decision-item-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.decision-item-amount {
  font-size: 16px;
  font-weight: 700;
  float: right;
}

.decision-item-reason {
  font-size: 11px;
  color: var(--color-warning);
  margin-top: 4px;
}

.decision-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-choice {
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-choice-yes.active {
  background: var(--color-success);
  color: #0b0f19;
  border-color: var(--color-success);
  font-weight: 700;
}

.btn-choice-no.active {
  background: rgba(255, 214, 10, 0.2);
  color: var(--color-warning);
  border-color: var(--color-warning);
  font-weight: 700;
}

.wizard-actions-split {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
}

.preview-item-hero-balance {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
}

.preview-item-sub-label {
  font-size: 10px;
  color: var(--text-muted);
}

.preview-item-change {
  font-size: 11px;
  font-weight: 600;
  display: block;
}

/* Timeline View */
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.timeline-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.account-tag {
  font-size: 12px;
  color: var(--text-secondary);
}

.daily-timeline-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.day-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.day-card-baseline {
  background: linear-gradient(135deg, #1b263b 0%, var(--bg-surface) 100%);
  border-color: var(--accent-blue);
}

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

.day-date-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.day-date-main {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.day-net-badge {
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.35);
  padding: 3px 8px;
  border-radius: 8px;
}

/* HERO BALANCE DISPLAY */
.day-hero-section {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: rgba(0, 0, 0, 0.28);
  border-radius: 14px;
  padding: 12px 16px;
  margin-bottom: 12px;
}

.day-hero-main {
  display: flex;
  flex-direction: column;
}

.day-hero-amount {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #ffffff;
  line-height: 1.1;
}

.day-hero-caption {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.day-own-section {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.day-own-caption {
  font-size: 10px;
  color: var(--text-muted);
}

.day-own-amount {
  font-size: 14px;
  font-weight: 700;
}

/* Movements Box */
.day-movements-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.day-movement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.movement-name {
  color: var(--text-secondary);
}

.movement-amt {
  font-weight: 600;
}

.timeline-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.timeline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 14px;
}

.timeline-card-baseline {
  background: linear-gradient(135deg, #1c263b 0%, var(--bg-surface) 100%);
  border-color: var(--accent-blue);
}

.timeline-row-top {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 10px;
  align-items: center;
}

.timeline-date-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 6px;
  border-radius: 10px;
}

.timeline-day {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.timeline-month-year {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 600;
}

.timeline-amount-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.timeline-amount {
  font-size: 15px;
  font-weight: 700;
}

.timeline-balance {
  font-size: 12px;
  color: var(--text-muted);
}

/* Status Badges */
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.3px;
  margin-top: 4px;
}

.badge-checkpoint { background: rgba(10, 132, 255, 0.2); color: var(--accent-blue); }
.badge-confirmed { background: rgba(48, 209, 88, 0.2); color: var(--color-success); }
.badge-pending { background: rgba(255, 69, 58, 0.2); color: var(--color-danger); }
.badge-uncertain { background: rgba(255, 214, 10, 0.2); color: var(--color-warning); }
.badge-auto { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }
.badge-manual { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.badge-oneoff { background: rgba(191, 90, 242, 0.2); color: #bf5af2; }

.timeline-overdraft-alert {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}

.overdraft-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.overdraft-critical {
  background: rgba(255, 69, 58, 0.15);
  color: var(--color-danger);
}

/* Planned Expenses Tab */
.section-header {
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.section-header p {
  font-size: 13px;
  color: var(--text-secondary);
}

.form-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 24px;
}

.form-card h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.existing-planned-list h3 {
  font-size: 15px;
  margin-bottom: 12px;
}

.planned-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.planned-item-name {
  font-size: 14px;
  font-weight: 600;
  display: block;
}

.planned-item-note {
  font-size: 11px;
  color: var(--text-muted);
}

.planned-item-date {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
}

.planned-item-amount {
  font-size: 15px;
  font-weight: 700;
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--color-danger);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
}

/* Settings Tab */
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 16px;
}

.settings-card h3 {
  font-size: 16px;
  margin-bottom: 14px;
}

.settings-btn-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-dialog {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 16px 20px;
  flex: 1;
  overflow: auto;
}

.json-textarea {
  width: 100%;
  height: 320px;
  background: #090e17;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: #38bdf8;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  outline: none;
  resize: vertical;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
}

/* Notifications */
.notification {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  width: calc(100% - 32px);
  max-width: 540px;
  padding: 12px 16px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  font-weight: 500;
}

.notification-success {
  background: #143522;
  border: 1px solid var(--color-success);
  color: #86efac;
}

.notification-error {
  background: #3b1717;
  border: 1px solid var(--color-danger);
  color: #fca5a5;
}

.notification-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 16px;
  cursor: pointer;
}

/* iOS Bottom Tab Bar */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border-top: 1px solid var(--border-subtle);
  padding-bottom: env(safe-area-inset-bottom, 10px);
}

.tab-bar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 60px;
}

.tab-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.tab-item.active {
  color: var(--accent-blue);
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-label {
  font-size: 10px;
  font-weight: 600;
}

/* Initial loader */
.initial-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 16px;
}

.loader-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(10, 132, 255, 0.2);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-title {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
}

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