/* ═══════════════════════════════════════════════════════════════
   Groundwrk · style.css
   Two themes in one file using CSS custom properties.
   Dark is the default (:root). Light overrides only what changes.
   The <html data-theme="light"> attribute is set by theme.js.
   ═══════════════════════════════════════════════════════════════ */


/* ─── Design Tokens · DARK (default) ────────────────────────── */
:root {
  /* Backgrounds */
  --bg:               #0D1117;
  --surface:          #161B22;
  --surface-elevated: #21262D;
  --border:           #30363D;

  /* Text */
  --text-primary:     #C9D1D9;
  --text-muted:       #8B949E;
  --text-placeholder: #484F58;

  /* Accents */
  --teal:             #4ECDC4;
  --teal-dim:         rgba(78, 205, 196, 0.15);
  --green:            #2EA043;
  --green-dim:        rgba(46, 160, 67, 0.15);
  --amber:            #D29922;
  --amber-dim:        rgba(210, 153, 34, 0.15);
  --red:              #F85149;
  --red-dim:          rgba(248, 81, 73, 0.15);
  --blue:             #58A6FF;

  /* Shadows — dark mode has no visible shadows */
  --shadow-sm:        none;
  --shadow-md:        none;

  /* Spacing */
  --xs:  4px;
  --sm:  8px;
  --md:  16px;
  --lg:  24px;
  --xl:  32px;
  --xxl: 48px;

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 8px;
}


/* ─── Design Tokens · LIGHT override ────────────────────────── */
/*
  Only the tokens that differ from dark are listed here.
  Spacing, radii, and accent hues are identical so they stay in :root.
*/
[data-theme="light"] {
  /* Backgrounds */
  --bg:               #FFFFFF;
  --surface:          #F6F8FA;
  --surface-elevated: #EFF1F3;
  --border:           #D0D7DE;

  /* Text */
  --text-primary:     #1F2328;
  --text-muted:       #656D76;
  --text-placeholder: #8C959F;

  /* Accent dims — slightly more transparent on white */
  --teal-dim:         rgba(78, 205, 196, 0.12);
  --green-dim:        rgba(46, 160, 67, 0.12);
  --amber-dim:        rgba(210, 153, 34, 0.12);
  --red:              #CF222E;
  --red-dim:          rgba(207, 34, 46, 0.08);

  /* Shadows — light mode uses subtle drop shadows on cards */
  --shadow-sm:        0 1px 3px rgba(31, 35, 40, 0.08);
  --shadow-md:        0 3px 8px rgba(31, 35, 40, 0.10);
}


/* ─── Theme transition ───────────────────────────────────────── */
/*
  Smooth crossfade when toggling. Only animate colour properties —
  animating everything can cause layout jank.
*/
body,
.task-card,
.add-form,
.btn,
.badge,
.task-counter,
.app-footer {
  transition:
    background-color 0.2s ease,
    border-color     0.2s ease,
    color            0.2s ease,
    box-shadow       0.2s ease;
}


/* ─── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}


/* ─── Layout ─────────────────────────────────────────────────── */
.app-wrapper {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--xl) clamp(var(--md), 4vw, var(--xxl));
}

.main-layout {
  display: flex;
  gap: var(--lg);
  align-items: flex-start;
}

.content-left {
  flex: 1;
  min-width: 0;
}


/* ─── Header / Wordmark ─────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--md);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--sm);
}

.wordmark {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  user-select: none;
}

.wordmark span { color: var(--teal); }

.task-counter {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--xs) var(--sm);
}


/* ─── Navigation Banner ─────────────────────────────────────── */
.app-nav {
  display: flex;
  align-items: center;
  gap: 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--xl);
  padding: 0 2px;
  background: var(--surface);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: var(--sm) var(--md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
}

.nav-link.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: 600;
}

.nav-link.disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}


/* ─── Mode Toggle Switch ──────────────────────────────────── */

.mode-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--md);
}

.mode-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  opacity: 0.4;
  transition: opacity 0.2s, color 0.2s;
}

.mode-icon.active {
  color: var(--teal);
  opacity: 1;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  transition: background 0.2s, border-color 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--teal);
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
}


/* ─── Header inline auth form ───────────────────────────────── */
.header-right .auth-wrap {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-wrap: wrap;
}

.header-right .auth-wrap input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: var(--xs) var(--sm);
  outline: none;
  width: 130px;
  transition: border-color 0.2s;
}

.header-right .auth-wrap input::placeholder { color: var(--text-placeholder); }
.header-right .auth-wrap input:focus { border-color: var(--teal); }


/* ─── User Avatar Dropdown ──────────────────────────────────── */
.user-menu {
  position: relative;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.user-avatar:hover { opacity: 0.85; }

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 1000;
  overflow: hidden;
}
.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 10px 14px;
}
.user-dropdown-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border);
}

.user-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
}
.user-dropdown-item:hover { background: var(--border); }

.user-dropdown-item-danger { color: var(--red); }

.user-dropdown-theme {
  cursor: default;
  gap: 6px;
}
.user-dropdown-theme:hover { background: transparent; }
.user-dropdown-theme .toggle-switch { cursor: pointer; margin: 0 2px; }
.user-dropdown-item-danger:hover { background: var(--red-dim); }


/* ─── Theme Toggle Button ────────────────────────────────────── */
.theme-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: var(--teal-dim);
}


/* ─── Page Hero (used on inner pages) ───────────────────────── */
.page-hero {
  display: flex;
  align-items: center;
  gap: var(--md);
  margin-bottom: var(--xl);
}

.page-hero-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--teal-dim);
  border: 1px solid rgba(78, 205, 196, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

.page-hero-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-hero-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}


/* ─── Add Task Form ──────────────────────────────────────────── */
.add-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  margin-bottom: var(--lg);
  display: flex;
  gap: var(--sm);
  align-items: center;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s;
}

.add-form:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.08);
}


/* ─── Sort / Filter Toolbar ─────────────────────────────── */
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sm);
  flex-wrap: wrap;
  margin-bottom: var(--md);
}

.toolbar-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  flex-shrink: 0;
}

.form-icon {
  color: var(--text-placeholder);
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.task-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
}

.task-input::placeholder { color: var(--text-placeholder); }

.priority-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: var(--xs) var(--sm);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.priority-select:focus { border-color: var(--teal); }


/* ─── Form Select Button (priority & category icon buttons) ─── */
.form-select-wrap {
  position: relative;
  flex-shrink: 0;
}

/* The real <select> is invisible but sits on top — clicking the button
   area triggers the native dropdown */
.form-select-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  color-scheme: dark;
}

[data-theme="light"] .form-select-overlay { color-scheme: light; }

