/* ╔═══════════════════════════════════════════════════════════════╗
   ║  CLARITY  —  calm SaaS light theme (+ Slate: dark menu)       ║
   ║  Neutral greys, white cards with hairline borders, one indigo ║
   ║  accent, light sidebar, tabular figures (Inter).              ║
   ║  Tokens first; only components with hard-coded colours below. ║
   ╚═══════════════════════════════════════════════════════════════╝ */
:root[data-theme^="clarity"] {
  /* Surfaces */
  --bg: #fafbfc;          /* near-white workspace; the sidebar is the grey part */
  --bg-secondary: #f1f3f6;
  --card: #ffffff;
  --card-hover: #fafbfc;
  --bg-input: #ffffff;
  --border: #e3e6eb;
  --text: #1a1f2b;
  --text-secondary: #4b5565;
  --muted: #5f6878;

  /* One accent (own indigo shade) — used for actions, focus and charts */
  --blue: #5048e5;
  --blue-light: #ecebfd;
  --primary: #5048e5;
  --primary-dark: #4038c8;
  --primary-light: #ecebfd;
  --indigo: #5048e5;

  /* Meaning only: money up/down and states. All text colours ≥ 4.5:1 on white and on --bg (WCAG AA). */
  --green: #0a7f57;
  --green-light: #e3f6ee;
  --success: #0a7f57;
  --success-light: #e3f6ee;
  --red: #c8323f;
  --red-light: #fdecee;
  --danger: #c8323f;
  --danger-light: #fdecee;
  --amber: #a3620a;
  --amber-light: #fdf3e1;
  --warning: #a3620a;
  --warning-light: #fdf3e1;
  --purple: #7c5ce0;
  --purple-light: #f1edfd;

  /* Flatter, tighter */
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);

  /* Grey sidebar, set apart from the near-white workspace; the active page is a white tab */
  --sidebar-bg: #eef0f3;
  --sidebar-bg-dark: #eef0f3;
  --sidebar-border: #dfe3e9;
  --sidebar-hover: #e4e7ec;
  --sidebar-active: #5048e5;
  --sidebar-active-bg: #ffffff;

  --font-num: inherit;

  color-scheme: light;
}

/* Typography: Inter with figures that line up */
[data-theme^="clarity"] body { font-family: 'Inter', 'Poppins', system-ui, sans-serif; font-feature-settings: "cv11", "ss01"; }
[data-theme^="clarity"] .page-title { font-weight: 650; letter-spacing: -0.02em; }
[data-theme^="clarity"] table td,
[data-theme^="clarity"] .dash-kpi-value,
[data-theme^="clarity"] .dash-flow-val,
[data-theme^="clarity"] .dash-ue-value,
[data-theme^="clarity"] .dash .num,
[data-theme^="clarity"] .stat-value,
[data-theme^="clarity"] .logs-stat-value { font-variant-numeric: tabular-nums; }
[data-theme^="clarity"] .dash-kpi-value { letter-spacing: -0.02em; }

