/* =========================================================
   Goal Dashboard — Modern UI
   Pure CSS, no framework. Light + dark mode via prefers-color-scheme.
   ========================================================= */

/* ---------- Design tokens ---------- */
:root {
  /* Brand */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  /* Neutrals (slate) */
  --gray-25:  #fcfcfd;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --gray-950: #020617;

  /* Semantic */
  --success-50:  #ecfdf5;
  --success-200: #a7f3d0;
  --success-500: #10b981;
  --success-600: #059669;
  --success-700: #047857;

  --warning-50:  #fffbeb;
  --warning-200: #fde68a;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --warning-700: #b45309;

  --danger-50:  #fef2f2;
  --danger-200: #fecaca;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --danger-700: #b91c1c;

  --info-50:  #ecfeff;
  --info-200: #a5f3fc;
  --info-500: #06b6d4;
  --info-600: #0891b2;

  /* Light surfaces */
  --bg: var(--gray-50);
  --surface: #ffffff;
  --surface-2: var(--gray-100);
  --surface-3: var(--gray-200);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-soft: var(--gray-700);
  --text-muted: var(--gray-500);
  --text-faint: var(--gray-400);
  --text-on-brand: #ffffff;

  /* Sidebar (dark on both themes) */
  --side-bg: #0b1220;
  --side-bg-2: #111a2e;
  --side-border: rgba(255, 255, 255, 0.06);
  --side-text: #e2e8f0;
  --side-text-muted: #94a3b8;
  --side-hover: rgba(255, 255, 255, 0.06);
  --side-active: rgba(59, 130, 246, 0.16);
  --side-active-bar: var(--brand-500);

  /* Radii */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;
  --r-pill: 999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.10);
  --ring: 0 0 0 3px rgba(59, 130, 246, 0.25);
  --ring-danger: 0 0 0 3px rgba(239, 68, 68, 0.25);

  /* Motion */
  --t-fast: 120ms ease;
  --t: 180ms ease;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07101f;
    --surface: #0f1a30;
    --surface-2: #15243f;
    --surface-3: #1c3052;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --text: #e2e8f0;
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 18px 36px rgba(0, 0, 0, 0.50);
  }
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

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

a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--brand-600); }

p { margin: 0; color: var(--text-soft); }

h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.625rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: 0.95rem; font-weight: 600; }

small, .small { font-size: 0.8125rem; color: var(--text-muted); }

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

::selection { background: var(--brand-200); color: var(--brand-700); }

/* ---------- Layout shells ---------- */
.shell {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}

.content {
  padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem;
  min-width: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%);
  border-right: 1px solid var(--side-border);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.25rem 0.85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  padding: 0.4rem 0.55rem;
  color: var(--side-text);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand:hover { color: white; }
.brand-mark {
  align-items: center;
  background: linear-gradient(135deg, var(--brand-500), #6366f1);
  border-radius: 9px;
  color: white;
  display: inline-flex;
  font-weight: 800;
  height: 30px;
  justify-content: center;
  width: 30px;
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.35);
}

.nav-section-label {
  color: var(--side-text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 0.5rem 0.6rem 0.25rem;
  text-transform: uppercase;
}

.nav { display: grid; gap: 0.15rem; }

.nav-link {
  align-items: center;
  border-radius: var(--r-sm);
  color: var(--side-text);
  display: flex;
  font-size: 0.9rem;
  font-weight: 500;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover { background: var(--side-hover); color: white; }
.nav-link svg { flex-shrink: 0; opacity: 0.85; }
.nav-link.is-active {
  background: var(--side-active);
  color: white;
  font-weight: 600;
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -0.85rem;
  top: 50%;
  transform: translateY(-50%);
  height: 60%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--side-active-bar);
}
.nav-link.is-active svg { opacity: 1; color: var(--brand-400); }

.sidebar-footer { margin-top: auto; display: grid; gap: 0.15rem; }

.logout-form { margin: 0; }
.logout-form button {
  background: transparent;
  border: 0;
  color: var(--side-text-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.logout-form button:hover { background: var(--side-hover); color: white; }

/* ---------- Mobile top bar ---------- */
.topbar {
  display: none;
  background: var(--side-bg);
  color: var(--side-text);
  padding: 0.65rem 1rem;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--side-border);
}
.topbar .brand { padding: 0; }
.topbar summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--side-text);
}
.topbar summary::-webkit-details-marker { display: none; }
.topbar summary:hover { background: var(--side-hover); }

