/* ============================================================
   Migrated to Genie design tokens 2026-04-29.
   All values reference genie-tokens.css. See context/rules/genie-design.md.
   ============================================================ */

/*
  Genei Design System — matches Order Follow-Up mockup exactly
  Load AFTER themes.css (which is loaded after genie-tokens.css).
  Page <style> blocks contain ONLY page-unique layout/widgets.
*/

/* ── Google Fonts (kept as backup; tokens import these too) ───────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* ── Root variables (legacy aliases — kept for in-file references) ────────── */
:root {
  --font:       var(--font-sans);
  /* --font-mono is provided by genie-tokens.css */
  --radius:     var(--radius-md);
  /* --radius-sm and --radius-lg are provided by genie-tokens.css */
  --tr:         var(--transition);
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: var(--text-body);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Topbar — always dark navy ───────────────────────────────────────────── */
.topbar {
  background: var(--color-topbar);
  border-bottom: 1px solid rgba(255,255,255,.07);
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  height: var(--height-topbar);
  gap: var(--space-3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: var(--text-body);
  font-weight: var(--weight-bold);
  letter-spacing: -.3px;
  color: var(--color-surface);
  text-decoration: none;
  flex-shrink: 0;
}
.logo span { color: #38BDF8; /* night-accent glyph color on dark topbar */ }

/* ── Navigation — white on dark ──────────────────────────────────────────── */
.nav {
  display: flex;
  gap: 2px;
  align-items: center;
  margin-left: var(--space-2);
  flex: 1;
}

.nav a {
  color: rgba(255,255,255,.55);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-dense);
  font-weight: var(--weight-medium);
  transition: var(--transition);
  white-space: nowrap;
}
.nav a:hover { color: var(--color-surface); background: rgba(255,255,255,.08); }
.nav a.active { color: var(--color-surface); background: rgba(255,255,255,.13); font-weight: var(--weight-semibold); }

/* Day/Night toggle button (injected by theme.js into .nav) */
.theme-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--text-dense);
  line-height: 1;
  transition: var(--transition);
  color: rgba(255,255,255,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}
.theme-btn:hover { background: rgba(255,255,255,.08); color: var(--color-surface); }

/* ── User chip (injected by auth.js into .topbar) ─────────────────────────── */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
.user-name {
  font-size: var(--text-dense);
  color: rgba(255,255,255,.55);
  font-weight: var(--weight-medium);
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-surface);
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: .5px;
}
.logout-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,.45);
  font-size: var(--text-dense);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--transition);
}
.logout-btn:hover { border-color: rgba(239,68,68,.7); color: var(--color-error); }

/* ── Page layout ──────────────────────────────────────────────────────────── */
.page { max-width: 1200px; margin: 0 auto; padding: var(--space-5) var(--space-5) var(--space-8); }

h1 { font-size: var(--text-title); font-weight: var(--weight-bold); letter-spacing: -.02em; margin-bottom: var(--space-1); }
h2 { font-size: var(--text-title); font-weight: var(--weight-bold); margin-bottom: var(--space-1); }
.subtitle, .section-desc { color: var(--muted); font-size: var(--text-dense); margin-bottom: var(--space-5); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
}
.card-title {
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-header);
  color: var(--muted);
  margin-bottom: var(--space-3);
}

/* ── Stat cards ───────────────────────────────────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: var(--transition);
}
.stat-card:hover { border-color: var(--accent); }
.stat-label {
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-header);
  color: var(--muted);
  margin-bottom: var(--space-1);
}
.stat-val {
  font-size: var(--text-title);
  font-weight: var(--weight-heavy);
  letter-spacing: -.03em;
  font-family: var(--font-mono);
  line-height: 1.1;
}
.stat-sub { font-size: var(--text-dense); color: var(--muted); margin-top: var(--space-1); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: var(--text-dense);
  font-weight: var(--weight-semibold);
  font-family: var(--font-sans);
  letter-spacing: .01em;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}
.btn:disabled { opacity: .42; cursor: not-allowed; }

.btn-primary  { background: var(--accent); color: var(--color-surface); border-color: var(--accent); }
.btn-primary:hover:not(:disabled)  { opacity: .88; }

.btn-ghost    { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover:not(:disabled)    { color: var(--text); border-color: var(--muted); background: var(--surface2); }

.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface2); }

.btn-success  { background: var(--color-success); color: var(--color-surface); border-color: var(--color-success); }
.btn-success:hover:not(:disabled)  { opacity: .88; }

.btn-danger   { background: transparent; border-color: var(--error); color: var(--error); }
.btn-danger:hover:not(:disabled)   { background: var(--error); color: var(--color-surface); }

.btn-sm { padding: var(--space-1) var(--space-2); font-size: var(--text-dense); }
.btn-lg { padding: var(--space-2) var(--space-4); font-size: var(--text-body); }
.btn-icon { padding: var(--space-1) var(--space-2); }

/* ── Spinner ──────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: var(--space-3); height: var(--space-3);
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border-radius: 9999px; /* pill */
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-family: var(--font-mono);
}
.badge-draft    { background: rgba(100,116,139,.14); color: var(--muted); }
.badge-sale     { background: rgba(3,105,161,.13);   color: var(--color-accent); }
.badge-done     { background: rgba(22,163,74,.12);   color: var(--color-success); }
.badge-cancel   { background: rgba(220,38,38,.12);   color: var(--color-error); }
.badge-warning  { background: rgba(217,119,6,.12);   color: var(--color-warning); }
.badge-sent     { background: var(--accent-dim);     color: var(--accent); }
.badge-accepted { background: rgba(22,163,74,.12);   color: var(--color-success); }
.badge-rejected { background: rgba(220,38,38,.12);   color: var(--color-error); }

/* Night mode badge overrides */
[data-theme="night"] .badge-sale { color: #38BDF8; background: rgba(56,189,248,.15); }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-dense);
  margin-bottom: var(--space-3);
  display: none;
  font-weight: var(--weight-medium);
}
.alert.show  { display: block; }
.alert-success { background: var(--color-success-dim);  border: 1px solid var(--success); color: var(--success); }
.alert-error   { background: var(--color-error-dim);    border: 1px solid var(--error);   color: var(--error); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: var(--text-dense);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  margin-bottom: var(--space-1);
  letter-spacing: .01em;
}
input[type=text],
input[type=email],
input[type=number],
input[type=password],
input[type=date],
select,
textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-body);
  font-family: var(--font-sans);
  width: 100%;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
input[type=text]:focus,
input[type=email]:focus,
input[type=number]:focus,
input[type=password]:focus,
input[type=date]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  /* focus ring — allowed shadow per Genie spec (focus state, not elevation) */
  box-shadow: 0 0 0 2px var(--accent-dim);
}
textarea { resize: vertical; min-height: 80px; }

input[type=checkbox] {
  width: var(--space-4); height: var(--space-4);
  accent-color: var(--accent);
  cursor: pointer;
  vertical-align: middle;
}