/* ── Shell: grey sidebar with a hairline edge ── */
[data-theme^="clarity"] #sidebar { background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); box-shadow: none; }
[data-theme^="clarity"] .sidebar-header,
[data-theme^="clarity"] .sidebar-global,
[data-theme^="clarity"] .sidebar-user { border-color: var(--sidebar-border); }
[data-theme^="clarity"] .sidebar-user { background: transparent; }
[data-theme^="clarity"] .sidebar-logo { color: var(--text); }
[data-theme^="clarity"] .sidebar-logo .logo-icon { background: #fff; box-shadow: 0 0 0 1px var(--sidebar-border); }
[data-theme^="clarity"] .sidebar-toggle { background: #fff; color: var(--text-secondary); box-shadow: 0 0 0 1px var(--sidebar-border); }
[data-theme^="clarity"] .sidebar-toggle:hover { background: #fff; color: var(--text); box-shadow: 0 0 0 1px #c9ced7; }
/* Sidebar: thin thumb without the page scrollbar's light border (it showed as a white ring on Slate) */
[data-theme^="clarity"] .sidebar-nav::-webkit-scrollbar { width: 6px; }
[data-theme^="clarity"] .sidebar-nav::-webkit-scrollbar-thumb { background: #d3d8df; border: 0; }

[data-theme^="clarity"] .nav-item { color: var(--text-secondary); border-radius: 8px; }
[data-theme^="clarity"] .nav-item:hover { color: var(--text); background: var(--sidebar-hover); }
[data-theme^="clarity"] .nav-item.active {
  color: var(--text); background: var(--sidebar-active-bg); font-weight: 600;
  box-shadow: 0 0 0 1px var(--sidebar-border), 0 1px 2px rgba(16, 24, 40, 0.06);
}
[data-theme^="clarity"] .nav-item.active .nav-icon { color: var(--primary); }
[data-theme^="clarity"] .nav-item::before { display: none; } /* no side bar: colour marks the active page */
[data-theme^="clarity"] .nav-section-label { color: var(--muted); }
[data-theme^="clarity"] body.sidebar-collapsed .nav-section-label { background: var(--sidebar-border); }
[data-theme^="clarity"] .nav-store { background: #fff; color: var(--text); box-shadow: 0 0 0 1px var(--sidebar-border); }
[data-theme^="clarity"] .nav-tooltip { background: var(--text); color: #fff; }

[data-theme^="clarity"] .user-avatar { background: var(--primary); box-shadow: none; }
[data-theme^="clarity"] .user-name { color: var(--text); }
[data-theme^="clarity"] .user-email { color: var(--muted); }
[data-theme^="clarity"] .logout-btn { background: #fff; color: var(--text-secondary); box-shadow: 0 0 0 1px var(--sidebar-border); }
[data-theme^="clarity"] .logout-btn:hover { background: var(--red-light); color: var(--red); }

[data-theme^="clarity"] .app-topbar { background: color-mix(in srgb, var(--card) 90%, transparent); }

/* ── Cards: hairline border, no lift, no gradient strip ── */
[data-theme^="clarity"] .card { box-shadow: var(--shadow); }
[data-theme^="clarity"] .card:hover { box-shadow: var(--shadow); transform: none; }
[data-theme^="clarity"] .card::before { display: none; }

/* ── Tables: grey header, thin rows ── */
[data-theme^="clarity"] table th {
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[data-theme^="clarity"] table th,
[data-theme^="clarity"] table td { border-color: var(--border); }

/* Denser data tables (more rows per screen, as in finance dashboards) */
[data-theme^="clarity"] .ord-table td { padding-top: .5rem; padding-bottom: .5rem; }
[data-theme^="clarity"] .prod-table td { padding-top: .4rem; padding-bottom: .4rem; height: 44px; }
[data-theme^="clarity"] .logs-table td,
[data-theme^="clarity"] .settings-table td { padding-top: .45rem; padding-bottom: .45rem; }
[data-theme^="clarity"] .as-table td,
[data-theme^="clarity"] .timeline-table td { padding-top: 7px; padding-bottom: 7px; }

/* ── Forms ── */
[data-theme^="clarity"] input:not([type="checkbox"]):not([type="radio"]),
[data-theme^="clarity"] select,
[data-theme^="clarity"] textarea { border-color: #d6dae1; }
[data-theme^="clarity"] input:not([type="checkbox"]):not([type="radio"]):focus,
[data-theme^="clarity"] select:focus,
[data-theme^="clarity"] textarea:focus { border-color: var(--primary); }

/* ── Dashboard: flat cards, hairline lines ── */
[data-theme^="clarity"] .dash {
  --dash-radius: 12px;
  --dash-radius-sm: 8px;
  --dash-soft: #f6f7f9;
  --dash-line: #eceef2;
  --dash-elev: 0 1px 2px rgba(16, 24, 40, 0.04);
  --dash-elev-hover: 0 1px 2px rgba(16, 24, 40, 0.04), 0 0 0 1px #d6dae1;
}

/* ── Scrollbars ── */
[data-theme^="clarity"] ::-webkit-scrollbar { width: 10px; height: 10px; }
[data-theme^="clarity"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme^="clarity"] ::-webkit-scrollbar-thumb { background: #d6dae1; border-radius: 10px; border: 2px solid var(--bg); }

/* Running version on the grey sidebar (Clarity only; Slate keeps the dark-sidebar colour) */
[data-theme="clarity"] .app-version { color: var(--muted); }

/* ╔═══════════════════════════════════════════════════════════════╗
   ║  CLARITY SLATE  —  same theme, dark slate sidebar             ║
   ║  Everything above applies ([data-theme^="clarity"]); only the ║
   ║  sidebar is overridden here.                                  ║
   ╚═══════════════════════════════════════════════════════════════╝ */
:root[data-theme="clarity-slate"] {
  --bg: #f5f6f8;
  --sidebar-bg: #111827;
  --sidebar-bg-dark: #111827;
  --sidebar-border: #1f2937;
  --sidebar-hover: rgba(255, 255, 255, 0.06);
  --sidebar-active: #a5a1ff;
  --sidebar-active-bg: rgba(255, 255, 255, 0.09);
}
[data-theme="clarity-slate"] .sidebar-logo { color: #fff; }
[data-theme="clarity-slate"] .sidebar-logo .logo-icon,
[data-theme="clarity-slate"] .sidebar-toggle,
[data-theme="clarity-slate"] .logout-btn { background: rgba(255, 255, 255, 0.08); box-shadow: none; color: rgba(255, 255, 255, 0.75); }
[data-theme="clarity-slate"] .sidebar-toggle:hover { background: rgba(255, 255, 255, 0.14); box-shadow: none; color: #fff; }
[data-theme="clarity-slate"] .logout-btn:hover { background: rgba(239, 68, 68, 0.2); color: #f87171; }
[data-theme="clarity-slate"] .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); }
[data-theme="clarity-slate"] .sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); }

[data-theme="clarity-slate"] .nav-item { color: rgba(255, 255, 255, 0.7); }
[data-theme="clarity-slate"] .nav-item:hover { color: #fff; background: var(--sidebar-hover); }
[data-theme="clarity-slate"] .nav-item.active { color: #fff; background: var(--sidebar-active-bg); box-shadow: none; }
[data-theme="clarity-slate"] .nav-item.active .nav-icon { color: var(--sidebar-active); }
[data-theme="clarity-slate"] .nav-section-label { color: rgba(255, 255, 255, 0.52); }
[data-theme="clarity-slate"] body.sidebar-collapsed .nav-section-label { background: rgba(255, 255, 255, 0.1); }
[data-theme="clarity-slate"] .nav-store { background: rgba(255, 255, 255, 0.06); color: #fff; box-shadow: none; }
[data-theme="clarity-slate"] .nav-tooltip { background: #111827; color: #fff; }

[data-theme="clarity-slate"] .user-name { color: #fff; }
[data-theme="clarity-slate"] .user-email { color: rgba(255, 255, 255, 0.6); }
