/* ========================================================================
   Hwadi · مركز التحصيل — Command Center
   Single-page Hybrid layout · 2026-04-29 rebuild
   ======================================================================== */

/* ─── DESIGN TOKENS ────────────────────────────────────────────────────── */
:root {
  /* surfaces */
  --bg: #fafaf7;
  --surface: #ffffff;
  --surface-2: #f4f4ee;
  --ink: #0a0a0a;
  --ink-2: #404040;
  --ink-3: #737373;
  --border: #e5e5e5;
  --border-2: #d4d4d4;

  /* brand (warm Hwadi-inspired) */
  --brand: #0a0a0a;
  --brand-fg: #fafaf7;
  --accent: #c2410c;       /* warm rust — sparingly */
  --accent-soft: #fed7aa;

  /* semantic */
  --hot: #dc2626;
  --hot-soft: #fee2e2;
  --warn: #f59e0b;
  --warn-soft: #fef3c7;
  --soft: #fbbf24;
  --soft-bg: #fffbeb;
  --fresh: #2563eb;
  --fresh-soft: #dbeafe;
  --paid: #16a34a;
  --paid-soft: #dcfce7;
  --legal: #6b7280;
  --legal-soft: #f3f4f6;

  /* day stages */
  --day1: #2563eb;  /* فتح */
  --day2: #0891b2;  /* متابعة */
  --day3: #f59e0b;  /* تصعيد خفيف */
  --day4: #ea580c;  /* إشعار نهائي */
  --day5: #dc2626;  /* قانوني */
  --paid-col: #16a34a;
  --closed-col: #6b7280;

  /* type */
  --font-body: "Tajawal", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Courier New", monospace;
  --lh-ar: 1.7;
  --lh-en: 1.5;

  /* spacing 4px scale */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 24px; --s6: 32px; --s7: 48px; --s8: 64px;

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

  /* shadows */
  --sh-sm: 0 1px 2px rgb(0 0 0 / 0.05);
  --sh-md: 0 4px 8px rgb(0 0 0 / 0.06);
  --sh-lg: 0 8px 24px rgb(0 0 0 / 0.08);

  /* layout */
  --topbar-h: 60px;
  --sidebar-w: 240px;
  --container: 1440px;
  --gutter: 16px;

  /* motion */
  --ease: cubic-bezier(.2,.8,.2,1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #18181b;
  --surface-2: #27272a;
  --ink: #fafafa;
  --ink-2: #d4d4d8;
  --ink-3: #a1a1aa;
  --border: #2a2a2a;
  --border-2: #3f3f46;
  --brand: #fafafa;
  --brand-fg: #0a0a0a;
  --accent: #fb923c;
  --accent-soft: rgba(251, 146, 60, 0.15);
  --hot-soft: rgba(220, 38, 38, 0.18);
  --warn-soft: rgba(245, 158, 11, 0.18);
  --soft-bg: rgba(251, 191, 36, 0.12);
  --fresh-soft: rgba(37, 99, 235, 0.18);
  --paid-soft: rgba(22, 163, 74, 0.18);
  --legal-soft: rgba(107, 114, 128, 0.18);
  --sh-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --sh-md: 0 4px 8px rgb(0 0 0 / 0.5);
  --sh-lg: 0 8px 24px rgb(0 0 0 / 0.6);
}

/* ─── RESET ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: var(--lh-ar);
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "kern", "ss01";
  text-rendering: optimizeLegibility;
  transition: background var(--dur-base) var(--ease), color var(--dur-base) var(--ease);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 700; }
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }

::selection { background: var(--ink); color: var(--bg); }

/* ─── ICONS ────────────────────────────────────────────────────────────── */
.ico { width: 18px; height: 18px; flex: none; }
.ico-flip { transform: scaleX(-1); }   /* RTL arrow */

/* ─── BUTTONS ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  transition: all var(--dur-fast) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--ink); color: var(--bg);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-secondary {
  background: var(--surface); color: var(--ink);
  border-color: var(--border-2);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  background: transparent; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-link {
  background: transparent; color: var(--ink-2);
  padding: var(--s2);
}
.btn-link:hover { color: var(--ink); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.icon-btn {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
  background: var(--hot); color: #fff; border-color: var(--hot);
}
.btn-success {
  background: var(--paid); color: #fff; border-color: var(--paid);
}

/* theme icon swap */
[data-theme="light"] .ico-moon { display: none; }
[data-theme="dark"]  .ico-sun  { display: none; }

/* ─── TOPBAR ───────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s4);
  padding: 0 var(--s5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(1.4);
}
.topbar-left { display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: var(--s3); }
.brand-mark {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ink); color: var(--bg);
  border-radius: var(--r-md);
  font-family: "Inter", var(--font-body);
  font-weight: 900;
  font-size: 18px;
}
.brand-name { font-weight: 900; font-size: 16px; letter-spacing: -0.01em; }

.topbar-search {
  position: relative;
  display: flex; align-items: center;
  max-width: 480px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 var(--s3);
  transition: border-color var(--dur-fast) var(--ease);
}
.topbar-search:focus-within { border-color: var(--ink); background: var(--surface); }
.topbar-search .ico { color: var(--ink-3); margin-inline-end: var(--s2); }
.topbar-search input {
  flex: 1;
  height: 38px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 14px;
}
.kbd-hint {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 7px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  color: var(--ink-3);
}

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

/* ─── LAYOUT ───────────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--topbar-h));
  transition: grid-template-columns 0.2s ease;
}

/* Sidebar collapsed (toggled via header button) — persistent across pages */
body.sidebar-hidden .app-layout { grid-template-columns: 1fr !important; }
body.sidebar-hidden .sidebar { display: none !important; }

/* Excel-like Sheet view: full width, sticky header, sticky first col, tighter rows */
#sheet .widget-body { padding: 0 !important; overflow: auto; }
.sheet-table {
  border-collapse: separate; border-spacing: 0;
  font-family: var(--font-mono, 'IBM Plex Mono', Consolas, monospace);
  font-size: 12.5px;
  width: 100%;
}
.sheet-table thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  border-bottom: 2px solid var(--border);
  border-inline-end: 1px solid var(--border-soft, var(--border));
  padding: 8px 10px;
  font-weight: 600;
  z-index: 5;
  white-space: nowrap;
}
.sheet-table tbody td {
  border-bottom: 1px solid var(--border-soft, var(--border));
  border-inline-end: 1px solid var(--border-soft, var(--border));
  padding: 6px 10px;
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  max-width: 320px;
}
.sheet-table tbody tr:nth-child(even) { background: rgba(0,0,0,0.018); }
.sheet-table tbody tr:hover { background: var(--surface-2); }
.sheet-table .col-name {
  position: sticky; right: 0; /* RTL: pin to right */
  background: var(--surface);
  z-index: 4;
  font-family: var(--font-sans, system-ui);
  font-weight: 500;
}
.sheet-table thead .col-name { background: var(--surface-2); z-index: 6; }