.fg         { display: flex; flex-direction: column; gap: var(--space-1); flex: 1; min-width: 140px; }
.fg.full    { flex: 0 0 100%; }
.form-row   { display: flex; gap: var(--space-3); margin-bottom: var(--space-3); flex-wrap: wrap; }
.btn-row    { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; margin-top: var(--space-3); }

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.toolbar      { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.toolbar-left { display: flex; align-items: center; gap: var(--space-2); flex: 1; flex-wrap: wrap; }
.toolbar-right{ display: flex; align-items: center; gap: var(--space-2); }
.sync-info    { font-size: var(--text-dense); color: var(--muted); }

.toolbar input[type=text], .toolbar select { width: auto; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: var(--text-dense); }

thead th {
  background: var(--surface2);
  color: var(--text);
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-header);
  padding: var(--space-1) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th[onclick] { cursor: pointer; user-select: none; }
thead th[onclick]:hover { color: var(--text); }
thead th.sorted { color: var(--accent); }
thead th .sort-icon { margin-left: var(--space-1); opacity: .3; }
thead th.sorted .sort-icon { opacity: 1; }

tbody tr { border-bottom: 1px solid var(--border); transition: background 120ms; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: var(--space-1) var(--space-3); vertical-align: middle; }

.num     { text-align: right; font-variant-numeric: tabular-nums; }
/* Canonical ID column class. Use for SO#, SP#, Q#, PO#, any business identifier shown as a list-row primary key. */
.so-name, .id-cell { font-size: var(--text-dense); color: var(--accent); font-weight: var(--weight-semibold); text-decoration: none; }
.so-name a, .id-cell a { color: inherit; text-decoration: none; }
.so-name a:hover, .id-cell a:hover { text-decoration: none; color: inherit; filter: brightness(1.15); }

/* ── Selection bar ────────────────────────────────────────────────────────── */
.sel-bar {
  display: none;
  align-items: center;
  gap: var(--space-3);
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-dense);
}
.sel-bar.show { display: flex; }
.sel-bar .sel-count { color: var(--accent); font-weight: var(--weight-semibold); flex: 1; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: var(--space-8) var(--space-5); color: var(--muted); }
.empty .empty-icon { font-size: var(--text-title); margin-bottom: var(--space-3); }
.empty h3 { font-size: var(--text-body); font-weight: var(--weight-bold); margin-bottom: var(--space-1); color: var(--text); }
.empty p  { font-size: var(--text-dense); }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: var(--space-1); margin-top: var(--space-4); flex-wrap: wrap; }
.page-info        { font-size: var(--text-dense); color: var(--muted); margin-right: var(--space-1); }
.page-ellipsis    { color: var(--muted); padding: 0 var(--space-1); font-size: var(--text-dense); }
.page-size-chip   { font-size: var(--text-dense); color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 2px var(--space-2); cursor: pointer; user-select: none; margin-right: var(--space-1); }
.page-size-chip:hover { background: var(--accent-dim); }

/* ── Status indicators ────────────────────────────────────────────────────── */
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: var(--space-1); vertical-align: middle; }
.dot-ok  { background: var(--success); }
.dot-err { background: var(--error); }
.dot-unk { background: var(--muted); animation: pulse 1.4s ease infinite; }

/* ── Admin sidebar layout ─────────────────────────────────────────────────── */
.layout { display: flex; min-height: calc(100vh - var(--height-topbar)); }
.sidebar {
  width: 210px;
  border-right: 1px solid var(--border);
  padding: var(--space-3) var(--space-2);
  flex-shrink: 0;
  background: var(--surface);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--muted);
  transition: var(--transition);
  margin-bottom: 2px;
}
.sidebar-item:hover  { color: var(--text); background: var(--surface2); }
.sidebar-item.active { color: var(--accent); background: var(--accent-dim); font-weight: var(--weight-semibold); }
.content { flex: 1; padding: var(--space-6); max-width: 720px; }

/* ── Dashboard module cards ───────────────────────────────────────────────── */
.modules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-7);
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-5);
  text-decoration: none;
  color: var(--text);
  transition: var(--transition);
  display: block;
}
.module-card:hover {
  border-color: var(--accent);
  background: var(--surface2);
  transform: translateY(-2px);
}
.module-card .icon      { font-size: var(--text-title); margin-bottom: var(--space-3); }
.module-card .mod-title { font-size: var(--text-title); font-weight: var(--weight-bold); letter-spacing: -.01em; margin-bottom: var(--space-1); }
.module-card .mod-desc  { font-size: var(--text-dense); color: var(--muted); line-height: 1.55; }
.module-card .mod-badge {
  display: inline-block;
  margin-top: var(--space-3);
  padding: 2px var(--space-2);
  border-radius: 9999px;
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: .05em;
  background: var(--accent-dim);
  color: var(--accent);
}

/* ── Mode tabs ────────────────────────────────────────────────────────────── */
.mode-tabs {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--space-4);
  width: fit-content;
  background: var(--surface);
}
.mode-tab {
  padding: var(--space-2) var(--space-4);
  cursor: pointer;
  font-size: var(--text-dense);
  font-weight: var(--weight-medium);
  color: var(--muted);
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  transition: var(--transition);
  border-right: 1px solid var(--border);
}
.mode-tab:last-child { border-right: none; }
.mode-tab:hover  { color: var(--text); background: var(--surface2); }
.mode-tab.active { color: var(--accent); background: var(--accent-dim); font-weight: var(--weight-semibold); }

/* ── Theme panel (day/night only) ─────────────────────────────────────────── */
.theme-panel {
  position: fixed;
  top: 56px;
  right: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  width: 200px;
  z-index: 9999;
  display: none;
}
.theme-panel.open { display: block; }
.theme-picker-title {
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: var(--letter-header);
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.theme-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
.theme-swatch {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  background: var(--surface2);
}
.theme-swatch:hover  { border-color: var(--accent); }
.theme-swatch.active { border-color: var(--accent); background: var(--accent-dim); }
.swatch-dot  { width: var(--space-5); height: var(--space-5); border-radius: 50%; flex-shrink: 0; border: 2px solid rgba(255,255,255,.15); }
.swatch-name { font-size: var(--text-dense); font-weight: var(--weight-semibold); color: var(--text); }

/* ── Utilities ────────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: var(--text-dense); }
.mono  { font-family: var(--font-mono); }

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--scrollbar); border-radius: var(--radius-sm); }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Tasks: topnav badge + bell + overflow ───────────────────────────────── */
.nav-badge {
  display: inline-block; min-width: var(--space-4); padding: 1px var(--space-1); margin-left: var(--space-1);
  font-size: var(--text-header); font-weight: var(--weight-bold); line-height: 14px; text-align: center;
  background: rgba(255,255,255,.15); color: var(--color-surface); border-radius: var(--radius-lg);
}
.nav-badge.overdue { background: var(--color-error); }
.nav-more { position: relative; }
.nav-more-btn {
  background: transparent; color: #cbd5e1; border: 0; padding: var(--space-2) var(--space-2);
  font: inherit; font-size: var(--text-dense); cursor: pointer;
}
.nav-more-btn:hover { color: var(--color-surface); }
.nav-more-menu {
  display: none; position: absolute; right: 0; top: calc(100% + var(--space-1));
  background: #1e293b; border: 1px solid #334155; border-radius: var(--radius-md);
  min-width: 180px; z-index: 200;
}
.nav-more-menu.open { display: block; }
.nav-more-menu a { display: block; padding: var(--space-2) var(--space-3); color: #e2e8f0; text-decoration: none; font-size: var(--text-dense); }
.nav-more-menu a:hover { background: #334155; }

/* Hover-dropdown nav groups (Products, Sales Orders, Tasks) */
.nav-group { position: relative; }
.nav-group-label {
  display: inline-flex; align-items: center; gap: var(--space-1);
  color: rgba(255,255,255,.55); text-decoration: none;
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-md);
  font-size: var(--text-dense); font-weight: var(--weight-medium); white-space: nowrap;
  transition: var(--transition);
}
.nav-group-label:hover,
.nav-group:hover .nav-group-label { color: var(--color-surface); background: rgba(255,255,255,.08); }
.nav-group-label.active { color: var(--color-surface); background: rgba(255,255,255,.13); font-weight: var(--weight-semibold); }
.nav-caret { font-size: 9px; opacity: .7; }
.nav-group-menu {
  display: none; position: absolute; left: 0; top: 100%;
  min-width: 180px; background: #1e293b; border: 1px solid #334155;
  border-radius: var(--radius-md); z-index: 200;
  padding: var(--space-1) 0;
}
.nav-group:hover .nav-group-menu,
.nav-group:focus-within .nav-group-menu { display: block; }
.nav-group-menu a {
  display: block; padding: var(--space-2) var(--space-3); color: #e2e8f0;
  text-decoration: none; font-size: var(--text-dense);
}
.nav-group-menu a:hover { background: #334155; color: var(--color-surface); }

.nav-bell { position: relative; margin-left: var(--space-1); }
.bell-btn {
  background: transparent; border: 0; color: #cbd5e1; cursor: pointer;
  font-size: var(--text-body); padding: var(--space-1) var(--space-1); position: relative;
}
.bell-btn:hover { color: var(--color-surface); }
.bell-dot {
  position: absolute; top: 2px; right: 2px; width: 7px; height: 7px;
  background: var(--color-error); border-radius: 50%; border: 1.5px solid var(--color-topbar);
}
.bell-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + var(--space-1));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  width: 320px; max-height: 400px; overflow-y: auto;
  z-index: 200;
}
.bell-dropdown.open { display: block; }
.bell-loading, .bell-empty { padding: var(--space-4); text-align: center; color: var(--muted); font-size: var(--text-dense); }
.bell-header { display: flex; justify-content: space-between; align-items: center;
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); font-size: var(--text-dense); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bell-mark { background: transparent; border: 0; color: var(--accent); font-size: var(--text-dense); cursor: pointer; }
.bell-list { display: flex; flex-direction: column; }
.bell-item { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); display: block; }
.bell-item:hover { background: var(--surface2); }
.bell-item.unread .bell-body { font-weight: var(--weight-semibold); }
.bell-item.read .bell-body { color: var(--muted); }
.bell-body { font-size: var(--text-dense); line-height: 1.4; }
.bell-time { font-size: var(--text-header); color: var(--muted); margin-top: 2px; }