/* The visible label text inside the button */
.form-select-val {
  font-size: 12px;
  font-weight: 500;
}

/* Priority colours */
.pri-high   { color: var(--red);   }
.pri-medium { color: var(--amber); }
.pri-low    { color: var(--teal);  }

[data-theme="light"] .pri-medium { color: #9a6700; }
[data-theme="light"] .pri-low    { color: #1a7f76; }


/* ─── Date Picker Button ─────────────────────────────────────── */
.date-picker-btn-wrap {
  position: relative;
  flex-shrink: 0;
}

/* All date inputs inside a picker-wrap are invisible — they just supply the native picker */
#taskDueDate,
.date-picker-btn-wrap input[type="date"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  color-scheme: dark;
}

[data-theme="light"] #taskDueDate,
[data-theme="light"] .date-picker-btn-wrap input[type="date"] { color-scheme: light; }


/* ─── Due Date Chip (on task cards) ─────────────────────────── */
.task-meta {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-wrap: wrap;
  margin-top: 3px;
}

.due-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
}

.due-overdue  { background: var(--red-dim);   color: var(--red);          }
.due-today    { background: var(--amber-dim);  color: var(--amber);        }
.due-soon     { background: var(--teal-dim);   color: var(--teal);         }
.due-future   { background: rgba(139,148,158,.1); color: var(--text-muted); }
.due-done     { background: rgba(139,148,158,.1); color: var(--text-muted); }

/* Clickable chips (not done) */
.due-chip:not(.due-done) { cursor: pointer; }

/* Placeholder shown on hover when no due date */
.due-add {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--text-placeholder);
  opacity: 0;
  transition: opacity 0.15s;
}
.task-card:hover .due-add { opacity: 1; }

/* Inline due date input on card */
.due-edit-input {
  background: var(--surface-elevated);
  border: 1px solid var(--teal);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 6px;
  outline: none;
  color-scheme: dark;
  width: 110px;
}
[data-theme="light"] .due-edit-input { color-scheme: light; }

[data-theme="light"] .due-today { color: #9a6700; }
[data-theme="light"] .due-soon  { color: #1a7f76; }


/* ─── Buttons ────────────────────────────────────────────────── */
.btn, a.btn, button.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--xs);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: var(--xs) var(--sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

/* Primary — teal fill. var(--bg) is #0D1117 in dark (dark text on teal ✓)
   and #FFFFFF in light (white text on teal ✓). Both have strong contrast. */
.btn-primary {
  background: var(--teal);
  color: var(--bg);
  border-color: var(--teal);
}
.btn-primary:hover { background: #3dbdb5; border-color: #3dbdb5; }

/* Secondary — outlined */
.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }

/* Danger — ghost red */
.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: transparent;
}
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); }

/* Ghost — no border */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--text-primary); background: var(--surface-elevated); }

/* Confirm delete — ghost green tick */
.btn-confirm {
  background: transparent;
  color: var(--teal);
  border-color: transparent;
}
.btn-confirm:hover { background: var(--teal-dim); border-color: var(--teal); }



/* ─── Section Heading ────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--sm);
  padding-left: var(--xs);
}


/* ─── Task List ──────────────────────────────────────────────── */
#taskList { display: flex; flex-direction: column; gap: var(--sm); }


/* ─── Task Card ──────────────────────────────────────────────── */
.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  display: flex;
  align-items: center;
  gap: var(--md);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.2s ease;
}

.task-card:hover {
  border-color: var(--teal);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
}

.task-card.done { opacity: 0.55; }
.task-card.done .task-title { text-decoration: line-through; color: var(--text-muted); }

/* Priority left accent */
.task-card.priority-high   { border-left: 3px solid var(--red);   }
.task-card.priority-medium { border-left: 3px solid var(--amber); }
.task-card.priority-low    { border-left: 3px solid var(--teal);  }


/* ─── Checkbox ───────────────────────────────────────────────── */
.task-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.task-check:hover { border-color: var(--teal); }

.task-card.done .task-check {
  border-color: var(--green);
  background: var(--green-dim);
  color: var(--green);
}


/* ─── Task Body ──────────────────────────────────────────────── */
.task-body { flex: 1; min-width: 0; }

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ─── Priority Badge ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  padding: 2px 7px;
  line-height: 1.6;
}

.badge-high   { background: var(--red-dim);                        color: var(--red);        }
.badge-medium { background: var(--amber-dim);                      color: var(--amber);      }
.badge-low    { background: var(--teal-dim);                       color: var(--teal);       }
.badge-done   { background: var(--green-dim);                      color: var(--green);      }
.badge-todo   { background: rgba(139, 148, 158, 0.15);             color: var(--text-muted); }

/* Badge text contrast adjustments for light mode */
[data-theme="light"] .badge-medium { color: #9a6700; }
[data-theme="light"] .badge-low    { color: #1a7f76; }
[data-theme="light"] .badge-done   { color: #1a7f37; }


/* ─── Task Actions ───────────────────────────────────────────── */
.task-actions {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-shrink: 0;
}


/* ─── Empty State ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--xxl) var(--md);
  display: none;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--teal-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--md);
  color: var(--teal);
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--xs);
}

.empty-sub {
  font-size: 13px;
  color: var(--text-muted);
}


/* ─── Divider between active / done ─────────────────────────── */
.tasks-divider {
  display: flex;
  align-items: center;
  gap: var(--sm);
  margin: var(--md) 0 var(--sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tasks-divider::before,
.tasks-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}


/* ─── Profile Page ───────────────────────────────────────────── */
.profile-hero-card {
  display: flex;
  align-items: center;
  gap: var(--lg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--lg) var(--xl);
  margin-bottom: var(--lg);
}

.profile-avatar-large {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  flex-shrink: 0;
  border: 3px solid var(--teal-dim);
}

.profile-hero-info {
  flex: 1;
  min-width: 0;
}

.profile-hero-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-hero-meta {
  display: flex;
  align-items: center;
  gap: var(--md);
  flex-wrap: wrap;
}

.profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--teal-dim);
  color: var(--teal);
  text-transform: capitalize;
}

.profile-since {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.profile-stats {
  display: flex;
  gap: var(--xl);
  margin-left: auto;
  flex-shrink: 0;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.profile-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.profile-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
  margin-bottom: var(--lg);
}

.profile-card .field-input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.form-hint {
  font-size: 11px;
  color: var(--text-placeholder);
  margin-top: 2px;
}

.profile-msg {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.profile-msg-ok {
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid var(--teal);
}

.profile-msg-err {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.profile-back {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: var(--md);
  transition: color 0.15s;
}
.profile-back:hover { color: var(--teal); }


/* ─── Settings page ──────────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sm) 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }

.setting-row-info {
  display: flex;
  align-items: center;
  gap: var(--sm);
  font-size: 13px;
  color: var(--text-primary);
}

.setting-row-icon {
  width: 15px;
  height: 15px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.setting-row-desc {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.setting-row-disabled { opacity: 0.55; }

.settings-nav-group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-placeholder);
  margin-bottom: var(--xs);
}

.settings-coming-soon {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

/* Checked (visible) state for nav setting toggles */
.setting-toggle input:checked + .toggle-slider {
  background: var(--teal);
  border-color: var(--teal);
}
.setting-toggle input:checked + .toggle-slider::before {
  background: #fff;
}


/* ─── Footer ─────────────────────────────────────────────────── */
.app-footer {
  margin-top: var(--xxl);
  padding-top: var(--md);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-placeholder);
}

.footer-brand { font-weight: 600; }
.footer-brand span { color: var(--teal); }


/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-placeholder); }


/* ─── Category Sidebar ───────────────────────────────────────── */
.category-sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: var(--xl);
}

.category-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  box-shadow: var(--shadow-sm);
}

