/* Family Dashboard — shared styles */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-alt: #fbfaf6;
  --border: #e8e4dc;
  --text: #1f1d1a;
  --text-muted: #6b6660;
  --text-soft: #8e8a82;
  --accent-emi: #d96b8f;        /* warm pink */
  --accent-emi-soft: #fde7ed;
  --accent-mia: #4f7da3;        /* deep blue */
  --accent-mia-soft: #e3edf6;
  --accent-edu: #6b6f8e;        /* muted indigo for Education section */
  --accent-edu-soft: #eaecf3;
  --accent-fin: #4f8a7d;        /* deep teal for Finance section */
  --accent-fin-soft: #e1efea;
  --warn: #c97a1a;
  --warn-soft: #fbeed7;
  --good: #4a8a5c;
  --good-soft: #e1efe2;
  --bad: #b14a4a;
  --bad-soft: #f7e2e2;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 4px 14px rgba(20, 20, 20, 0.05);
  --radius: 14px;
  --radius-sm: 8px;
  --maxw: 1100px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 32px 28px 80px;
}

/* Top nav */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 18px 28px;
  background: var(--surface);
}
.topnav-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 16px;
}
.brand .dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: linear-gradient(135deg, var(--accent-emi), var(--accent-mia));
  border-radius: 50%;
  margin-right: 10px;
  vertical-align: middle;
}
.navlinks { display: flex; gap: 6px; flex-wrap: wrap; }
.navlinks a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}
.navlinks a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.navlinks a.active { background: var(--text); color: var(--surface); }
/* Cross-app link (Dashboard <-> Planner) — visually set apart from section links */
.navlinks a.cross { margin-left: 10px; border: 1px solid var(--border); color: var(--text-soft); }
.navlinks a.cross:hover { background: var(--accent-fin); color: #fff; border-color: var(--accent-fin); }

/* Planner hub tool tiles */
.tool-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 760px) { .tool-grid { grid-template-columns: 1fr; } }
.tool-card {
  background: var(--surface); border: 1px solid var(--border);
  border-top: 3px solid var(--accent-fin); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px; min-height: 150px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(20,20,20,0.05), 0 12px 24px rgba(20,20,20,0.08); text-decoration: none; }
.tool-card .tool-emoji { font-size: 26px; line-height: 1; }
.tool-card .tool-name { font-weight: 600; font-size: 18px; letter-spacing: -0.01em; color: var(--text); }
.tool-card .tool-desc { font-size: 13px; color: var(--text-muted); }
.tool-card .tool-go { font-size: 13px; color: var(--accent-fin); font-weight: 600; margin-top: auto; }

/* Headings */
h1 {
  font-size: 32px;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  font-weight: 600;
}
h2 {
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  font-weight: 600;
}
h3 {
  font-size: 15px;
  margin: 0 0 8px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.subtitle {
  color: var(--text-muted);
  margin: 0 0 28px;
  font-size: 15px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-tight { padding: 16px 18px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Profile cards on index */
.kid-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(20,20,20,0.05), 0 12px 24px rgba(20,20,20,0.08);
  text-decoration: none;
}
.kid-card .kid-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.kid-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 20px;
  color: white;
  letter-spacing: -0.01em;
}
.kid-card.emi { border-top: 3px solid var(--accent-emi); }
.kid-card.mia { border-top: 3px solid var(--accent-mia); }
.kid-card.emi .kid-avatar { background: var(--accent-emi); }
.kid-card.mia .kid-avatar { background: var(--accent-mia); }
.kid-name { font-weight: 600; font-size: 19px; letter-spacing: -0.01em; }
.kid-meta { color: var(--text-muted); font-size: 13px; }

/* Page header strip with accent */
.page-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 4px;
}
.page-header .kid-avatar {
  width: 60px; height: 60px;
  font-size: 22px;
}
.emi-accent { color: var(--accent-emi); }
.mia-accent { color: var(--accent-mia); }

/* Lists */
ul.clean { padding-left: 18px; margin: 0; }
ul.clean li { margin-bottom: 6px; }