/* ── Tasks page ──────────────────────────────────────────────────────────── */
.tasks-page { display: grid; grid-template-columns: 200px 1fr; gap: var(--space-3); max-width: 1400px; }
.tasks-sidebar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2); height: fit-content; position: sticky; top: var(--space-3); }
.tasks-sidebar h3 { font-size: var(--text-header); font-weight: var(--weight-bold); color: var(--muted); text-transform: uppercase; letter-spacing: var(--letter-header); padding: 0 var(--space-1) var(--space-1); margin: 0 0 var(--space-1); border-bottom: 1px solid var(--border); }
.tasks-tab { display: flex; justify-content: space-between; align-items: center; padding: var(--space-1) var(--space-2); cursor: pointer; border-radius: var(--radius-sm); font-size: var(--text-dense); }
.tasks-tab:hover { background: var(--surface2); }
.tasks-tab.active { background: var(--accent-dim); color: var(--accent); font-weight: var(--weight-semibold); }
.tasks-tab .count { font-size: var(--text-header); color: var(--muted); }
.tasks-main { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-2); }
.tasks-toolbar { display: flex; gap: var(--space-1); align-items: center; margin-bottom: var(--space-2); flex-wrap: wrap; }
.chip { padding: var(--space-1) var(--space-2); border-radius: 9999px; font-size: var(--text-dense); font-weight: var(--weight-semibold); cursor: pointer; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); }
.chip.active { background: var(--accent); color: var(--color-surface); border-color: var(--accent); }
.chip-overdue.active { background: var(--color-error); border-color: var(--color-error); }

.task-row { display: grid; grid-template-columns: 22px 1fr 90px 110px 60px 84px; gap: var(--space-1); align-items: center;
  padding: 2px var(--space-1); border-bottom: 1px solid var(--border); font-size: var(--text-dense); }
.task-row:hover { background: var(--surface2); }
.task-row:hover .task-actions { opacity: 1; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-check { width: var(--space-4); height: var(--space-4); cursor: pointer; }
.task-title { font-weight: var(--weight-medium); cursor: text; padding: 1px var(--space-1); border-radius: var(--radius-sm); }
.task-title:hover { background: var(--accent-dim); }
.task-title.editing { background: var(--surface2); outline: 1px solid var(--accent); cursor: text; }
.task-titlewrap { min-width: 0; }
.task-parent { font-size: var(--text-header); color: var(--muted); margin-top: 1px; padding: 0 var(--space-1); }
.task-due { font-size: var(--text-dense); color: var(--muted); cursor: pointer; padding: 1px var(--space-1); border-radius: var(--radius-sm); text-align: left; }
.task-due:hover { background: var(--accent-dim); color: var(--accent); }
.task-due.overdue { color: var(--color-error); font-weight: var(--weight-semibold); }
.task-due.task-due-empty { font-style: italic; opacity: .6; }

.task-actions { display: flex; gap: 2px; opacity: .35; transition: opacity 120ms; justify-content: flex-start; }
.ptask-row:hover .ptask-actions { opacity: 1 !important; }

.user-picker-pop { position: fixed; z-index: 9000; width: 220px; max-height: 280px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0,0,0,.12); overflow: hidden; }
.user-picker-search { border: 0; border-bottom: 1px solid var(--border); padding: var(--space-2);
  background: var(--surface); color: var(--text); font-size: var(--text-dense); outline: none; }
.user-picker-list { overflow-y: auto; padding: var(--space-1) 0; }
.user-picker-row { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-1) var(--space-2);
  cursor: pointer; font-size: var(--text-dense); color: var(--text); }
.user-picker-row:hover { background: var(--color-accent-dim); color: var(--color-accent); }
.user-picker-avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--color-accent-dim);
  color: var(--color-accent); display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: var(--weight-bold); flex-shrink: 0; }

.proj-task-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 9500; display: flex; align-items: center; justify-content: center; }
.proj-task-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  width: min(720px, 92vw); max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; }
.ptm-head { display: flex; justify-content: space-between; align-items: flex-start;
  padding: var(--space-3); border-bottom: 1px solid var(--border); gap: var(--space-2); }
.ptm-head h2 { margin: 0; font-size: var(--text-title); font-weight: var(--weight-bold); color: var(--text); }
.ptm-x { background: transparent; border: 0; font-size: var(--text-title); color: var(--muted); cursor: pointer; line-height: 1; }
.ptm-x:hover { color: var(--text); }
.ptm-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1) var(--space-3);
  padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
  font-size: var(--text-dense); color: var(--text); }
.ptm-meta b { color: var(--muted); font-weight: var(--weight-semibold); margin-right: var(--space-1); }
.ptm-section { padding: var(--space-3); border-bottom: 1px solid var(--border); overflow-y: auto; }
.ptm-section h4 { margin: 0 0 var(--space-2); font-size: var(--text-header); text-transform: uppercase;
  letter-spacing: var(--letter-header); color: var(--muted); font-weight: var(--weight-bold); }
.ptm-comment { padding: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin-bottom: var(--space-2); background: var(--surface2); }
.ptm-comment.ptm-ai { background: var(--color-accent-dim); border-color: var(--color-accent); }
.ptm-comment-head { font-size: var(--text-header); color: var(--muted); margin-bottom: var(--space-1); }
.ptm-comment-body { font-size: var(--text-dense); color: var(--text); white-space: pre-wrap; line-height: 1.5; }
.ptm-footer { display: flex; gap: var(--space-2); justify-content: flex-end;
  padding: var(--space-2) var(--space-3); }