.category-widget-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--md);
}

.category-add-form {
  display: flex;
  gap: var(--xs);
  margin-bottom: var(--md);
}

.category-input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: var(--xs) var(--sm);
  outline: none;
  transition: border-color 0.2s;
}

.category-input::placeholder { color: var(--text-placeholder); }
.category-input:focus { border-color: var(--teal); }

.category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px var(--sm);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.category-item:hover {
  background: var(--surface-elevated);
}

.category-item.active {
  background: var(--teal-dim);
  color: var(--teal);
}

.category-item-name {
  font-size: 13px;
  font-weight: 500;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.category-item.active .category-item-name { color: var(--teal); }

.category-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1px 7px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.category-item.active .category-count {
  background: var(--teal-dim);
  border-color: var(--teal);
  color: var(--teal);
}

.category-item-actions {
  display: none;
  gap: 2px;
}

.category-item:hover .category-item-actions { display: flex; }
.category-item:hover .category-count { display: none; }

.category-error {
  font-size: 11px;
  color: var(--red);
  margin-bottom: var(--sm);
  min-height: 16px;
}

/* Hide sidebar delete btn for Uncategorized */
.category-item[data-default="true"] .category-item-actions { display: none !important; }
.category-item[data-default="true"]:hover .category-count { display: flex; }


/* ─── Project Card ──────────────────────────────────────────── */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  display: flex;
  align-items: flex-start;
  gap: var(--md);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.2s ease;
  cursor: pointer;
  margin-bottom: var(--sm);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.project-card:hover {
  border-color: var(--teal);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
}

.project-card.priority-high   { border-left: 3px solid var(--red);   }
.project-card.priority-medium { border-left: 3px solid var(--amber); }
.project-card.priority-low    { border-left: 3px solid var(--teal);  }

.project-card-body { flex: 1; min-width: 0; }

.project-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.project-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card-meta {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-wrap: wrap;
}

.project-card-actions {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-shrink: 0;
}


/* ─── Back Link ─────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--xs);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: var(--lg);
  transition: color 0.15s;
}

.back-link:hover { color: var(--teal); }


/* ─── Project Hero (detail page) ────────────────────────────── */
.project-hero { margin-bottom: var(--lg); }

.project-hero-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-hero-desc-empty {
  font-style: italic;
  color: var(--text-placeholder);
}


/* ─── Project Info Panel (sidebar) ──────────────────────────── */
.project-info-panel {
  display: flex;
  flex-direction: column;
  gap: var(--sm);
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sm);
}

.info-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.info-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
}
.info-value.muted {
  color: var(--text-muted);
  font-weight: 400;
}


/* ─── Team Chips ────────────────────────────────────────────── */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-chip {
  display: flex;
  align-items: center;
  gap: var(--xs);
  padding: 5px var(--sm);
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s;
}

.team-chip:hover { background: var(--border); }

.chip-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-placeholder);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.team-chip:hover .chip-remove { opacity: 1; }
.chip-remove:hover { color: var(--red); }


/* ─── Deliverable Sections ──────────────────────────────────── */
.deliverable-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  margin-bottom: var(--md);
  box-shadow: var(--shadow-sm);
}

.deliverable-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sm);
  margin-bottom: var(--md);
}

.deliverable-header-info { flex: 1; min-width: 0; }

.deliverable-title {
  display: flex;
  align-items: center;
  gap: var(--xs);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.deliverable-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: var(--xs);
}

.deliverable-meta {
  display: flex;
  align-items: center;
  gap: var(--xs);
  flex-wrap: wrap;
}

.deliverable-header-actions {
  flex-shrink: 0;
}

.deliverable-tasks {
  display: flex;
  flex-direction: column;
  gap: var(--xs);
  margin-bottom: var(--sm);
}

.deliverable-tasks .task-card {
  padding: var(--sm) var(--md);
}

.deliverable-footer {
  display: flex;
  gap: var(--sm);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--sm);
  padding-top: var(--sm);
  border-top: 1px solid var(--border);
}

.deliverable-add-form {
  flex: 1;
  min-width: 200px;
  margin-bottom: 0;
  padding: var(--sm);
  font-size: 12px;
}

.deliverable-add-form .task-input {
  font-size: 12px;
}

.deliverable-assign {
  flex-shrink: 0;
}

.deliverable-assign .priority-select {
  font-size: 11px;
}

.deliverable-add-section {
  margin-top: var(--lg);
  margin-bottom: var(--lg);
}


/* ─── Date inputs on projects pages ─────────────────────────── */
#projectDueDate,
#newDeliverableDueDate {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
  color-scheme: dark;
}

[data-theme="light"] #projectDueDate,
[data-theme="light"] #newDeliverableDueDate {
  color-scheme: light;
}


/* ─── Category sidebar spacing for multiple widgets ─────────── */
.category-sidebar .category-widget + .category-widget {
  margin-top: var(--md);
}


/* ─── Overrun warning (project info panel) ──────────────────── */
.overrun-warning {
  margin-top: var(--sm);
  padding: var(--sm);
  background: var(--red-dim);
  border: 1px solid rgba(248, 81, 73, 0.3);
  border-radius: var(--radius-sm);
}

.overrun-warning-title {
  display: flex;
  align-items: center;
  gap: var(--xs);
  font-size: 11px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: var(--xs);
}

.overrun-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.overrun-list li {
  font-size: 11px;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overrun-type {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--red);
  opacity: 0.7;
}


/* ─── Task project badge (on task cards in Tasks page) ───────── */
.task-project-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--teal-dim);
  color: var(--teal);
  text-decoration: none;
  border: 1px solid rgba(78, 205, 196, 0.2);
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.task-project-badge:hover {
  background: rgba(78, 205, 196, 0.25);
  border-color: var(--teal);
}

