/* ========== Vildez Design System ========== */
:root {
  /* Brand */
  --brand: #B0301A;
  --brand-hover: #C0341D;
  --brand-soft: rgba(176, 48, 26, 0.08);
  --brand-border: rgba(176, 48, 26, 0.2);

  /* Light theme - warm off-white base */
  --bg: #FAFAF9;
  --bg-elev: #FFFFFF;
  --bg-sunken: #F4F4F2;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(0, 0, 0, 0.06);
  --border: #E7E5E2;
  --border-strong: #D4D2CD;
  --text: #18181B;
  --text-muted: #6B6B70;
  --text-faint: #9A9A9F;
  --shadow-sm: 0 1px 2px rgba(20, 20, 20, 0.04);
  --shadow: 0 1px 3px rgba(20, 20, 20, 0.05), 0 0 0 1px rgba(20, 20, 20, 0.04);
  --shadow-lg: 0 8px 24px rgba(20, 20, 20, 0.08), 0 0 0 1px rgba(20, 20, 20, 0.04);

  /* Semantic */
  --success: #15803D;
  --success-bg: #DCFCE7;
  --warning: #B45309;
  --warning-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --info: #1D4ED8;
  --info-bg: #DBEAFE;

  /* Type scale */
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', monospace;

  /* Spacing (density: comfortable default) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --row-h: 44px;
  --pad-y: 12px;
  --pad-x: 16px;

  /* Radii */
  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Sidebar widths */
  --sidebar-primary: 208px;
  --sidebar-collapsed: 56px;
  --sidebar-secondary: 224px;
  --header-h: 52px;
}

[data-theme="dark"] {
  --bg: #1A1A1C;
  --bg-elev: #222225;
  --bg-sunken: #161618;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(255, 255, 255, 0.07);
  --border: #2D2D31;
  --border-strong: #3A3A3F;
  --text: #F4F4F5;
  --text-muted: #A1A1A6;
  --text-faint: #6E6E74;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);

  --success: #4ADE80;
  --success-bg: rgba(74, 222, 128, 0.12);
  --warning: #FBBF24;
  --warning-bg: rgba(251, 191, 36, 0.12);
  --danger: #F87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info: #60A5FA;
  --info-bg: rgba(96, 165, 250, 0.12);

  --brand-soft: rgba(208, 80, 50, 0.14);
  --brand-border: rgba(208, 80, 50, 0.3);
  --brand: #D05032;
  --brand-hover: #DD5A3A;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root { height: 100vh; }

/* ========== App layout ========== */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-primary) var(--sidebar-secondary) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar-primary sidebar-secondary header"
    "sidebar-primary sidebar-secondary main";
  height: 100vh;
  background: var(--bg);
  overflow: hidden;
}
.app[data-sidebar-collapsed="true"] { --sidebar-primary: var(--sidebar-collapsed); }
.app[data-secondary-hidden="true"] {
  grid-template-columns: var(--sidebar-primary) 1fr;
  grid-template-areas:
    "sidebar-primary header"
    "sidebar-primary main";
}
.app[data-sidebar-collapsed="true"][data-secondary-hidden="true"] { --sidebar-primary: var(--sidebar-collapsed); }

.sidebar-primary { grid-area: sidebar-primary; }
.sidebar-secondary { grid-area: sidebar-secondary; }
.header { grid-area: header; }
.main { grid-area: main; overflow-y: auto; overflow-x: hidden; }

/* ========== Sidebar Primary ========== */
.sidebar-primary {
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 200ms cubic-bezier(0.2, 0, 0, 1);
}
.sidebar-brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand img.brand-icon { width: 24px; height: 24px; flex-shrink: 0; }
.sidebar-brand img.brand-wordmark { height: 22px; width: auto; max-width: 140px; object-fit: contain; }
[data-theme="light"] .sidebar-brand .dark-only,
[data-theme="dark"] .sidebar-brand .light-only { display: none; }

.sidebar-section {
  padding: 12px 8px 4px;
}
.sidebar-section-label {
  font-size: 11px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 4px 10px 8px;
  font-weight: 500;
}
/* Keep font-size identical to the expanded state so label height doesn't change
   between modes. Otherwise the whole nav slides vertically as labels shrink. */
.app[data-sidebar-collapsed="true"] .sidebar-section-label {
  text-align: center;
  padding: 4px 0 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Padding-left chosen so the icon center sits at x=28 from the sidebar edge,
     which is also the visual center of the collapsed (56px) sidebar.
     Result: icons don't shift when collapsing/expanding. */
  padding: 7px 11px;
  /* Min-height locked so the row stays the same when the label disappears in
     collapsed mode — otherwise the nav shrinks vertically (~2px per row) and
     the whole sidebar looks "smaller". */
  min-height: 34px;
  box-sizing: border-box;
  border-radius: var(--r);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
  transition: background 120ms, color 120ms;
  margin-bottom: 1px;
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--bg-active);
  color: var(--text);
  font-weight: 600;
}
.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-item .nav-icon svg { width: 18px; height: 18px; }
.nav-item.active .nav-icon { color: var(--brand); }

.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .nav-badge {
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 10px;
  font-family: var(--font-mono);
}
.nav-item .nav-soon {
  color: var(--text-faint);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}
.nav-item .nav-soon svg { width: 14px; height: 14px; }
/* Keep nav-item padding identical in both modes so the icon stays at the same X.
   Only hide the label, badges and "coming soon" hint when collapsed. */
.app[data-sidebar-collapsed="true"] .nav-item .nav-label,
.app[data-sidebar-collapsed="true"] .nav-item .nav-badge,
.app[data-sidebar-collapsed="true"] .nav-item .nav-soon { display: none; }