/* Date cell with auto-aging badge */
.date-cell { display: flex; flex-direction: column; gap: 1px; line-height: 1.2; }
.date-val { font-family: var(--font-mono, monospace); font-size: 12px; }
.date-aging { font-size: 10px; font-weight: 600; padding: 1px 5px; border-radius: 3px; align-self: flex-start; }
.date-aging-ok       { background: #e6f7ee; color: #0a7a3f; }
.date-aging-warn     { background: #fff5e0; color: #b07000; }
.date-aging-bad      { background: #ffe9e9; color: #b03030; }
.date-aging-critical { background: #d10000; color: #fff; }

/* Mobile responsive — auto-hide sidebar below 768px */
@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr !important; }
  .sidebar { display: none !important; }
  body.sidebar-mobile-open .sidebar {
    display: flex !important;
    position: fixed; top: var(--topbar-h); right: 0;
    width: 280px; height: calc(100vh - var(--topbar-h));
    z-index: 100; box-shadow: -4px 0 16px rgba(0,0,0,0.1);
  }
  .topbar { padding: 0 8px; }
  .topbar-search { display: none; }
  .topbar .brand-name { font-size: 14px; }
  .sheet-table { font-size: 11px; }
  .sheet-table thead th, .sheet-table tbody td { padding: 4px 6px; }
  .sheet-table .col-name { max-width: 130px; }
}

/* Dark mode — finish styling for cards/widgets */
@media (prefers-color-scheme: dark), (data-theme: dark) {
  body.theme-dark .widget,
  body.theme-dark .card,
  body.theme-dark .fm-section,
  body.theme-dark .sheet-table tbody td,
  body.theme-dark .sheet-table .col-name,
  body.theme-dark .alert-banner {
    background: var(--surface) !important;
    color: var(--ink) !important;
  }
  body.theme-dark .sheet-table thead th { background: var(--surface-2) !important; }
  body.theme-dark .alert-banner { background: #3d2a0a !important; color: #ffd9a0 !important; }
}
body.theme-dark .widget,
body.theme-dark .card,
body.theme-dark .sheet-table thead th,
body.theme-dark .sheet-table .col-name {
  background: var(--surface);
  color: var(--ink);
}
body.theme-dark .alert-banner { background: #3d2a0a; color: #ffd9a0; border-color: #6e4f1a; }

/* Unified notes column (combines poc + sattamRemark + notes) */
.all-notes { display: flex; flex-direction: column; gap: 3px; }
.note-tag {
  display: block; padding: 2px 8px; border-radius: 4px;
  font-size: 11.5px; line-height: 1.35;
  white-space: normal; word-break: break-word;
  border-inline-start: 3px solid transparent;
}
.note-tag-poc    { background: #eef6ff; color: #1a3d6b; border-inline-start-color: #4a90e2; }
.note-tag-saeed  { background: #fff7e6; color: #8a4a00; border-inline-start-color: #d97800; }
.note-tag-other  { background: #f5f5f5; color: #555; border-inline-start-color: #888; }
.sheet-table tbody td:has(.all-notes) { white-space: normal; max-width: 320px; vertical-align: top; padding: 6px 8px; }

/* ─── SIDEBAR ──────────────────────────────────────────────────────────── */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  padding: var(--s4) var(--s3);
  display: flex; flex-direction: column;
  gap: var(--s5);
}
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  transition: all var(--dur-fast) var(--ease);
}
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.is-active {
  background: var(--ink);
  color: var(--bg);
}
.side-section { display: flex; flex-direction: column; gap: var(--s2); }
.side-title {
  display: flex; align-items: center; gap: var(--s2);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  padding: 0 var(--s3);
}
.side-title .ico { width: 14px; height: 14px; }

.side-filters { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 var(--s2); }
.filter-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid transparent;
  color: var(--ink-2);
  transition: all var(--dur-fast) var(--ease);
}
.filter-chip:hover { background: var(--border); color: var(--ink); }
.filter-chip.is-active {
  background: var(--ink); color: var(--bg);
}
.filter-chip-count {
  display: inline-block;
  margin-inline-start: 4px;
  padding: 0 5px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255,255,255,0.18);
}
.filter-chip:not(.is-active) .filter-chip-count {
  background: rgba(0,0,0,0.06);
}
[data-theme="dark"] .filter-chip:not(.is-active) .filter-chip-count {
  background: rgba(255,255,255,0.08);
}

.side-section--excel, .side-section--graph {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--s3);
  border: 1px solid var(--border);
}
.excel-zone, .graph-zone { display: flex; flex-direction: column; gap: var(--s2); }
.excel-row { display: flex; justify-content: space-between; font-size: 12px; }
.excel-label { color: var(--ink-3); }
.excel-value { font-family: var(--font-mono); }
.excel-status, .graph-status {
  font-size: 12px;
  padding: 2px 8px;
  background: var(--surface);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  align-self: flex-start;
}
.excel-status.is-ok, .graph-status.is-ok {
  background: var(--paid-soft); color: var(--paid);
}
.excel-actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.excel-actions .btn { flex: 1; justify-content: center; }

.side-foot { margin-top: auto; padding-top: var(--s3); border-top: 1px solid var(--border); }
.side-foot .btn { width: 100%; justify-content: flex-start; }

/* ─── MAIN ─────────────────────────────────────────────────────────────── */
.main {
  padding: var(--s5);
  display: flex; flex-direction: column; gap: var(--s5);
  max-width: var(--container);
  width: 100%;
  margin: 0 auto;
}

/* ─── HERO TODAY ───────────────────────────────────────────────────────── */
.hero {
  position: relative;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s4);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--hot);
}
.hero[data-priority="warn"]::before { background: var(--warn); }
.hero[data-priority="fresh"]::before { background: var(--fresh); }

.hero-spine {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); flex-wrap: wrap;
}
.hero-flag {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--hot-soft);
  color: var(--hot);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.hero-counter {
  font-size: 13px;
  color: var(--ink-3);
  font-family: var(--font-mono);
}

.hero-body { display: grid; gap: var(--s4); }
.hero-customer-name {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.hero-meta {
  display: flex; flex-wrap: wrap; gap: var(--s4);
  color: var(--ink-3);
  font-size: 13px;
}
.hero-meta-item { display: inline-flex; align-items: center; gap: var(--s1); }
.hero-meta-item .ico { width: 14px; height: 14px; }
.hero-amount {
  font-family: var(--font-mono);
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
}
.hero-amount-sub { font-size: 14px; color: var(--ink-3); margin-inline-start: var(--s2); }

.hero-actions {
  display: flex; flex-wrap: wrap; gap: var(--s2);
}
.hero-actions .btn { padding: 12px 18px; font-size: 15px; }
.hero-actions .btn .ico { width: 20px; height: 20px; }

.hero-actions .btn-call {
  background: var(--paid); color: #fff; border-color: var(--paid);
}
.hero-actions .btn-call:hover { filter: brightness(0.95); }
.hero-actions .btn-mail {
  background: var(--fresh); color: #fff; border-color: var(--fresh);
}
.hero-actions .btn-log {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.hero-actions .btn-missing {
  background: var(--surface);
  color: var(--ink-3);
  border: 1px dashed var(--border-2);
}
.hero-actions .btn-missing:hover {
  border-color: var(--ink-2);
  color: var(--ink-2);
}

.hero-footer { display: flex; justify-content: flex-end; }

.hero-empty {
  padding: var(--s7) 0;
  text-align: center;
  color: var(--ink-3);
}
.hero-done {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s5) 0;
  color: var(--paid);
}
.hero-done .ico { width: 32px; height: 32px; }
.hero-done-text strong { display: block; font-size: 18px; color: var(--ink); }
.hero-done-text span { font-size: 13px; color: var(--ink-3); }

/* ─── KPI STRIP ────────────────────────────────────────────────────────── */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter);
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s4) var(--s5);
  display: flex; flex-direction: column;
  gap: var(--s2);
  transition: all var(--dur-base) var(--ease);
}
.kpi-card:hover {
  border-color: var(--border-2);
  box-shadow: var(--sh-md);
}
.kpi-head {
  display: flex; align-items: center; gap: var(--s2);
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
}
.kpi-head .ico { width: 16px; height: 16px; }
.kpi-value {
  font-size: 40px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.kpi-card[data-kpi="overdue"] .kpi-value { color: var(--hot); }
.kpi-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2);
  margin-top: var(--s1);
  min-height: 24px;
}
.kpi-spark { width: 60px; height: 24px; }
.kpi-spark path { fill: none; stroke: var(--ink-3); stroke-width: 1.5; }
.kpi-card[data-kpi="overdue"] .kpi-spark path { stroke: var(--hot); }
.kpi-trend { font-size: 12px; color: var(--ink-3); font-family: var(--font-mono); }
.kpi-trend.up { color: var(--paid); }
.kpi-trend.down { color: var(--hot); }
.kpi-sub { font-size: 12px; color: var(--ink-3); }

/* ─── GRID ─────────────────────────────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gutter);
}
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
  transition: border-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.widget:hover { border-color: var(--border-2); }
.widget[data-w="4"]  { grid-column: span 4; }
.widget[data-w="6"]  { grid-column: span 6; }
.widget[data-w="8"]  { grid-column: span 8; }
.widget[data-w="12"] { grid-column: span 12; }
.widget[data-h="2"]  { min-height: 460px; }
.widget[data-h="1"]  { min-height: 280px; }

.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--border);
}
.widget-title {
  display: flex; align-items: center; gap: var(--s2);
  flex: 1; min-width: 0;
}
.widget-title h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.widget-title .drag-handle {
  color: var(--ink-3);
  cursor: grab;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
body.is-edit-mode .widget-title .drag-handle { opacity: 1; }
.widget-title .drag-handle:active { cursor: grabbing; }

.widget-hide {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  color: var(--ink-3);
  display: none;
  align-items: center; justify-content: center;
}
body.is-edit-mode .widget-hide { display: inline-flex; }
.widget-hide:hover { background: var(--hot-soft); color: var(--hot); }

.badge {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge-soft { background: var(--warn-soft); color: var(--warn); }
.badge-hot { background: var(--hot-soft); color: var(--hot); }
.badge-paid { background: var(--paid-soft); color: var(--paid); }

.widget-body {
  padding: var(--s3) var(--s4);
  flex: 1;
  overflow: auto;
  min-height: 0;
}
.widget[data-h="2"] .widget-body { max-height: 420px; }

/* drag/resize edit mode */
body.is-edit-mode .widget {
  outline: 2px dashed var(--border-2);
  outline-offset: -2px;
}
body.is-edit-mode .widget.is-dragging {
  opacity: 0.7;
  outline-color: var(--ink);
  cursor: grabbing;
}
body.is-edit-mode .widget.drag-target-before {
  outline-color: var(--paid);
}

.widget-resize {
  position: absolute;
  inset-inline-end: 4px; bottom: 4px;
  width: 14px; height: 14px;
  border-inline-end: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  border-bottom-right-radius: 4px;
  cursor: nwse-resize;
  display: none;
}
[dir="rtl"] .widget-resize {
  cursor: nesw-resize;
  border-inline-end: 0;
  border-inline-start: 2px solid var(--ink-3);
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 0;
  inset-inline-end: auto;
  inset-inline-start: 4px;
}
body.is-edit-mode .widget-resize { display: block; }