.mobile-menu {
  position: relative;
}
.mobile-menu[open] > .mobile-nav-panel {
  display: grid;
}
.mobile-nav-panel {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: min(260px, 80vw);
  background: var(--side-bg-2);
  border: 1px solid var(--side-border);
  border-radius: var(--r-md);
  padding: 0.5rem;
  gap: 0.1rem;
  box-shadow: var(--shadow-lg);
  z-index: 40;
}
.mobile-nav-panel .nav-link.is-active::before { display: none; }

/* ---------- Page header ---------- */
.page-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-head h1 { font-size: 1.625rem; }
.page-head p { color: var(--text-muted); margin-top: 0.25rem; max-width: 60ch; }

.eyebrow {
  color: var(--brand-600);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
}

.section-head {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.section-head h2 { font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.section-head a {
  color: var(--brand-600);
  font-size: 0.85rem;
  font-weight: 600;
}
.section-head a:hover { color: var(--brand-700); }

/* ---------- Buttons ---------- */
.button,
button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  gap: 0.45rem;
  padding: 0.55rem 0.85rem;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
}
.button:hover,
button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.button:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.button:active,
button:active { transform: translateY(1px); }

.button svg { flex-shrink: 0; }

.button.primary,
button.primary {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.10) inset, var(--shadow-sm);
}
.button.primary:hover,
button.primary:hover {
  background: var(--brand-700);
  border-color: var(--brand-700);
}

.button.ghost,
button.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-soft);
}
.button.ghost:hover { background: var(--surface-2); color: var(--text); }

.button.danger,
button.danger {
  background: var(--danger-600);
  border-color: var(--danger-600);
  color: white;
}
.button.danger:hover { background: var(--danger-700); border-color: var(--danger-700); }
.button.danger:focus-visible { box-shadow: var(--ring-danger); }

.button.sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.button.icon { padding: 0.5rem; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.row-actions a {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.55rem;
  border-radius: var(--r-xs);
  transition: background var(--t-fast), color var(--t-fast);
}
.row-actions a:hover { background: var(--surface-2); color: var(--text); }
.row-actions a.danger-link:hover { color: var(--danger-600); background: var(--danger-50); }

/* ---------- Grids ---------- */
.metric-grid,
.grid,
.lane-grid,
.note-grid {
  display: grid;
  gap: 1rem;
}
.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.5rem;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 1.5rem; }
.lane-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.note-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.stack { display: grid; gap: 0.6rem; }
.week-board { display: grid; gap: 1.5rem; }
.week-section { display: grid; gap: 0.75rem; }
.week-section.needs-date {
  border-left: 4px solid var(--warning-500);
  padding-left: 1rem;
}
.board-copy {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.2rem;
  max-width: 72ch;
}
.lane-board {
  display: grid;
  gap: 0.75rem;
}
.lane-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.lane-section summary {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  list-style: none;
  min-height: 3rem;
  padding: 0.75rem 1rem;
}
.lane-section summary::-webkit-details-marker { display: none; }
.lane-section summary::before {
  color: var(--text-muted);
  content: "▸";
  font-size: 0.8rem;
  transition: transform var(--t-fast);
}
.lane-section[open] summary::before { transform: rotate(90deg); }
.lane-section summary:hover { background: var(--surface-2); }
.lane-section summary:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
.lane-summary-main {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  flex: 1 1 auto;
  font-weight: 700;
  gap: 0.55rem;
  min-width: 0;
}
.lane-swatch {
  background: var(--lane-color, var(--brand-500));
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lane-color, var(--brand-500)) 18%, transparent);
  flex: 0 0 auto;
  height: 0.7rem;
  width: 0.7rem;
}
.lane-section .table-card {
  border: 0;
  border-radius: 0;
  box-shadow: none;
  border-top: 1px solid var(--border);
}

/* ---------- Cards ---------- */
.card,
.metric,
.lane-card,
.table-card,
.form-card,
.note-grid > article,
.trend,
.row-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}