.sidebar-footer {
  margin-top: auto;
  /* Horizontal padding 14 picks the same x=28 as nav-item icons:
     in collapsed mode (56px wide) the 28px button fits exactly, in expanded
     mode the button stays at x=14 with flex-start. No shift between modes. */
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-start;
}
.app[data-sidebar-collapsed="true"] .sidebar-footer { justify-content: center; flex-direction: column; }
.collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms;
}
.collapse-btn:hover { background: var(--bg-hover); color: var(--text); }
.collapse-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.collapse-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.sidebar-cookies {
  padding: 6px 14px 8px;
}
.cookies-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--r);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.cookies-btn:hover { background: var(--bg-hover); color: var(--text); }
.cookies-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.app[data-sidebar-collapsed="true"] .sidebar-cookies { padding: 6px 0 8px; display: flex; justify-content: center; }
.app[data-sidebar-collapsed="true"] .cookies-btn { width: 28px; height: 28px; padding: 0; justify-content: center; }
.app[data-sidebar-collapsed="true"] .cookies-btn-label { display: none; }

/* Tooltips for collapsed sidebar */
.tooltip-wrap { position: relative; }
.app[data-sidebar-collapsed="true"] .nav-item:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 4px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}

/* ========== Sidebar Secondary ========== */
.sidebar-secondary {
  background: var(--bg-sunken);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.secondary-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}
.secondary-content {
  padding: 12px 8px;
  overflow-y: auto;
  flex: 1;
}
.sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--r);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 1px;
  transition: background 120ms, color 120ms;
  background: none;
  border: 0;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.secondary-footer {
  margin-top: auto;
  padding: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.subnav-reopen {
  position: fixed;
  left: var(--sidebar-collapsed);
  bottom: 14px;
  z-index: 60;
  width: 24px;
  height: 48px;
  border-radius: 0 8px 8px 0;
  border: 1px solid var(--border);
  border-left: none;
  background: var(--bg-elev);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 120ms, color 120ms, transform 150ms, left 200ms;
}
.subnav-reopen:hover { background: var(--bg-hover); color: var(--text); transform: translateX(2px); }
.app:not([data-sidebar-collapsed="true"]) .subnav-reopen { left: var(--sidebar-primary); }
.sidebar-secondary { display: flex; flex-direction: column; }
.sub-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 4px 10px 6px;
}
.page-tab {
  background: none;
  border: none;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 120ms, border-color 120ms;
}
.page-tab:hover { color: var(--text); }
.page-tab[data-active="true"] {
  color: var(--text);
  font-weight: 500;
  border-bottom-color: var(--brand);
}
.secondary-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 4px 10px 6px;
}
.sub-item:hover { background: var(--bg-hover); color: var(--text); }
.sub-item.active { background: var(--bg-elev); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }
.sub-item .sub-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); flex-shrink: 0; }
.sub-item.active .sub-dot { background: var(--brand); }
.sub-item .sub-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

/* ========== Header ========== */
.header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumbs .crumb { padding: 2px 6px; border-radius: var(--r-sm); cursor: pointer; }
.breadcrumbs .crumb:hover { background: var(--bg-hover); color: var(--text); }
.breadcrumbs .crumb.current { color: var(--text); font-weight: 500; }
.breadcrumbs .sep { color: var(--text-faint); }

.search-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-sunken);
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  min-width: 240px;
  transition: border-color 120ms, background 120ms;
}
.search-trigger:hover { border-color: var(--border-strong); background: var(--bg-elev); }
.search-trigger .kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-faint);
}

.header-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: background 120ms, color 120ms;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn .ind {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--bg);
}

.lang-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: transparent;
  padding: 4px 10px 4px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.lang-toggle:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.lang-toggle svg { width: 14px; height: 14px; color: var(--text-muted); }
.lang-toggle .lang-current { letter-spacing: 0.04em; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background 120ms;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
}
.user-chip:hover { background: var(--bg-hover); }
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B0301A, #6B1F12);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.xl { width: 88px; height: 88px; font-size: 32px; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.user-chip .name { font-size: 13px; font-weight: 500; }