[data-theme="light"] .task-project-badge { color: #1a7f76; }


/* ─── Deliverable due date placeholder ──────────────────────── */
/* Always visible (faint) in deliverable context, unlike task cards where it's hover-only */
.deliverable-meta .due-add,
.del-due-placeholder {
  opacity: 0.5;
}
.deliverable-meta .due-add:hover,
.del-due-placeholder:hover {
  opacity: 1;
}


/* ─── Deliverable member chips ───────────────────────────────── */
.del-members-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--xs);
  margin-top: var(--xs);
}

.del-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.del-member-chip .chip-remove {
  background: none;
  border: none;
  color: var(--text-placeholder);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.del-member-chip:hover .chip-remove { opacity: 1; }
.del-member-chip .chip-remove:hover { color: var(--red); }

.del-member-add { display: flex; align-items: center; }

.del-member-input {
  background: transparent;
  border: none;
  border-bottom: 1px dashed var(--border);
  border-radius: 0;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 4px;
  outline: none;
  width: 90px;
  transition: width 0.2s, border-color 0.2s;
}

.del-member-input::placeholder { color: var(--text-placeholder); font-style: italic; }
.del-member-input:focus { border-color: var(--teal); color: var(--text-primary); }


/* ─── Dashboard KPI Grid ─────────────────────────────────────── */
.kpi-grid {
  display: grid;
  gap: var(--md);
  margin-bottom: var(--sm);
}

.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md) var(--lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  border-top: 3px solid transparent;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  border-color: var(--teal);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
}

.kpi-card-accent-teal  { border-top-color: var(--teal);  }
.kpi-card-accent-red   { border-top-color: var(--red);   }
.kpi-card-accent-amber { border-top-color: var(--amber); }
.kpi-card-accent-green { border-top-color: var(--green); }

.kpi-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sm);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-teal  { background: var(--teal-dim);  color: var(--teal);  }
.kpi-icon-red   { background: var(--red-dim);   color: var(--red);   }
.kpi-icon-amber { background: var(--amber-dim); color: var(--amber); }
.kpi-icon-green { background: var(--green-dim); color: var(--green); }

.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}


/* ─── Dashboard Project KPI Rows ─────────────────────────────── */
.project-kpi-row {
  display: flex;
  align-items: center;
  gap: var(--md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--md);
  margin-bottom: var(--sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

.project-kpi-row:hover {
  border-color: var(--teal);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-md);
}

.project-kpi-accent {
  width: 4px;
  height: 40px;
  border-radius: 2px;
  flex-shrink: 0;
}

.project-kpi-body {
  flex: 1;
  min-width: 0;
}

.project-kpi-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-kpi-bar-wrap {
  display: flex;
  align-items: center;
  gap: var(--sm);
}

.project-kpi-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-elevated);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.project-kpi-bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 0;
}

.project-kpi-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

.project-kpi-stats {
  display: flex;
  align-items: center;
  gap: var(--sm);
  flex-shrink: 0;
}

.project-kpi-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
}

.project-kpi-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.5px;
}

.project-kpi-stat-value.kpi-done { color: var(--green); }

.project-kpi-stat-label {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

.project-kpi-stat-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}


/* ─── Dashboard Responsive ──────────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .kpi-grid-4,
  .kpi-grid-3 { grid-template-columns: 1fr 1fr; }
  .kpi-value  { font-size: 28px; }
}

@media (max-width: 400px) {
  .kpi-grid-4,
  .kpi-grid-3 { grid-template-columns: 1fr; }
}


/* ─── Archived Task Card ─────────────────────────────────────── */
.task-card-archived {
  opacity: 0.8;
  border-left-color: var(--text-placeholder) !important;
}


/* ─── Gantt Chart ────────────────────────────────────────────── */
.gantt-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.gantt-header {
  display: flex;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

.gantt-label-header {
  border-bottom: none;
}

.gantt-header-dates {
  position: relative;
  height: 28px;
}

.gantt-date-label {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  padding: 6px 0;
  line-height: 1;
}

.gantt-body {
  display: flex;
  flex-direction: column;
}

.gantt-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid rgba(48, 54, 61, 0.3);
  min-height: 32px;
}

.gantt-row:last-child { border-bottom: none; }

.gantt-row-task {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .gantt-row-task {
  background: rgba(0, 0, 0, 0.15);
}

.gantt-row-project {
  background: var(--surface-elevated);
  border-top: 1px solid var(--border);
}

.gantt-row-project:first-child { border-top: none; }

.gantt-label-project {
  font-size: 13px;
}

.gantt-label {
  width: 160px;
  min-width: 160px;
  padding: 6px var(--sm);
  font-size: 12px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.gantt-label-del {
  font-weight: 600;
  color: var(--text-primary);
}

.gantt-label-task {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 11px;
}

.gantt-indent {
  display: inline-block;
  width: 14px;
  flex-shrink: 0;
}

.gantt-bar-area {
  flex: 1;
  position: relative;
  min-width: 300px;
  min-height: 100%;
}

/* Grid lines */
.gantt-grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
  opacity: 0.3;
  pointer-events: none;
}

/* Today marker */
.gantt-today-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--blue);
  opacity: 0.6;
  pointer-events: none;
  z-index: 1;
}

/* Project deadline marker */
.gantt-deadline {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--red);
  opacity: 0.7;
  pointer-events: none;
  z-index: 1;
  border-left: 1px dashed var(--red);
}

/* Bars */
.gantt-bar {
  position: absolute;
  top: 6px;
  height: calc(100% - 12px);
  min-height: 8px;
  border-radius: 4px;
  cursor: default;
  transition: filter 0.15s;
  min-width: 4px;
}

.gantt-bar:hover { filter: brightness(1.15); }

/* Shape: deliverables are taller/bolder, tasks slimmer */
.gantt-bar-del-shape {
  top: 5px;
  height: calc(100% - 10px);
  cursor: pointer;
}

.gantt-bar-task-shape {
  top: 9px;
  height: calc(100% - 18px);
  opacity: 0.75;
}

/* Status colours */
.gantt-bar-not-started { background: var(--text-muted);  }
.gantt-bar-in-progress { background: var(--teal);        }
.gantt-bar-blocked     { background: var(--red);         }
.gantt-bar-complete    { background: var(--green);       }

/* Legend */
.gantt-legend {
  display: flex;
  align-items: center;
  gap: var(--md);
  padding: var(--sm) var(--md);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.gantt-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
}

.gantt-legend-swatch {
  width: 12px;
  height: 4px;
  border-radius: 2px;
}