.task-iconbtn { background: transparent; border: 0; color: var(--muted); cursor: pointer;
  width: var(--space-5); height: var(--space-5); border-radius: var(--radius-sm); font-size: var(--text-body); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0; position: relative; }
.task-iconbtn:hover { background: var(--surface2); color: var(--color-accent); }
.task-iconbtn.icon-delete:hover { color: var(--color-error); }
.task-iconbtn.icon-ai { color: var(--color-accent); }
.task-iconbtn.icon-ai:hover { color: var(--color-accent); filter: brightness(1.15); }
.task-iconbtn svg { width: 14px; height: 14px; display: block; }
.task-iconbtn::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + var(--space-1)); left: 50%; transform: translateX(-50%);
  background: var(--color-topbar); color: var(--color-surface); font-size: var(--text-header); padding: var(--space-1) var(--space-1); border-radius: var(--radius-sm);
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 120ms; z-index: 10;
}
.task-iconbtn:hover::after { opacity: 1; }
.task-priority { font-size: var(--text-header); padding: 2px var(--space-1); border-radius: var(--radius-lg); text-align: center; }
.task-priority.high { background: var(--color-error-dim); color: #991b1b; /* TODO: needs deep-error token */ }
.task-priority.med  { background: var(--color-warning-dim); color: #92400e; /* TODO: needs deep-warning token */ }
.task-priority.low  { background: #dbeafe; color: #1e40af; /* TODO: needs info-dim/deep tokens */ }
[data-theme="night"] .task-priority.high { background: #4a1414; color: #fca5a5; }
[data-theme="night"] .task-priority.med  { background: #3a2a14; color: #fcd34d; }
[data-theme="night"] .task-priority.low  { background: #1a2440; color: #93c5fd; }
.task-assignee { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-dense); }
.task-avatar { width: 18px; height: 18px; border-radius: 50%; background: var(--accent-dim); color: var(--accent); font-size: 9px; font-weight: var(--weight-bold); display: flex; align-items: center; justify-content: center; }

.tasks-add-row { display: flex; gap: var(--space-1); padding: 2px var(--space-1); border-bottom: 1px solid var(--border); align-items: center; position: relative; }
.tasks-add-row input[type=text] { flex: 1; background: transparent; border: 0; color: var(--text); font-size: var(--text-dense); outline: none; padding: 2px 0; }
.tasks-add-row input[type=text]::placeholder { color: var(--muted); }
.quick-add-due { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: var(--text-dense); padding: var(--space-1) var(--space-1); }
.quick-due-btn { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: var(--text-dense); padding: var(--space-1) var(--space-2); cursor: pointer; display: inline-flex; align-items: center; gap: var(--space-1); font-variant-numeric: tabular-nums; height: 22px; line-height: 1; font-family: inherit; }
.quick-due-btn:hover { border-color: var(--muted); }

/* ── Detail modal ───────────────────────────────────────────────────────── */
.task-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 600;
  align-items: flex-start; justify-content: center; padding: var(--space-7) var(--space-4); overflow-y: auto; }
.task-modal-overlay.open { display: flex; }
.task-modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  width: 100%; max-width: 640px;
  /* modal scrim shadow allowed by Genie spec */
  box-shadow: 0 16px 48px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 80px); }

/* ── AI workspace side panel ────────────────────────────────────────────── */
.ai-panel-toggle { position: fixed; right: var(--space-3); top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%; border: 0; background: linear-gradient(135deg,#8b5cf6,#6366f1); /* TODO: AI gradient — needs tokens */
  color: var(--color-surface); font-size: var(--text-title); cursor: pointer; z-index: 480; }
.ai-side-panel { position: fixed; top: 0; right: -360px; width: 360px; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 490;
  transition: right 120ms ease; display: flex; flex-direction: column; }
.ai-side-panel.open { right: 0; }
.ai-side-header { padding: var(--space-3) var(--space-3); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; background: linear-gradient(135deg, rgba(139,92,246,.10), rgba(99,102,241,.06)); }
.ai-side-body { flex: 1; overflow-y: auto; padding: var(--space-3); }
.ai-side-section { margin-bottom: var(--space-3); }
.ai-side-section h4 { font-size: var(--text-header); font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: var(--letter-header); color: var(--muted); margin: 0 0 var(--space-1); }
.ai-quick-actions { display: flex; flex-direction: column; gap: var(--space-1); }
.ai-quick { background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-dense); cursor: pointer; text-align: left; }
.ai-quick:hover { border-color: #8b5cf6; /* TODO: AI accent — needs token */ }
.ai-side-output { margin-top: var(--space-3); }

/* ── Copilot sidebar (page-aware chat) ──────────────────────────────────── */
.copilot-toggle { position: fixed; right: var(--space-4); bottom: var(--space-4); z-index: 480;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: linear-gradient(135deg,#8b5cf6,#6366f1); /* TODO: AI gradient — needs tokens */ color: var(--color-surface);
  font-size: var(--text-title); cursor: pointer; }
.copilot-toggle:hover { transform: scale(1.05); }

.copilot-panel { position: fixed; top: 0; right: -400px; width: 400px; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 495;
  transition: right 120ms ease; display: flex; flex-direction: column; }
.copilot-panel.open { right: 0; }

.copilot-head { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(135deg, rgba(139,92,246,.10), rgba(99,102,241,.06)); }
.copilot-head-title { display: flex; align-items: center; gap: var(--space-1); font-size: var(--text-dense); flex-wrap: wrap; }
.copilot-spark { font-size: var(--text-numeric); }
.copilot-pills { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-left: var(--space-1); }
.copilot-pill { background: rgba(139,92,246,.14); color: #8b5cf6; /* TODO: AI accent — needs token */
  padding: 2px var(--space-2); border-radius: var(--radius-lg); font-size: var(--text-header); font-weight: var(--weight-semibold); }
.copilot-head-actions { display: flex; gap: var(--space-1); }
.copilot-icon-btn { background: transparent; border: 0; color: var(--muted);
  font-size: var(--text-numeric); cursor: pointer; padding: 2px var(--space-1); border-radius: var(--radius-sm); }
.copilot-icon-btn:hover { background: var(--surface2); color: var(--text); }

.copilot-body { flex: 1; overflow-y: auto; padding: var(--space-3); font-size: var(--text-dense); }
.copilot-empty { padding: var(--space-2) 0; }
.copilot-suggestions { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-3); }
.copilot-sugg { background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-dense); cursor: pointer; text-align: left; }
.copilot-sugg:hover { border-color: #8b5cf6; /* TODO: AI accent — needs token */ }

.copilot-msg { margin-bottom: var(--space-3); }
.copilot-msg-user .copilot-msg-body {
  background: var(--accent-dim, rgba(99,102,241,.15)); border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); max-width: 90%; margin-left: auto; }
.copilot-msg-asst .copilot-msg-body {
  background: var(--surface2); border: 1px solid var(--border);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); max-width: 95%; }
.copilot-msg-body { font-size: var(--text-dense); line-height: 1.45; word-wrap: break-word; white-space: normal; }
.copilot-msg-body code { background: rgba(139,92,246,.10); padding: 1px var(--space-1); border-radius: var(--radius-sm); font-size: var(--text-dense); }
.copilot-tools { display: flex; gap: var(--space-1); margin-bottom: var(--space-1); flex-wrap: wrap; }
.copilot-tool-chip { background: rgba(139,92,246,.12); color: #8b5cf6; /* TODO: AI accent — needs token */
  padding: 1px var(--space-1); border-radius: var(--radius-md); font-size: var(--text-header); font-weight: var(--weight-semibold); cursor: help; }

.copilot-typing { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-3); }
.copilot-typing span { width: 6px; height: 6px; border-radius: 50%;
  background: #8b5cf6; opacity: .35; animation: copilotBlink 1.2s infinite; /* TODO: AI accent — needs token */ }
.copilot-typing span:nth-child(2) { animation-delay: .2s; }
.copilot-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes copilotBlink { 0%,80%,100% { opacity: .25; } 40% { opacity: 1; } }

.copilot-foot { border-top: 1px solid var(--border); padding: var(--space-2) var(--space-3);
  display: flex; gap: var(--space-1); align-items: stretch; background: var(--surface); }
.copilot-foot textarea { flex: 1; resize: none; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text);
  padding: var(--space-1) var(--space-2); font-size: var(--text-dense); font-family: inherit; }