/* ========== Main / Pages ========== */
.page {
  padding: 28px 32px 80px;
  max-width: 1280px;
  margin: 0 auto;
  animation: pageIn 240ms cubic-bezier(0.2, 0, 0, 1);
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.15;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.page-actions { display: flex; gap: 8px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  height: 32px;
  border-radius: var(--r);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  transition: background 120ms, border-color 120ms, transform 80ms;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(0.98); }
.btn svg { width: 14px; height: 14px; }
.btn.primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn.primary:hover { background: var(--text); opacity: 0.9; }
.btn.brand {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn.brand:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.danger { color: var(--danger); }
.btn.sm { height: 26px; padding: 4px 8px; font-size: 12px; }

/* ========== Card ========== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.card-pad { padding: 20px; }
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }

/* Stats cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: border-color 150ms, transform 150ms;
}
.stat:hover { border-color: var(--border-strong); }
.stat .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.stat .stat-label svg { width: 14px; height: 14px; }
.stat .stat-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum";
  line-height: 1.1;
}
.stat .stat-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat .delta-up { color: var(--success); }
.stat .delta-down { color: var(--danger); }

/* Mini sparkline */
.spark {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  opacity: 0.7;
  pointer-events: none;
}

/* ========== Tables ========== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: transparent;
}
.tbl tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background 120ms; cursor: pointer; }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl .num { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tbl .right { text-align: right; }
.mono { font-family: var(--font-mono); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  border: 1px solid transparent;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.success { color: var(--success); background: var(--success-bg); }
.badge.warning { color: var(--warning); background: var(--warning-bg); }
.badge.danger { color: var(--danger); background: var(--danger-bg); }
.badge.info { color: var(--info); background: var(--info-bg); }
.badge.neutral { color: var(--text-muted); background: var(--bg-sunken); border-color: var(--border); }

/* ========== Skeletons ========== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel {
  background: linear-gradient(90deg, var(--bg-sunken) 0%, var(--bg-hover) 50%, var(--bg-sunken) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

/* Empty state placeholders */
.empty {
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 48px 24px;
  text-align: center;
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.empty .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.empty .empty-icon svg { width: 28px; height: 28px; }
.empty h3 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.empty p { margin: 0; color: var(--text-muted); font-size: 13px; max-width: 380px; line-height: 1.5; }

/* Soon badge */
.soon-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
}

/* ========== Inputs ========== */
.input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 120ms, box-shadow 120ms;
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input::placeholder { color: var(--text-faint); }
input[type="number"].input { -moz-appearance: textfield; appearance: textfield; }
input[type="number"].input::-webkit-outer-spin-button,
input[type="number"].input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input.num-input {
  text-align: right;
  padding-left: 6px;
  padding-right: 6px;
  font-family: var(--font-mono);
  font-feature-settings: "tnum";
  font-size: 12.5px;
}

/* Auto-grow description textarea inside line-item tables */
textarea.input.desc-input {
  min-height: 0;
  height: auto;
  line-height: 1.5;
  resize: none;
  overflow: hidden;
  display: block;
  padding-top: 6px;
  padding-bottom: 6px;
}

/* Top-align cells in line-item tables so growing rows stay tidy */
.lines-table tbody td { vertical-align: top; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
label.field .input { color: var(--text); font-weight: 400; }

/* Toggle */
.switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 150ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch.on { background: var(--text); }
.switch.on::after { transform: translateX(14px); }

/* ========== Stagger animation utility ========== */
.stag > * { animation: stagIn 320ms cubic-bezier(0.2, 0, 0, 1); }
.stag > *:nth-child(1) { animation-delay: 20ms; }
.stag > *:nth-child(2) { animation-delay: 60ms; }
.stag > *:nth-child(3) { animation-delay: 100ms; }
.stag > *:nth-child(4) { animation-delay: 140ms; }
.stag > *:nth-child(5) { animation-delay: 180ms; }
.stag > *:nth-child(6) { animation-delay: 220ms; }
.stag > *:nth-child(7) { animation-delay: 260ms; }
.stag > *:nth-child(8) { animation-delay: 300ms; }
@keyframes stagIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar - subtle */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); border: 2px solid transparent; background-clip: content-box; }

/* Onboarding overlay */
.onb-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.onb-card {
  width: 520px;
  max-width: calc(100vw - 48px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  animation: cardIn 320ms cubic-bezier(0.2, 0, 0, 1);
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Profile */
.profile-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  align-items: start;
}
.profile-tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: sticky;
  top: 16px;
}
.profile-tab {
  padding: 8px 12px;
  border-radius: var(--r);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 120ms, color 120ms;
}
.profile-tab svg { width: 16px; height: 16px; }
.profile-tab:hover { background: var(--bg-hover); color: var(--text); }
.profile-tab.active { background: var(--bg-active); color: var(--text); font-weight: 600; }

.section-block + .section-block { margin-top: 24px; }
.section-block h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.section-block .desc { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }

.row-list { display: flex; flex-direction: column; }
.row-list .row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.row-list .row:last-child { border-bottom: 0; }
.row-list .row .row-main { flex: 1; min-width: 0; }
.row-list .row .row-title { font-size: 13.5px; font-weight: 500; }
.row-list .row .row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Module landing — placeholder */
.module-hero {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  padding: 40px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
  position: relative;
  overflow: hidden;
}
.module-hero h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}
.module-hero p { font-size: 14px; color: var(--text-muted); margin: 0 0 20px; max-width: 420px; line-height: 1.55; }
.module-hero .hero-art {
  width: 220px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-sunken);
  position: relative;
  overflow: hidden;
}

/* feature grid */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 20px;
}
.feat {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg-elev);
}
.feat .feat-icon {
  width: 32px; height: 32px;
  border-radius: var(--r);
  background: transparent;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text);
  margin-bottom: 10px;
}
.feat .feat-icon svg { width: 22px; height: 22px; }
.feat h4 { margin: 0 0 4px; font-size: 13px; font-weight: 600; }
.feat p { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.5; }

/* Alerts list */
.alert-row {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 120ms;
  align-items: flex-start;
}
.alert-row:hover { background: var(--bg-hover); }
.alert-row:last-child { border-bottom: 0; }
.alert-row.unread { background: var(--brand-soft); }
.alert-row.unread:hover { background: var(--brand-soft); }
.alert-icon-wrap {
  width: 32px; height: 32px;
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.alert-row .a-title { font-size: 13.5px; font-weight: 500; }
.alert-row .a-body { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.5; }
.alert-row .a-time { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); flex-shrink: 0; margin-left: 12px; }

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.toolbar .input { max-width: 280px; }
.tab-bar {
  display: flex;
  gap: 2px;
  background: var(--bg-sunken);
  padding: 3px;
  border-radius: var(--r);
  border: 1px solid var(--border);
}
.tab-bar button {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 500;
}
.tab-bar button.active { background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow-sm); }

.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* Inline kbd */
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* Subtle gradient backgrounds for stat cards */
.stat[data-tone="brand"] .spark { background: linear-gradient(180deg, var(--brand-soft) 0%, transparent 100%); }
.stat[data-tone="green"] .spark { background: linear-gradient(180deg, rgba(21, 128, 61, 0.08) 0%, transparent 100%); }
.stat[data-tone="blue"] .spark { background: linear-gradient(180deg, rgba(29, 78, 216, 0.08) 0%, transparent 100%); }
.stat[data-tone="amber"] .spark { background: linear-gradient(180deg, rgba(180, 83, 9, 0.08) 0%, transparent 100%); }