.gantt-swatch-today       { background: var(--blue); }
.gantt-swatch-deadline    { background: var(--red); }
.gantt-swatch-not-started { background: var(--text-muted); }
.gantt-swatch-in-progress { background: var(--teal); }
.gantt-swatch-blocked     { background: var(--red); }
.gantt-swatch-complete    { background: var(--green); }

/* No dates message */
.gantt-no-dates {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sm);
  padding: var(--lg);
  margin-top: var(--lg);
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}


/* ═══════════════════════════════════════════════════════════════
   Responsive breakpoints
   ═══════════════════════════════════════════════════════════════ */

/* ─── Wide: sidebar grows a bit ─────────────────────────────── */
@media (min-width: 1200px) {
  .category-sidebar { width: 260px; }
}

/* ─── Medium (≤ 1024px): tighten sidebar ────────────────────── */
@media (max-width: 1024px) {
  .category-sidebar { width: 200px; }
}

/* ─── Tablet (≤ 768px): sidebar stacks below tasks ─────────── */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }

  .category-sidebar {
    width: 100%;
    position: static;
  }

  /* Category list becomes horizontal scroll row at tablet */
  .category-list {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--xs);
  }

  .category-item {
    flex: 0 0 auto;
    padding: 4px var(--sm);
  }

  /* Header: allow the auth row to wrap onto a second line */
  .app-header {
    flex-wrap: wrap;
    gap: var(--sm);
  }

  .header-right {
    flex-wrap: wrap;
  }

  /* Add-form: let controls wrap onto a second row */
  .add-form {
    flex-wrap: wrap;
  }

  .task-input { min-width: 160px; }
}

/* ═══════════════════════════════════════════════════════════════
   Appointments / Calendar
   ═══════════════════════════════════════════════════════════════ */

/* ─── Layout ─────────────────────────────────────────────────── */
.appt-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--lg);
  align-items: start;
}

@media (max-width: 900px) {
  .appt-layout { grid-template-columns: 1fr; }
}

/* ─── Calendar header ─────────────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  gap: var(--sm);
  margin-bottom: var(--md);
}

.cal-month-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 160px;
  text-align: center;
}

.cal-nav-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 14px;
  transition: background 0.15s;
}
.cal-nav-btn:hover { background: var(--border); }

.cal-view-toggle {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.cal-view-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.cal-view-btn.active {
  background: var(--teal-dim);
  border-color: var(--teal);
  color: var(--teal);
}

/* ─── Month grid ─────────────────────────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

.cal-dow {
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.cal-cell {
  min-height: 90px;
  padding: 6px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  vertical-align: top;
  position: relative;
}
.cal-cell:hover { background: var(--surface-elevated); }

.cal-cell.other-month .cal-day-num { color: var(--text-placeholder); }
.cal-cell.other-month { background: rgba(0,0,0,0.08); }

.cal-cell.today { background: var(--teal-dim); }
.cal-cell.today .cal-day-num {
  background: var(--teal);
  color: #0D1117;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-day-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Event chips in calendar ────────────────────────────────── */
.cal-event-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 3px;
  margin-bottom: 2px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  transition: opacity 0.15s;
  color: #fff;
}
.cal-event-chip:hover { opacity: 0.8; }

.cal-event-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.7;
}

.cal-more {
  font-size: 10px;
  color: var(--text-muted);
  padding: 1px 5px;
  cursor: pointer;
}
.cal-more:hover { color: var(--teal); }