.copilot-send { background: linear-gradient(135deg,#8b5cf6,#6366f1); color: var(--color-surface); /* TODO: AI gradient — needs tokens */
  border: 0; padding: 0 var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-dense); font-weight: var(--weight-bold); cursor: pointer; }
.copilot-send:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 768px) {
  .copilot-panel { width: 100%; right: -100%; }
  .copilot-panel.open { right: 0; }
}

/* ── Side panel ─────────────────────────────────────────────────────────── */
.task-panel { position: fixed; top: 0; right: -380px; width: 380px; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border); z-index: 500;
  transition: right 120ms ease; display: flex; flex-direction: column; }
.task-panel.open { right: 0; }
.task-panel-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.18); z-index: 499; }
.task-panel-overlay.open { display: block; }
.task-panel-header { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.task-panel-close { background: transparent; border: 0; color: var(--muted); font-size: var(--text-title); cursor: pointer; }
.task-panel-body { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-3); }
.task-panel-section { margin-bottom: var(--space-3); }
.task-panel-section h4 { font-size: var(--text-header); font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: var(--letter-header); color: var(--muted); margin: 0 0 var(--space-1); }
.task-panel-input, .task-panel-textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: var(--space-1) var(--space-1); font-size: var(--text-dense); font-family: inherit; box-sizing: border-box; }
.task-panel-textarea { min-height: 48px; resize: vertical; }
.task-panel-meta { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
.task-panel-footer { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: var(--space-2) var(--space-3); display: flex; gap: var(--space-1); justify-content: flex-end; margin: var(--space-3) calc(-1 * var(--space-3)) calc(-1 * var(--space-2)); }
.task-panel-footer button { font-size: var(--text-dense); padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-weight: var(--weight-semibold); }
.task-panel-footer button.primary { background: var(--accent); border-color: var(--accent); color: var(--color-surface); }
.task-panel-footer button:hover { border-color: var(--accent); }
.ai-button { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: var(--color-surface); border: 0; /* TODO: AI gradient — needs tokens */
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-dense); font-weight: var(--weight-bold); cursor: pointer; }
.ai-button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--color-accent); color: var(--color-surface); border: 1px solid var(--color-accent);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-dense);
  font-weight: var(--weight-bold); cursor: pointer; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary-outline { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent);
  padding: var(--space-1) var(--space-3); border-radius: var(--radius-sm); font-size: var(--text-dense);
  font-weight: var(--weight-bold); cursor: pointer; }
.btn-primary-outline:hover:not(:disabled) { background: var(--color-accent-dim); }
.btn-ai-suggest { background: var(--color-accent); color: var(--color-surface); border: 0;
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--text-header); font-weight: var(--weight-bold); cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--space-1); white-space: nowrap; }
.btn-ai-suggest:hover:not(:disabled) { filter: brightness(1.08); }
.btn-ai-suggest:disabled { opacity: .6; cursor: wait; }
.btn-row { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.btn-row button { font-size: var(--text-dense); padding: var(--space-1) var(--space-2); border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; }
.btn-row button:hover { border-color: var(--accent); }

.comment { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.comment-head { display: flex; justify-content: space-between; font-size: var(--text-header); color: var(--muted); margin-bottom: var(--space-1); }
.comment-author { font-weight: var(--weight-bold); color: var(--text); }
.comment-body { font-size: var(--text-dense); white-space: pre-wrap; line-height: 1.45; }
.comment-attach { margin-top: var(--space-1); font-size: var(--text-dense); }
.comment-attach a { color: var(--accent); text-decoration: none; margin-right: var(--space-2); }
.reactions { display: flex; gap: var(--space-1); margin-top: var(--space-1); }
.reaction { background: var(--surface2); border: 1px solid var(--border); padding: 1px var(--space-1); border-radius: var(--radius-lg); font-size: var(--text-dense); cursor: pointer; }
.reaction.mine { border-color: var(--accent); background: var(--accent-dim); }

/* AI draft block */
.ai-block {
  background: linear-gradient(135deg, rgba(139,92,246,.12), rgba(99,102,241,.08)); /* TODO: AI gradient — needs tokens */
  border: 1px solid rgba(139,92,246,.4); border-radius: var(--radius-md); padding: var(--space-3); margin: var(--space-2) 0;
}
.ai-block-head { font-size: var(--text-header); font-weight: var(--weight-bold); color: #8b5cf6; text-transform: uppercase; letter-spacing: var(--letter-header); margin-bottom: var(--space-1); }
.ai-pills { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-1); }
.ai-pill { background: rgba(139,92,246,.15); color: #8b5cf6; padding: 2px var(--space-2); border-radius: var(--radius-lg); font-size: var(--text-header); font-weight: var(--weight-semibold); }
.ai-chips { display: flex; gap: var(--space-1); margin-top: var(--space-2); flex-wrap: wrap; }
.ai-chip { background: var(--surface); border: 1px solid var(--border); padding: var(--space-1) var(--space-2); border-radius: var(--radius-lg); font-size: var(--text-dense); cursor: pointer; }
.ai-chip:hover { border-color: #8b5cf6; /* TODO: AI accent — needs token */ }

/* Mobile */
@media (max-width: 768px) {
  .tasks-page { grid-template-columns: 1fr; }
  .tasks-sidebar { position: static; }
  .task-row { grid-template-columns: 24px 1fr 80px; padding: var(--space-3) var(--space-1); }
  .task-row .task-actions, .task-row .task-priority, .task-row .task-assignee { display: none; }
  .task-row .task-actions { opacity: 1; }
  .ai-side-panel { width: 100%; right: -100%; }
  .ai-side-panel.open { right: 0; }
  .task-modal { max-width: 100%; }
}

/* ── Project page sections ────────────────────────────────────────────────── */
.proj-section { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: var(--space-3); }
.proj-section > summary { cursor: pointer; padding: var(--space-3); list-style: none;
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--text-header); font-weight: var(--weight-bold); text-transform: uppercase;
  letter-spacing: var(--letter-header); color: var(--muted); }
.proj-section > summary::-webkit-details-marker { display: none; }
.proj-section > summary::before { content: '▸'; font-size: var(--text-dense); transition: transform 120ms; color: var(--muted); }
.proj-section[open] > summary::before { transform: rotate(90deg); }
.proj-section .sec-icon { font-size: var(--text-body); }
.proj-section .sec-body { padding: 0 var(--space-3) var(--space-3); }
.proj-section .sec-count { margin-left: var(--space-1); }
.proj-section .sec-count-num { display: inline-block; font-size: 9px; font-weight: var(--weight-semibold);
  letter-spacing: 0; padding: 1px var(--space-1); border-radius: var(--radius-lg);
  background: var(--surface2); color: var(--muted); }

/* Activity */
.act-tabs { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-2); }
.act-tabs .chip { display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-header); padding: 2px var(--space-2); border: 1px solid var(--border);
  background: transparent; color: var(--muted); border-radius: var(--radius-lg); cursor: pointer;
  font-family: inherit; }
.act-tabs .chip .chip-icon { display: inline-flex; }
.act-tabs .chip .chip-icon svg { display: block; width: 11px; height: 11px; }
.act-tabs .chip.chip-on { background: var(--text); color: var(--surface); border-color: var(--text); }
.act-meta-row { display: flex; gap: var(--space-1); flex-wrap: wrap; margin-bottom: var(--space-1); }
.act-input { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: var(--space-1) var(--space-2); font-size: var(--text-dense); font-family: var(--font-sans);
  height: 26px; line-height: 1.2; }
.act-input::placeholder { font-family: var(--font-sans); font-size: var(--text-dense); color: var(--muted); }
.act-input[type="datetime-local"] { font-size: var(--text-dense); }
.act-input[type="datetime-local"]::-webkit-datetime-edit { font-size: var(--text-dense); font-family: var(--font-sans); }
.act-input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper { font-size: var(--text-dense); }
.act-input[type="datetime-local"]::-webkit-calendar-picker-indicator { padding: 0; margin-left: var(--space-1); cursor: pointer; }
.act-input#act-sender { width: 160px; }

/* When-chips (relative time) */
.act-when { display: inline-flex; align-items: center; gap: var(--space-1); flex-wrap: wrap; }
.when-chip { font-size: var(--text-header); padding: var(--space-1) var(--space-2); height: 22px;
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 9999px; cursor: pointer; font-family: inherit; line-height: 1; }
.when-chip:hover { color: var(--text); border-color: var(--muted); }
.when-chip.when-on { background: var(--accent); color: var(--color-surface); border-color: var(--accent); }
.when-custom-input { height: 22px; padding: 2px var(--space-1); font-size: var(--text-header); }
.when-preview { font-size: var(--text-header); color: var(--muted); margin-left: var(--space-1);
  font-variant-numeric: tabular-nums; }
.act-quickadd textarea { width: 100%; box-sizing: border-box; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: var(--space-1) var(--space-2);
  font-size: var(--text-dense); font-family: inherit; resize: vertical; }
.act-post-row { text-align: right; margin-top: var(--space-1); }
.act-filter-chips { display: flex; gap: var(--space-1); flex-wrap: wrap; margin: var(--space-2) 0; }
.act-filter-chips .chip, .file-tag-bar .chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  font-size: var(--text-header); padding: 2px var(--space-2); border: 1px solid var(--border);
  background: transparent; color: var(--muted); border-radius: var(--radius-lg); cursor: pointer; }