/* ============ Header: clickable breadcrumbs ============ */
.breadcrumbs .crumb-link {
  background: none;
  border: 0;
  font: inherit;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.breadcrumbs .crumb-link:hover { background: var(--bg-hover); color: var(--text); }
.breadcrumbs .crumb.current { cursor: default; }

/* ============ Search overlay (⌘K palette) ============ */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn 140ms ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.search-palette {
  width: min(640px, calc(100vw - 32px));
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--border);
  overflow: hidden;
  animation: paletteIn 180ms cubic-bezier(.2,.8,.2,1);
}
@keyframes paletteIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input-row input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 15px;
  color: var(--text);
}
.search-input-row input::placeholder { color: var(--text-faint); }
.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}
.search-result {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 0;
  background: transparent;
  border-radius: var(--r);
  cursor: pointer;
  font: inherit;
  color: var(--text);
  text-align: left;
  transition: background 90ms;
}
.search-result svg { width: 14px; height: 14px; color: var(--text-muted); flex-shrink: 0; }
.search-result:hover,
.search-result:focus-visible { background: var(--bg-hover); outline: 0; }
.search-result .search-label { flex: 1; font-size: 13.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .search-meta { font-size: 11.5px; color: var(--text-muted); }
.search-result .search-kind {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

/* ============ Bell popover ============ */
.icon-btn[data-active="true"] { background: var(--bg-hover); color: var(--text); }
.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28), 0 0 0 1px var(--border);
  z-index: 100;
  overflow: hidden;
  animation: popIn 140ms cubic-bezier(.2,.8,.2,1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
}
.popover-link {
  background: none;
  border: 0;
  font: inherit;
  font-size: 12px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 500;
}
.popover-link:hover { text-decoration: underline; }
.popover-body {
  max-height: 380px;
  overflow-y: auto;
}
.popover-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 90ms;
}
.popover-item:last-child { border-bottom: 0; }
.popover-item:hover { background: var(--bg-hover); }
.popover-item.unread { background: var(--brand-soft); }
.popover-item.unread:hover { background: var(--bg-hover); }
.popover-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.popover-icon svg { width: 14px; height: 14px; }
.popover-icon[data-tone="danger"] { background: var(--danger-bg); color: var(--danger); }
.popover-icon[data-tone="warning"] { background: var(--warning-bg); color: var(--warning); }
.popover-icon[data-tone="info"] { background: var(--info-bg); color: var(--info); }
.popover-icon[data-tone="success"] { background: var(--success-bg); color: var(--success); }
.popover-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; line-height: 1.3; }
.popover-sub { font-size: 12px; color: var(--text-muted); line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.popover-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; padding-top: 2px; font-family: var(--font-mono); }



/* ========== Modal ========== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 8vh;
  animation: fadeIn 160ms ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);
  max-height: 80vh;
  display: flex; flex-direction: column;
  animation: modalIn 200ms cubic-bezier(.2,.8,.2,1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.modal-head > div:first-child { flex: 1; min-width: 0; }
.modal-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.modal-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ========== Drag & drop niceties (shared) ========== */
/* Force the grabbing cursor everywhere while a drag is live. The element under
   the pointer often has its own cursor; the !important here is the simplest way
   to win without per-selector overrides. */
body.is-dragging,
body.is-dragging * {
  cursor: grabbing !important;
  user-select: none !important;
}
/* The source disappears entirely while a drag is alive — feels like the card
   was literally picked up and is now in your hand (the .dnd-floating clone).
   We use visibility:hidden (not display:none) so the layout slot is preserved
   as a "shadow of where the card was" placeholder. */
.dragging-source {
  visibility: hidden !important;
}
/* The clone we render ourselves and position:fixed-track to the cursor in
   ui-overlays.jsx. Crisp, fully opaque, slight rotation + drop shadow so it
   reads as a card being held off the surface. */
.dnd-floating {
  box-shadow: 0 22px 56px rgba(0,0,0,0.42), 0 8px 18px rgba(0,0,0,0.28);
  transform: rotate(2deg) scale(1.02);
  border-radius: var(--r);
  opacity: 1 !important;
  /* Solid background so the clone never reveals what's behind it — many of
     our draggable elements (e.g. table rows) inherit their background from a
     parent container that the clone has been removed from. */
  background-color: var(--bg-elev);
  /* Smooth out the cursor-tracking jitter just a bit (long enough to feel
     responsive, short enough to never lag behind the cursor noticeably). */
  transition: transform 60ms ease;
  will-change: left, top;
}
/* Flat variant for long elements like table rows where the rotation looks
   awkward (the corners tilt off the edges of the row's visual rectangle). */
.dnd-floating.flat {
  transform: scale(1.01);
  border-radius: var(--r-md);
}
/* While a drag is alive, the storage breadcrumb chips and the "Up" button
   gain a dashed outline so they read as obvious drop zones. Without this,
   users don't realize they can drop files/folders onto a parent breadcrumb
   to move them up the folder tree. */
body.is-dragging .storage-up,
body.is-dragging .storage-crumb {
  outline: 1.5px dashed var(--border-strong);
  outline-offset: 2px;
}
/* Subtle pulse on valid drop targets so it's obvious where you can let go. */
@keyframes dndDropPulse {
  0%, 100% { outline-color: var(--brand); }
  50%      { outline-color: transparent; }
}

/* ========== Tasks / Kanban board ========== */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row:last-child { margin-bottom: 0; }
.form-label { font-size: 11.5px; font-weight: 500; color: var(--text-muted); }

.kanban-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  margin: 8px 0 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.kanban-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.kanban-toolbar-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}
.kanban-toolbar .select-trigger { width: 200px; }

.kanban-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: auto;
  /* gridTemplateColumns is set inline based on the number of states */
}
.kanban-col-header {
  background: var(--bg-elev);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}
