/* ============================================================
   EducationHUB — Warm Professional Design System
   Phase 1 visual refresh. Class names preserved for backward
   compatibility with existing page templates and JS.
   Fonts (Fraunces + Switzer) are loaded via <link> tags in
   index-saas.html head for parallel loading.
   ============================================================ */

:root {
  /* ── Typography ────────────────────────────────────────── */
  --font: 'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Fraunces', Georgia, serif;
  --font-mono: 'SF Mono', 'Roboto Mono', ui-monospace, monospace;

  /* ── Colors: warm professional palette ────────────────── */
  /* Canvas — warm cream, not clinical white */
  --c-bg:           #faf7f1;
  --c-surface:      #ffffff;
  --c-surface-alt:  #f4f0e6;
  --c-overlay:      rgba(26, 24, 18, 0.42);

  /* Borders — warm, not gray */
  --c-border:       #e6dfcf;
  --c-border-strong:#d4ccb5;

  /* Text — warm near-blacks */
  --c-text:         #1a1814;
  --c-text-muted:   #615b4e;
  --c-text-faint:   #938c7c;
  --c-text-inverse: #faf7f1;

  /* Accent — forest green: trustworthy, grounded, distinctive */
  --c-accent:       #2d5a3d;
  --c-accent-soft:  #436f52;
  --c-accent-hover: #1f4029;
  --c-accent-tint:  rgba(45, 90, 61, 0.08);
  --c-accent-ring:  rgba(45, 90, 61, 0.18);

  /* State colors — muted, earthy, not clinical */
  --c-success:      #3a7d47;
  --c-success-tint: rgba(58, 125, 71, 0.10);
  --c-warn:         #b8754a;
  --c-warn-tint:    rgba(184, 117, 74, 0.12);
  --c-danger:       #9a2e2e;
  --c-danger-tint:  rgba(154, 46, 46, 0.10);
  --c-info:         #3c5a7a;
  --c-info-tint:    rgba(60, 90, 122, 0.10);

  /* Sidebar chrome — warm near-black, slightly green-tinted */
  --c-sidebar:            #1d1f1c;
  --c-sidebar-elev:       #282a26;
  --c-sidebar-active:     #32352f;
  --c-sidebar-text:       #c9c4b7;
  --c-sidebar-text-bright:#faf7f1;
  --c-sidebar-group:      #ece8dd;
  --c-sidebar-border:     rgba(236, 232, 221, 0.08);

  /* Legacy tokens removed. Pages now reference --c-accent,
     --c-accent-tint, --c-text, and --c-text-muted directly. */

  /* ── Spacing (4px base) ───────────────────────────────── */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;

  /* ── Radius ───────────────────────────────────────────── */
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* ── Shadows — warm-tinted, not neutral gray ──────────── */
  --shadow-sm: 0 1px 2px rgba(40, 30, 10, 0.05);
  --shadow:    0 2px 6px rgba(40, 30, 10, 0.06);
  --shadow-md: 0 4px 12px rgba(40, 30, 10, 0.07);
  --shadow-lg: 0 12px 32px rgba(40, 30, 10, 0.09);
  --shadow-xl: 0 24px 56px rgba(40, 30, 10, 0.14);
  --shadow-ring: 0 0 0 3px var(--c-accent-ring);

  /* ── Layout ───────────────────────────────────────────── */
  --sidebar-w:           304px;
  --sidebar-w-collapsed: 76px;
  --topbar-h:            68px;
  --content-max:         1280px;

  /* ── Motion ───────────────────────────────────────────── */
  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
  --ease-snap: cubic-bezier(0.25, 0.1, 0.25, 1.0);
  --dur-fast:  140ms;
  --dur-med:   260ms;
  --dur-slow:  420ms;
}

/* ============================================================
   Base
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: -0.005em;

  /* Subtle paper-like atmosphere */
  background-image:
    radial-gradient(ellipse at top left, rgba(45, 90, 61, 0.022) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(184, 117, 74, 0.022) 0%, transparent 50%);
  background-attachment: fixed;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
  color: var(--c-text);
  font-optical-sizing: auto;
}
h1 { font-size: 42px; font-weight: 500; font-variation-settings: "opsz" 144; }
h2 { font-size: 32px; font-weight: 600; font-variation-settings: "opsz" 72; }
h3 { font-size: 22px; font-weight: 600; font-variation-settings: "opsz" 36; }
h4 { font-size: 17px; font-weight: 600; font-variation-settings: "opsz" 18; }