/* ─── WORKLIST ─────────────────────────────────────────────────────────── */
.worklist-list { display: flex; flex-direction: column; gap: var(--s2); }
.worklist-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--dur-fast) var(--ease);
  cursor: pointer;
}
.worklist-row:hover {
  border-color: var(--ink-3);
  background: var(--surface-2);
}
.priority-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--fresh);
  flex: none;
}
.priority-dot.hot   { background: var(--hot);  box-shadow: 0 0 0 3px var(--hot-soft); }
.priority-dot.warn  { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.priority-dot.soft  { background: var(--soft); }
.priority-dot.fresh { background: var(--fresh); }

.worklist-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.worklist-name {
  font-size: 14px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.worklist-meta {
  display: flex; gap: var(--s3);
  font-size: 12px; color: var(--ink-3);
}
.worklist-meta strong { font-family: var(--font-mono); color: var(--ink); font-weight: 700; }

.worklist-actions { display: flex; gap: 4px; }
.qa-btn {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease);
}
.qa-btn:hover { background: var(--ink); color: var(--bg); }
.qa-btn.qa-call:hover { background: var(--paid); }
.qa-btn.qa-mail:hover { background: var(--fresh); }
.qa-btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.qa-btn.is-disabled:hover { background: var(--surface-2); color: var(--ink-2); }

/* ─── KANBAN ───────────────────────────────────────────────────────────── */
.kanban-body {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--s2);
  padding: var(--s3);
  height: 380px;
}
.kan-col {
  display: flex; flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.kan-col:hover { border-color: var(--ink-3); }
.kan-col.is-filtered {
  border-color: var(--ink);
  box-shadow: var(--sh-md);
}
.kan-col-head {
  padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-inline-start: 4px solid var(--day1);
}
.kan-col[data-stage="day1"] .kan-col-head { border-inline-start-color: var(--day1); }
.kan-col[data-stage="day2"] .kan-col-head { border-inline-start-color: var(--day2); }
.kan-col[data-stage="day3"] .kan-col-head { border-inline-start-color: var(--day3); }
.kan-col[data-stage="day4"] .kan-col-head { border-inline-start-color: var(--day4); }
.kan-col[data-stage="day5"] .kan-col-head { border-inline-start-color: var(--day5); }
.kan-col[data-stage="paid"] .kan-col-head { border-inline-start-color: var(--paid-col); }
.kan-col[data-stage="closed"] .kan-col-head { border-inline-start-color: var(--closed-col); }

.kan-col-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kan-col-stat {
  display: flex; justify-content: space-between;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.kan-col-count {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.kan-col-amount { font-size: 11px; }
.kan-col-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s2);
  display: flex; flex-direction: column;
  gap: 4px;
}
.kan-card {
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.kan-card:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.kan-card-name {
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kan-card-amount {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.kan-col-empty {
  padding: var(--s3);
  font-size: 11px;
  color: var(--ink-3);
  text-align: center;
}

/* ─── TEAM PANEL ───────────────────────────────────────────────────────── */
.team-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--gutter);
}
.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s4);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s3);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
}
.team-card:hover { border-color: var(--ink-3); transform: translateY(-2px); box-shadow: var(--sh-md); }
.team-card.is-filtered { border-color: var(--ink); box-shadow: var(--sh-md); }

.team-card.is-empty {
  background: var(--surface-2);
  border-style: dashed;
}

.team-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 900;
  font-size: 16px;
  flex: none;
}
.team-card[data-id="qaboos"] .team-avatar { background: #2563eb; color: #fff; }
.team-card[data-id="said"] .team-avatar { background: #c2410c; color: #fff; }
.team-card[data-id="abdullah"] .team-avatar { background: #16a34a; color: #fff; }
.team-card[data-id="sattam"] .team-avatar { background: var(--ink-3); color: #fff; }

.team-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team-name {
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; gap: var(--s2);
}
.team-role {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 1px 6px;
  background: var(--surface-2);
  border-radius: 4px;
}
.team-card[data-id="qaboos"] .team-role { background: var(--fresh-soft); color: var(--fresh); }
.team-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
  margin-top: var(--s2);
  padding-top: var(--s2);
  border-top: 1px solid var(--border);
}
.team-stat { display: flex; flex-direction: column; gap: 2px; }
.team-stat-label { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; }
.team-stat-value { font-family: var(--font-mono); font-size: 16px; font-weight: 700; }
.team-stat-value.amt { font-size: 13px; }

.team-empty-cta {
  margin-top: var(--s2);
  padding: var(--s2);
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  border: 1px dashed var(--border-2);
  border-radius: var(--r-sm);
}

/* ─── CASH FLOW ────────────────────────────────────────────────────────── */
.cash-total {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--s2);
}
.cash-total-label {
  display: block;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.cash-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  height: 100px;
  align-items: end;
  margin-top: var(--s3);
}
.cash-bar {
  position: relative;
  background: var(--fresh-soft);
  border-radius: 4px 4px 0 0;
  min-height: 6px;
  border-bottom: 2px solid var(--fresh);
  cursor: pointer;
  transition: filter var(--dur-fast) var(--ease);
}
.cash-bar:hover { filter: brightness(0.9); }
.cash-bar.is-empty { background: var(--surface-2); border-bottom-color: var(--border-2); }
.cash-bar-tip {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--ink);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}
.cash-bar:hover .cash-bar-tip { opacity: 1; }
.cash-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 4px;
  font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  font-family: var(--font-mono);
}

/* ─── AGING ────────────────────────────────────────────────────────────── */
.aging-list { display: flex; flex-direction: column; gap: var(--s3); }
.aging-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  align-items: center;
  gap: var(--s3);
  cursor: pointer;
}
.aging-label { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.aging-bar-wrap {
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}
.aging-bar {
  height: 100%;
  background: var(--fresh);
  transition: width var(--dur-base) var(--ease);
}
.aging-row[data-bucket="0-7"] .aging-bar    { background: var(--fresh); }
.aging-row[data-bucket="8-14"] .aging-bar   { background: var(--soft); }
.aging-row[data-bucket="15-30"] .aging-bar  { background: var(--warn); }
.aging-row[data-bucket="31-60"] .aging-bar  { background: var(--accent); }
.aging-row[data-bucket="60+"] .aging-bar    { background: var(--hot); }
.aging-num {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  text-align: end;
  min-width: 70px;
}
.aging-row:hover .aging-bar { filter: brightness(0.92); }

/* ─── ACTIVITY ─────────────────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: var(--s2); }
.activity-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s2);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.activity-row:last-child { border-bottom: 0; }
.activity-icon {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center;
  flex: none;
}
.activity-icon .ico { width: 12px; height: 12px; }
.activity-row[data-type="call"] .activity-icon       { background: var(--paid-soft); color: var(--paid); }
.activity-row[data-type="email"] .activity-icon      { background: var(--fresh-soft); color: var(--fresh); }
.activity-row[data-type="payment_received"] .activity-icon { background: var(--paid-soft); color: var(--paid); }
.activity-row[data-type="escalation"] .activity-icon { background: var(--warn-soft); color: var(--warn); }
.activity-row[data-type="legal_handoff"] .activity-icon { background: var(--legal-soft); color: var(--legal); }
.activity-row[data-type="imported"] .activity-icon   { background: var(--surface-2); color: var(--ink-3); }

.activity-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.activity-text { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-time { color: var(--ink-3); font-size: 11px; font-family: var(--font-mono); }

/* empty / loading states */
.empty-state {
  padding: var(--s5);
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty-state .ico {
  width: 36px; height: 36px;
  margin: 0 auto var(--s2);
  color: var(--ink-3);
  opacity: 0.5;
}

/* ─── SHEET WIDGET (Excel-like editable table) ─────────────────────────── */
.widget-sheet[data-h="2"] { min-height: 540px; }
.widget-sheet .widget-head .sheet-toolbar {
  display: flex; align-items: center; gap: var(--s2);
}
.widget-sheet .widget-body { padding: 0; max-height: 520px; }
.widget-sheet.is-tall .widget-body { max-height: 800px; }

.sheet-body {
  overflow: auto;
  position: relative;
}
.sheet-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  background: var(--surface);
}
.sheet-table thead th {
  position: sticky; top: 0;
  z-index: 5;
  background: var(--surface-2);
  text-align: start;
  padding: var(--s2) var(--s3);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-2);
  border-inline-end: 1px solid var(--border);
}
.sheet-table thead th:last-child { border-inline-end: 0; }
.sheet-table tbody td {
  padding: 0;
  border-bottom: 1px solid var(--border);
  border-inline-end: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
  background: var(--surface);
}
.sheet-table tbody td:last-child { border-inline-end: 0; }
.sheet-table tbody tr:hover td { background: var(--surface-2); }

/* sticky first column (customer name) */
.sheet-table .col-name {
  position: sticky;
  inset-inline-start: 0;
  z-index: 4;
  background: var(--surface);
  min-width: 220px;
  max-width: 280px;
  border-inline-end: 2px solid var(--border-2) !important;
}
.sheet-table thead .col-name {
  z-index: 6;
  background: var(--surface-2);
}
.sheet-table tbody tr:hover .col-name { background: var(--surface-2); }

.sheet-cell {
  display: block;
  padding: 8px 12px;
  min-height: 36px;
  cursor: cell;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
  outline: none;
  border: 2px solid transparent;
  border-radius: 0;
  transition: border-color var(--dur-fast) var(--ease);
}

