/* ===================================================================
   TASKTRACKER — DESIGN SYSTEM v2
   Palette:
     Obsidian  #09090B   (deepest bg, sidebar)
     Ink       #18181B   (sidebar body)
     Surface   #FFFFFF   (cards, panels)
     Ground    #FAFAFA   (page background)
     Border    #E4E4E7   (subtle dividers)
     Muted     #71717A   (secondary text)
     Accent    #6366F1   (primary indigo)
     Accent2   #4F46E5   (hover)
     Emerald   #10B981   (success / complete)
     Amber     #F59E0B   (warning / soon)
     Rose      #F43F5E   (danger / overdue)
     Sky       #0EA5E9   (info)

   Typography: Inter (Google Fonts)
=================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

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

/* ── Token map ────────────────────────────────────────────────────── */
:root {
  --obsidian:  #09090B;
  --ink:       #18181B;
  --ink2:      #27272A;
  --border:    #E4E4E7;
  --border2:   #F4F4F5;
  --ground:    #FAFAFA;
  --surface:   #FFFFFF;
  --muted:     #71717A;
  --muted2:    #A1A1AA;
  --body:      #18181B;

  --accent:    #6366F1;
  --accent2:   #4F46E5;
  --accent-bg: #EEF2FF;

  --emerald:   #10B981;
  --emerald-bg:#ECFDF5;
  --amber:     #F59E0B;
  --amber-bg:  #FFFBEB;
  --rose:      #F43F5E;
  --rose-bg:   #FFF1F2;
  --sky:       #0EA5E9;
  --sky-bg:    #F0F9FF;
  --violet:    #8B5CF6;
  --violet-bg: #F5F3FF;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.12);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w: 256px;

  --transition: .15s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--ground);
  color: var(--body);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell ────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--obsidian);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

/* subtle side gradient for depth */
.sidebar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(99,102,241,.06) 0%, transparent 40%);
  pointer-events: none;
}

.sidebar-brand {
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.sidebar-brand a {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent) 0%, #818CF8 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  color: white;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.brand-name {
  font-size: 1rem;
  font-weight: 800;
  color: #FFFFFF;
  letter-spacing: -.4px;
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: rgba(255,255,255,.22);
  padding: 0 10px;
  margin: 18px 0 6px;
}
.nav-label:first-child { margin-top: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 1px;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.85);
}

.nav-item.active {
  background: rgba(99,102,241,.18);
  color: #A5B4FC;
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 99px;
}