p { margin: 0; }

a { color: var(--c-accent); text-decoration: none; transition: color var(--dur-fast) var(--ease-soft); }
a:hover { color: var(--c-accent-hover); text-decoration: underline; text-underline-offset: 3px; }

code, kbd {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--c-surface-alt);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--c-border);
}

/* ============================================================
   Utility classes (kept for compat with existing templates)
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.py-20 { padding-top: 5rem; padding-bottom: 5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.divider { height: 1px; background: var(--c-border); margin: 16px 0; }
.text-primary { color: var(--c-accent); }
.text-accent { color: var(--c-accent); }
.bg-primary { background: var(--c-accent); }
.bg-accent { background: var(--c-accent); }
.link { color: var(--c-accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ============================================================
   Layout shell
   ============================================================ */

.shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   Sidebar
   ============================================================ */

.sidebar {
  width: var(--sidebar-w);
  background: var(--c-sidebar);
  color: var(--c-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: width var(--dur-med) var(--ease-soft),
              transform var(--dur-med) var(--ease-soft);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-group-title,
.sidebar.collapsed .sidebar-footer-info { display: none; }
.sidebar.collapsed .sidebar-brand span { display: none; }
.sidebar.collapsed .sidebar-nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-group-items { max-height: none !important; overflow: visible; }

.sidebar-brand {
  padding: var(--s-6) var(--s-6) var(--s-5);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  border-bottom: 1px solid var(--c-sidebar-border);
  margin-bottom: var(--s-2);
}
.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent-soft) 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(45, 90, 61, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.sidebar-brand-icon svg {
  width: 20px;
  height: 20px;
  color: var(--c-sidebar-text-bright);
}
.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--c-sidebar-text-bright);
  white-space: nowrap;
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 24;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-3) var(--s-4) var(--s-4);
  scrollbar-width: thin;
  scrollbar-color: rgba(236, 232, 221, 0.12) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(236, 232, 221, 0.12);
  border-radius: 3px;
}

.sidebar-group-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--c-sidebar-group);
  padding: var(--s-5) var(--s-3) var(--s-2);
  letter-spacing: 0.03em;
  font-variation-settings: "opsz" 15;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
}

.sidebar-group-chevron {
  transition: transform var(--dur-fast) var(--ease-soft);
  opacity: 0.5;
  flex-shrink: 0;
}

.sidebar-group.collapsed .sidebar-group-chevron {
  transform: rotate(-90deg);
}

.sidebar-group-items {
  overflow: hidden;
  transition: max-height var(--dur-med) var(--ease-soft);
}

.sidebar-group.collapsed .sidebar-group-items {
  max-height: 0 !important;
  overflow: hidden;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 14px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--c-sidebar-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--dur-fast) var(--ease-soft),
              color var(--dur-fast) var(--ease-soft);
  position: relative;
  white-space: nowrap;
}
.sidebar-nav-item:hover {
  background: var(--c-sidebar-elev);
  color: var(--c-sidebar-text-bright);
}
.sidebar-nav-item.active {
  background: var(--c-sidebar-active);
  color: var(--c-sidebar-text-bright);
  font-weight: 600;
}
.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  background: var(--c-accent-soft);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
.sidebar-nav-item.active .sidebar-nav-icon { opacity: 1; color: var(--c-accent-soft); }

.sidebar-footer {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  min-height: 52px;
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #b8754a 0%, #8a4f2e 100%);
  display: grid;
  place-items: center;
  color: var(--c-text-inverse);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.sidebar-footer-info { overflow: hidden; flex: 1; min-width: 0; }
.sidebar-footer-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--c-sidebar-text-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer-role {
  font-size: 10px;
  color: var(--c-sidebar-text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.7;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--c-sidebar-text);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background var(--dur-fast) var(--ease-soft);
  margin-left: auto;
}
.sidebar-toggle:hover { background: var(--c-sidebar-elev); color: var(--c-sidebar-text-bright); }

/* Sidebar toggle footer button */
.sidebar-toggle-footer {
  padding: var(--s-3) var(--s-4);
  border-top: 1px solid var(--c-sidebar-border);
}
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--c-sidebar-text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-soft),
              color var(--dur-fast) var(--ease-soft);
  white-space: nowrap;
}
.sidebar-toggle-btn:hover {
  background: var(--c-sidebar-elev);
  color: var(--c-sidebar-text-bright);
}
.sidebar-toggle-icon {
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-soft);
}
.sidebar.collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}
.sidebar.collapsed .sidebar-toggle-footer {
  display: flex;
  justify-content: center;
  padding: var(--s-3) 0;
}
.sidebar.collapsed .sidebar-toggle-btn {
  justify-content: center;
  padding: 8px 0;
  width: 44px;
}

