:root {
  /* Summer Dream palette: deep teal-blue, teal, cream, peach, coral */
  --deep: #1b6e8c;
  --bg: #fdf6d8;
  --surface: #ffffff;
  --primary: #14b8ac;
  --primary-dark: #1b6e8c;
  --primary-tint: #dff5f2;
  --teal: #14b8ac;
  --teal-tint: #dff5f2;
  --amber: #f0a868;
  --amber-tint: #fdeedc;
  --danger: #e8705f;
  --danger-tint: #fce7e3;
  --text: #17313a;
  --text-dim: #5b7278;
  --text-faint: #96a8ac;
  --border: #eae2c8;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(20, 45, 50, 0.08);
  --shadow-sm: 0 4px 14px rgba(20, 45, 50, 0.06);
}

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

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.icon svg { width: 100%; height: 100%; display: block; }
.icon-lg { width: 30px; height: 30px; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.phone {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
  padding-bottom: 92px;
}

/* ---------- top bar ---------- */

.topbar {
  padding: 22px 20px 14px;
}

.topbar .eyebrow {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.page-header {
  padding: 22px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.page-header h1 { margin: 0; font-size: 22px; font-weight: 800; }

/* ---------- views ---------- */

.view { display: none; padding: 0 16px; }
.view.active { display: block; }

/* ---------- section / card ---------- */

.section { margin-bottom: 18px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-head .link {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.card + .card { margin-top: 12px; }

/* ---------- stat / hero cards ---------- */

.hero-stat {
  background: linear-gradient(135deg, var(--danger), var(--amber));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 14px 30px rgba(232, 112, 95, 0.28);
}

.hero-stat .label { font-size: 12px; opacity: 0.85; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.hero-stat .amount { font-size: 32px; font-weight: 800; margin-top: 6px; }
.hero-stat .sub { font-size: 13px; opacity: 0.9; margin-top: 8px; display: flex; gap: 14px; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.mini-stat {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.mini-stat .label { font-size: 11px; color: var(--text-dim); font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; }
.mini-stat .value { font-size: 20px; font-weight: 800; margin-top: 4px; }
.mini-stat .value.income { color: var(--teal); }
.mini-stat .value.expense { color: var(--danger); }

/* ---------- DB Navigator ---------- */

.route-card {
  background: linear-gradient(135deg, #123544, var(--deep));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 14px 30px rgba(18, 53, 68, 0.32);
}

.route-stations {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 15px;
  font-weight: 700;
}

.route-stations .arrow { color: #8fd6ce; }

.refresh-btn {
  background: none;
  border: none;
  padding: 4px;
  margin: 0;
  opacity: 0.55;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.refresh-btn:hover { opacity: 1; }
.refresh-btn .icon { width: 15px; height: 15px; }
.refresh-btn.spinning .icon svg { animation: spin 0.7s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
}
.tag.late { background: var(--danger-tint); color: var(--danger); }
.tag.ontime { background: var(--teal-tint); color: #0b6f66; }

.route-meta { font-size: 12px; color: #a9dcd5; margin-top: 8px; }

.route-empty {
  text-align: center;
  padding: 10px 0 4px;
}
.route-empty .icon { margin: 0 auto; color: #a9dcd5; }
.route-empty p { color: #a9dcd5; font-size: 13px; margin: 8px 0 14px; }

.journey-list { margin-top: 10px; }
.journey-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 13px;
}
.journey-row:first-child { border-top: none; }

/* ---------- todos ---------- */

.todo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.todo-row:last-child { border-bottom: none; }

.todo-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.todo-title { font-size: 14px; font-weight: 600; flex: 1; }
.todo-row.done .todo-title { text-decoration: line-through; color: var(--text-faint); }

.priority-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.priority-dot.high { background: var(--danger); }
.priority-dot.medium { background: var(--amber); }
.priority-dot.low { background: var(--teal); }

/* ---------- inputs / buttons ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; color: var(--text-dim); font-weight: 700; }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fffdf3;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}
textarea { resize: vertical; min-height: 60px; }

.quick-add {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.quick-add input { flex: 1; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
}
button:active { transform: scale(0.98); }
button.secondary { background: var(--primary-tint); color: var(--primary-dark); }
button.ghost { background: transparent; color: var(--primary); padding: 10px; }
button.danger-ghost { background: var(--danger-tint); color: var(--danger); padding: 10px 14px; font-size: 13px; }
button.block { width: 100%; }
button.round {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.priority-select { display: flex; gap: 8px; }
.priority-select button {
  flex: 1;
  background: var(--primary-tint);
  color: var(--text-dim);
  font-size: 13px;
  padding: 10px;
}
.priority-select button.active { background: var(--primary); color: #fff; }

/* ---------- lists / rows ---------- */

.list-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 700; font-size: 14px; }
.list-row .subtitle { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.list-row .amount { font-weight: 800; font-size: 15px; white-space: nowrap; }
.list-row .amount.income { color: var(--teal); }
.list-row .amount.expense { color: var(--danger); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge.high { background: var(--danger-tint); color: var(--danger); }
.badge.medium { background: var(--amber-tint); color: #a3672c; }
.badge.low { background: var(--teal-tint); color: #0b6f66; }

.tab-pills { display: flex; gap: 8px; margin-bottom: 14px; }
.tab-pill {
  padding: 8px 14px;
  border-radius: 20px;
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.tab-pill.active { background: var(--primary); color: #fff; }

.icon-x {
  background: transparent;
  color: var(--text-faint);
  padding: 4px 8px;
  font-weight: 400;
  flex-shrink: 0;
}
.icon-x:hover { color: var(--danger); }

.empty-state { color: var(--text-dim); font-size: 13px; text-align: center; padding: 26px 10px; }
.empty-state .icon { margin: 0 auto 8px; color: var(--text-faint); }

/* ---------- modal / bottom sheet ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 40, 45, 0.45);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(20, 45, 50, 0.25);
  animation: sheet-up 0.22s ease-out;
}

@keyframes sheet-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}
.modal-header h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-header .icon-x { margin-top: -4px; }

.leg-block {
  position: relative;
  padding: 0 0 18px 22px;
  border-left: 2px solid var(--border);
  margin-left: 6px;
}
.leg-block:last-child { border-left-color: transparent; padding-bottom: 0; }
.leg-block::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
}
.leg-block.walking::before { background: var(--text-faint); }

.leg-mode {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 4px;
}
.leg-block.walking .leg-mode { color: var(--text-dim); font-weight: 700; }

.leg-stop {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 2px 0;
}
.leg-stop .name { font-weight: 600; }
.leg-stop .time { color: var(--text-dim); font-weight: 700; white-space: nowrap; margin-left: 10px; }
.leg-stop .time.late { color: var(--danger); }
.leg-stop .platform { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

/* ---------- events / weekly view ---------- */

.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.week-nav .ghost { padding: 6px 8px; font-size: 13px; }
.week-label { font-size: 14px; font-weight: 800; }

.week-day {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.week-day:first-child { border-top: none; }

.week-day-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.week-day-header.today { color: var(--primary); }

.week-event {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  background: var(--primary-tint);
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 4px;
}
.week-event:last-child { margin-bottom: 0; }
.week-event .time { font-size: 11px; font-weight: 700; color: var(--text-dim); white-space: nowrap; }

.event-row {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.event-row:last-child { border-bottom: none; }
.event-row .date-chip {
  flex-shrink: 0;
  width: 44px;
  text-align: center;
  background: var(--primary-tint);
  border-radius: var(--radius-sm);
  padding: 6px 0;
}
.event-row .date-chip .day { font-size: 16px; font-weight: 800; color: var(--primary-dark); line-height: 1; }
.event-row .date-chip .mon { font-size: 10px; font-weight: 700; color: var(--text-dim); text-transform: uppercase; margin-top: 2px; }

/* ---------- autocomplete ---------- */

.autocomplete { position: relative; }
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
}
.suggestions .sug-item {
  padding: 11px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.suggestions .sug-item:last-child { border-bottom: none; }
.suggestions .sug-item:hover { background: var(--primary-tint); }

/* ---------- bottom nav ---------- */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: #fff;
  display: flex;
  justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 24px rgba(30, 20, 90, 0.08);
  border-radius: 22px 22px 0 0;
  z-index: 50;
}

.nav-btn {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  color: var(--text-faint);
  font-size: 10px;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
}
.nav-btn .nav-icon { width: 21px; height: 21px; }
.nav-btn .nav-icon svg { width: 100%; height: 100%; display: block; }
.nav-btn.active { color: var(--primary); background: var(--primary-tint); }

/* ---------- toasts ---------- */

.toast-container {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  width: calc(100% - 40px);
  max-width: 420px;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--teal); color: #072e29; }

@media (min-width: 481px) {
  body { background: #f0e8cd; }
  .phone { box-shadow: 0 0 60px rgba(20, 45, 50, 0.14); }
}