.nav-item .icon {
  font-size: .95rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 12px 18px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #818CF8 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-name   { font-size: .8rem; font-weight: 600; color: rgba(255,255,255,.85); }
.user-email  { font-size: .7rem; color: rgba(255,255,255,.35); }

/* ── Main content ─────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-xs);
}

.page-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--body);
  letter-spacing: -.2px;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-sm); }

.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--body);
  letter-spacing: -.1px;
}

.card-body { padding: 20px; }

/* ── Stat cards ───────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: #EEF2FF; }
.stat-icon.green  { background: var(--emerald-bg); }
.stat-icon.amber  { background: var(--amber-bg); }
.stat-icon.red    { background: var(--rose-bg); }
.stat-icon.teal   { background: var(--sky-bg); }
.stat-icon.violet { background: var(--violet-bg); }

.stat-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--body);
  line-height: 1;
  letter-spacing: -.5px;
}

.stat-label {
  font-size: .73rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: .01em;
}

/* ── Progress bar ─────────────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--border2);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), #34D399);
  border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: .85rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition), box-shadow var(--transition), transform .1s;
  line-height: 1;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99,102,241,.35);
}
.btn-primary:hover {
  background: var(--accent2);
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}

.btn-secondary {
  background: var(--surface);
  color: var(--body);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--ground); }

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid #FECDD3;
}
.btn-danger:hover { background: #FFE4E6; }

.btn-success {
  background: var(--emerald-bg);
  color: var(--emerald);
  border: 1px solid #A7F3D0;
}
.btn-success:hover { background: #D1FAE5; }

.btn-sm  { padding: 6px 12px; font-size: .78rem; }
.btn-icon { padding: 8px; }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  color: #3F3F46;
  margin-bottom: 6px;
  letter-spacing: .01em;
}

.form-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 13px;
  font-size: .875rem;
  font-family: var(--font);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--body);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

.form-control::placeholder { color: var(--muted2); }

textarea.form-control { resize: vertical; min-height: 96px; }

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2371717A' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-hint  { font-size: .73rem; color: var(--muted); margin-top: 4px; }
.form-error { font-size: .73rem; color: var(--rose); margin-top: 4px; font-weight: 500; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row > * { min-width: 0; }

input[type="date"].form-control,
input[type="time"].form-control {
  display: block;
  min-height: 42px;
  text-align: left;
}

/* ── Table ────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}

.table th {
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--ground);
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border2);
  vertical-align: middle;
  color: #3F3F46;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--ground); }

.task-title-cell {
  font-weight: 600;
  color: var(--body);
  letter-spacing: -.1px;
}

.task-desc-cell {
  color: var(--muted);
  font-size: .78rem;
  max-width: 360px;
  margin-top: 3px;
}

.task-desc-cell span {
  display: block;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.badge-pending    { background: #FFF7ED; color: #C2410C; }
.badge-inprogress { background: #EFF6FF; color: #1D4ED8; }
.badge-completed  { background: var(--emerald-bg); color: #065F46; }
.badge-overdue    { background: var(--rose-bg); color: #BE123C; }

.badge-low      { background: #F0FDF4; color: #166534; }
.badge-medium   { background: var(--amber-bg); color: #92400E; }
.badge-high     { background: #FFF7ED; color: #C2410C; }
.badge-critical { background: var(--rose-bg); color: #9F1239; }

/* ── Alerts ───────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
}

.alert-success { background: var(--emerald-bg); border: 1px solid #A7F3D0; color: #065F46; }
.alert-error   { background: var(--rose-bg);    border: 1px solid #FECDD3; color: #BE123C; }
.alert-warning { background: var(--amber-bg);   border: 1px solid #FDE68A; color: #92400E; }
.alert-info    { background: var(--sky-bg);     border: 1px solid #BAE6FD; color: #0369A1; }

/* ── Filter bar ───────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 18px;
}

.filter-bar .form-control { width: auto; min-width: 138px; }
.search-input { min-width: 220px !important; }

/* ── Days remaining ───────────────────────────────────────────────── */
.days-ok     { color: var(--emerald); font-weight: 600; font-size: .82rem; }
.days-soon   { color: var(--amber);   font-weight: 600; font-size: .82rem; }
.days-urgent { color: var(--rose);    font-weight: 600; font-size: .82rem; }
.days-na     { color: var(--muted2); font-size: .82rem; }

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  font-size: 2.6rem;
  margin-bottom: 14px;
  opacity: .35;
  display: block;
}

.empty-state h3 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--body);
  margin-bottom: 6px;
}

.empty-state p { font-size: .85rem; }

/* ── Auth pages ───────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: var(--ground);
  /* Allow scrolling on mobile if content is taller than viewport */
  overflow-y: auto;
}

/* Left panel — branding / value prop */
.auth-left {
  flex: 1;
  background: linear-gradient(145deg, var(--obsidian) 0%, #1C1C24 50%, #0D0D10 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}

/* decorative circles */
.auth-left::before,
.auth-left::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  opacity: .08;
}
.auth-left::before {
  width: 460px; height: 460px;
  background: var(--accent);
  top: -120px; left: -140px;
}
.auth-left::after {
  width: 300px; height: 300px;
  background: #818CF8;
  bottom: -80px; right: -80px;
}

.auth-left-inner {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.auth-brand {
  display: flex;
  align-items: center;
  margin-bottom: 52px;
}

/*
  Logo on the dark left panel.
  mix-blend-mode:screen makes the white PNG background "disappear"
  against the dark panel while keeping the coloured artwork fully
  visible. This replaces filter:brightness(0)invert(1) which was
  converting the entire opaque-white-background logo to a solid
  white rectangle (i.e. invisible on the white portion, and white
  on the dark background).
*/
.auth-panel-logo {
  height: 72px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: screen;
  filter: brightness(1.1);
  max-width: 280px;
}

/* ── Mobile branding header ──────────────────────────────────────── */
/*
  Shown only when .auth-left is hidden (≤1100px). Gives mobile users
  the Tinstodo identity before they see the form.
  On desktop (>1100px) it's hidden — the left panel handles branding.
*/
.auth-mobile-brand {
  display: none; /* hidden on desktop — left panel shows branding */
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

.auth-mobile-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
  max-width: 240px;
  margin-bottom: 12px;
}

.auth-mobile-name {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--body);
  letter-spacing: -.5px;
  line-height: 1;
  margin-bottom: 6px;
}

.auth-mobile-tagline {
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.5;
}

.auth-headline {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.22;
  letter-spacing: -.6px;
  margin-bottom: 18px;
}

.auth-headline span {
  background: linear-gradient(90deg, #818CF8, #C4B5FD);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-tagline {
  color: rgba(255,255,255,.55);
  font-size: .9rem;
  line-height: 1.65;
  margin-bottom: 40px;
}

.auth-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.7);
  font-size: .85rem;
}