/* ─── Category colours ───────────────────────────────────────── */
.chip-medical   { background: #b91c1c; }
.chip-work      { background: #1d4ed8; }
.chip-personal  { background: #0f766e; }
.chip-social    { background: #7e22ce; }
.chip-family    { background: #b45309; }
.chip-other     { background: #4b5563; }

.dot-medical   { color: #ef4444; }
.dot-work      { color: #3b82f6; }
.dot-personal  { color: #14b8a6; }
.dot-social    { color: #a855f7; }
.dot-family    { color: #f59e0b; }
.dot-other     { color: #6b7280; }

/* ─── Agenda view ────────────────────────────────────────────── */
.agenda-list { display: flex; flex-direction: column; gap: var(--sm); }

.agenda-day-header {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 6px 0 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--xs);
}
.agenda-day-header.today-header { color: var(--teal); }

.agenda-item {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--sm) var(--md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.15s;
}
.agenda-item:hover { border-color: var(--teal); }

.agenda-item-stripe {
  width: 3px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}

.agenda-item-body { flex: 1; min-width: 0; }
.agenda-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agenda-item-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.agenda-item-meta i { width: 10px; height: 10px; }

/* ─── Upcoming sidebar ────────────────────────────────────────── */
.upcoming-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.upcoming-card {
  display: flex;
  align-items: stretch;
  gap: var(--sm);
  padding: var(--sm) var(--md);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--xs);
  cursor: pointer;
  transition: border-color 0.15s;
}
.upcoming-card:hover { border-color: var(--teal); }

.upcoming-card-stripe {
  width: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}

.upcoming-card-body { flex: 1; min-width: 0; }
.upcoming-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.upcoming-card-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.upcoming-card-time {
  font-size: 11px;
  color: var(--teal);
  margin-top: 1px;
}

.upcoming-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: var(--lg) 0;
}

/* ─── Appointment modal ───────────────────────────────────────── */
.appt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}

.appt-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.appt-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
}

.appt-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.appt-modal-body {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

.appt-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sm);
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--border);
}

.appt-modal-footer .btn-delete {
  margin-right: auto;
}

/* ─── Form fields in modal ────────────────────────────────────── */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.field-input {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  padding: 8px 10px;
  width: 100%;
  font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.field-input:focus { outline: none; border-color: var(--teal); }
.field-input::placeholder { color: var(--text-placeholder); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--md);
}

.field-checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--sm);
  cursor: pointer;
}
.field-checkbox-row input[type="checkbox"] {
  accent-color: var(--teal);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.field-checkbox-label {
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}

.cat-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--xs);
}

.cat-btn {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.cat-btn:hover { border-color: var(--text-muted); color: var(--text-primary); }
.cat-btn.selected { color: #fff; border-color: transparent; }
.cat-btn.selected.cat-medical   { background: #b91c1c; }
.cat-btn.selected.cat-work      { background: #1d4ed8; }
.cat-btn.selected.cat-personal  { background: #0f766e; }
.cat-btn.selected.cat-social    { background: #7e22ce; }
.cat-btn.selected.cat-family    { background: #b45309; }
.cat-btn.selected.cat-other     { background: #4b5563; }

.cat-dot-sm {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Light theme overrides ───────────────────────────────────── */
[data-theme="light"] .cal-cell.other-month { background: rgba(0,0,0,0.03); }

/* ─── Mobile (≤ 480px): stack the add-form vertically ───────── */
@media (max-width: 480px) {
  .add-form {
    flex-direction: column;
    align-items: stretch;
  }

  .task-input { min-width: unset; }

  .priority-select { width: 100%; }

  /* Full-width task action buttons */
  .task-actions { flex-wrap: wrap; }

  /* Tighten task card padding */
  .task-card { padding: var(--sm); gap: var(--sm); }

  /* Header auth: stack inputs */
  .header-right .auth-wrap {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }

  .header-right .auth-wrap input {
    width: 100%;
  }

  .filter-toolbar { gap: var(--xs); }
  .toolbar-divider { display: none; }

  .deliverable-footer { flex-direction: column; }
  .deliverable-add-form { min-width: unset; width: 100%; }

  .gantt-label { width: 100px; min-width: 100px; font-size: 10px; }
  .gantt-bar-area { min-width: 200px; }
}


/* ═══════════════════════════════════════════════════════════════
   Habit Tracker
   ═══════════════════════════════════════════════════════════════ */

/* ─── Week navigation bar ──────────────────────────────────── */
.habit-week-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--md);
  margin-bottom: var(--md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Grid wrapper ─────────────────────────────────────────── */
.habit-grid-wrap {
  overflow-x: auto;
  margin-bottom: var(--xl);
}

/* ─── Grid (CSS Grid, not HTML table) ─────────────────────── */
.habit-grid {
  display: grid;
  grid-template-columns: minmax(160px, 220px) repeat(7, minmax(52px, 1fr)) 72px;
  min-width: 620px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ─── Header row ────────────────────────────────────────────── */
.habit-col-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: var(--sm) var(--xs);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

.habit-col-header:first-child { text-align: left; padding-left: var(--md); }
.habit-col-header:last-child  { border-right: none; }

.habit-col-header.today-col {
  background: var(--teal-dim);
  color: var(--teal);
}

/* ─── Data row ──────────────────────────────────────────────── */
.habit-row-name,
.habit-row-day,
.habit-row-streak {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
}

.habit-row-streak { border-right: none; }

/* Name cell */
.habit-row-name {
  justify-content: flex-start;
  padding: var(--sm) var(--md);
  gap: var(--sm);
  cursor: pointer;
}

.habit-row-name:hover { background: var(--surface-elevated); }

.habit-name-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.habit-name-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.habit-edit-btn {
  opacity: 0;
  transition: opacity 0.15s;
  color: var(--text-muted);
  flex-shrink: 0;
}

.habit-row-name:hover .habit-edit-btn { opacity: 1; }

/* Day cell */
.habit-row-day { padding: var(--xs); }

.habit-row-day.today-col {
  background: rgba(78, 205, 196, 0.04);
}

/* ─── Check circle (binary habits) ─────────────────────────── */
.habit-check {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  color: transparent;
  flex-shrink: 0;
}

.habit-check:hover:not(.not-scheduled) { border-color: var(--teal); }

.habit-check.checked {
  background: var(--teal);
  border-color: var(--teal);
  color: #0D1117;
}

.habit-check.not-scheduled {
  border: none;
  cursor: default;
  color: var(--border);
  font-size: 15px;
}

.habit-check.future { opacity: 0.4; }

/* ─── Weekly target: N-checkbox spanning cell ───────────────── */
.habit-row-day-week {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: var(--sm) var(--md);
  gap: var(--sm);
  flex-wrap: wrap;
}

.weekly-target-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: var(--xs);
}

.weekly-target-label.met { color: var(--teal); }

/* ─── Multi-circle per day ──────────────────────────────────── */
.habit-day-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  justify-content: center;
}
.habit-day-checks.future { opacity: 0.5; }

/* ─── Measurable count (X/N) ────────────────────────────────── */
.habit-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  min-width: 34px;
  text-align: center;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.habit-count:hover:not(.not-scheduled) { border-color: var(--teal); color: var(--teal); }
.habit-count.target-met { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.habit-count.not-scheduled { border: none; cursor: default; color: var(--border); }

/* ─── Streak cell ───────────────────────────────────────────── */
.habit-row-streak {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  gap: 3px;
  padding: var(--xs) var(--sm);
  flex-direction: column;
}

.streak-active { color: var(--teal); }

/* ─── Heatmap row (full width, collapsible) ─────────────────── */
.habit-heatmap-wrap {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--md);
}

.heatmap-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sm);
}

.heatmap-grid {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.heatmap-week-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  flex-shrink: 0;
}

.heatmap-0 { background: var(--surface-elevated); }
.heatmap-1 { background: rgba(78, 205, 196, 0.25); }
.heatmap-2 { background: rgba(78, 205, 196, 0.55); }
.heatmap-3 { background: var(--teal); }

/* ─── Value popover (measurable check-in) ───────────────────── */
.value-popover {
  position: fixed;
  background: var(--surface-elevated);
  border: 1px solid var(--teal);
  border-radius: var(--radius-md);
  padding: var(--sm);
  display: flex;
  gap: var(--xs);
  align-items: center;
  z-index: 300;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.value-popover input[type="number"] {
  width: 56px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: var(--xs) var(--sm);
  text-align: center;
}

.value-popover input[type="number"]:focus { outline: none; border-color: var(--teal); }

/* ─── Habit modal ───────────────────────────────────────────── */
.habit-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.60);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}

.habit-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.habit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
}

.habit-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.habit-modal-body {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}

.habit-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sm);
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--border);
}

/* ─── Frequency toggle buttons ──────────────────────────────── */
.freq-toggle-group {
  display: flex;
  gap: var(--xs);
  flex-wrap: wrap;
}

.freq-btn {
  padding: 5px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.freq-btn:hover { border-color: var(--teal); color: var(--text-primary); }
.freq-btn.active { background: var(--teal); border-color: var(--teal); color: #0D1117; font-weight: 600; }

/* ─── Day pills (custom schedule) ───────────────────────────── */
.custom-days-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: var(--xs);
}

.day-pill {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.day-pill:hover { border-color: var(--teal); color: var(--text-primary); }
.day-pill.active { background: var(--teal); border-color: var(--teal); color: #0D1117; }

/* ─── Habit category buttons (in modal) ─────────────────────── */
.habit-cat-btn.selected.cat-health   { background: #047857; border-color: #047857; color: #fff; }
.habit-cat-btn.selected.cat-fitness  { background: #b45309; border-color: #b45309; color: #fff; }
.habit-cat-btn.selected.cat-mind     { background: #6d28d9; border-color: #6d28d9; color: #fff; }
.habit-cat-btn.selected.cat-work     { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.habit-cat-btn.selected.cat-social   { background: #7e22ce; border-color: #7e22ce; color: #fff; }
.habit-cat-btn.selected.cat-other    { background: #4b5563; border-color: #4b5563; color: #fff; }

/* ─── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .habit-grid {
    grid-template-columns: minmax(110px, 150px) repeat(7, 40px) 56px;
  }
  .habit-name-text { font-size: 12px; }
}


/* ═══════════════════════════════════════════════════════════════
   FINANCES
   ═══════════════════════════════════════════════════════════════ */

/* ─── Tab Bar ────────────────────────────────────────────────── */
.fin-tab-bar {
  display: flex;
  gap: var(--sm);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--xl);
  overflow-x: auto;
}

.fin-tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--sm) var(--md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.fin-tab-btn:hover { color: var(--text-primary); }
.fin-tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); font-weight: 600; }

.fin-tab-content { display: none; }
.fin-tab-content.active { display: block; }

/* ─── Sub-tabs ───────────────────────────────────────────────── */
.fin-sub-tabs {
  display: flex;
  gap: var(--xs);
  margin-bottom: var(--md);
  flex-wrap: wrap;
}

.fin-sub-tab {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.fin-sub-tab:hover { color: var(--text-primary); }
.fin-sub-tab.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* ─── Overview Grid ──────────────────────────────────────────── */
.fin-overview-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--xl);
}

/* ─── Section ────────────────────────────────────────────────── */
.fin-section { margin-bottom: 0; }
.fin-section-title {
  display: flex;
  align-items: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--md);
  gap: var(--sm);
}

/* ─── Cards ──────────────────────────────────────────────────── */
.fin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--md) var(--lg);
  margin-bottom: var(--sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fin-card:hover { border-color: var(--teal); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.fin-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.fin-card-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.fin-card-subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Progress Bars ──────────────────────────────────────────── */
.fin-progress-wrap {
  height: 8px;
  background: var(--surface-elevated);
  border-radius: 4px;
  overflow: hidden;
}
.fin-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.fin-progress-bar.green { background: var(--green); }
.fin-progress-bar.teal  { background: var(--teal); }
.fin-progress-bar.amber { background: var(--amber); }
.fin-progress-bar.red   { background: var(--red); }

/* ─── Transaction List ───────────────────────────────────────── */
.fin-tx-list { display: flex; flex-direction: column; gap: 2px; }

.fin-tx-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto 40px;
  align-items: center;
  gap: var(--sm);
  padding: var(--sm) var(--md);
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.fin-tx-row:hover { background: var(--surface-elevated); }

.fin-tx-date { font-size: 12px; color: var(--text-muted); }
.fin-tx-title { font-size: 13px; color: var(--text-primary); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fin-tx-cat {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.fin-tx-amount { font-size: 13px; font-weight: 600; text-align: right; }
.fin-tx-amount.income { color: var(--green); }
.fin-tx-amount.expense { color: var(--red); }
.fin-tx-actions { text-align: center; }

/* ─── Budget Bars ────────────────────────────────────────────── */
.fin-budget-row { padding: var(--xs) 0; }
.fin-budget-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.fin-budget-label { font-size: 13px; color: var(--text-primary); font-weight: 500; }
.fin-budget-amounts { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; }

/* ─── Month Navigator ────────────────────────────────────────── */
.fin-month-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--md);
  margin-bottom: var(--lg);
}

/* ─── Bills ──────────────────────────────────────────────────── */
.fin-bill-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sm) 0;
  border-bottom: 1px solid var(--border);
}
.fin-bill-item:last-child { border-bottom: none; }
.fin-bill-due { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.fin-bill-amount { font-size: 14px; font-weight: 600; }

/* ─── Account Groups ─────────────────────────────────────────── */
.fin-acct-group-header {
  display: flex;
  justify-content: space-between;
  padding: var(--xs) 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
  margin-top: var(--md);
}
.fin-acct-group-header:first-child { margin-top: 0; }

/* ─── Chart Wrap ─────────────────────────────────────────────── */
.fin-chart-wrap { min-height: 180px; }

/* ─── Debt Calculator ────────────────────────────────────────── */
.fin-calc-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--lg);
}

.fin-strategy-toggle { display: flex; gap: 2px; }
.fin-strat-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}
.fin-strat-btn:first-child { border-radius: 6px 0 0 6px; }
.fin-strat-btn:last-child  { border-radius: 0 6px 6px 0; }
.fin-strat-btn.active { background: var(--teal); border-color: var(--teal); color: #fff; }

.fin-payoff-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.fin-payoff-table th {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--xs) var(--sm);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.fin-payoff-table td {
  font-size: 12px;
  padding: var(--xs) var(--sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

/* ─── Goals Grid ─────────────────────────────────────────────── */
.fin-goals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--md);
}

.fin-goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--teal);
  border-radius: 8px;
  padding: var(--md) var(--lg);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fin-goal-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.fin-goal-progress-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Investment Table ───────────────────────────────────────── */
.fin-invest-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.fin-invest-table th {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--xs) var(--sm);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.fin-invest-table td {
  font-size: 13px;
  padding: var(--sm) var(--sm);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.fin-invest-table tr:hover { background: var(--surface-elevated); }
.fin-gain { color: var(--green); font-weight: 600; }
.fin-loss { color: var(--red); font-weight: 600; }

/* ─── Donut Chart ────────────────────────────────────────────── */
.fin-donut-wrap { text-align: center; }
.fin-donut-legend { display: flex; flex-direction: column; gap: var(--xs); margin-top: var(--sm); }
.fin-donut-legend-item { display: flex; align-items: center; gap: var(--sm); }
.fin-donut-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ─── KPI grid-3 ─────────────────────────────────────────────── */
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .fin-overview-grid { grid-template-columns: 1fr; }
  .fin-tx-row { grid-template-columns: 50px 1fr auto auto; }
  .fin-tx-actions { display: none; }
  .kpi-grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .fin-tab-bar { gap: 0; }
  .fin-tab-btn { padding: var(--xs) var(--sm); font-size: 12px; }
  .fin-goals-grid { grid-template-columns: 1fr; }
  .fin-invest-table { font-size: 11px; }
}

/* ═══════════════════════════════════════════════════════════
   MEAL PLANNING  (meal-*)
   ═══════════════════════════════════════════════════════════ */

/* Tab bar */
.meal-tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.meal-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.meal-tab-btn:hover { color: var(--text-primary); }
.meal-tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: 600;
}

/* cat-btn active state for meal types (generic teal highlight) */
.cat-btn.selected {
  background: var(--teal);
  color: #fff;
  border-color: transparent;
}

/* Ingredient rows inside recipe modal */
.meal-ingredient-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}
.meal-ing-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.meal-ing-name { flex: 1; color: var(--text-primary); }
.meal-ing-qty  { font-size: 12px; font-weight: 600; color: var(--teal); white-space: nowrap; }
.meal-ing-del  {
  background: none; border: none; cursor: pointer; padding: 0;
  color: var(--text-muted); display: flex; align-items: center;
  opacity: 0; transition: opacity .15s;
}
.meal-ing-row:hover .meal-ing-del { opacity: 1; }

/* Shopping list */
.meal-shop-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: var(--sm);
  align-items: center;
}
.meal-shop-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.meal-shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: opacity .15s;
}
.meal-shop-item.checked {
  opacity: .55;
}
.meal-shop-item.checked .meal-shop-name {
  text-decoration: line-through;
  color: var(--text-muted);
}
.meal-shop-check {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.meal-shop-name {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
}
.meal-shop-qty {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  white-space: nowrap;
}
.meal-shop-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity .15s;
}
.meal-shop-item:hover .meal-shop-delete { opacity: 1; }