.act-filter-chips .chip .chip-icon { display: inline-flex; }
.act-filter-chips .chip .chip-icon svg { display: block; width: 11px; height: 11px; }
.act-filter-chips .chip.chip-on, .file-tag-bar .chip.chip-on {
  background: var(--text); color: var(--surface); border-color: var(--text); }
.act-list { max-height: 480px; overflow-y: auto; }
.act-entry { position: relative; padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.act-del-x { position: absolute; top: var(--space-2); right: 0; z-index: 2; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.85);
  border: 1px solid var(--border); border-radius: 999px; color: #dc2626; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity .12s ease, background .12s ease; }
.act-entry:hover .act-del-x { opacity: 1; }
.act-del-x:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.act-entry .act-meta { font-size: var(--text-dense); color: var(--muted);
  display: flex; gap: var(--space-1); align-items: center; }
.act-entry .act-meta strong { color: var(--text); font-size: var(--text-dense); font-weight: var(--weight-semibold); }
.act-entry .act-icon { display: inline-flex; }
.act-entry .act-icon svg { display: block; }
.act-entry .act-ts { font-size: var(--text-header); color: var(--muted); }
.act-entry .act-actions { margin-left: auto; }
.act-entry .act-actions a { color: var(--muted); margin-left: var(--space-1); font-size: var(--text-header); text-decoration: none; }
.act-entry .act-content { font-size: var(--text-dense); color: var(--text); margin-top: var(--space-1); white-space: pre-wrap; }

/* Files */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--space-2); }
.file-card { position: relative; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-1); display: flex; flex-direction: column; gap: 2px; }
.file-del-x { position: absolute; top: 2px; right: 2px; z-index: 2; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.85);
  border: 1px solid var(--border); border-radius: 999px; color: #dc2626; cursor: pointer; padding: 0;
  opacity: 0; transition: opacity .12s ease, background .12s ease; }
.file-card:hover .file-del-x { opacity: 1; }
.file-del-x:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.file-thumb { width: 100%; height: 110px; object-fit: cover; background: var(--surface);
  border-radius: var(--radius-sm); cursor: pointer; }
/* glyph icon, not text — design-system exception */
.file-thumb-icon { display: flex; align-items: center; justify-content: center; font-size: 28px; }
.file-name { font-size: 9px; font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; line-height: 1.2; }
.file-sub { font-size: 8px; color: var(--muted); line-height: 1.2; }
.file-tags { display: flex; gap: 2px; flex-wrap: wrap; min-height: 0; }
.file-tag { font-size: 8px; background: var(--surface); color: var(--muted);
  padding: 0 var(--space-1); border-radius: var(--radius-md); }
.file-actions { display: flex; gap: var(--space-1); align-items: center; font-size: 9px;
  margin-top: auto; padding-top: 2px; }
.file-actions label { color: var(--muted); display: flex; align-items: center; gap: var(--space-1); }
.file-actions a { color: var(--muted); text-decoration: none; }

/* Email Threads */
.em-suggestions { background: rgba(139,92,246,.06); border: 1px solid rgba(139,92,246,.3); /* TODO: AI accent panel — needs tokens */
  border-radius: var(--radius-md); padding: var(--space-2); margin-bottom: var(--space-3); }
.em-section-h { font-size: var(--text-header); text-transform: uppercase; letter-spacing: var(--letter-header);
  color: var(--muted); margin-bottom: var(--space-1); }