/* MODERN customer-name column — full name in a card-style box, wraps to 2 lines */
.sheet-table .col-customerName,
.sheet-table .col-name {
  min-width: 280px;
  max-width: 380px;
}
.sheet-table .col-customerName .sheet-cell,
.sheet-table .col-name .sheet-cell {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
  padding: 10px 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.35;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(180deg, var(--surface) 0%, var(--soft-bg) 100%);
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: all var(--dur-fast) var(--ease);
}
.sheet-table .col-customerName .sheet-cell:hover,
.sheet-table .col-name .sheet-cell:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  background: var(--surface);
  transform: translateY(-1px);
}
[data-theme="dark"] .sheet-table .col-customerName .sheet-cell,
[data-theme="dark"] .sheet-table .col-name .sheet-cell {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
}
.sheet-cell.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; text-align: end; }
.sheet-cell.is-readonly { color: var(--ink-3); cursor: default; }
.sheet-cell:hover:not(.is-readonly):not(.is-editing) {
  background: var(--soft-bg);
}
.sheet-cell.is-editing {
  padding: 0;
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: var(--sh-md);
}
.sheet-cell.is-focused:not(.is-editing) {
  border-color: var(--fresh);
}
.sheet-cell.is-saving {
  background: var(--paid-soft);
}
.sheet-cell input,
.sheet-cell select,
.sheet-cell textarea {
  width: 100%;
  height: 36px;
  padding: 8px 12px;
  border: 0;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
}
.sheet-cell.mono input { font-family: var(--font-mono); text-align: end; }
.sheet-cell select { padding-inline-start: 8px; }

.sheet-empty {
  padding: var(--s7);
  text-align: center;
  color: var(--ink-3);
}

/* status pill inside cell */
.sheet-pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: var(--fresh-soft);
  color: var(--fresh);
}
.sheet-pill[data-v="legal"] { background: var(--legal-soft); color: var(--legal); }
.sheet-pill[data-v="paid"]  { background: var(--paid-soft); color: var(--paid); }
.sheet-pill[data-v="closed"]{ background: var(--surface-2); color: var(--ink-3); }

.sheet-row-actions {
  display: flex; gap: 2px;
  padding: 4px 8px;
}
.sheet-row-actions .qa-btn {
  width: 26px; height: 26px;
}

/* density modes */
.sheet-table.is-compact tbody td { font-size: 12px; }
.sheet-table.is-compact .sheet-cell { padding: 4px 10px; min-height: 28px; }
.sheet-table.is-compact .sheet-cell input,
.sheet-table.is-compact .sheet-cell select { height: 28px; padding: 4px 10px; }
.sheet-table.is-compact thead th { padding: 4px 10px; }

/* ─── HIDDEN TRAY ──────────────────────────────────────────────────────── */
.hidden-tray {
  position: sticky;
  bottom: var(--s3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s2) var(--s3);
  display: flex; align-items: center; gap: var(--s2);
  flex-wrap: wrap;
  box-shadow: var(--sh-md);
}
.hidden-tray-label {
  font-size: 12px;
  color: var(--ink-3);
}
.hidden-tray-chips { display: flex; gap: var(--s1); flex-wrap: wrap; }
.tray-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12px;
  border: 1px solid var(--border);
}
.tray-chip:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ─── PRESETS BAR ──────────────────────────────────────────────────────── */
.presets-bar {
  position: fixed;
  bottom: var(--s4);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-lg);
  padding: var(--s2) var(--s3);
  box-shadow: var(--sh-lg);
}
.presets-bar-inner {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
}
.presets-label { font-size: 12px; color: rgba(255,255,255,0.7); }
.presets-divider { width: 1px; height: 20px; background: rgba(255,255,255,0.2); }
.presets-bar .btn-secondary {
  background: rgba(255,255,255,0.12);
  color: var(--bg);
  border-color: rgba(255,255,255,0.18);
}
.presets-bar .btn-secondary:hover {
  background: rgba(255,255,255,0.2);
}
.presets-bar .btn-ghost { color: rgba(255,255,255,0.8); }
.presets-bar .btn-ghost:hover { background: rgba(255,255,255,0.12); color: var(--bg); }
.presets-bar .btn-primary {
  background: var(--bg); color: var(--ink); border-color: var(--bg);
}

/* ─── MODALS ───────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: var(--s4);
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
  animation: fade-in var(--dur-base) var(--ease);
}
[data-theme="dark"] .modal-backdrop { background: rgba(0,0,0,0.6); }
.modal-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--sh-lg);
  animation: pop-in var(--dur-base) var(--ease);
  overflow: hidden;
}
.modal-card--lg { max-width: 760px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s4);
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-body {
  padding: var(--s4);
  overflow-y: auto;
  flex: 1;
}
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  margin: 0 calc(var(--s4) * -1) calc(var(--s4) * -1);
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* form inside modal */
.form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field-full { grid-column: 1 / -1; }
.field span {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.field input, .field select, .field textarea {
  height: 38px;
  padding: 0 var(--s3);
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  outline: none;
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease);
}
.field textarea { height: auto; padding: var(--s2) var(--s3); resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--ink);
}

/* file modal — details */
.fm-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--s4);
}
.fm-section { display: flex; flex-direction: column; gap: var(--s3); }
.fm-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 700;
}
.fm-row {
  display: flex; justify-content: space-between; gap: var(--s3);
  padding: var(--s2) 0;
  border-bottom: 1px solid var(--border);
}
.fm-row:last-child { border-bottom: 0; }
.fm-label { color: var(--ink-3); font-size: 13px; }
.fm-value { font-weight: 500; font-size: 13px; }
.fm-value.mono { font-family: var(--font-mono); }
.fm-amount {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}
.fm-status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--fresh-soft); color: var(--fresh);
}
.fm-status-pill[data-status="legal"] { background: var(--legal-soft); color: var(--legal); }
.fm-status-pill[data-status="paid"]  { background: var(--paid-soft); color: var(--paid); }

.fm-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.fm-actions .btn { flex: 1 1 auto; min-width: 0; justify-content: center; }

.fm-timeline {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column;
  border-inline-start: 2px solid var(--border);
  padding-inline-start: var(--s4);
  gap: var(--s3);
}
.fm-timeline li {
  position: relative;
  font-size: 13px;
}
.fm-timeline li::before {
  content: ""; position: absolute;
  inset-inline-start: calc(-1 * var(--s4) - 4px); top: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
}
.fm-timeline li[data-type="call"]::before { background: var(--paid); }
.fm-timeline li[data-type="email"]::before { background: var(--fresh); }
.fm-timeline li[data-type="payment_received"]::before { background: var(--paid); }
.fm-timeline li[data-type="escalation"]::before { background: var(--warn); }
.fm-timeline li[data-type="legal_handoff"]::before { background: var(--hot); }

.fm-timeline-head {
  display: flex; justify-content: space-between; gap: var(--s2);
  font-weight: 700;
}
.fm-timeline-time { color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; font-weight: 500; }
.fm-timeline-by { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.fm-timeline-notes { color: var(--ink-2); margin-top: 4px; line-height: 1.55; }

.action-target {
  background: var(--surface-2);
  border-radius: var(--r-md);
  padding: var(--s2) var(--s3);
  font-size: 13px;
  grid-column: 1 / -1;
}
.action-target strong { font-weight: 700; }

.kbd-list {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: var(--s3) var(--s4);
  margin: 0;
  align-items: center;
}
.kbd-list dt { display: flex; gap: 4px; }
.kbd-list kbd {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
}
.kbd-list dd { color: var(--ink-2); font-size: 13px; margin: 0; }

/* ─── TOAST ────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + var(--s3));
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: var(--ink);
  color: var(--bg);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--sh-lg);
  animation: pop-in var(--dur-base) var(--ease);
}
.toast.is-error { background: var(--hot); color: #fff; }
.toast.is-success { background: var(--paid); color: #fff; }
.toast[hidden] { display: none; }

/* ─── SEARCH HIGHLIGHT ─────────────────────────────────────────────────── */
mark {
  background: var(--soft-bg);
  color: var(--ink);
  padding: 0 2px;
  border-radius: 2px;
}

/* ─── RESPONSIVE ───────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .widget[data-w="4"] { grid-column: span 6; }
  .widget[data-w="8"] { grid-column: span 12; }
  .kanban-body { grid-template-columns: repeat(4, 1fr); height: auto; }
  .kan-col { min-height: 200px; }
}
@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-inline-end: 0; top: var(--topbar-h);
    transform: translateX(100%);
    z-index: 40;
    width: 280px;
    height: calc(100vh - var(--topbar-h));
    box-shadow: var(--sh-lg);
    transition: transform var(--dur-base) var(--ease);
  }
  .sidebar.is-open { transform: none; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .widget[data-w] { grid-column: span 12; }
  .kanban-body { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { max-width: none; }
  .brand-name { display: none; }
  .form { grid-template-columns: 1fr; }
  .fm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .main { padding: var(--s3); }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-value { font-size: 32px; }
  .hero-amount { font-size: 32px; }
  .hero-customer-name { font-size: 22px; }
  .kanban-body { grid-template-columns: 1fr; }
}

/* ─── PRINT ────────────────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .presets-bar, .toast, .widget-hide, .hidden-tray, .hero-actions { display: none; }
  .app-layout { grid-template-columns: 1fr; }
  .widget { break-inside: avoid; }
}

/* ─── A11Y ─────────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--fresh);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ SHEET — bigger by default + fullscreen ============ */
.widget-sheet[data-h="8"] { min-height: 90vh; }
.widget-sheet[data-h="8"] .widget-body { max-height: calc(90vh - 70px); height: calc(90vh - 70px); }
.widget-sheet[data-h="8"] .sheet-body { min-height: calc(90vh - 80px); overflow: auto; }
.widget-sheet.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 9999 !important;
  margin: 0 !important;
  border-radius: 0 !important;
  min-height: 100vh !important;
  width: 100vw !important;
  max-width: 100vw !important;
}
.widget-sheet.is-fullscreen .widget-body {
  max-height: calc(100vh - 60px) !important;
  height: calc(100vh - 60px) !important;
}
.widget-sheet.is-fullscreen .drag-handle { display: none; }