.kanban-col-header[data-terminal="true"] { color: var(--success); }
/* Active-work columns (anything that isn't the entry "Backlog" or the exit
   "Completed") get the info blue, mirroring how Completed gets the success green. */
.kanban-col-header:not([data-initial="true"]):not([data-terminal="true"]) { color: var(--info); }
.kanban-col-count {
  background: var(--bg-sunken);
  color: var(--text-muted);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}
.kanban-row-header {
  background: var(--bg-elev);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  border-right: 1px solid var(--border);
  position: sticky;
  left: 0;
  z-index: 1;
}
.kanban-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.kanban-row-cta {
  display: flex;
  gap: 6px;
}
.kanban-row-cta .kanban-add-btn { flex: 1; text-align: center; padding: 4px 6px; }
.kanban-story-meta { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.kanban-story-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.kanban-story-assignee { flex-shrink: 0; }
.kanban-story-actions { display: flex; gap: 4px; flex-shrink: 0; opacity: 0; transition: opacity 120ms; }
.kanban-row-header:hover .kanban-story-actions { opacity: 1; }

.kanban-cell {
  background: var(--bg);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
  transition: background 120ms;
}
.kanban-cell.drop-target {
  background: var(--brand-soft);
  outline: 2px dashed var(--brand);
  outline-offset: -3px;
  animation: dndDropPulse 1.1s ease-in-out infinite;
}
.kanban-cell.drop-invalid {
  background: repeating-linear-gradient(
    45deg,
    var(--bg-sunken),
    var(--bg-sunken) 6px,
    var(--bg) 6px,
    var(--bg) 12px
  );
  position: relative;
}
.kanban-cell.drop-invalid::after {
  content: attr(data-invalid-msg);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  pointer-events: none;
  text-align: center;
  padding: 0 8px;
}

.kanban-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  cursor: grab;
  transition: border-color 120ms, transform 120ms, box-shadow 120ms;
  user-select: none;
}
.kanban-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kanban-card:active { cursor: grabbing; }
.kanban-card[data-type="bug"] { border-left: 3px solid var(--danger); }
.kanban-card[data-type="task"] { border-left: 3px solid var(--brand); }
.kanban-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.kanban-card-type {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kanban-card-menu {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 120ms, color 120ms, background 120ms;
}
.kanban-card:hover .kanban-card-menu { opacity: 1; }
.kanban-card-menu:hover { color: var(--danger); background: var(--bg-hover); }
.kanban-card-title {
  font-size: 12.5px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.4;
}
.kanban-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.kanban-add-btn {
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 4px 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 120ms, color 120ms, background 120ms;
  font-family: inherit;
}
.kanban-add-btn:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }
.kanban-add-btn.alt:hover { border-color: var(--danger); color: var(--danger); background: transparent; }

.kanban-truncated {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--warning);
  border-radius: var(--r);
  color: var(--text);
  font-size: 12.5px;
}

/* Board settings modal — state list */
.kanban-states-list { display: flex; flex-direction: column; gap: 6px; }
.kanban-state-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.kanban-state-grip { color: var(--text-muted); cursor: grab; user-select: none; }
.kanban-state-flag {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.kanban-confirm-strip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--warning);
  border-radius: var(--r);
}
.kanban-error {
  margin-top: 10px;
  padding: 10px;
  background: var(--danger-soft, var(--bg-sunken));
  border: 1px solid var(--danger);
  border-radius: var(--r);
  color: var(--danger);
  font-size: 12.5px;
}

@media (max-width: 720px) {
  .kanban-toolbar { flex-direction: column; align-items: stretch; }
  .kanban-toolbar-group { flex-wrap: wrap; }
  .kanban-toolbar .select-trigger { width: 100%; min-width: 0; }
}

/* ========== Cookie consent ========== */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 180;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.28);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  animation: cookieIn 220ms cubic-bezier(.2,.8,.2,1);
}
@keyframes cookieIn {
  from { opacity: 0; transform: translateY(100%); }
  to { opacity: 1; transform: translateY(0); }
}
.cookie-banner-text { flex: 1; min-width: 0; }
.cookie-banner-title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.cookie-banner-body {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.cookie-banner-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
@media (max-width: 720px) {
  .cookie-banner {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 14px 16px;
  }
  .cookie-banner-actions { justify-content: stretch; }
  .cookie-banner-actions .btn { flex: 1 1 auto; justify-content: center; }
}
.cookie-policy { font-size: 13px; color: var(--text); line-height: 1.6; }
.cookie-policy-h {
  margin: 18px 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.cookie-policy-h:first-child { margin-top: 0; }
.cookie-policy-p { margin: 0 0 10px; color: var(--text-muted); }
.cookie-policy-ul {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--text-muted);
}
.cookie-policy-ul li { margin-bottom: 4px; }

/* ========== Toast ========== */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  min-width: 220px;
  animation: toastIn 220ms cubic-bezier(.2,.8,.2,1);
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
.toast-success { border-left: 3px solid var(--success); }
.toast-info { border-left: 3px solid var(--info); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-danger { border-left: 3px solid var(--danger); }

/* ========== UI Popover (dropdown) ========== */
.ui-popover {
  position: fixed; z-index: 250;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
  padding: 6px;
  animation: popIn 160ms cubic-bezier(.2,.8,.2,1);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.ui-popover .ui-popover-section { padding: 4px 0; }
.ui-popover .ui-popover-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); padding: 4px 10px; font-weight: 600;
}
.ui-popover .ui-popover-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  background: none; border: 0; width: 100%; text-align: left;
  color: var(--text);
}
.ui-popover .ui-popover-item:hover { background: var(--bg-hover); }
.ui-popover .ui-popover-item[data-active="true"] { background: var(--brand-soft); color: var(--brand); }
.ui-popover .ui-popover-divider { height: 1px; background: var(--border); margin: 4px 0; }
.ui-popover-checkbox {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1.5px solid var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.ui-popover-checkbox[data-checked="true"] {
  background: var(--brand); border-color: var(--brand);
  color: white;
}
.ui-popover-checkbox[data-checked="true"]::after {
  content: "✓"; font-size: 10px; line-height: 1;
}


/* Form field stack */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-muted); font-weight: 500; }
.field > span { font-size: 11.5px; }
.field input, .field select, .field textarea { color: var(--text); font-weight: 400; }
select.input { appearance: none; background: var(--bg-elev); padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

/* ========== Custom Select / DatePicker trigger ========== */
button.select-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  min-height: 32px;
}
button.select-trigger:hover:not(:disabled) { border-color: var(--border-strong); }
button.select-trigger[data-open="true"] {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
button.select-trigger:disabled { opacity: 0.5; cursor: not-allowed; }
button.select-trigger .select-value {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text);
}
button.select-trigger .select-placeholder {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-faint);
}
.select-chevron {
  width: 14px; height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 120ms, transform 160ms;
}
button.select-trigger[data-open="true"] .select-chevron { color: var(--brand); }
.select-check {
  width: 13px; height: 13px;
  color: var(--brand);
  flex-shrink: 0;
}