/* ============================================================
   Main area + topbar
   ============================================================ */

.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--dur-med) var(--ease-soft);
  display: flex;
  flex-direction: column;
}
.sidebar.collapsed ~ .main-area { margin-left: var(--sidebar-w-collapsed); }

.topbar {
  height: var(--topbar-h);
  background: rgba(250, 247, 241, 0.85);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-8);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: var(--s-3); }
.topbar-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.015em;
  font-variation-settings: "opsz" 24;
}
.topbar-breadcrumb {
  font-size: 12px;
  color: var(--c-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.topbar-breadcrumb a {
  color: var(--c-text);
  text-decoration: none;
  font-weight: 600;
}
.topbar-breadcrumb a:hover { color: var(--c-accent); text-decoration: underline; }
.topbar-right { display: flex; align-items: center; gap: var(--s-2); }

.content-area {
  flex: 1;
  padding: var(--s-8) var(--s-8) var(--s-12);
  max-width: var(--content-max);
  width: 100%;
  margin: 0 auto;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-soft);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-ring); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.btn svg { width: 15px; height: 15px; stroke-width: 2; }

.btn-primary {
  background: var(--c-accent);
  color: var(--c-text-inverse);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.btn-primary:hover {
  background: var(--c-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(45, 90, 61, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.btn-accent {
  background: var(--c-warn);
  color: var(--c-text-inverse);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.btn-accent:hover { filter: brightness(1.06); transform: translateY(-1px); }

.btn-secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-strong);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
  border-color: var(--c-accent);
  color: var(--c-accent);
  background: var(--c-accent-tint);
}

.btn-ghost {
  background: transparent;
  color: var(--c-text-muted);
}
.btn-ghost:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
}

.btn-danger {
  background: var(--c-surface);
  color: var(--c-danger);
  border-color: var(--c-danger);
}
.btn-danger:hover {
  background: var(--c-danger);
  color: var(--c-text-inverse);
}

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 9px; min-width: 36px; width: 36px; }

/* ============================================================
   Form inputs
   ============================================================ */

.input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-surface);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-soft),
              box-shadow var(--dur-fast) var(--ease-soft);
}
.input:focus {
  border-color: var(--c-accent);
  box-shadow: var(--shadow-ring);
}
.input::placeholder { color: var(--c-text-faint); }
.input:disabled { background: var(--c-surface-alt); color: var(--c-text-muted); cursor: not-allowed; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23615b4e' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text);
  margin-bottom: 6px;
  letter-spacing: -0.005em;
}

textarea.input { min-height: 84px; resize: vertical; font-family: var(--font); }

/* Checkbox / toggle */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  font-size: 14px;
  color: var(--c-text);
}
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 38px;
  height: 22px;
  background: var(--c-border-strong);
  border-radius: 11px;
  transition: background var(--dur-fast) var(--ease-soft);
  position: relative;
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--c-accent); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--c-surface);
  border-radius: 50%;
  transition: transform var(--dur-fast) var(--ease-soft);
  box-shadow: 0 1px 3px rgba(40, 30, 10, 0.25);
}
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
  transition: transform var(--dur-fast) var(--ease-soft),
              box-shadow var(--dur-fast) var(--ease-soft),
              border-color var(--dur-fast) var(--ease-soft);
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--c-border-strong);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--c-border);
}
.card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--c-text);
  font-variation-settings: "opsz" 18;
  letter-spacing: -0.01em;
}

.nav-card {
  border-left: 3px solid transparent;
  transition: all var(--dur-med) var(--ease-soft);
}
.nav-card:hover {
  border-left-color: var(--c-accent);
  transform: translateX(2px);
}

/* ============================================================
   Stat cards
   ============================================================ */