.auth-features li .feat-icon {
  width: 28px; height: 28px;
  background: rgba(99,102,241,.2);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}

/* Right panel — the form */
.auth-right {
  width: 480px;
  flex-shrink: 0;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  overflow-y: auto;
}

.auth-form-wrap {
  width: 100%;
  max-width: 380px;
}

.auth-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--body);
  letter-spacing: -.4px;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--muted);
  font-size: .875rem;
  margin-bottom: 28px;
  line-height: 1.5;
}

.auth-divider {
  text-align: center;
  color: var(--muted);
  font-size: .8rem;
  margin: 14px 0;
}

.auth-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition);
}
.auth-link:hover { color: var(--accent2); text-decoration: underline; }

/* Small auth card used on verify / resend pages */
.auth-card-simple {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

/* ── Dashboard grid ───────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 18px;
}

/* ── Completion ring ──────────────────────────────────────────────── */
.completion-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px;
}

.ring-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ring-wrap svg { transform: rotate(-90deg); }

.ring-center { position: absolute; text-align: center; }
.ring-pct    { font-size: 1.75rem; font-weight: 800; color: var(--body); line-height: 1; }
.ring-sub    { font-size: .68rem; color: var(--muted); margin-top: 2px; }

/* ── Mobile toggle ────────────────────────────────────────────────── */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--body);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.mobile-toggle:hover { background: var(--border2); }

/* ── Sidebar overlay (mobile) ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .auth-left { display: none; }
  .auth-right {
    width: 100%;
    /* On tablet/mobile the right panel is the whole page.
       Switch from center-aligned to top-aligned so the mobile
       branding header sits naturally at the top. */
    align-items: flex-start;
    padding-top: 0;
  }
  .auth-form-wrap {
    max-width: 480px;
    margin: 0 auto;
    padding-top: 0;
    width: 100%;
  }
  /* Show the mobile branding block that is hidden on desktop */
  .auth-mobile-brand { display: flex; }
}

@media (max-width: 960px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .table th, .table td { padding: 10px 12px; }
  .task-desc-cell { max-width: 160px; }
}

