:root {
  /* color */
  --ink: #14171f;
  --ink-soft: #3a4150;
  --muted: #6b7280;
  --border: #e4e7ec;
  --border-soft: #eef0f3;
  --bg: #f8f9fb;
  --card: #ffffff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;

  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --todo: #9aa1ab;
  --todo-soft: #f1f2f4;
  --in-progress: #d97706;
  --in-progress-soft: #fef3e2;
  --done: #16a34a;
  --done-soft: #ecfdf3;

  /* radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  /* shadow */
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);

  /* spacing */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-8: 48px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; color: var(--ink); margin: 0 0 var(--space-2); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; }

.icon { width: 16px; height: 16px; display: inline-block; vertical-align: -3px; flex-shrink: 0; }

/* --- header / nav --------------------------------------------------- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-6);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 650;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-mark .icon { width: 14px; height: 14px; vertical-align: 0; }

.site-nav { display: flex; align-items: center; gap: var(--space-4); }
.nav-user { color: var(--muted); font-size: 0.85rem; }

.site-main {
  max-width: 880px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-8);
}

.page-header, .section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.header-actions { display: flex; gap: var(--space-2); align-items: center; }

/* --- flash messages --------------------------------------------------- */

.flashes { list-style: none; padding: 0; margin: 0 0 var(--space-4); }
.flash {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  font-size: 0.9rem;
}
.flash-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.flash-success { background: var(--done-soft); color: var(--done); border: 1px solid #bbf0cf; }

/* --- auth cards --------------------------------------------------- */

.auth-card {
  max-width: 400px;
  margin: var(--space-6) auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}
.auth-card h1 { text-align: center; margin-bottom: var(--space-5); }

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
}
.auth-logo .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.auth-logo .brand-mark .icon { width: 20px; height: 20px; }

.auth-switch { margin-top: var(--space-4); font-size: 0.88rem; color: var(--muted); text-align: center; }

.dev-reset-box {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--in-progress-soft);
  border: 1px solid #fbd39a;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
}
.dev-reset-box p { margin: var(--space-1) 0; word-break: break-all; }

/* --- forms --------------------------------------------------- */

.form-card {
  max-width: 560px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5) var(--space-6);
}
.form-card h1 { margin-bottom: var(--space-4); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: var(--space-4);
}
.back-link:hover { color: var(--accent); }

form.stacked-form, .auth-card form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

label { display: flex; flex-direction: column; gap: var(--space-1); font-size: 0.88rem; color: var(--ink-soft); font-weight: 500; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  font: inherit;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

button, .button, .button-secondary, .button-danger {
  font: inherit;
  font-weight: 550;
  font-size: 0.9rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: var(--space-2) var(--space-4);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
button:active, .button:active, .button-secondary:active, .button-danger:active { transform: translateY(1px); }

/* :where() zeroes out the [type="submit"] attribute's specificity, so
   this stays a low-priority default that .button-secondary/.button-danger/
   .link-button (plain class selectors) can still override -- without
   :where() here, button[type="submit"] (0,1,1) would outrank those
   single-class selectors (0,1,0) and always win regardless of source
   order, which is exactly the bug this replaced (delete/link buttons
   rendering as solid accent pills instead of their intended style). */
:where(button[type="submit"]), .button {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
:where(button[type="submit"]):hover, .button:hover { background: var(--accent-hover); }

.button-secondary { background: var(--card); color: var(--ink-soft); border-color: var(--border); }
.button-secondary:hover { background: var(--border-soft); }

.button-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.button-danger:hover { background: #fee2e2; }

.link-button {
  background: none;
  border: none;
  color: var(--muted);
  padding: var(--space-1) 0;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}
.link-button:hover { color: var(--accent); }
.link-button.link-danger:hover { color: var(--danger); }

.inline-form { display: inline-flex; }

/* --- empty states --------------------------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--muted);
  text-align: center;
  padding: var(--space-6) var(--space-4);
  font-size: 0.9rem;
}
.empty-state .icon {
  width: 32px;
  height: 32px;
  padding: var(--space-2);
  background: var(--border-soft);
  border-radius: 50%;
  color: var(--muted);
  vertical-align: 0;
}

/* --- dashboard client list --------------------------------------------------- */

.client-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-3); }
.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.client-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-soft); }

.client-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 650;
  font-size: 1rem;
  flex-shrink: 0;
}