/* ========== DatePicker panel ========== */
.date-panel {
  padding: 4px;
  user-select: none;
}
.date-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 8px;
}
.date-panel-title {
  font-size: 12.5px; font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
  letter-spacing: -0.01em;
}
.date-nav {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  transition: background 120ms, color 120ms;
}
.date-nav:hover { background: var(--bg-hover); color: var(--text); }
.date-nav svg { width: 14px; height: 14px; }
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.date-dow {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  text-align: center;
  padding: 6px 0 4px;
}
.date-cell {
  background: none; border: 0;
  height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-mono);
  transition: background 100ms, color 100ms;
}
.date-cell:hover { background: var(--bg-hover); }
.date-cell[data-other="true"] { color: var(--text-faint); opacity: 0.55; }
.date-cell[data-today="true"] { box-shadow: inset 0 0 0 1px var(--border-strong); }
.date-cell[data-selected="true"] {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}
.date-cell[data-selected="true"]:hover { background: var(--brand-hover); }
.date-panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--border);
}
.date-foot-btn {
  font-size: 12px;
  color: var(--text-muted);
  background: none; border: 0;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 5px;
  transition: background 100ms, color 100ms;
}
.date-foot-btn:hover { background: var(--bg-hover); color: var(--text); }
.date-foot-btn.brand { color: var(--brand); font-weight: 500; }
.date-foot-btn.brand:hover { background: var(--brand-soft); }

.dot-brand { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); margin-left: 4px; }
.btn.active-pill { border-color: var(--brand); color: var(--brand); }

/* Page tab (top-level Invoices/Clients style) */
.page-tab { background: none; border: 0; padding: 8px 14px; font-size: 13px; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color 120ms, border-color 120ms; }
.page-tab[data-active="true"] { color: var(--text); border-bottom-color: var(--brand); font-weight: 500; }
.page-tab:hover { color: var(--text); }


/* Form sections inside modals */
.form-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.form-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.form-section-title {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-faint);
}
.field-lab { font-size: 12px; font-weight: 500; color: var(--text-muted); display: block; }
.req { color: var(--danger); font-style: normal; font-weight: 600; margin-left: 2px; }
.check-inline {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text-muted); cursor: pointer;
  user-select: none; font-weight: 500;
}
.check-inline input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: var(--brand); cursor: pointer; margin: 0;
}
textarea.input { font-family: inherit; line-height: 1.5; resize: vertical; min-height: 64px; }

/* === Docs (Notion-like pages) ============================================ */
/* The docs workspace ignores the .page padding/max-width and instead anchors
   itself to the visible main area, so the tree and editor each get their
   own scroll container. */