.em-row { display: flex; gap: var(--space-3); padding: var(--space-1) var(--space-1); border-bottom: 1px solid var(--border); align-items: flex-start; }
.em-row-main { flex: 1; min-width: 0; }
.em-row-main strong { font-size: var(--text-dense); }
.em-meta { font-size: var(--text-header); color: var(--muted); margin-top: 2px; }
.em-snippet { font-size: var(--text-dense); color: var(--muted); margin-top: var(--space-1);
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.em-row-actions { display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-end; font-size: var(--text-header); }
.em-row-actions a { color: var(--muted); text-decoration: none; }
.em-subject { color: var(--text); text-decoration: none; }
.em-subject:hover { color: var(--accent); text-decoration: underline; }
.em-attach { font-size: var(--text-dense); margin-left: var(--space-1); color: var(--muted); }
.em-attach-pending { color: var(--warning); }
.em-save-att {
  font-size: var(--text-header); font-weight: var(--weight-medium);
  letter-spacing: var(--letter-header); text-transform: uppercase;
  padding: 2px var(--space-2);
  color: var(--accent); background: var(--accent-dim);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  cursor: pointer; transition: var(--transition);
}
.em-save-att:hover { background: var(--accent); color: #FFFFFF; }
.em-save-att:focus-visible { outline: var(--focus-ring); }
.em-save-att[disabled] { opacity: 0.6; cursor: progress; }
.em-x {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--text-dense); font-weight: var(--weight-bold);
  color: var(--error); background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; line-height: 1; padding: 0;
  transition: var(--transition);
}
.em-x:hover { background: var(--color-error-dim); border-color: var(--error); }
.em-x:focus-visible { outline: var(--focus-ring); }

/* ── Project sidebar ──────────────────────────────────────────────────────── */
/* Sidebar shifts only the page content — topbar must stay full width */
body.has-sidebar .page { padding-left: 300px; transition: padding-left 120ms; }
body.has-sidebar.sidebar-collapsed .page { padding-left: var(--space-7); }

.genei-sidebar {
  position: fixed; top: var(--height-topbar); left: 0; bottom: 0; width: 280px;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
  transition: width 120ms, transform 120ms;
}
.genei-sidebar:not(.open) { width: 28px; }
.genei-sidebar:not(.open) .sb-toggle {
  width: 28px; height: 56px; background: var(--surface); border: 1px solid var(--border);
  border-left: none; border-radius: 0 var(--radius-md) var(--radius-md) 0; cursor: pointer; color: var(--muted);
  font-size: var(--text-numeric); margin-top: var(--space-3);
}
.sb-head { padding: var(--space-3); border-bottom: 1px solid var(--border); }
.sb-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.sb-title { font-size: var(--text-body); font-weight: var(--weight-bold); color: var(--text); }
.sb-toggle-close { background: transparent; border: none; color: var(--muted);
  font-size: var(--text-numeric); cursor: pointer; padding: 2px var(--space-1); }
.sb-new-proj { background: var(--accent-dim); border: 1px solid var(--accent);
  color: var(--accent); font-size: var(--text-body); font-weight: var(--weight-bold); line-height: 1;
  cursor: pointer; padding: 2px var(--space-2); border-radius: var(--radius-sm); }
.sb-new-proj:hover { background: var(--accent); color: var(--color-surface); }
.sb-filters { display: flex; gap: var(--space-1); align-items: center; margin-bottom: var(--space-1); }
.sb-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.sb-seg button { font-size: var(--text-header); padding: var(--space-1) var(--space-2); background: var(--surface2); color: var(--muted);
  border: none; cursor: pointer; }
.sb-seg button.on { background: var(--text); color: var(--surface); }
.sb-status-wrap { position: relative; flex: 1; }
.sb-status-btn { width: 100%; font-size: var(--text-header); padding: var(--space-1) var(--space-2); text-align: left;
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text); cursor: pointer; }
.sb-status-menu { position: absolute; top: 100%; left: 0; right: 0; margin-top: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  z-index: 60; max-height: 280px; overflow-y: auto; }
.sb-status-item { font-size: var(--text-dense); padding: var(--space-1) var(--space-3); cursor: pointer; color: var(--text); }
.sb-status-item:hover { background: var(--surface2); }
.sb-status-item.on { background: var(--surface2); font-weight: var(--weight-semibold); }
.sb-search { width: 100%; box-sizing: border-box; font-size: var(--text-dense); padding: var(--space-1) var(--space-2);
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.sb-list { flex: 1; overflow-y: auto; }
.sb-group-h { font-size: 9px; text-transform: uppercase; letter-spacing: var(--letter-header);
  color: var(--muted); padding: var(--space-2) var(--space-3) var(--space-1); font-weight: var(--weight-bold); }
.sb-row { display: flex; padding: var(--space-1) var(--space-3); border-bottom: 1px solid var(--border);
  align-items: center; gap: var(--space-1); }
.sb-row:hover { background: var(--surface2); }
.sb-row-hover { background: var(--accent-dim); }
.sb-row-current { background: rgba(99,102,241,.08); border-left: 3px solid #6366f1; padding-left: var(--space-2); /* TODO: AI accent — needs token */ }
.sb-row-main { flex: 1; display: flex; gap: var(--space-1); align-items: flex-start; cursor: pointer; min-width: 0; }
.sb-dot { width: var(--space-2); height: var(--space-2); border-radius: 50%; margin-top: var(--space-1); flex-shrink: 0; }
.sb-dot-red { background: var(--color-warning); /* mapped from #f97316 (orange) → warning token */ }
.sb-dot-amber { background: var(--color-warning); /* mapped from #fbbf24 → warning token */ }
.sb-dot-gray { background: var(--muted); /* mapped from #94a3b8 → muted token */ }
.sb-row-text { min-width: 0; flex: 1; }
.sb-row-title { font-size: var(--text-dense); font-weight: var(--weight-semibold); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-row-sub { font-size: var(--text-header); color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-dismiss { background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: var(--text-dense); cursor: pointer; padding: 2px var(--space-1); flex-shrink: 0; }
.sb-dismiss:hover { background: var(--surface2); color: var(--text); }

@media (max-width: 900px) {
  body.has-sidebar .page { padding-left: 0; }
  .genei-sidebar { transform: translateX(-100%); }
  .genei-sidebar.open { transform: translateX(0); width: 280px; }
}

/* ── Files dropzone + remark ─────────────────────────────────────────────── */
.file-dropzone { border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-2); margin-bottom: var(--space-2); transition: background 120ms, border-color 120ms; }
.file-dropzone.dz-over { background: var(--color-accent-dim); border-color: var(--color-accent); }
.file-remark { width: 100%; box-sizing: border-box; font-size: 9px; padding: 1px var(--space-1);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text);
  line-height: 1.3; }
.file-remark::placeholder { color: var(--muted); font-style: italic; }
.file-remark:hover, .file-remark:focus { border-color: var(--border); background: var(--surface); outline: none; }

/* Page-wide drop overlay */
.page-dropzone-overlay {
  position: fixed; inset: 0; background: rgba(3, 105, 161, 0.12); border: 3px dashed var(--color-accent);
  z-index: 9000; pointer-events: none; display: flex; align-items: center; justify-content: center;
  font-size: var(--text-title); font-weight: var(--weight-bold); color: var(--color-accent);
}

/* ── Genie date picker (genie-date-picker.js) ────────────────────────────── */
.genie-date-pop {
  position: absolute;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  width: 252px;
  font-family: var(--font-sans);
  color: var(--text);
}
.genie-date-pop .gd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}
.genie-date-pop .gd-month {
  font-size: var(--text-body);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.genie-date-pop .gd-nav {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: var(--text-dense);
  font-family: var(--font-sans);
  line-height: 1;
}
.genie-date-pop .gd-nav:hover { background: var(--surface2); }
.genie-date-pop .gd-grid {
  display: grid;
  grid-template-columns: repeat(7, 32px);
  gap: var(--space-1);
}
.genie-date-pop .gd-dow {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-header);
  font-weight: var(--weight-bold);
  letter-spacing: var(--letter-header);
  text-transform: uppercase;
  color: var(--muted);
}
.genie-date-pop .gd-day {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
  color: var(--text);
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background var(--transition);
  padding: 0;
}
.genie-date-pop .gd-day:hover { background: var(--surface2); }
.genie-date-pop .gd-day.muted { color: var(--muted); }
.genie-date-pop .gd-day.today {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: var(--weight-semibold);
}
.genie-date-pop .gd-day.selected {
  background: var(--accent);
  color: var(--color-surface);
  font-weight: var(--weight-semibold);
}
.genie-date-pop .gd-foot {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}
.genie-date-pop .gd-clear,
.genie-date-pop .gd-today {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: var(--text-dense);
  font-family: var(--font-sans);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.genie-date-pop .gd-clear:hover,
.genie-date-pop .gd-today:hover {
  background: var(--surface2);
  color: var(--text);
}

/* Inputs flagged as Genie dates inherit the standard input styling already; no extra rules needed. */

/* ── New Project modal ──────────────────────────────────────────────────── */
.np-modal { width: min(560px, 92vw); }
.np-body { padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-3); overflow-y: auto; }
.np-row { display: flex; flex-direction: column; gap: var(--space-1); }
.np-label { font-size: var(--text-header); text-transform: uppercase; letter-spacing: var(--letter-header);
  color: var(--muted); font-weight: var(--weight-bold); }
.np-opt { font-weight: var(--weight-regular); text-transform: none; letter-spacing: 0; color: var(--muted); }
.np-input { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font-sans); font-size: var(--text-dense);
  padding: var(--space-1) var(--space-2); outline: none; height: 28px; }