.client-card-body { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: 1rem; color: var(--ink); text-decoration: none; }
.client-stats { display: flex; gap: var(--space-4); color: var(--muted); font-size: 0.83rem; margin-top: var(--space-1); flex-wrap: wrap; }

.client-profile p { margin: var(--space-1) 0; font-size: 0.92rem; }
.client-profile strong { color: var(--ink-soft); }
.client-birthday { display: flex; align-items: center; gap: var(--space-2); color: var(--ink-soft); }

.birthday-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--in-progress);
  background: var(--in-progress-soft);
  padding: 2px var(--space-2);
  border-radius: 999px;
}

/* --- intake --------------------------------------------------- */

.intake-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin: var(--space-4) 0;
  font-size: 0.88rem;
  flex-wrap: wrap;
}
.intake-status span { display: inline-flex; align-items: center; gap: var(--space-2); }
.intake-status-pending { background: var(--in-progress-soft); border: 1px solid #fbd39a; color: var(--ink-soft); }
.intake-status-done { background: var(--done-soft); border: 1px solid #bbf0cf; color: var(--ink-soft); }

.intake-intro { color: var(--muted); font-size: 0.9rem; margin-bottom: var(--space-5); }
.intake-form label { gap: var(--space-2); }
.intake-question-number { font-weight: 650; color: var(--accent); }

/* --- goals / milestones --------------------------------------------------- */

.goal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.goal-header { display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.goal-why, .goal-timeframe { color: var(--muted); font-size: 0.88rem; }

.goal-progress { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-4) 0; }
.goal-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}
.goal-progress-fill {
  height: 100%;
  background: var(--done);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.goal-progress-label { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }

.milestone-timeline { list-style: none; margin: var(--space-4) 0; padding: 0; }
.timeline-item {
  position: relative;
  padding-left: 1.85rem;
  padding-bottom: var(--space-4);
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 20px;
  bottom: -6px;
  width: 2px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-marker {
  position: absolute;
  left: 0;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--card);
  border: 3px solid var(--todo);
  box-sizing: border-box;
}
.timeline-item.status-in-progress .timeline-marker {
  border-color: var(--in-progress);
  box-shadow: 0 0 0 3px var(--in-progress-soft);
}
.timeline-item.status-done .timeline-marker {
  border-color: var(--done);
  background: var(--done);
}
.timeline-item.status-done .timeline-marker::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.timeline-content {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.milestone-header { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.status-badge {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px var(--space-2);
  border-radius: 999px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.status-badge.status-todo { background: var(--todo-soft); color: var(--todo); }
.status-badge.status-in-progress { background: var(--in-progress-soft); color: var(--in-progress); }
.status-badge.status-done { background: var(--done-soft); color: var(--done); }

.actions { list-style: none; padding: 0; margin: var(--space-2) 0; display: flex; flex-direction: column; gap: var(--space-2); }
.action { display: flex; align-items: center; gap: var(--space-2); font-size: 0.88rem; flex-wrap: wrap; }
.action-description { color: var(--ink-soft); }
.action-meta { color: var(--muted); font-size: 0.78rem; }

/* --- check-ins --------------------------------------------------- */

.checkin-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.checkin {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
}
.checkin-date { font-size: 0.75rem; color: var(--muted); }
.checkin p { margin: var(--space-1) 0; font-size: 0.9rem; }

/* --- wealth --------------------------------------------------- */

.wealth-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.wealth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
}
.wealth-card-main { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.wealth-date { font-size: 0.78rem; color: var(--muted); }
.wealth-net-worth { font-size: 1.15rem; font-weight: 650; color: var(--ink); }
.wealth-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.wealth-delta-up { color: var(--done); }
.wealth-delta-down { color: var(--danger); }
.wealth-breakdown { color: var(--muted); font-size: 0.8rem; margin-top: var(--space-1); }
.wealth-note { margin: var(--space-1) 0 0; font-size: 0.88rem; color: var(--ink-soft); }
.wealth-card-main form.inline-form { margin-left: auto; }

/* --- responsive --------------------------------------------------- */

@media (max-width: 480px) {
  .site-header { padding: var(--space-3) var(--space-4); }
  .site-main { padding: var(--space-4) var(--space-3) var(--space-6); }
  .page-header, .section-header { flex-direction: column; align-items: flex-start; }
  .client-card { flex-wrap: wrap; }
  .auth-card { padding: var(--space-5); margin: var(--space-4) auto; }
}