.stat-card {
  padding: var(--s-5);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--c-accent);
  opacity: 0.85;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 500;
  color: var(--c-text);
  line-height: 1;
  font-variation-settings: "opsz" 72;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--s-3);
}

/* ============================================================
   Badges (status chips)
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-green  { background: var(--c-success-tint); color: var(--c-success); }
.badge-yellow { background: var(--c-warn-tint);    color: var(--c-warn); }
.badge-red    { background: var(--c-danger-tint);  color: var(--c-danger); }
.badge-blue   { background: var(--c-info-tint);    color: var(--c-info); }
.badge-gray   { background: var(--c-surface-alt);  color: var(--c-text-muted); }
.badge-accent { background: var(--c-accent-tint);  color: var(--c-accent); }

/* ============================================================
   Tables
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  font-weight: 600;
  color: var(--c-text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--c-border);
  background: var(--c-surface-alt);
  position: sticky;
  top: 0;
}
.data-table tbody td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
  color: var(--c-text);
}
.data-table tbody tr { transition: background var(--dur-fast) var(--ease-soft); }
.data-table tbody tr:hover { background: var(--c-surface-alt); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn var(--dur-med) var(--ease-soft);
  display: flex;
  align-items: center;
  gap: var(--s-2);
  max-width: 380px;
  border: 1px solid transparent;
}
.toast-success {
  background: var(--c-surface);
  color: var(--c-success);
  border-color: var(--c-success-tint);
  border-left: 3px solid var(--c-success);
}
.toast-error {
  background: var(--c-surface);
  color: var(--c-danger);
  border-color: var(--c-danger-tint);
  border-left: 3px solid var(--c-danger);
}
.toast-info {
  background: var(--c-surface);
  color: var(--c-accent);
  border-color: var(--c-accent-tint);
  border-left: 3px solid var(--c-accent);
}
@keyframes toastIn {
  from { transform: translateX(80px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   Modals
   ============================================================ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--dur-fast) var(--ease-soft);
}
.modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--s-6) var(--s-8);
  max-width: 500px;
  width: 92%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: modalIn var(--dur-med) var(--ease-soft);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  color: var(--c-text);
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.02em;
  margin-bottom: var(--s-4);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   Spinner
   ============================================================ */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-accent-tint);
  border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-light {
  border-color: rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Empty state
   ============================================================ */

.empty-state {
  text-align: center;
  padding: var(--s-12) var(--s-5);
  color: var(--c-text-muted);
}
.empty-state-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--s-4);
  background: var(--c-accent-tint);
  border-radius: var(--radius-lg);
  display: grid;
  place-items: center;
}
.empty-state-icon svg { width: 28px; height: 28px; color: var(--c-accent); }
.empty-state h3 {
  font-size: 20px;
  margin-bottom: var(--s-2);
  color: var(--c-text);
}
.empty-state p {
  font-size: 14px;
  max-width: 360px;
  margin: 0 auto;
  line-height: 1.55;
}

/* ============================================================
   Page transitions
   ============================================================ */

.page-enter { animation: pageIn var(--dur-med) var(--ease-soft); }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-area { margin-left: 0 !important; }
  .content-area { padding: var(--s-5); }
  .topbar { padding: 0 var(--s-5); }
  h1 { font-size: 30px; }
  h2 { font-size: 24px; }
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-faint); }

/* ============================================================
   Theme picker (settings page — Phase 1 placeholder)
   ============================================================ */

.theme-swatch {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: all var(--dur-fast) var(--ease-soft);
  border: 2px solid transparent;
  overflow: hidden;
}
.theme-swatch:hover { transform: scale(1.06); }
.theme-swatch.active {
  border-color: var(--c-accent);
  box-shadow: var(--shadow-ring);
}
.theme-swatch-half { position: absolute; top: 0; bottom: 0; width: 50%; }
.theme-swatch-half:first-child { left: 0; }
.theme-swatch-half:last-child { right: 0; }

/* ============================================================
   Public pages (login, register, forgot, reset, pricing)
   ============================================================ */