.np-input:focus { border-color: var(--accent); }
.np-textarea { height: auto; min-height: 48px; resize: vertical; line-height: 1.4; padding: var(--space-2); }
.np-select { width: 100%; height: 28px; }
.np-hint { font-size: var(--text-header); color: var(--muted); }

.np-cust-wrap { position: relative; }
.np-cust-results { position: absolute; top: calc(100% + 2px); left: 0; right: 0; z-index: 10;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 200px; overflow-y: auto; }
.np-cust-item { padding: var(--space-1) var(--space-2); font-size: var(--text-dense); color: var(--text); cursor: pointer; }
.np-cust-item:hover { background: var(--surface2); }
.np-cust-empty { padding: var(--space-2); font-size: var(--text-dense); color: var(--muted); }
.np-cust-pill { display: inline-flex; align-items: center; gap: var(--space-1);
  background: var(--accent-dim); color: var(--accent); padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm); font-size: var(--text-dense); font-weight: var(--weight-medium);
  width: fit-content; }
.np-cust-clear { background: transparent; border: 0; color: var(--accent); cursor: pointer;
  font-size: var(--text-body); line-height: 1; padding: 0 var(--space-1); }

.np-seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  width: fit-content; background: var(--surface); }
.np-seg-btn { background: transparent; border: 0; color: var(--text); font-family: var(--font-sans);
  font-size: var(--text-dense); padding: var(--space-1) var(--space-3); cursor: pointer; height: 28px;
  border-right: 1px solid var(--border); transition: background var(--transition); }
.np-seg-btn:last-child { border-right: 0; }
.np-seg-btn:hover:not(.is-active):not(:disabled) { background: var(--surface2); }
.np-seg-btn.is-active { background: var(--accent-dim); color: var(--accent); font-weight: var(--weight-medium); }
.np-seg-btn:disabled { opacity: .5; cursor: not-allowed; }

.np-pri { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.np-pri-chip { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--font-sans); font-size: var(--text-header);
  font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: var(--letter-header);
  padding: var(--space-1) var(--space-2); height: 24px; cursor: pointer; transition: background var(--transition); }
.np-pri-chip:hover:not(.is-active) { background: var(--surface2); }
.np-pri-chip.is-active.np-pri-normal { background: var(--surface2); color: var(--text); border-color: var(--muted); }
.np-pri-chip.is-active.np-pri-medium { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.np-pri-chip.is-active.np-pri-high   { background: var(--color-warning-dim); color: var(--color-warning); border-color: var(--color-warning); }
.np-pri-chip.is-active.np-pri-urgent { background: var(--color-error-dim); color: var(--color-error); border-color: var(--color-error); }

.np-error { background: var(--color-error-dim); color: var(--color-error); border: 1px solid var(--color-error);
  border-radius: var(--radius-sm); padding: var(--space-1) var(--space-2); font-size: var(--text-dense); }

/* Project header chips (priority + visibility) */
.proj-pri-chip { display: inline-flex; align-items: center; padding: 2px var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--text-header); font-weight: var(--weight-bold); text-transform: uppercase; letter-spacing: var(--letter-header);
  border: 1px solid var(--border); }
.proj-pri-chip.np-pri-normal { background: var(--surface2); color: var(--muted); }
.proj-pri-chip.np-pri-medium { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.proj-pri-chip.np-pri-high   { background: var(--color-warning-dim); color: var(--color-warning); border-color: var(--color-warning); }
.proj-pri-chip.np-pri-urgent { background: var(--color-error-dim); color: var(--color-error); border-color: var(--color-error); }
.proj-vis-chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2);
  border-radius: var(--radius-sm); font-size: var(--text-header); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: var(--letter-header);
  background: var(--surface2); color: var(--muted); border: 1px solid var(--border); }

/* ── Project channel thread + quick-create (Phase 5) ─────────────────────── */
.thread-frame {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.thread-feed {
  max-height: 380px;
  overflow-y: auto;
  padding: var(--space-3);
}
.thread-msg { padding: var(--space-2) 0; border-bottom: 1px solid var(--border); font-size: var(--text-body); }
.thread-msg:last-child { border-bottom: none; }
.thread-msg.is-system { background: var(--surface2); padding: var(--space-2) var(--space-2); border-radius: var(--radius-sm); margin-bottom: var(--space-2); }
.thread-msg .meta { font-size: var(--text-header); color: var(--muted); margin-bottom: 2px; }
.thread-msg .meta .author { color: var(--text); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: var(--text-dense); margin-right: var(--space-2); }
.thread-msg .body { white-space: pre-wrap; word-break: break-word; }
.thread-composer { display: flex; gap: var(--space-2); padding: var(--space-3); border-top: 1px solid var(--border); background: var(--surface2); }
.thread-composer textarea { flex: 1; resize: none; padding: var(--space-2); font-family: var(--font-sans); font-size: var(--text-body); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.thread-composer .btn { align-self: flex-end; }

.qc-trigger {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-dense);
  font-weight: 600;
  cursor: pointer;
  margin-right: var(--space-2);
}
.qc-trigger:hover { filter: brightness(1.05); }

.qc-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.qc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-5);
  width: min(440px, 92vw);
  display: flex; flex-direction: column; gap: var(--space-3);
}
.qc-card h3 { margin: 0; font-size: var(--text-title); }
.qc-card input { padding: var(--space-2); font-family: var(--font-sans); font-size: var(--text-body); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.qc-error { color: var(--color-error); font-size: var(--text-dense); min-height: 16px; }
.qc-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }
.qc-actions .btn-primary { background: var(--accent); color: #fff; border: none; padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer; }
.qc-actions button:not(.btn-primary) { background: var(--surface2); color: var(--text); border: 1px solid var(--border); padding: 6px 14px; border-radius: var(--radius-sm); cursor: pointer; }

/* Catch-up banner + auto-status chip (Phase 8) */
.thread-catchup {
  position: relative;
  background: var(--accent-dim);
  border-bottom: 1px solid var(--accent);
  padding: var(--space-3);
  margin: 0;
}
.catchup-title { font-size: var(--text-header); font-weight: 700; letter-spacing: var(--letter-header); text-transform: uppercase; color: var(--accent); margin-bottom: var(--space-1); }
.catchup-body { font-size: var(--text-dense); color: var(--text); white-space: pre-wrap; }
.catchup-close { position: absolute; top: 4px; right: 8px; background: transparent; border: none; cursor: pointer; font-size: 18px; color: var(--accent); line-height: 1; }

.proj-auto-chip {
  display: inline-flex; align-items: center;
  padding: 2px var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--text-header); font-weight: var(--weight-bold);
  text-transform: uppercase; letter-spacing: var(--letter-header);
  border: 1px solid var(--border);
}
.proj-auto-chip.is-active       { background: var(--color-success-dim); color: var(--color-success); border-color: var(--color-success); }
.proj-auto-chip.is-idle         { background: var(--surface2); color: var(--muted); }
.proj-auto-chip.is-stale        { background: var(--color-warning-dim); color: var(--color-warning); border-color: var(--color-warning); }
.proj-auto-chip.is-likely-done  { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