.docs-page {
  padding: 0 !important;
  max-width: none !important;
  margin: 0 !important;
  height: calc(100vh - var(--header-h, 56px));
  display: flex;
  flex-direction: column;
  animation: none;
}
.docs-workspace {
  display: grid;
  grid-template-columns: 280px 1fr;
  flex: 1;
  min-height: 0;
}
.docs-tree {
  border-right: 1px solid var(--border);
  background: var(--bg-sunken);
  display: flex; flex-direction: column;
  min-height: 0;
}
.docs-tree-header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}
.docs-tree-newbtn {
  display: inline-flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
}
.docs-tree-newbtn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.docs-tree-newbtn svg { width: 14px; height: 14px; }
.docs-tree-body {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 6px 6px 16px;
}
.docs-tree-status {
  padding: 12px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.docs-tree-status.err { color: var(--danger, #c0392b); }
.docs-tree-row {
  display: flex; align-items: center;
  gap: 4px;
  padding: 0 6px 0 0;
  height: 28px;
  border-radius: 5px;
  cursor: pointer;
  position: relative;
  user-select: none;
  font-size: 13px;
  line-height: 1;
}
.docs-tree-row:hover { background: var(--bg-hover); }
.docs-tree-row.selected { background: var(--brand-soft); }
.docs-tree-row.selected .docs-tree-title { color: var(--text); font-weight: 500; }
.docs-tree-chevron {
  width: 16px; height: 16px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  transition: transform 120ms ease;
  flex-shrink: 0;
}
.docs-tree-chevron:hover:not(.empty) { background: var(--bg-hover); color: var(--text); }
.docs-tree-chevron.empty { cursor: default; visibility: hidden; }
.docs-tree-chevron.open { transform: rotate(90deg); }
.docs-tree-chevron svg { width: 12px; height: 12px; }
.docs-tree-icon {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.docs-tree-icon svg { width: 14px; height: 14px; }
.docs-tree-emoji { font-size: 14px; line-height: 1; }
.docs-tree-title {
  flex: 1; min-width: 0;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.docs-tree-row .docs-tree-title:empty::before {
  content: attr(data-empty);
  color: var(--text-faint);
}
.docs-tree-actions {
  display: none;
  gap: 2px;
  flex-shrink: 0;
}
.docs-tree-row:hover .docs-tree-actions { display: inline-flex; }
.docs-tree-action {
  width: 22px; height: 22px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.docs-tree-action:hover { background: var(--bg-elev); color: var(--text); }
.docs-tree-action svg { width: 13px; height: 13px; }
.docs-row-menu { position: relative; display: inline-flex; }
.docs-popover {
  position: absolute; top: 24px; right: 0;
  min-width: 180px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 4px;
  z-index: 50;
}
.docs-popover-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none; background: transparent;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}
.docs-popover-item:hover { background: var(--bg-hover); }
.docs-popover-item.danger { color: var(--danger, #c0392b); }
.docs-popover-item.danger:hover { background: rgba(192, 57, 43, 0.08); }
.docs-popover-item svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Editor pane */
.docs-editor-wrap {
  min-height: 0;
  overflow-y: auto;
  position: relative;
}
.docs-editor {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 96px 0;
  position: relative;
  min-height: 100%;
}
.docs-editor-loading,
.docs-trash-status {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}
.docs-editor-status {
  position: absolute;
  top: 12px; right: 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--font-mono, ui-monospace, monospace);
  opacity: 0;
  transition: opacity 200ms ease;
}
.docs-editor-status[data-state="dirty"],
.docs-editor-status[data-state="saving"],
.docs-editor-status[data-state="saved"],
.docs-editor-status[data-state="error"] { opacity: 1; }
.docs-editor-status[data-state="error"] { color: var(--danger, #c0392b); }
.docs-page-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.docs-icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 30px;
}
.docs-icon-btn:hover { background: var(--bg-hover); }
.docs-icon-btn svg { width: 18px; height: 18px; }
.docs-icon-emoji { font-size: 32px; line-height: 1; }
.docs-title-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 36px;
  font-weight: 700;
  color: var(--text);
  font-family: inherit;
  padding: 4px 0;
}
.docs-title-input::placeholder { color: var(--text-faint); }

.docs-blocklist {
  position: relative;
  margin-top: 12px;
  padding-bottom: 200px;
  min-height: 200px;
}
.docs-block {
  position: relative;
  padding: 2px 0;
  display: flex;
  align-items: flex-start;
}
.docs-editable {
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  flex: 1;
  min-width: 0;
  line-height: 1.55;
  font-size: 15px;
  color: var(--text);
  padding: 3px 2px;
  border-radius: 3px;
  min-height: 1.55em;
  cursor: text;
}
.docs-editable:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
  display: inline-block;
}
/* Dim the placeholder on unfocused empty blocks so the focused one stands
   out, but keep it visible — otherwise the editor looks like a dead area. */
.docs-editable:empty:not(:focus)::before { opacity: 0.55; }
.docs-blocklist { cursor: text; }

/* Block-type styles */
.bk-h1 .docs-editable { font-size: 28px; font-weight: 700; line-height: 1.25; padding-top: 14px; }
.bk-h2 .docs-editable { font-size: 22px; font-weight: 600; line-height: 1.3;  padding-top: 12px; }
.bk-h3 .docs-editable { font-size: 18px; font-weight: 600; line-height: 1.35; padding-top: 8px; }
.bk-li { gap: 6px; }
.bk-li .bk-li-marker {
  width: 18px; min-width: 18px;
  display: inline-flex;
  justify-content: flex-end;
  padding-top: 4px;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
}
.bk-li-bullet .bk-li-marker { font-size: 18px; line-height: 1; padding-top: 6px; }
.bk-li .bk-li-text { flex: 1; min-width: 0; display: flex; }
.bk-quote .docs-editable {
  border-left: 3px solid var(--border-strong);
  padding-left: 12px;
  font-style: italic;
  color: var(--text-muted);
}
.bk-code .docs-editable {
  font-family: var(--font-mono, ui-monospace, "JetBrains Mono", monospace);
  font-size: 13px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  white-space: pre-wrap;
  color: var(--text);
}
.bk-divider {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.bk-todo-row { gap: 6px; align-items: flex-start; }
.bk-todo-check {
  margin-top: 8px;
  width: 14px; height: 14px;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}
.bk-todo-text { flex: 1; min-width: 0; display: flex; }
.bk-todo-text.checked .docs-editable {
  color: var(--text-muted);
  text-decoration: line-through;
}

/* Emoji picker popover */
.docs-emoji-picker { padding: 8px; }
.docs-emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
}
.docs-emoji-cell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  aspect-ratio: 1 / 1;
  font-size: 18px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
}
.docs-emoji-cell:hover { background: var(--bg-hover); }
.docs-emoji-cell.active { background: var(--brand-soft); }
.docs-emoji-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.docs-emoji-custom { flex: 1; min-width: 0; font-size: 14px; padding: 6px 8px; }
.docs-emoji-foot .btn { font-size: 12px; padding: 4px 10px; }

/* Slash menu */
.docs-slashmenu {
  position: absolute;
  z-index: 60;
  min-width: 240px;
  max-height: 280px; overflow-y: auto;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.16);
  padding: 4px;
}
.docs-slash-item {
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.docs-slash-item:hover,
.docs-slash-item.active { background: var(--brand-soft); }
.docs-slash-title { font-size: 13px; color: var(--text); font-weight: 500; }
.docs-slash-desc  { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

/* Trash view */
.docs-trash-list {
  max-width: 760px;
  margin: 12px auto 0;
  padding: 0 24px;
  display: flex; flex-direction: column;
  gap: 6px;
}
.docs-trash-row {
  display: flex; align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
}
.docs-trash-title {
  flex: 1; min-width: 0;
  font-size: 14px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.docs-trash-actions { display: flex; gap: 6px; flex-shrink: 0; }
.docs-trash-actions .btn.danger { color: var(--danger, #c0392b); }
.docs-trash-actions .btn svg { width: 13px; height: 13px; }

/* Empty state */
.docs-empty {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 60px 40px;
  color: var(--text-muted);
}
.docs-empty .empty-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--bg-sunken);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted);
}
.docs-empty .empty-icon svg { width: 24px; height: 24px; }
.docs-empty h3 { margin: 4px 0 0; font-size: 16px; color: var(--text); }
.docs-empty p { margin: 0 0 8px; font-size: 13px; }

/* Narrow viewports: collapse the tree under the editor. */
@media (max-width: 900px) {
  .docs-workspace { grid-template-columns: 1fr; }
  .docs-tree { display: none; }
  .docs-editor { padding: 32px 20px 160px; }
}

/* === AI assistant chat panel ============================================== */
/* The header trigger: keeps the search-trigger silhouette but signals AI
   intent with a Sparkles icon and brand accent on hover. */
.search-trigger.ai-trigger:hover {
  border-color: var(--brand-border);
  background: var(--brand-soft);
  color: var(--text);
}
.search-trigger.ai-trigger svg { color: var(--brand); }

.ai-panel-wrap {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}
.ai-panel-backdrop {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  animation: aiBackdropIn 160ms ease-out forwards;
}
[data-theme="dark"] .ai-panel-backdrop { background: rgba(0, 0, 0, 0.45); }
@keyframes aiBackdropIn { from { opacity: 0; } to { opacity: 1; } }

.ai-panel {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 96px));
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  animation: aiPanelIn 200ms cubic-bezier(0.2, 0, 0, 1);
}
[data-theme="dark"] .ai-panel { box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6); }
@keyframes aiPanelIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.ai-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.ai-panel-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--text);
}
.ai-panel-title svg { width: 16px; height: 16px; color: var(--brand); }
.ai-panel-actions { display: inline-flex; gap: 4px; }
.ai-icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 6px;
  color: var(--text-muted); cursor: pointer;
  padding: 0;
}
.ai-icon-btn:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.ai-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-icon-btn svg { width: 14px; height: 14px; }