.public-page {
  min-height: 100vh;
  background: var(--c-bg);
  background-image:
    radial-gradient(ellipse at top left, rgba(45, 90, 61, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse at bottom right, rgba(184, 117, 74, 0.05) 0%, transparent 55%),
    radial-gradient(circle at 50% 20%, rgba(250, 247, 241, 1) 0%, transparent 40%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}
.public-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: var(--s-10) var(--s-10);
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}
.public-brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-content: center;
  margin-bottom: var(--s-6);
}
.public-brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--c-accent) 0%, var(--c-accent-soft) 100%);
  border-radius: 12px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(45, 90, 61, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.public-brand-icon svg { width: 24px; height: 24px; color: var(--c-text-inverse); }
.public-brand span {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--c-text);
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 36;
}

/* ============================================================
   Goal Setting page (Phase 2)
   ============================================================ */

/* Scope segmented control */
.seg-ctl {
  display: inline-flex;
  background: var(--c-surface-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-btn {
  padding: 8px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--c-text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-soft);
  font-family: var(--font);
}
.seg-btn:hover { color: var(--c-text); }
.seg-btn.active {
  background: var(--c-surface);
  color: var(--c-accent);
  box-shadow: var(--shadow-sm);
}

/* Goal card grid */
.goal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-4);
}
.goal-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  min-height: 180px;
}

/* Progress dots for action steps */
.dots { display: inline-flex; gap: 4px; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-border-strong);
}
.dot.done { background: var(--c-accent); }

/* ============================================================
   Right drawer (goal detail)
   ============================================================ */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--c-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 70;
  display: flex;
  justify-content: flex-end;
  animation: fadeIn var(--dur-fast) var(--ease-soft);
}
.drawer {
  background: var(--c-surface);
  width: calc(100vw - var(--sidebar-w));
  max-width: calc(100vw - var(--sidebar-w));
  height: 100vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: drawerIn var(--dur-med) var(--ease-soft);
  display: flex;
  flex-direction: column;
}
@media (max-width: 768px) {
  .drawer {
    width: 100vw;
    max-width: 100vw;
  }
}
@keyframes drawerIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.drawer-header {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 5;
}
.drawer-body { flex: 1; }

.drawer-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.2;
  font-variation-settings: "opsz" 36;
  letter-spacing: -0.02em;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  margin: -4px -6px;
}
.drawer-title.editable:hover { background: var(--c-surface-alt); cursor: text; }

.drawer-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--s-2);
}

.drawer-text {
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--c-text);
  padding: var(--s-2) var(--s-3);
  border-radius: var(--radius-sm);
  margin: 0 -var(--s-3);
  min-height: 32px;
  white-space: pre-wrap;
}
.drawer-text.editable { cursor: text; }
.drawer-text.editable:hover { background: var(--c-surface-alt); }

/* Action step row */
.step-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease-soft);
}
.step-row:hover { background: var(--c-surface-alt); }
.step-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--c-accent);
  cursor: pointer;
}
.step-text {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--c-text);
  padding: 2px 6px;
  border-radius: 4px;
}
.step-text.editable:hover { background: var(--c-bg); cursor: text; }
.step-row input[type="checkbox"]:checked + .step-text {
  color: var(--c-text-muted);
  text-decoration: line-through;
}
.step-remove {
  opacity: 0;
  padding: 4px;
  min-width: 24px;
  width: 24px;
  height: 24px;
}
.step-row:hover .step-remove { opacity: 1; }

/* Check-in row */
.checkin-row {
  padding: var(--s-3);
  background: var(--c-surface-alt);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--c-accent-soft);
}

/* Link chip */
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--c-accent-tint);
  color: var(--c-accent);
  font-size: var(--text-xs);
  font-weight: 500;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-soft);
}
.link-chip:hover {
  background: rgba(45, 90, 61, 0.15);
  text-decoration: none;
}
.link-kind {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  background: var(--c-accent);
  color: var(--c-text-inverse);
  border-radius: 3px;
}

/* Stat cards in filter context get their border bar suppressed */
.stats-row .stat-card::before { display: none; }
.stats-row .stat-card {
  padding: var(--s-4) var(--s-5);
}
.stats-row .stat-value {
  font-size: 32px;
  line-height: 1;
  margin-top: 4px;
}

/* ============================================================
   SSO buttons
   ============================================================ */

.sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border-strong);
  background: var(--c-surface);
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-soft);
  text-decoration: none;
}
.sso-btn:hover {
  background: var(--c-surface-alt);
  border-color: var(--c-accent);
  color: var(--c-accent);
}