/* ============ STATUS COLUMN — stage + days-in-stage display ============ */
.sheet-pill.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--surface-2, #f7f5f0);
  color: var(--ink-1, #1a1611);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.sheet-pill.stage-pill strong { font-weight: 800; color: var(--accent, #c2410c); }
.sheet-pill.stage-pill.overdue {
  background: #fef3c7;
  color: #92400e;
}
.sheet-pill.stage-pill.overdue strong { color: #b45309; }
.sheet-pill.stage-pill.overdue-hot {
  background: #fee2e2;
  color: #991b1b;
}
.sheet-pill.stage-pill.overdue-hot strong { color: #dc2626; }
.sheet-pill .irp-flag { margin-inline-start: 4px; }

/* ============ SINGLE-PAGE MODE — each sidebar link = its own page ============ */
/* When body has single-page-X class, hide hero/kpi/all widgets except #X */
body[class*="single-page-"] #hero { display: none !important; }
body[class*="single-page-"] .kpi-strip { display: none !important; }
body[class*="single-page-"] #widgetGrid > .widget { display: none !important; }
body[class*="single-page-"] #widgetGrid {
  display: block !important;
  grid-template-columns: none !important;
}
body[class*="single-page-"] #widgetGrid > .widget {
  width: 100% !important;
  max-width: 100% !important;
  grid-column: unset !important;
}
/* Show only the matching widget — full width, taller */
body.single-page-worklist  #widgetGrid > #worklist,
body.single-page-kanban    #widgetGrid > #kanban,
body.single-page-team      #widgetGrid > #team,
body.single-page-cashflow  #widgetGrid > #cashflow,
body.single-page-aging     #widgetGrid > #aging,
body.single-page-activity  #widgetGrid > #activity,
body.single-page-sheet     #widgetGrid > #sheet {
  display: block !important;
  width: 100% !important;
  min-height: calc(100vh - 100px);
}
/* Larger body for the single shown widget */
body[class*="single-page-"] .widget-body {
  min-height: calc(100vh - 180px);
  max-height: none !important;
}
/* Sheet in single-page mode: take full screen height */
body.single-page-sheet #sheet { min-height: 95vh !important; }
body.single-page-sheet #sheet .widget-body {
  height: calc(95vh - 60px) !important;
  max-height: calc(95vh - 60px) !important;
}

/* ============ TYPOGRAPHY — enlarge small fonts + organize ============ */
/* Bump base body font for better Arabic readability */
body { font-size: 16px; line-height: 1.7; }

/* Sidebar — bigger, more breathing */
.sidebar { font-size: 15px; }
.side-title {
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--ink-3);
  padding: 14px 16px 6px;
  margin: 0;
}
.side-link {
  font-size: 15px !important;
  padding: 9px 12px !important;
  line-height: 1.4;
}
.side-link span { font-weight: 600; }
.side-section { margin-bottom: 6px; }

/* Topbar */
.brand-name { font-size: 17px !important; }
.topbar-search input { font-size: 15px !important; height: 40px !important; }

/* Buttons */
.btn { font-size: 15px !important; }
.btn-sm { font-size: 14px !important; }

/* KPI cards */
.kpi-head span { font-size: 14px !important; }
.kpi-value { font-size: 32px !important; }
.kpi-sub { font-size: 13px !important; }

/* Sheet table — readable rows */
.sheet-table thead th { font-size: 13px !important; padding: 10px 8px !important; }
.sheet-table tbody td { font-size: 14px !important; padding: 9px 8px !important; }

/* Worklist rows */
.worklist-name { font-size: 15px !important; font-weight: 700; }
.worklist-meta { font-size: 13px !important; }

/* Team cards */
.team-name { font-size: 15px !important; font-weight: 700; }
.team-stat-label { font-size: 12px !important; }
.team-stat-value { font-size: 17px !important; font-weight: 700; }

/* Modal & form */
.fm-section-title, .ext-section-title { font-size: 15px !important; font-weight: 800 !important; }
.fm-label, .field label { font-size: 13px !important; font-weight: 600; }
.fm-value { font-size: 14px !important; }

/* Generic small text everywhere — never below 12 */
.meta, .sub, .empty-state { font-size: 13px !important; }
small { font-size: 12px !important; }

/* Tooltips / badges */
.pill, .day-badge, .ext-pill, .pending-badge, .role-pill, .badge { font-size: 12px !important; padding: 3px 9px !important; }

/* User badge in topbar */
.user-badge-name { font-size: 14px !important; }
.user-badge-role { font-size: 11px !important; }

/* RTL number consistency */
.mono { font-feature-settings: "tnum"; letter-spacing: 0; }

/* ─────────────────────────────────────────────────────────────────────
   ANALYTICS — modern grid of charts
   ───────────────────────────────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 18px;
  padding: 8px 0;
}
.analytics-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  position: relative;
  overflow: hidden;
}
.analytics-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #c2410c 0%, #d97800 50%, #eab308 100%);
  border-radius: 14px 14px 0 0;
}
.analytics-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 8px 24px rgba(0,0,0,0.06);
}
.analytics-card h3 {
  font-size: 14px; font-weight: 700; margin: 4px 0 12px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 8px;
}
.analytics-card canvas {
  max-height: 280px !important;
  width: 100% !important;
}
[data-theme="dark"] .analytics-card { background: var(--surface-2); }

/* ─────────────────────────────────────────────────────────────────────
   COMMAND PALETTE — modern Ctrl/⌘+K quick navigator
   ───────────────────────────────────────────────────────────────────── */