.ai-panel-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-empty {
  margin: auto 0;
  padding: 32px 24px;
  text-align: center;
  color: var(--text-muted);
}
.ai-empty svg {
  width: 28px; height: 28px;
  color: var(--brand);
  margin-bottom: 8px;
}
.ai-empty h4 { margin: 0 0 12px; font-size: 14px; color: var(--text); font-weight: 500; }
.ai-empty ul {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12.5px;
}
.ai-empty li {
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 6px;
  background: var(--bg-sunken);
}

.ai-msg {
  display: flex; flex-direction: column;
  gap: 8px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  max-width: 92%;
}
.ai-msg-user {
  align-self: flex-end;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  padding: 8px 12px;
  border-radius: 12px 12px 2px 12px;
}
.ai-msg-assistant { align-self: flex-start; }
.ai-msg-p { margin: 0; }
.ai-msg-p + .ai-msg-p { margin-top: 8px; }
.ai-link {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ai-link:hover { opacity: 0.85; }
.ai-code {
  font-family: var(--font-mono, ui-monospace, "JetBrains Mono", monospace);
  font-size: 12.5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.ai-typing { color: var(--text-faint); font-size: 16px; letter-spacing: 2px; }

.ai-tool-chip {
  display: inline-flex;
  flex-direction: column;
  align-self: flex-start;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 8px;
  font-size: 12.5px;
  max-width: 100%;
  overflow: hidden;
}
.ai-tool-summary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--text);
  font-family: inherit; font-size: 12.5px;
  text-align: left;
}
.ai-tool-summary:hover { background: var(--bg-hover); }
.ai-tool-summary svg { width: 12px; height: 12px; color: var(--text-muted); }
.ai-tool-name {
  font-family: var(--font-mono, ui-monospace, "JetBrains Mono", monospace);
  color: var(--text);
}
.ai-tool-status {
  margin-left: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.ai-tool-running .ai-tool-status { color: var(--brand); }
.ai-tool-error  .ai-tool-status { color: var(--danger, #c0392b); }
.ai-tool-error  { border-color: rgba(192, 57, 43, 0.4); }
.ai-tool-detail {
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono, ui-monospace, "JetBrains Mono", monospace);
  font-size: 11.5px;
  color: var(--text-muted);
  background: var(--bg);
  white-space: pre-wrap;
  max-height: 220px;
  overflow-y: auto;
}

.ai-error {
  align-self: flex-start;
  padding: 8px 12px;
  border: 1px solid rgba(192, 57, 43, 0.4);
  background: rgba(192, 57, 43, 0.06);
  color: var(--danger, #c0392b);
  border-radius: 8px;
  font-size: 12.5px;
}

.ai-panel-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  align-items: flex-end;
}
.ai-input {
  flex: 1;
  min-height: 38px;
  max-height: 160px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  resize: none;
}
.ai-input:focus { border-color: var(--brand-border); }
.ai-input:disabled { opacity: 0.5; }
.ai-send-btn {
  width: 38px; height: 38px;
  border: none;
  background: var(--brand);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  padding: 0;
}
.ai-send-btn:hover:not(:disabled) { background: var(--brand-hover); }
.ai-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ai-send-btn svg { width: 16px; height: 16px; }

@media (max-width: 700px) {
  .ai-panel {
    top: 8px;
    left: 8px; right: 8px;
    width: auto;
    transform: none;
    height: calc(100vh - 16px);
  }
  @keyframes aiPanelIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