@media (max-width: 700px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .page-body { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .form-control,
  .filter-bar .search-input { min-width: 100%; width: 100%; }
  .filter-bar > button,
  .filter-bar > a.btn { width: 100%; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .topbar {
    height: auto;
    min-height: 56px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
  }

  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .topbar-actions > a,
  .topbar-actions > button { flex: 1; }

  /* Table → Card on mobile */
  .table-wrap { overflow-x: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 4px 0;
    background: var(--surface);
  }
  .table tr:last-child { margin-bottom: 0; }
  .table td {
    border-bottom: none;
    padding: 8px 14px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    text-align: right;
  }
  .table td[data-label]::before {
    content: attr(data-label);
    font-size: .67rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    flex-shrink: 0;
    padding-top: 2px;
  }
  .table td[data-label="Title"] {
    text-align: left;
    flex-direction: column;
    align-items: flex-start;
  }
  .table td[data-label="Title"]::before { margin-bottom: 4px; }
  .table td[data-label="Actions"] {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }
  .table td[data-label="Actions"]::before { margin-bottom: 6px; }
  .table td[data-label="Actions"] .d-flex { justify-content: flex-start; }
  .task-desc-cell { max-width: none; }

  .auth-right { padding: 0 20px 32px; }
  .auth-form-wrap { max-width: 100%; }
  .auth-card-simple { padding: 28px 20px; }
  .auth-mobile-brand { padding: 24px 0 22px; margin-bottom: 22px; }
  .auth-mobile-logo  { height: 52px; }
  .auth-mobile-name  { font-size: 1.25rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ────────────────────────────────────────────────────── */
.text-muted      { color: var(--muted); }
.text-sm         { font-size: .8rem; }
.fw-600          { font-weight: 600; }
.fw-700          { font-weight: 700; }
.d-flex          { display: flex; }
.align-center    { align-items: center; }
.gap-8           { gap: 8px; }
.gap-12          { gap: 12px; }
.mb-0            { margin-bottom: 0 !important; }
.mb-4            { margin-bottom: 4px; }
.mb-8            { margin-bottom: 8px; }
.mb-16           { margin-bottom: 16px; }
.mb-20           { margin-bottom: 20px; }
.mb-28           { margin-bottom: 28px; }
.mt-4            { margin-top: 4px; }
.mt-8            { margin-top: 8px; }
.mt-16           { margin-top: 16px; }
.justify-between { justify-content: space-between; }
.text-center     { text-align: center; }
.w-full          { width: 100%; }

/* ===================================================================
   APP FOOTER (authenticated area)
=================================================================== */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: .75rem;
  color: var(--muted);
  margin-left: var(--sidebar-w); /* align with main content */
}

.app-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color var(--transition);
}

.app-footer a:hover { color: var(--accent); }

.app-footer-sep { color: var(--border); }

@media (max-width: 700px) {
  .app-footer { margin-left: 0; padding: 14px 16px; }
}

/* ===================================================================
   LEGAL PAGES (privacy, terms, ip-policy, contact, public pages)
=================================================================== */

/* Shared wrapper for all public/legal pages */
.legal-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
}

/* Slim top nav for unauthenticated public pages */
.legal-nav {
  background: var(--obsidian);
  padding: 0 40px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.legal-nav-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  mix-blend-mode: screen;
  filter: brightness(1.1);
}

.legal-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: .82rem;
}

.legal-nav-links a {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  transition: color var(--transition);
}

.legal-nav-links a:hover { color: rgba(255,255,255,.9); }

.legal-nav-links .btn-sm { padding: 6px 14px; font-size: .78rem; }

/* Main content area for legal docs */
.legal-content {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 40px 64px;
}

.legal-content h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--body);
  letter-spacing: -.5px;
  margin-bottom: 6px;
}

.legal-effective {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: 36px;
  display: block;
}

.legal-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--body);
  margin: 32px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border2);
}

.legal-content p {
  font-size: .9rem;
  color: #3F3F46;
  line-height: 1.75;
  margin-bottom: 14px;
}

.legal-content ul {
  font-size: .9rem;
  color: #3F3F46;
  line-height: 1.75;
  margin: 0 0 14px 20px;
}

.legal-content li { margin-bottom: 4px; }

.legal-content a { color: var(--accent); }
.legal-content a:hover { text-decoration: underline; }

.legal-content strong { color: var(--body); font-weight: 600; }

.legal-todo {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: .82rem;
  color: #92400E;
  font-family: monospace;
  margin-bottom: 14px;
}

/* Public site footer (legal/auth pages) */
.public-footer {
  background: var(--obsidian);
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: .78rem;
  color: rgba(255,255,255,.35);
  flex-shrink: 0;
}

.public-footer-links {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.public-footer-links a {
  color: rgba(255,255,255,.4);
  text-decoration: none;
  transition: color var(--transition);
}

.public-footer-links a:hover { color: rgba(255,255,255,.8); }

/* Contact page form */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 32px;
}

@media (max-width: 700px) {
  .legal-nav  { padding: 0 20px; }
  .legal-content { padding: 32px 20px 48px; }
  .public-footer { padding: 20px; flex-direction: column; align-items: flex-start; }
  .contact-grid  { grid-template-columns: 1fr; }
}