#cmd-palette {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; pointer-events: none;
  animation: cp-fade 0.18s var(--ease) both;
}
#cmd-palette .cp-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,15,15,0.55);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}
#cmd-palette .cp-card {
  position: relative;
  width: min(640px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25), 0 8px 24px rgba(0,0,0,0.12);
  pointer-events: auto;
  overflow: hidden;
  animation: cp-pop 0.22s var(--ease) both;
}
#cmd-palette .cp-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
#cmd-palette .cp-icon {
  font-size: 18px; opacity: 0.7;
}
#cmd-palette .cp-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 16px; font-family: inherit; color: var(--ink);
}
#cmd-palette .cp-esc {
  background: var(--soft-bg); padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-family: inherit;
  border: 1px solid var(--border);
  color: var(--ink-3);
}
#cmd-palette .cp-list {
  max-height: 50vh; overflow-y: auto;
  padding: 8px 0;
}
#cmd-palette .cp-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; cursor: pointer;
  transition: background-color 0.1s;
}
#cmd-palette .cp-item.active,
#cmd-palette .cp-item:hover {
  background: var(--soft-bg);
}
#cmd-palette .cp-kind {
  font-size: 16px; width: 24px; text-align: center;
}
#cmd-palette .cp-label {
  flex: 1; font-size: 14px; font-weight: 500;
}
#cmd-palette .cp-sub {
  font-size: 12px; color: var(--ink-3);
  font-feature-settings: "tnum";
}
#cmd-palette .cp-empty {
  padding: 24px; text-align: center; color: var(--ink-3); font-size: 13px;
}
#cmd-palette .cp-foot {
  display: flex; justify-content: space-around;
  padding: 8px 16px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--ink-3);
  background: var(--soft-bg);
}
[data-theme="dark"] #cmd-palette .cp-card { background: var(--surface-2); }
@keyframes cp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cp-pop  { from { opacity: 0; transform: translateY(-12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ─────────────────────────────────────────────────────────────────────
   MODERN POLISH — buttons, hovers, transitions
   ───────────────────────────────────────────────────────────────────── */
.btn {
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease), background-color 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(194,65,12,0.25);
}
/* Subtle global background shimmer */
body {
  background-image: radial-gradient(ellipse at top, rgba(255,247,230,0.4) 0%, transparent 60%);
}
[data-theme="dark"] body {
  background-image: radial-gradient(ellipse at top, rgba(40,30,20,0.4) 0%, transparent 60%);
}
/* Tabular numerals everywhere money/dates appear */
.sheet-cell.mono, .kpi-value, .kan-card-amount, .worklist-amount {
  font-feature-settings: "tnum", "lnum";
}
/* Smoother card lifts */
.widget, .ext-card {
  transition: box-shadow 0.18s var(--ease), transform 0.12s var(--ease);
}
.widget:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* ─────────────────────────────────────────────────────────────────────
   SMART INSIGHTS WIDGET
   ───────────────────────────────────────────────────────────────────── */
.smart-insights-widget {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, var(--surface) 0%, var(--soft-bg) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.smart-insights-widget::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #db2777);
}
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
  padding: 12px;
}
.insight-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  border-left: 4px solid var(--info, #2563eb);
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.insight-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}
.insight-card.insight-good   { border-left-color: #0a7a3f; }
.insight-card.insight-warn   { border-left-color: #d97800; }
.insight-card.insight-danger { border-left-color: #b91c1c; }
.insight-card.insight-info   { border-left-color: #2563eb; }
.insight-icon {
  font-size: 22px; line-height: 1;
  flex-shrink: 0;
}
.insight-content { flex: 1; min-width: 0; }
.insight-title {
  font-size: 13px; font-weight: 700; color: var(--ink);
  margin-bottom: 4px;
}
.insight-body {
  font-size: 12px; color: var(--ink-2);
  line-height: 1.45;
}
.insight-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 24px;
  color: var(--ink-3); font-size: 13px;
}

/* ─────────────────────────────────────────────────────────────────────
   QUICK-FILTER CHIPS (above Sheet)
   ───────────────────────────────────────────────────────────────────── */
.sheet-quick-filters {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 12px 14px 8px;
  background: var(--soft-bg);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.qf-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.12s var(--ease);
  color: var(--ink-2);
  white-space: nowrap;
}
.qf-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}
.qf-chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(194,65,12,0.25);
}
.qf-info {
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--ink-3);
  font-feature-settings: "tnum";
}

/* ─────────────────────────────────────────────────────────────────────
   FAB — Floating Action Button
   ───────────────────────────────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: 28px;
  inset-inline-end: 28px;
  z-index: 80;
}
.fab-main {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #d97800 100%);
  color: #fff; border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(194,65,12,0.35), 0 2px 6px rgba(0,0,0,0.1);
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
  display: flex; align-items: center; justify-content: center;
}
.fab-main:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 24px rgba(194,65,12,0.45), 0 4px 10px rgba(0,0,0,0.15);
}
.fab-menu {
  position: absolute;
  bottom: 70px;
  inset-inline-end: 0;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 0; pointer-events: none;
  transform: translateY(8px) scale(0.95);
  transition: all 0.18s var(--ease);
}
.fab.is-open .fab-menu {
  opacity: 1; pointer-events: auto;
  transform: none;
}
.fab-action {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px; font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
  color: var(--ink);
  transition: all 0.12s var(--ease);
}
.fab-action:hover {
  background: var(--soft-bg);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* ─────────────────────────────────────────────────────────────────────
   DARK MODE quality pass for new features
   ───────────────────────────────────────────────────────────────────── */
[data-theme="dark"] .analytics-card {
  background: linear-gradient(180deg, #2a2825 0%, #1f1d1b 100%);
  border-color: #3d3a36;
}
[data-theme="dark"] .analytics-card h3 { color: #d4d0c8; }
[data-theme="dark"] .insight-card {
  background: #2a2825;
  border-color: #3d3a36;
}
[data-theme="dark"] .insight-title { color: #efece8; }
[data-theme="dark"] .insight-body  { color: #b8b3ab; }
[data-theme="dark"] .smart-insights-widget {
  background: linear-gradient(135deg, #1f1d1b 0%, #2a2624 100%);
}
[data-theme="dark"] .qf-chip {
  background: #2a2825;
  border-color: #3d3a36;
  color: #d4d0c8;
}
[data-theme="dark"] .qf-chip:hover {
  background: #36322d;
  color: #fb923c;
}
[data-theme="dark"] .qf-chip.active {
  background: #c2410c;
  color: #fff;
}
[data-theme="dark"] .sheet-quick-filters {
  background: #1f1d1b;
  border-bottom-color: #3d3a36;
}
[data-theme="dark"] .fab-action {
  background: #2a2825;
  color: #efece8;
  border-color: #3d3a36;
}
[data-theme="dark"] .fab-action:hover {
  background: #36322d;
  color: #fb923c;
}
[data-theme="dark"] #cmd-palette .cp-card {
  background: #1f1d1b;
  border-color: #3d3a36;
}
[data-theme="dark"] #cmd-palette .cp-input { color: #efece8; }
[data-theme="dark"] #cmd-palette .cp-item:hover,
[data-theme="dark"] #cmd-palette .cp-item.active {
  background: #2a2825;
}
[data-theme="dark"] #cmd-palette .cp-foot {
  background: #1a1816;
  border-top-color: #3d3a36;
}

/* ─────────────────────────────────────────────────────────────────────
   MOBILE RESPONSIVE for new features
   ───────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }
  .analytics-card canvas {
    max-height: 220px !important;
  }
  .analytics-card h3 { font-size: 13px; }
  .insights-grid {
    grid-template-columns: 1fr !important;
  }
  .sheet-quick-filters {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .qf-chip { flex-shrink: 0; }
  .fab {
    bottom: 16px;
    inset-inline-end: 16px;
  }
  .fab-main {
    width: 48px; height: 48px;
    font-size: 22px;
  }
  .fab-action {
    padding: 6px 12px;
    font-size: 12px;
  }
  #cmd-palette {
    padding-top: 8vh;
  }
  #cmd-palette .cp-card {
    width: 96vw;
    max-height: 80vh;
  }
}

/* ─────────────────────────────────────────────────────────────────────
   LOADING SKELETONS
   ───────────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--soft-bg) 0%, rgba(0,0,0,0.04) 50%, var(--soft-bg) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
  display: inline-block;
}
@keyframes skel-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #2a2825 0%, #36322d 50%, #2a2825 100%);
  background-size: 200% 100%;
}

/* ─────────────────────────────────────────────────────────────────────
   STAGGERED CHART ENTRY
   ───────────────────────────────────────────────────────────────────── */
.analytics-card {
  animation: card-fade 0.5s var(--ease) both;
}
.analytics-card:nth-child(1) { animation-delay: 0.05s; }
.analytics-card:nth-child(2) { animation-delay: 0.1s; }
.analytics-card:nth-child(3) { animation-delay: 0.15s; }
.analytics-card:nth-child(4) { animation-delay: 0.2s; }
.analytics-card:nth-child(5) { animation-delay: 0.25s; }
.analytics-card:nth-child(6) { animation-delay: 0.3s; }
.analytics-card:nth-child(7) { animation-delay: 0.35s; }
.analytics-card:nth-child(8) { animation-delay: 0.4s; }
.analytics-card:nth-child(9) { animation-delay: 0.45s; }
@keyframes card-fade {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

.insight-card { animation: insight-pop 0.4s var(--ease) both; }
.insight-card:nth-child(1) { animation-delay: 0.05s; }
.insight-card:nth-child(2) { animation-delay: 0.1s; }
.insight-card:nth-child(3) { animation-delay: 0.15s; }
.insight-card:nth-child(4) { animation-delay: 0.2s; }
.insight-card:nth-child(5) { animation-delay: 0.25s; }
.insight-card:nth-child(6) { animation-delay: 0.3s; }
.insight-card:nth-child(7) { animation-delay: 0.35s; }
.insight-card:nth-child(8) { animation-delay: 0.4s; }
@keyframes insight-pop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: none; }
}

/* FAB pulse animation on first appearance */
.fab .fab-main { animation: fab-pulse 2.4s ease-in-out infinite; }
@keyframes fab-pulse {
  0%, 100% { box-shadow: 0 6px 16px rgba(194,65,12,0.35), 0 2px 6px rgba(0,0,0,0.1); }
  50%       { box-shadow: 0 6px 16px rgba(194,65,12,0.55), 0 2px 6px rgba(0,0,0,0.1), 0 0 0 6px rgba(194,65,12,0.1); }
}
.fab.is-open .fab-main { animation: none; }

/* ─────────────────────────────────────────────────────────────────────
   ROUND 7 — DESIGN OVERHAUL: MODERN + DYNAMIC + OUT-OF-THE-BOX
   ───────────────────────────────────────────────────────────────────── */

/* Animated mesh gradient background — warm + subtle motion */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 15% 20%, rgba(255, 200, 130, 0.18) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(255, 150, 100, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(255, 180, 110, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(252, 165, 102, 0.10) 0%, transparent 50%);
  animation: mesh-drift 30s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes mesh-drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-20px, -10px) scale(1.05); }
  100% { transform: translate(20px, 10px) scale(1); }
}
[data-theme="dark"] body::before {
  background:
    radial-gradient(circle at 15% 20%, rgba(60, 30, 10, 0.4) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(80, 40, 20, 0.3) 0%, transparent 45%),
    radial-gradient(circle at 50% 80%, rgba(70, 35, 15, 0.35) 0%, transparent 50%);
}

/* Glass-morphism top bar */
.topbar, header.topbar, body > header:first-of-type {
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  background: rgba(255, 252, 248, 0.75) !important;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}
[data-theme="dark"] .topbar,
[data-theme="dark"] header.topbar,
[data-theme="dark"] body > header:first-of-type {
  background: rgba(20, 18, 16, 0.78) !important;
  border-bottom-color: rgba(255,255,255,0.08);
}
/* Smart hide-on-scroll-down */
body.scroll-hide-header .topbar,
body.scroll-hide-header header.topbar,
body.scroll-hide-header > header:first-of-type {
  transform: translateY(-100%);
  box-shadow: none;
}