.meal-week-nav {
  display: flex;
  align-items: center;
  gap: var(--sm);
  margin-bottom: var(--md);
}
.meal-week-label {
  flex: 1;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

.meal-grid-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-elevated);
}
.meal-grid {
  display: grid;
  grid-template-columns: 100px repeat(7, minmax(110px, 1fr));
  min-width: 870px;
}
.meal-col-header {
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.meal-col-header.today-col {
  color: var(--teal);
}
.meal-row-label {
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  background: var(--surface);
}
.meal-row-label:last-of-type { border-bottom: none; }
.meal-cell {
  min-height: 80px;
  padding: 6px 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
  vertical-align: top;
}
.meal-cell:last-child { border-right: none; }
.meal-grid > .meal-cell:nth-last-child(-n+8) { border-bottom: none; }
.meal-cell.today-col {
  background: color-mix(in srgb, var(--teal) 4%, transparent);
}
.meal-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s;
  overflow: hidden;
}
.meal-chip:hover { border-color: var(--teal); }
.meal-chip-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.meal-chip-cal {
  font-size: 10px;
  font-weight: 700;
  color: var(--teal);
  white-space: nowrap;
}
.meal-chip-leftover {
  font-size: 10px;
  color: var(--text-secondary);
  opacity: 0.7;
  white-space: nowrap;
  cursor: default;
}
.meal-cell-add {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px dashed var(--border);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  background: none;
  transition: border-color .15s, color .15s;
  line-height: 1;
  padding: 0;
  margin-top: auto;
}
.meal-cell-add:hover { border-color: var(--teal); color: var(--teal); }

