/* Flow — black and grey dark theme (matches manifest colors). */

:root {
  --bg: #0a0a0a;
  --surface: #161616;
  --surface-2: #222222;
  --border: #333333;
  --text: #e8e8e8;
  --text-dim: #888888;
  --accent: #f0f0f0;
  --red: #f87171;
  --yellow: #fbbf24;
  --green: #4ade80;
  --gray: #666666;
  --danger: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', Roboto, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 18px 10px;
  flex-shrink: 0;
}

.topbar h1 {
  font-size: 22px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-date {
  font-size: 13px;
  color: var(--text-dim);
}

.view {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 24px;
  -webkit-overflow-scrolling: touch;
}

.view h2 {
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 18px 2px 10px;
}

/* tab bar */

.tabbar {
  display: flex;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-family: inherit;
}

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

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

/* stats row */

.stats-row {
  display: flex;
  gap: 10px;
  margin: 10px 0 4px;
}

.stat-tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 10px;
  text-align: center;
}

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

.stat-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* sections */

.section, .section-collapsible {
  margin-top: 18px;
}

.section h2 { margin-top: 0; }

.section-collapsible summary {
  list-style: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 2px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-collapsible summary::-webkit-details-marker { display: none; }
.section-collapsible .count {
  background: var(--surface-2);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
}

.empty {
  color: var(--text-dim);
  font-size: 14px;
  padding: 6px 2px;
}

/* flow card (home screen) */

.flow-card {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}

.flow-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.flow-card-title {
  font-size: 15px;
  font-weight: 600;
}

.flow-card-sub {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flow-card-status {
  font-size: 12px;
  color: var(--text-dim);
  flex-shrink: 0;
  padding-top: 1px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.dot-red { background: var(--red); box-shadow: 0 0 6px rgba(248,113,113,0.6); }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); }
.dot-gray { background: var(--gray); }

/* list header + entity cards (Goals / Debts / People tabs) */

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}
.list-header h2 { margin: 0; }

.total-banner {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.entity-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.entity-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.entity-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.entity-status {
  font-size: 12px;
  color: var(--text-dim);
}

.entity-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 6px;
}

.entity-next {
  font-size: 13px;
  color: var(--accent);
  margin-top: 4px;
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  margin-top: 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

/* money (Money tab + home banner) */

.money-banner {
  margin: 4px 0 14px;
}
.money-banner .progress-track {
  margin-top: 8px;
}

.money-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-top: 10px;
}

.money-plan-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
}

.money-plan-row.money-plan-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-dim);
  margin-top: 8px;
}

.money-plan-amount { font-size: 18px; }

.money-plan-callout {
  font-size: 13px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--text);
}
.money-plan-callout.money-plan-warn { color: var(--yellow); }
.money-plan-callout.money-plan-ok { color: var(--green); }

.alloc-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}

.alloc-row-clickable {
  display: block;
  width: 100%;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

.alloc-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.alloc-label { font-weight: 600; flex: 1; }
.alloc-amount { color: var(--text-dim); font-size: 13px; flex-shrink: 0; }

.section-hint {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  font-size: 11px;
}

.money-hint {
  font-size: 12px;
  color: var(--accent);
  margin-top: 6px;
}

.paycheck-estimate {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 14px;
  margin-bottom: 8px;
}
.paycheck-estimate .alloc-row-top { padding: 6px 0; }
.paycheck-total {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  font-weight: 700;
}
.paycheck-total .alloc-label { color: var(--text); }
.paycheck-total .alloc-amount { color: var(--accent); font-size: 16px; }

/* buttons */

.btn-primary, .btn-secondary, .btn-danger {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  padding: 9px 14px;
  border: 1px solid transparent;
  cursor: pointer;
  display: inline-block;
  text-align: center;
}
.btn-primary { background: var(--accent); color: #0a0a0a; }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(239,68,68,0.4); }
.btn-full { width: 100%; margin-bottom: 6px; }

/* settings */

.settings-block { margin: 14px 0; }
.settings-block .hint { font-size: 12px; color: var(--text-dim); margin: 6px 2px 0; }
.settings-block.danger { margin-top: 30px; }
.about { text-align: center; font-size: 12px; color: var(--text-dim); margin-top: 30px; }

/* modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.modal-sheet {
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 16px 18px max(18px, env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close {
  background: var(--surface-2);
  border: none;
  color: var(--text-dim);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
}

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

/* forms */

.form { display: flex; flex-direction: column; gap: 12px; }
.form label {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-row { display: flex; gap: 10px; }
.form-row label { flex: 1; }

.form input, .form select, .form textarea {
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
}
.form textarea { resize: vertical; }

.checklist-editor { margin-top: 4px; }
.checklist-label { font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.checklist-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.checklist-row span { flex: 1; }
.checklist-row span.done { color: var(--text-dim); text-decoration: line-through; }
.checklist-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
}

/* toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 85vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