/* Hero greeting widget */
.hero-greeting {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, rgba(255, 240, 220, 0.5) 0%, rgba(255, 220, 180, 0.3) 100%);
  border-radius: 16px;
  padding: 18px 24px;
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 18px;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  position: relative; overflow: hidden;
}
.hero-greeting::after {
  content: "";
  position: absolute; top: -50%; right: -20%; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(252,165,102,0.18) 0%, transparent 70%);
  pointer-events: none;
}
.hero-emoji { font-size: 38px; line-height: 1; }
.hero-text-block { flex: 1; }
.hero-title { font-size: 18px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.hero-sub { font-size: 13px; color: var(--ink-2); }
.hero-quick {
  display: flex; gap: 16px;
  font-size: 12px; color: var(--ink-2);
}
.hero-quick-item {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(0,0,0,0.04);
  padding: 6px 12px;
  border-radius: 10px;
  font-feature-settings: "tnum";
}
.hero-quick-item strong { color: var(--ink); display: block; font-size: 16px; font-weight: 700; }
[data-theme="dark"] .hero-greeting {
  background: linear-gradient(135deg, rgba(60,40,25,0.5) 0%, rgba(80,50,30,0.3) 100%);
  border-color: rgba(255,255,255,0.06);
}
[data-theme="dark"] .hero-quick-item {
  background: rgba(40,35,30,0.7);
  border-color: rgba(255,255,255,0.05);
}

/* 3D card tilt on hover */
.widget, .ext-card, .analytics-card, .insight-card {
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  transform-style: preserve-3d;
  perspective: 1000px;
}
.widget:hover,
.ext-card:hover,
.analytics-card:hover {
  transform: translateY(-3px) perspective(1000px) rotateX(0.5deg);
  box-shadow: 0 6px 20px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
}

/* Animated count-up cosmetic glow */
.kpi-value, .count-up-target {
  font-feature-settings: "tnum", "lnum";
  background: linear-gradient(135deg, var(--accent) 0%, #d97800 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
}

/* Pulse on urgent files (legal stage, danger status) */
.priority-dot.legal,
.priority-dot.danger,
.kan-card[data-stage="legal"]::before,
.worklist-row:has(.priority-dot.legal) {
  animation: urgent-pulse 1.8s ease-in-out infinite;
}
@keyframes urgent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  50%      { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Confetti container */
#confetti-canvas {
  position: fixed; inset: 0; pointer-events: none; z-index: 99999;
}

/* Slide-in toast for celebrations */
.celebrate-toast {
  position: fixed;
  top: 80px;
  inset-inline-end: 24px;
  background: linear-gradient(135deg, #0a7a3f 0%, #16a34a 100%);
  color: #fff;
  padding: 14px 22px;
  border-radius: 14px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 12px 30px rgba(10, 122, 63, 0.3);
  z-index: 99998;
  display: flex; align-items: center; gap: 12px;
  animation: cel-slide 4s ease-in-out forwards;
}
@keyframes cel-slide {
  0%   { transform: translateX(120%); opacity: 0; }
  10%  { transform: translateX(0);   opacity: 1; }
  90%  { transform: translateX(0);   opacity: 1; }
  100% { transform: translateX(120%); opacity: 0; }
}

/* Smoother focus rings */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Number scroll animation utility */
.num-scroll {
  display: inline-block;
  transition: transform 0.6s var(--ease);
}
/* ROUND 8 — KPI STRIP + HOVER PREVIEW + AI CHAT */

/* Big KPI strip */
.kpi-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  min-height: 130px;
  display: flex; flex-direction: column; gap: 8px;
}
.kpi-box:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}
.kpi-box::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  border-radius: 18px 18px 0 0;
}
.kpi-box-1::before { background: linear-gradient(90deg, #c2410c, #ea580c); }
.kpi-box-2::before { background: linear-gradient(90deg, #0a7a3f, #16a34a); }
.kpi-box-3::before { background: linear-gradient(90deg, #b91c1c, #dc2626); }
.kpi-box-4::before { background: linear-gradient(90deg, #2563eb, #6366f1); }
.kpi-box-head {
  display: flex; align-items: center; gap: 8px;
  color: var(--ink-2); font-size: 13px; font-weight: 600;
}
.kpi-icon { font-size: 20px; }
.kpi-label { flex: 1; }
.kpi-value-big {
  font-size: 32px; font-weight: 800; line-height: 1.1;
  color: var(--ink);
  font-feature-settings: "tnum", "lnum";
  background: linear-gradient(135deg, var(--accent) 0%, #d97800 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-box-2 .kpi-value-big { background: linear-gradient(135deg, #0a7a3f 0%, #16a34a 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-box-3 .kpi-value-big { background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-box-4 .kpi-value-big { background: linear-gradient(135deg, #2563eb 0%, #6366f1 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.kpi-sub { font-size: 11px; color: var(--ink-3); }
.kpi-spark {
  width: 100%; height: 28px; margin-top: auto; opacity: 0.85;
}
[data-theme="dark"] .kpi-box {
  background: linear-gradient(180deg, #2a2825 0%, #1f1d1b 100%);
  border-color: #3d3a36;
}

/* Hover preview card */
.hover-preview {
  position: fixed; z-index: 1000;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18);
  font-size: 13px;
  pointer-events: auto;
  animation: hp-fade 0.18s ease-out;
}
@keyframes hp-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.hp-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px; margin-bottom: 10px;
  gap: 12px;
}
.hp-name { font-weight: 700; flex: 1; min-width: 0; line-height: 1.35; }
.hp-amount { font-weight: 700; color: var(--accent); white-space: nowrap; font-feature-settings: "tnum"; }
.hp-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 10px;
}
.hp-cell { display: flex; flex-direction: column; gap: 2px; }
.hp-cell span { font-size: 11px; color: var(--ink-3); }
.hp-cell strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.hp-sub { font-size: 11px; color: var(--ink-2); padding-top: 8px; border-top: 1px solid var(--border); }
[data-theme="dark"] .hover-preview { background: #2a2825; border-color: #3d3a36; }

/* AI Chat assistant */
.ai-chat-bubble {
  position: fixed;
  bottom: 100px;
  inset-inline-end: 28px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  font-size: 24px; border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
  z-index: 70;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.ai-chat-bubble:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}
.ai-chat-panel {
  position: fixed;
  bottom: 28px;
  inset-inline-end: 28px;
  width: min(380px, 92vw);
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
  z-index: 75;
  display: none; flex-direction: column;
  animation: ac-slide 0.25s var(--ease);
  overflow: hidden;
}
.ai-chat-panel.is-open { display: flex; }
@keyframes ac-slide {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: none; }
}
.ac-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
}
.ac-head .ac-title { flex: 1; font-weight: 700; }
.ac-head .ac-close {
  background: rgba(255,255,255,0.2); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px;
}
.ac-body {
  flex: 1; overflow-y: auto;
  padding: 14px;
  background: var(--soft-bg);
  display: flex; flex-direction: column; gap: 10px;
}
.ac-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px; line-height: 1.5;
}
.ac-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb 0%, #6366f1 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ac-msg.bot {
  align-self: flex-start;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.ac-msg.plan {
  align-self: stretch;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 14px 16px;
}
.ac-msg.plan .plan-label {
  font-weight: 700; color: var(--accent); font-size: 12px; margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px;
}
.ac-msg.plan .plan-detail {
  background: var(--soft-bg); padding: 8px 12px; border-radius: 8px;
  font-family: monospace; font-size: 12px;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.ac-msg.plan .plan-actions {
  display: flex; gap: 8px; margin-top: 10px;
}
.ac-msg.plan .btn { padding: 6px 14px; font-size: 12px; }
.ac-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px;
  background: var(--surface);
}
.ac-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; font-family: inherit;
  outline: none;
  background: var(--soft-bg);
}
.ac-input:focus { border-color: var(--accent); }
.ac-send {
  padding: 8px 14px;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff; border: none; border-radius: 999px;
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.ac-thinking {
  align-self: flex-start;
  display: flex; gap: 4px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px;
}
.ac-thinking span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3);
  animation: typing-dot 1.4s ease-in-out infinite;
}
.ac-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ac-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}
[data-theme="dark"] .ai-chat-panel { background: #1f1d1b; border-color: #3d3a36; }
[data-theme="dark"] .ac-body { background: #16140f; }
[data-theme="dark"] .ac-msg.bot { background: #2a2825; border-color: #3d3a36; color: #efece8; }
[data-theme="dark"] .ac-input { background: #2a2825; color: #efece8; border-color: #3d3a36; }
[data-theme="dark"] .ac-foot { background: #1f1d1b; border-top-color: #3d3a36; }
/* ROUND 9 — Bento layout, bigger typography, deeper glassmorphism, undo button */

/* Bento dashboard grid — varied tile sizes (Apple-inspired) */
#widgetGrid.bento, .bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 18px;
  padding: 18px 0;
}
#widgetGrid.bento > .widget,
.bento-grid > .widget {
  grid-column: span 6;
}
/* Wide hero widgets */
#widgetGrid.bento > #smart-insights,
#widgetGrid.bento > #hero-greeting,
#widgetGrid.bento > #kpi-strip { grid-column: 1 / -1; }
#widgetGrid.bento > #worklist { grid-column: span 8; min-height: 480px; }
#widgetGrid.bento > #kanban { grid-column: span 12; min-height: 420px; }
#widgetGrid.bento > #team { grid-column: span 4; }
#widgetGrid.bento > #cashflow { grid-column: span 4; }
#widgetGrid.bento > #aging { grid-column: span 4; }
#widgetGrid.bento > #activity { grid-column: span 4; }
#widgetGrid.bento > #combined-widget { grid-column: span 8; }
#widgetGrid.bento > #sheet { grid-column: 1 / -1; min-height: 600px; }

@media (max-width: 1100px) {
  #widgetGrid.bento > .widget { grid-column: 1 / -1 !important; }
}

/* Bigger typography hierarchy */
.widget-title h3, .widget-head h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero-title { font-size: 24px !important; letter-spacing: -0.02em; }
.hero-sub { font-size: 14px !important; }
.kpi-value-big { font-size: 38px !important; }
.kpi-strip { gap: 18px; }
h1, h2 { letter-spacing: -0.02em; }
.ext-head h2 { font-size: 24px; letter-spacing: -0.02em; }
.ext-head p  { font-size: 14px; color: var(--ink-2); }

/* Stronger glassmorphism on every widget */
.widget {
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03), 0 8px 24px rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .widget {
  background: rgba(30, 28, 25, 0.65);
  border-color: rgba(255, 255, 255, 0.06);
}

/* Bigger paddings inside widgets */
.widget-head { padding: 16px 22px; }
.widget-body { padding: 14px 22px 22px; }

/* Worklist row spacing */
.worklist-row {
  padding: 14px 16px !important;
  border-radius: 12px !important;
  margin-bottom: 8px;
}

/* Undo button styling */
.undo-btn {
  border: 1px solid var(--border) !important;
  background: var(--surface) !important;
  font-weight: 600;
  transition: all 0.15s var(--ease);
}
.undo-btn:hover:not(:disabled) {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}
.undo-btn.is-disabled {
  cursor: not-allowed;
  pointer-events: none;
}

/* More breathing room */
main { padding-top: 16px; padding-bottom: 32px; }

/* Larger interactive elements */
.btn { font-size: 14px; padding: 10px 16px; border-radius: 10px; }
.btn-sm { font-size: 13px; padding: 7px 12px; border-radius: 8px; }
.btn-primary { box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08); }

/* Card hover-shimmer effect */
.widget::after,
.kpi-box::after,
.analytics-card::after {
  content: "";
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  transition: left 0.7s var(--ease);
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
}
.widget:hover::after,
.kpi-box:hover::after,
.analytics-card:hover::after {
  left: 100%;
}
.widget, .kpi-box, .analytics-card {
  position: relative;
  overflow: hidden;
}
.widget > *, .kpi-box > *, .analytics-card > * {
  position: relative;
  z-index: 2;
}
/* ROUND 10 — Health score, context menu, accent picker */

/* Health ring inside cells */
.health-cell { padding: 4px !important; vertical-align: middle; }
.health-ring { display: inline-block; vertical-align: middle; }
.col-health { font-size: 11px !important; line-height: 1.2; }

/* Worklist mini health */
.health-mini { display: inline-flex; align-items: center; }

/* Right-click context menu */
.row-context-menu {
  position: fixed;
  z-index: 99999;
  width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.2);
  padding: 6px;
  animation: rcm-pop 0.15s ease-out;
}
@keyframes rcm-pop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: none; }
}
.row-context-menu .rcm-head {
  font-weight: 700; padding: 8px 10px 4px;
  font-size: 12px; color: var(--ink-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.row-context-menu button {
  display: block; width: 100%;
  text-align: start; padding: 8px 12px;
  border: none; background: transparent;
  font-size: 13px; font-family: inherit;
  cursor: pointer; border-radius: 6px;
  color: var(--ink);
  font-weight: 500;
}
.row-context-menu button:hover {
  background: var(--soft-bg);
  color: var(--accent);
}
[data-theme="dark"] .row-context-menu {
  background: #2a2825; border-color: #3d3a36;
}

/* Accent picker */
.accent-picker { position: relative; display: inline-block; }
.accent-picker .ap-trigger {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center;
}
.accent-picker .ap-trigger:hover { background: var(--soft-bg); }
.accent-picker .ap-menu {
  position: absolute;
  top: 44px; inset-inline-end: 0;
  display: none;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.15);
  z-index: 100;
}
.accent-picker.is-open .ap-menu { display: flex; }
.accent-picker .ap-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  transition: transform 0.12s var(--ease);
}
.accent-picker .ap-swatch:hover { transform: scale(1.15); }
[data-theme="dark"] .accent-picker .ap-menu { background: #2a2825; border-color: #3d3a36; }
[data-theme="dark"] .accent-picker .ap-swatch { border-color: #2a2825; }

/* Empty state illustrations */
.empty-illustration {
  text-align: center;
  padding: 40px 20px;
}
.empty-illustration .ei-emoji {
  font-size: 64px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-illustration .ei-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.empty-illustration .ei-sub {
  font-size: 13px;
  color: var(--ink-3);
}

/* ROUND 11 — multi-chips + year pill */
.multi-chips {
  display: flex; flex-wrap: wrap; gap: 4px;
  align-items: center;
  padding: 2px 4px;
  max-width: 100%;
}
.multi-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--soft-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px 2px 4px;
  font-size: 11px;
  color: var(--ink);
  white-space: nowrap;
  font-family: var(--font-mono);
}
.multi-chip .chip-x {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  border: none; cursor: pointer;
  font-size: 11px; line-height: 1;
  color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all 0.12s var(--ease);
}
.multi-chip .chip-x:hover {
  background: #dc2626;
  color: #fff;
  transform: scale(1.1);
}
.chip-add {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  cursor: pointer;
  font-size: 13px; font-weight: 700;
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  transition: all 0.12s var(--ease);
}
.chip-add:hover { background: var(--accent); color: #fff; }
.year-pill {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 6px;
  font-weight: 700;
  font-feature-settings: "tnum";
}

/* Hide the legacy hero-greeting widget if it still appears */
#hero-greeting { display: none !important; }

/* ROUND 12 — KILL ANIMATIONS, RESTORE WHITE BG (performance fix) */

/* Disable mesh background entirely */
body::before { display: none !important; content: none !important; }
body { background: #ffffff !important; background-image: none !important; }
[data-theme="dark"] body { background: #0a0a0a !important; }

/* Disable FAB pulse */
.fab .fab-main { animation: none !important; }

/* Disable widget/card shimmer */
.widget::after, .kpi-box::after, .analytics-card::after { display: none !important; content: none !important; }

/* Disable card-fade + insight-pop staggered animations */
.analytics-card, .insight-card { animation: none !important; }

/* Disable hero animation if present */
.hero-greeting::after { display: none !important; }

/* Reduce transform-heavy hovers — keep tiny lift only */
.btn:hover:not(:disabled), .widget:hover, .ext-card:hover, .analytics-card:hover, .kpi-box:hover, .insight-card:hover {
  transform: none !important;
}
.btn-primary:hover:not(:disabled) { box-shadow: none !important; }

/* Disable mesh drift keyframes by overriding */
@keyframes mesh-drift { 0%, 100% { transform: none; } }
@keyframes fab-pulse { 0%, 100% { box-shadow: 0 6px 16px rgba(194,65,12,0.35); } }
@keyframes card-fade { from, to { opacity: 1; transform: none; } }
@keyframes insight-pop { from, to { opacity: 1; transform: none; } }

/* Faster transitions overall */
* {
  transition-duration: 100ms !important;
}

/* Disable backdrop blur on widgets (heavy on weak machines) */
.widget {
  background: var(--surface) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
[data-theme="dark"] .widget { background: var(--surface-2) !important; }

/* Disable backdrop blur on topbar */
.topbar, header.topbar {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  background: var(--surface) !important;
}
[data-theme="dark"] .topbar { background: #18181b !important; }

/* ROUND 13 — finance KPI + emoji-free + wider collector */
.kpi-box-5::before { background: linear-gradient(90deg, #7c3aed, #a855f7); }
.kpi-box-5 .kpi-value-big {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Wider collector cell */
.sheet-table .col-assignedTo, .sheet-table th:nth-child(3) {
  min-width: 200px;
}
.sheet-assignee-select { min-width: 180px; }

/* Remove emoji icons from analytics card titles */
.analytics-card h3 { letter-spacing: -0.01em; }

/* Hide emoji-only spans in headers */
.kpi-icon { display: none !important; }
.insight-icon { display: none !important; }

/* Tidy widget heads when icons removed */
.kpi-box-head { gap: 0; }
.insight-card { padding-left: 14px; }
.day-pill { display: inline-block; padding: 2px 10px; border-radius: 6px; font-weight: 700; font-feature-settings: "tnum"; }
.day-pill.day-early { background: #dcfce7; color: #166534; }
.day-pill.day-mid   { background: #fef3c7; color: #854d0e; }
.day-pill.day-late  { background: #fee2e2; color: #991b1b; }
/* TEMP: hide login overlay (auto-login bypass) — REVERT to re-enable login */