/* Recipe library */
.meal-recipe-section {
  margin-top: var(--lg);
}
.meal-recipe-toggle {
  display: flex;
  align-items: center;
  gap: var(--sm);
  width: 100%;
  background: none;
  border: none;
  padding: var(--sm) 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
}
.meal-recipe-toggle:hover { color: var(--teal); }
.meal-recipe-toggle-icon { transition: transform .2s; }
.meal-recipe-toggle-icon.open { transform: rotate(90deg); }
.meal-recipe-body { display: none; }
.meal-recipe-body.open { display: block; }
.meal-recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--md);
  padding-top: var(--sm);
}
.meal-recipe-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--md);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.meal-recipe-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
}
.meal-macro-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}
.meal-macro-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.meal-macro-pill.cal { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 30%, var(--border)); }
.meal-recipe-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
}

/* Meal modals (reuse .habit-modal-overlay pattern with meal- prefix) */
.meal-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}
.meal-modal-overlay.open { display: flex; }
.meal-modal-box {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.meal-modal-header {
  display: flex;
  align-items: center;
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
  gap: var(--sm);
}
.meal-modal-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}
.meal-modal-body {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}
.meal-modal-footer {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--border);
}
.meal-modal-footer .spacer { flex: 1; }

/* Recipe picker dropdown inside modal */
.meal-recipe-picker {
  position: relative;
}
.meal-recipe-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  display: none;
}
.meal-recipe-dropdown.open { display: block; }
.meal-recipe-option {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
}
.meal-recipe-option:hover { background: var(--surface); }

/* Macros grid (2x2) */
.meal-macro-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sm);
}

@media (max-width: 768px) {
  .meal-grid { grid-template-columns: 80px repeat(7, minmax(90px, 1fr)); }
  .meal-recipe-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════
   WEIGHT TRACKER  (wt-*)
   ═══════════════════════════════════════════════════════════ */

.wt-range-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--md);
}
.wt-range-tab {
  padding: 6px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.wt-range-tab:hover { border-color: var(--teal); color: var(--teal); }
.wt-range-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.wt-chart-wrap {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--md);
  margin-bottom: var(--lg);
  overflow: hidden;
  min-height: 180px;
}
.wt-chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}
.wt-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  color: var(--text-muted);
  font-size: 14px;
}

.wt-log-wrap {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wt-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
}
.wt-log-title {
  font-weight: 600;
  font-size: 14px;
}
.wt-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wt-log-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.wt-log-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}
.wt-log-table tr:last-child td { border-bottom: none; }
.wt-log-table tr:hover td { background: var(--surface); }
.wt-log-actions { display: flex; gap: 6px; }

.wt-change-pos { color: var(--red); font-weight: 600; }
.wt-change-neg { color: var(--green); font-weight: 600; }
.wt-change-zero { color: var(--text-muted); font-weight: 600; }

.wt-unit-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wt-unit-btn {
  padding: 5px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s;
}
.wt-unit-btn.active {
  background: var(--teal);
  color: #fff;
}

.wt-goal-bar-wrap {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--md) var(--lg);
  margin-bottom: var(--lg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wt-goal-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}
.wt-goal-bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.wt-goal-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--teal);
  transition: width .4s ease;
}

/* Weight modals */
.wt-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--md);
}
.wt-modal-overlay.open { display: flex; }
.wt-modal-box {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.wt-modal-header {
  display: flex;
  align-items: center;
  padding: var(--md) var(--lg);
  border-bottom: 1px solid var(--border);
  gap: var(--sm);
}
.wt-modal-title {
  flex: 1;
  font-weight: 700;
  font-size: 16px;
}
.wt-modal-body {
  padding: var(--lg);
  display: flex;
  flex-direction: column;
  gap: var(--md);
}
.wt-modal-footer {
  display: flex;
  align-items: center;
  gap: var(--sm);
  padding: var(--md) var(--lg);
  border-top: 1px solid var(--border);
}
.wt-modal-footer .spacer { flex: 1; }

@media (max-width: 768px) {
  .wt-range-tabs { flex-wrap: wrap; }
  .wt-log-table th:nth-child(3),
  .wt-log-table td:nth-child(3) { display: none; }
}