.metric {
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.metric .metric-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.metric .metric-value {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.metric .metric-sub {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.metric.accent-blue .metric-value { color: var(--brand-600); }
.metric.accent-green .metric-value { color: var(--success-600); }
.metric.accent-amber .metric-value { color: var(--warning-600); }
.metric.accent-stoic .metric-value { color: var(--gray-600); }

/* Lane card */
.lane-card {
  border-left: 4px solid var(--brand-500);
  padding: 1rem 1.1rem;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.lane-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.lane-card .lane-top {
  align-items: center;
  display: flex;
  gap: 0.6rem;
  justify-content: space-between;
}
.lane-card h3 a { color: var(--text); }
.lane-card h3 a:hover { color: var(--brand-600); }
.lane-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lane-card .lane-stats {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}
.lane-card .lane-stats strong {
  color: var(--text);
  font-weight: 700;
  margin-right: 0.2rem;
}

/* List / table-style cards */
.table-card { overflow: hidden; padding: 0; }

.table-row {
  align-items: center;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.95rem 1.1rem;
  transition: background var(--t-fast);
}
.table-row:last-child { border-bottom: 0; }
.table-row:hover { background: var(--surface-2); }
.table-row .item-title {
  font-weight: 600;
  color: var(--text);
}
.table-row .item-title:hover { color: var(--brand-600); }
.table-row .item-meta {
  color: var(--text-muted);
  font-size: 0.825rem;
  margin-top: 0.2rem;
}

/* Row card (compact) */
.row-card {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.75rem 0.95rem;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.row-card:hover { border-color: var(--border-strong); background: var(--surface); }
.row-card .row-main { min-width: 0; flex: 1; }
.row-card .row-main a { font-weight: 600; color: var(--text); }
.row-card .row-main a:hover { color: var(--brand-600); }
.row-card .row-main p {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-top: 0.15rem;
}

/* ---------- Pills / badges ---------- */
.pill {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  color: var(--text-soft);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-weight: 600;
  gap: 0.25rem;
  letter-spacing: 0.02em;
  padding: 0.22rem 0.6rem;
  text-transform: capitalize;
  white-space: nowrap;
}
.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* Status variants */
.pill-active,
.pill-doing,
.pill-info {
  background: var(--brand-50);
  border-color: var(--brand-200);
  color: var(--brand-700);
}
.pill-done,
.pill-success {
  background: var(--success-50);
  border-color: var(--success-200);
  color: var(--success-700);
}
.pill-paused,
.pill-warning {
  background: var(--warning-50);
  border-color: var(--warning-200);
  color: var(--warning-700);
}
.pill-todo,
.pill-open,
.pill-neutral {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-soft);
}
.pill-overdue,
.pill-missed,
.pill-danger {
  background: var(--danger-50);
  border-color: var(--danger-200);
  color: var(--danger-700);
}

/* Lane pill — color comes from inline style */
.pill-lane {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-soft);
}
.pill-lane .dot { background: var(--lane-color, var(--brand-500)); }

@media (prefers-color-scheme: dark) {
  .pill-active, .pill-doing, .pill-info {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.30);
    color: #93c5fd;
  }
  .pill-done, .pill-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.30);
    color: #6ee7b7;
  }
  .pill-paused, .pill-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.30);
    color: #fcd34d;
  }
  .pill-overdue, .pill-missed, .pill-danger {
    background: rgba(239, 68, 68, 0.14);
    border-color: rgba(239, 68, 68, 0.32);
    color: #fca5a5;
  }
  .row-actions a.danger-link:hover {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
  }
}

/* ---------- Forms ---------- */
.form-card {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.form-card.wide { max-width: none; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
}
/* Text areas span full width */
.form-grid > label:has(textarea) { grid-column: 1 / -1; }
/* Title-ish fields too */
.form-grid > label.form-field-wide { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
}

.field,
input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="color"],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.6rem 0.75rem;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
input::placeholder,
textarea::placeholder { color: var(--text-faint); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--ring);
}

textarea { min-height: 110px; resize: vertical; }

input[type="color"] {
  height: 42px;
  padding: 0.2rem;
  cursor: pointer;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 18px;
  padding-right: 2.1rem;
}