/* Tags / chips */
.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px solid var(--border);
  margin: 2px 4px 2px 0;
}
.chip.emi { background: var(--accent-emi-soft); color: var(--accent-emi); border-color: transparent; }
.chip.mia { background: var(--accent-mia-soft); color: var(--accent-mia); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.good { background: var(--good-soft); color: var(--good); border-color: transparent; }

/* Info / TODO callouts */
.callout {
  background: var(--warn-soft);
  border: 1px solid #f0ddb9;
  color: #6b4f1b;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-top: 10px;
}
.callout strong { color: var(--warn); }
.callout-info {
  background: #eef3f7;
  border-color: #d8e2eb;
  color: #2d4a63;
}
.callout-info strong { color: #2d4a63; }

/* Action items */
.action-list { list-style: none; padding: 0; margin: 0; }
.action-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.action-list li:last-child { border-bottom: none; }
.action-list .act-meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.checkbox {
  width: 16px;
  height: 16px;
  margin-top: 4px;
  border: 1.5px solid var(--text-soft);
  border-radius: 4px;
  flex-shrink: 0;
}

/* Tables — simple key/value and schedule */
table.kv {
  width: 100%;
  border-collapse: collapse;
}
table.kv td {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.kv tr:last-child td { border-bottom: none; }
table.kv td.k {
  color: var(--text-muted);
  width: 38%;
  font-size: 14px;
}

/* Schedule grid */
.schedule {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  table-layout: fixed;
}
.schedule th, .schedule td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  vertical-align: top;
  height: 56px;
}
.schedule th {
  background: var(--surface-alt);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  color: var(--text-muted);
}
.schedule td.time {
  color: var(--text-soft);
  font-size: 12px;
  width: 72px;
  background: var(--surface-alt);
}
.event {
  display: block;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.3;
  margin-bottom: 3px;
}
.event.emi { background: var(--accent-emi-soft); color: #8a3753; }
.event.mia { background: var(--accent-mia-soft); color: #2c5274; }
.event.shared { background: #ece9e1; color: #4a4640; }

.legend {
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.legend .swatch {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: middle;
}

/* Decision matrix */
.decision-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.decision-table th,
.decision-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.decision-table th {
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
}
.decision-table tr:last-child td { border-bottom: none; }

/* Footer */
.foot {
  text-align: center;
  color: var(--text-soft);
  font-size: 12px;
  margin-top: 50px;
}

/* Section spacing */
section { margin-bottom: 8px; }
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  margin-top: 26px;
}
.section-title h2 { margin: 0; }
.section-title .hint {
  font-size: 12px;
  color: var(--text-soft);
}

/* ===== Family hub & finance utilities ===== */

/* Sub-nav strip — section-level secondary navigation */
.subnav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 10px 0 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 22px;
  font-size: 13px;
}
.subnav a {
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--text-muted);
}
.subnav a:hover { background: var(--surface-alt); color: var(--text); text-decoration: none; }
.subnav a.active { background: var(--accent-edu-soft); color: var(--accent-edu); font-weight: 500; }
.subnav .crumb {
  color: var(--text-soft);
  font-size: 12px;
  align-self: center;
  margin-right: 6px;
}

/* Section hub cards on home page */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
  border-top: 3px solid var(--border);
}
.section-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(20,20,20,0.05), 0 12px 24px rgba(20,20,20,0.08);
  text-decoration: none;
}
.section-card.education { border-top-color: var(--accent-edu); }
.section-card.finance { border-top-color: var(--accent-fin); }
.section-card .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.section-card .section-name {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.section-card .section-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: white;
  letter-spacing: -0.01em;
}
.section-card.education .section-icon { background: var(--accent-edu); }
.section-card.finance .section-icon { background: var(--accent-fin); }
.section-card .section-summary {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}
.section-card .section-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.section-card .section-stats .stat { display: flex; flex-direction: column; }
.section-card .section-stats .stat-num {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.section-card .section-stats .stat-lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
}

/* Status pill (e.g. "Plan committed") */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.status-pill.committed { background: var(--good-soft); color: var(--good); }
.status-pill.in-progress { background: #f0e6d3; color: #8a6a1f; }
.status-pill.open { background: var(--accent-mia-soft); color: var(--accent-mia); }

/* KPI tiles for finance / hub */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
@media (max-width: 920px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.kpi .kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-soft);
  margin-bottom: 6px;
}
.kpi .kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.15;
}
.kpi .kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi.accent-fin { border-top: 3px solid var(--accent-fin); }
.kpi.accent-edu { border-top: 3px solid var(--accent-edu); }
.kpi.accent-emi { border-top: 3px solid var(--accent-emi); }
.kpi.accent-mia { border-top: 3px solid var(--accent-mia); }

/* Finance: expense type chips */
.chip.locked { background: #ece9e1; color: #4a4640; border-color: transparent; }
.chip.flex { background: #eef3f7; color: #2d4a63; border-color: transparent; }
.chip.cut { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* Number formatting helpers */
.num-pos { color: var(--good); font-variant-numeric: tabular-nums; }
.num-neg { color: var(--bad); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
td.num, th.num, td.num-pos, td.num-neg { text-align: right; }

/* Highlighted row for finance tables */
tr.row-cut td { background: #fdf3f3; }
tr.row-total td {
  background: var(--surface-alt);
  font-weight: 600;
  border-top: 2px solid var(--border);
}

/* Wealth bar — simple horizontal indicator */
.wealth-bar {
  position: relative;
  height: 28px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 6px 0;
}
.wealth-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-fin), #6fab9b);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.01em;
}
.wealth-fill.declining { background: linear-gradient(90deg, var(--warn), #d99a55); }

/* Trend arrows */
.trend-up { color: var(--good); font-weight: 600; }
.trend-down { color: var(--bad); font-weight: 600; }
.trend-flat { color: var(--text-soft); }

/* Caveat banner — softer than callout, for "honest about uncertainty" notes */
.caveat {
  background: #fbf6e9;
  border-left: 3px solid var(--warn);
  padding: 12px 16px;
  font-size: 13px;
  color: #5a4a26;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 12px 0;
}
.caveat strong { color: #6b4f1b; }

/* Compact two-up for inline summaries */
.inline-stats {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
  margin: 8px 0 6px;
}
.inline-stats .istat .num {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.inline-stats .istat .lbl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  display: block;
}

/* Timeline (vertical bullet list with dates) */
.timeline {
  position: relative;
  padding-left: 22px;
  margin: 0;
  list-style: none;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline li {
  position: relative;
  padding: 4px 0 12px;
  margin: 0;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-mia);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.timeline li.hot::before { background: var(--warn); }
.timeline li.done::before { background: var(--good); }
.timeline .tl-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  display: block;
  margin-bottom: 2px;
}
.timeline .tl-text {
  font-size: 14px;
  color: var(--text);
}

/* Soft section divider for long pages */
hr.soft {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0 22px;
}