.errorlist {
  color: var(--danger-600);
  font-size: 0.8rem;
  font-weight: 500;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.15rem;
}
.field-error input,
.field-error textarea,
.field-error select { border-color: var(--danger-500); }

.helptext, .form-card small {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 500;
}

.form-foot {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

/* ---------- Messages ---------- */
.messages {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.message {
  background: var(--success-50);
  border: 1px solid var(--success-200);
  border-radius: var(--r-md);
  color: var(--success-700);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.6rem 0.85rem;
}
@media (prefers-color-scheme: dark) {
  .message {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.30);
    color: #6ee7b7;
  }
}

/* ---------- Empty states ---------- */
.empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 1.25rem;
  text-align: center;
}

/* ---------- Progress bar ---------- */
.progress {
  background: var(--surface-3);
  border-radius: var(--r-pill);
  height: 10px;
  overflow: hidden;
  width: 100%;
}
.progress > span {
  background: linear-gradient(90deg, var(--brand-500), #6366f1);
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width 400ms ease;
}
.progress.is-done > span { background: linear-gradient(90deg, var(--success-500), var(--success-600)); }
.progress.is-low > span  { background: linear-gradient(90deg, var(--warning-500), var(--warning-600)); }

.progress-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin: 0.25rem 0 1.25rem;
}
.progress-row .progress { flex: 1; }
.progress-row .progress-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}

/* ---------- Health trend ---------- */
.trend {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  padding: 1rem;
}
.trend-point {
  border-left: 3px solid var(--success-500);
  display: grid;
  gap: 0.15rem;
  padding-left: 0.65rem;
}
.trend-point .date {
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.trend-point .value {
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}
.trend-point .sub {
  color: var(--text-muted);
  font-size: 0.74rem;
}

/* ---------- Notes ---------- */
.note-grid > article { padding: 1rem 1.1rem; }
.note-grid h2 {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
.note-grid p {
  color: var(--text-soft);
  font-size: 0.92rem;
  white-space: pre-wrap;
}

/* ---------- Rating bar (mood / energy / focus) ---------- */
.rating {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.rating-value {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.rating-bar {
  background: var(--surface-3);
  border-radius: var(--r-pill);
  height: 6px;
  overflow: hidden;
  position: relative;
}
.rating-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  width: calc(var(--level, 0) * 20%);
  background: linear-gradient(90deg, var(--brand-500), #6366f1);
  border-radius: inherit;
}

/* ---------- Auth page ---------- */
.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 1.25rem;
}
.auth-panel .auth-head { text-align: center; }
.auth-panel .auth-head h1 {
  font-size: 1.75rem;
  letter-spacing: -0.02em;
}
.auth-panel .auth-head p { color: var(--text-muted); margin-top: 0.4rem; }
.auth-panel .form-card { padding: 1.5rem; }
.auth-panel .form-card button { width: 100%; justify-content: center; }
.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-weight: 700;
}

/* ---------- Danger zone ---------- */
.danger-zone {
  background: var(--danger-50);
  border: 1px solid var(--danger-200);
  border-radius: var(--r-md);
  padding: 1.25rem;
  display: grid;
  gap: 1rem;
}
.danger-zone h1 { color: var(--danger-700); font-size: 1.25rem; }
.danger-zone p { color: var(--danger-700); }
@media (prefers-color-scheme: dark) {
  .danger-zone {
    background: rgba(239, 68, 68, 0.10);
    border-color: rgba(239, 68, 68, 0.30);
  }
  .danger-zone h1, .danger-zone p { color: #fca5a5; }
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.center { text-align: center; }
.flex { display: flex; gap: 0.5rem; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-2 { margin-bottom: 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { display: flex; }
  .content { padding: 1rem 1rem 2.5rem; }

  .table-row, .row-card {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.5rem;
  }
  .row-actions { width: 100%; justify-content: flex-start; }
  .lane-section summary {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .lane-section summary::before { margin-top: 0.2rem; }
  .lane-summary-main { flex: 1 1 calc(100% - 1.6rem); }

  .page-head { gap: 0.75rem; }
  .page-head h1 { font-size: 1.4rem; }

  .metric .metric-value { font-size: 1.5rem; }
}

/* Subtle scrollbar (webkit) */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--r-pill);
    border: 2px solid var(--bg);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }
}
