/* =============================================================================
   Broker Ledger — Global Stylesheet
   Design: Swiss & High-Contrast, PlexUI-inspired, light neutral
   ============================================================================= */

:root {
  /* Colors */
  --bg-root: #FAFAFA;
  --bg-surface: #FFFFFF;
  --bg-surface-hover: #F4F4F5;
  --bg-surface-active: #E4E4E7;
  --border-light: #E4E4E7;
  --border-strong: #D4D4D8;
  --text-primary: #09090B;
  --text-secondary: #52525B;
  --text-tertiary: #A1A1AA;
  --text-inverse: #FFFFFF;
  --brand-primary: #18181B;
  --brand-primary-hover: #27272A;
  --brand-accent: #2563EB;
  --state-error: #EF4444;
  --state-error-bg: #FEF2F2;
  --state-success: #10B981;
  --state-success-bg: #ECFDF5;
  --focus-ring: rgba(37, 99, 235, 0.3);

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-24: 6rem;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-heading: 'Chivo', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

/* Dark theme overrides ---------------------------------------------------- */
[data-theme="dark"] {
  --bg-root:           #0a0a0b;
  --bg-surface:        #111113;
  --bg-surface-hover:  #1c1c1f;
  --bg-surface-active: #26262b;
  --border-light:      #27272a;
  --border-strong:     #3f3f46;
  --text-primary:      #fafafa;
  --text-secondary:    #a1a1aa;
  --text-tertiary:     #52525b;
  --text-inverse:      #09090b;
  --brand-primary:     #fafafa;
  --brand-primary-hover: #e4e4e7;
  --brand-accent:      #6366f1;
  --state-error:       #f87171;
  --state-error-bg:    #1f1111;
  --state-success:     #34d399;
  --state-success-bg:  #0d1f19;
  --focus-ring:        rgba(99, 102, 241, 0.35);
  --shadow-sm:  0 1px 2px 0 rgba(0,0,0,0.4);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,0.4), 0 2px 4px -1px rgba(0,0,0,0.3);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,0.5), 0 4px 6px -2px rgba(0,0,0,0.3);
}

/* Theme toggle pill ------------------------------------------------------- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 8px;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  user-select: none;
  order: 3;          /* sits just before the user card (order:4) */
}
.theme-toggle:hover {
  background: var(--bg-surface-active);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.theme-toggle__track {
  width: 28px; height: 16px;
  background: var(--border-strong);
  border-radius: var(--radius-full);
  position: relative;
  transition: background 0.2s ease;
  flex-shrink: 0;
}
[data-theme="dark"] .theme-toggle__track { background: var(--brand-accent); }
.theme-toggle__thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
[data-theme="dark"] .theme-toggle__thumb { transform: translateX(12px); }
.theme-toggle__icon { font-size: 0.85rem; line-height: 1; }

/* Reset -------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-root);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  margin: 0;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
h1 { font-size: 2.5rem; letter-spacing: -0.04em; line-height: 1.1; font-weight: 700; }
h2 { font-size: 1.75rem; line-height: 1.2; font-weight: 700; }
h3 { font-size: 1.25rem; letter-spacing: -0.01em; line-height: 1.3; font-weight: 600; }
h4 { font-size: 1.125rem; line-height: 1.4; font-weight: 600; }

.overline {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 var(--space-2);
}
.small { font-size: 0.8125rem; }
.muted { color: var(--text-tertiary); font-weight: 400; }
.hidden { display: none !important; }

/* =============================================================================
   Shared components
   ============================================================================= */

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; }
.brand__mark {
  width: 22px; height: 22px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary) 55%, var(--brand-accent) 56%, var(--brand-accent) 100%);
  display: inline-block;
}
.brand__name {
  font-family: var(--font-heading);
  font-weight: 900; font-size: 1rem; letter-spacing: -0.02em;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 0.875rem; font-weight: 500;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}
.btn--primary { background: var(--brand-primary); color: var(--text-inverse); border-color: var(--brand-primary); }
.btn--primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn--secondary { background: transparent; color: var(--text-primary); border-color: var(--border-light); }
.btn--secondary:hover { background: var(--bg-surface-hover); border-color: var(--border-strong); }
.btn--ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn--ghost:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.btn--danger { background: var(--state-error); color: white; border-color: var(--state-error); }
.btn--danger:hover { background: #DC2626; border-color: #DC2626; }
.btn--full { width: 100%; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Form */
.form { display: flex; flex-direction: column; gap: var(--space-4); }
.form__field { display: flex; flex-direction: column; gap: 6px; }
.form__field label { font-size: 0.8125rem; font-weight: 500; color: var(--text-primary); }
.form__field .muted { font-weight: 400; }
input[type="text"],
input[type="password"],
input[type="email"],
select {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: var(--transition);
  width: 100%;
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus {
  outline: none;
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
input::placeholder { color: var(--text-tertiary); }

/* Alerts */
.alert {
  padding: 10px 12px; border-radius: var(--radius-md);
  font-size: 0.875rem; line-height: 1.4;
  border: 1px solid transparent;
}
.alert--error { background: var(--state-error-bg); color: var(--state-error); border-color: rgba(239, 68, 68, 0.25); }
.alert--success { background: var(--state-success-bg); color: var(--state-success); border-color: rgba(16, 185, 129, 0.25); }

/* Badge */
.badge {
  font-size: 0.6875rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 2px 6px; border-radius: var(--radius-sm);
  background: var(--bg-surface-hover); color: var(--text-tertiary);
  margin-left: auto;
}

/* Toast */
.toast {
  position: fixed; right: var(--space-6); bottom: var(--space-6);
  background: var(--brand-primary); color: var(--text-inverse);
  padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 0.875rem; box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  z-index: 60;
}
.toast--error { background: var(--state-error); }
.toast--success { background: var(--state-success); }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* =============================================================================
   Login (split-screen)
   ============================================================================= */
.auth-body { min-height: 100vh; }
.split-screen {
  display: grid; grid-template-columns: minmax(420px, 1fr) 1.1fr;
  min-height: 100vh;
}
.split-screen__form {
  display: flex; flex-direction: column;
  padding: var(--space-8) var(--space-12);
  background: var(--bg-surface);
}
.split-screen__form > .auth-card { margin: auto 0; }
.split-screen__form > .brand { flex-shrink: 0; }
.split-screen__form > .auth-footer { flex-shrink: 0; margin-top: auto; }
.split-screen__image { position: relative; overflow: hidden; background: #111; }
.split-screen__image img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
  filter: grayscale(0.15) contrast(1.05);
}
.split-screen__image-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(9,9,11,0) 40%, rgba(9,9,11,0.6) 100%);
  display: flex; align-items: flex-end;
  padding: var(--space-12);
}
.split-screen__image-overlay blockquote {
  color: var(--text-inverse);
  max-width: 420px; margin: 0;
}
.split-screen__image-overlay blockquote p {
  font-family: var(--font-heading);
  font-size: 1.5rem; line-height: 1.3; font-weight: 400;
  letter-spacing: -0.02em; margin: 0 0 var(--space-3);
}
.split-screen__image-overlay cite {
  font-style: normal; font-size: 0.8125rem;
  color: rgba(255,255,255,0.7); font-family: var(--font-mono);
}

.auth-card { max-width: 420px; width: 100%; margin: auto 0; }
.auth-card__title { margin-top: var(--space-3); margin-bottom: var(--space-2); }
.auth-card__subtitle { color: var(--text-secondary); margin: 0 0 var(--space-8); }
.auth-card__footer {
  margin-top: var(--space-6);
  font-size: 0.8125rem; color: var(--text-tertiary);
}
.auth-footer {
  font-size: 0.75rem; color: var(--text-tertiary);
  font-family: var(--font-mono);
}

@media (max-width: 880px) {
  .split-screen { grid-template-columns: 1fr; }
  .split-screen__image { display: none; }
  .split-screen__form { padding: var(--space-8) var(--space-6); }
}

/* =============================================================================
   App shell (sidebar + content)
   ============================================================================= */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Sidebar (Now Top Nav) */
.sidebar {
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-surface);
  display: flex; flex-direction: row; align-items: center;
  padding: var(--space-4) var(--space-6);
  gap: var(--space-4);
  position: sticky; top: 0; z-index: 100;
}
.sidebar__nav { display: flex; flex-direction: row; align-items: center; gap: 8px; flex: 1; order: 2; }
.sidebar__section-label {
  display: none;
}
.sidebar__section-label--spaced { margin-top: 0; }
.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  transition: var(--transition);
}
.sidebar__item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.sidebar__item--active { background: var(--bg-surface-active); color: var(--text-primary); font-weight: 600; }
.sidebar__item--disabled { color: var(--text-tertiary); cursor: not-allowed; }
.sidebar__item--disabled:hover { background: transparent; color: var(--text-tertiary); }
.sidebar__item-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.6;
}

.sidebar__footer { border-top: 1px solid var(--border-light); padding-top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }

/* ── Master Nav Dropdown ── */
.nav-dropdown { position: relative; }
.nav-dropdown__trigger {
  background: none; border: none; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
}
.nav-dropdown__chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.nav-dropdown--open .nav-dropdown__chevron { transform: rotate(180deg); }
.nav-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 6px;
  z-index: 200;
}
.nav-dropdown--open .nav-dropdown__menu { display: block; }
.nav-dropdown__group { padding: 2px 0; }
.nav-dropdown__group-label {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.nav-dropdown__item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px 7px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}
.nav-dropdown__item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-dropdown__item.sidebar__item--active { background: var(--bg-surface-active); color: var(--text-primary); font-weight: 600; }
.nav-dropdown__dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: 0.55; flex-shrink: 0;
}
.nav-dropdown__divider { height: 1px; background: var(--border-light); margin: 4px 6px; }

/* ── Nested sub-menu (Account List flyout) ── */
.nav-submenu { position: relative; }
.nav-submenu__trigger {
  width: 100%; background: none; border: none; cursor: pointer;
  text-align: left;
}
.nav-submenu__chevron {
  transition: transform 0.2s ease;
  flex-shrink: 0;
  opacity: 0.6;
}
.nav-submenu--open .nav-submenu__chevron { transform: rotate(180deg); }
.nav-submenu__menu {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  padding: 4px;
  margin-top: 2px;
  margin-left: 8px;
  margin-right: 2px;
}
.nav-submenu--open .nav-submenu__menu { display: block; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
}
.user-chip__avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--brand-primary); color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 700; font-size: 0.875rem;
  text-transform: uppercase;
}
.user-chip__meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-chip__name { font-weight: 600; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip__role { font-size: 0.75rem; color: var(--text-tertiary); text-transform: capitalize; }

/* Content */
.content { padding: var(--space-8) var(--space-8); width: 100%; box-sizing: border-box; }
.content__header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-6);
  margin-bottom: var(--space-12);
}
.content__title { margin: 0; }
.content__subtitle { color: var(--text-secondary); margin: var(--space-2) 0 0; max-width: 560px; }

/* Dashboard hero welcome block */
.content__header--dashboard {
  align-items: flex-start;
  margin-bottom: var(--space-8);
}
.dashboard-hero {
  flex: 1;
  text-align: center;
}
.dashboard-hero__overline {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brand-accent);
  margin: 0 0 var(--space-2);
}
.dashboard-hero__title {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 4vw, 3.25rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 0 0 var(--space-3);
}
.dashboard-hero__subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 480px;
  margin-inline: auto;
  line-height: 1.6;
}
.dashboard-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  opacity: 0.5;
  margin: 0 0 var(--space-12);
}

.section-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.section-meta { font-size: 0.8125rem; color: var(--text-tertiary); font-family: var(--font-mono); }

/* Stats row */
.stats-row {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-12);
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.stat-card__value {
  font-family: var(--font-heading);
  font-size: 2rem; font-weight: 700; letter-spacing: -0.03em;
}
.stat-card__value--mono { font-family: var(--font-mono); font-size: 1.25rem; font-weight: 500; letter-spacing: 0; }
.stat-card__hint { font-size: 0.75rem; color: var(--text-tertiary); }

/* Workspaces grid */
.workspaces__header {
  display: flex; align-items: baseline; justify-content: center;
  margin-bottom: var(--space-12);
}
.workspaces__grid {
  display: grid; 
  grid-template-columns: repeat(auto-fit, 260px);
  gap: var(--space-4);
  justify-content: center;
}
.workspace-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: var(--space-6) var(--space-4);
  display: flex; flex-direction: row; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative; min-height: 85px;
}
.workspace-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}
.workspace-card__name {
  font-family: var(--font-heading); font-weight: 600; font-size: 1.25rem;
  color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.workspace-card__actions {
  display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0;
}
.workspace-card__delete, .workspace-card__disable, .workspace-card__enable {
  background: transparent; border: none; color: var(--text-tertiary);
  font-size: 0.75rem; font-weight: 600; cursor: pointer;
  padding: 4px 8px; border-radius: var(--radius-sm); transition: all 0.15s;
}
.workspace-card__delete:hover { background: var(--state-error-bg); color: var(--state-error); }
.workspace-card__disable:hover { background: rgba(0,0,0,0.05); color: var(--text-primary); }
.workspace-card__enable:hover { background: var(--state-success-bg); color: var(--state-success); }
.workspace-card__cta {
  font-size: 0.8125rem; font-weight: 600; color: var(--brand-accent);
  white-space: nowrap; transition: color 0.15s ease;
}
.workspace-card:hover .workspace-card__cta { color: var(--text-primary); }
.workspace-card--disabled {
  opacity: 0.6;
  filter: grayscale(100%);
  background: var(--bg-body);
}
.workspace-card--disabled .workspace-card__cta {
  color: var(--text-tertiary);
}
.workspace-card--focused,
.workspace-card:focus {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: 2px;
  border-color: var(--accent, #6366f1);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

/* Empty state */
.empty-state {
  text-align: center; padding: var(--space-16) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.empty-state h3 { margin: 0 0 var(--space-2); }
.empty-state p { color: var(--text-secondary); margin: 0 0 var(--space-6); }

/* Data table */
.data-table { background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: var(--radius-lg); overflow: hidden; }
.data-table__toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-root);
}
.data-table__search { max-width: 320px; }
.data-table__scroll { overflow-x: auto; }
.data-table__el { width: 100%; border-collapse: collapse; }
.data-table__el thead tr { background: var(--bg-surface-hover); border-bottom: 1px solid var(--border-light); }
.data-table__el th {
  padding: 12px 16px; text-align: left;
  font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.data-table__el tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.2s ease; }
.data-table__el tbody tr:last-child { border-bottom: none; }
.data-table__el tbody tr:hover { background: var(--bg-surface-hover); }
.data-table__el td { padding: 14px 16px; font-size: 0.875rem; color: var(--text-primary); vertical-align: middle; }
.data-table__actions-col { text-align: right; }
.data-table__empty { text-align: center; color: var(--text-tertiary); padding: var(--space-12); }

.table-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
.table-btn {
  background: transparent; border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.75rem; padding: 6px 10px;
  color: var(--text-secondary); transition: var(--transition);
}
.table-btn:hover { background: var(--bg-surface-hover); color: var(--text-primary); border-color: var(--border-strong); }
.table-btn--danger:hover { color: var(--state-error); border-color: rgba(239, 68, 68, 0.4); background: var(--state-error-bg); }

.role-pill {
  display: inline-flex; align-items: center;
  padding: 3px 8px; font-size: 0.75rem; font-weight: 500;
  border-radius: var(--radius-full);
  background: var(--bg-surface-hover); color: var(--text-secondary);
}
.role-pill--superadmin { background: #EFF6FF; color: var(--brand-accent); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell__avatar {
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--brand-primary); color: var(--text-inverse);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading); font-weight: 700; font-size: 0.8125rem;
  text-transform: uppercase;
}
.user-cell__meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-cell__name { font-weight: 600; }
.user-cell__sub { font-size: 0.75rem; color: var(--text-tertiary); }

/* Cards & profile */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
}
.card__header { margin-bottom: var(--space-6); }
.profile-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-6); }
@media (max-width: 960px) { .profile-grid { grid-template-columns: 1fr; } }

.meta-list { display: grid; grid-template-columns: 1fr; gap: var(--space-4); margin: 0; }
.meta-list > div { display: flex; flex-direction: column; gap: var(--space-1); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border-light); }
.meta-list > div:last-child { border-bottom: none; padding-bottom: 0; }
.meta-list dt { font-size: 0.6875rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600; color: var(--text-tertiary); margin: 0; }
.meta-list dd { margin: 0; font-weight: 500; color: var(--text-primary); font-size: 0.9375rem; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.modal__backdrop { position: absolute; inset: 0; background: rgba(9, 9, 11, 0.45); backdrop-filter: blur(4px); }
.modal__panel {
  position: relative; z-index: 1;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 460px;
  padding: var(--space-6);
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
  display: flex; flex-direction: column; gap: var(--space-5);
}
.modal__panel--sm { max-width: 400px; }
.modal__header { display: flex; align-items: center; justify-content: space-between; }
.modal__header h3 { margin: 0; }
.modal__close {
  background: transparent; border: none;
  font-size: 1.5rem; color: var(--text-tertiary);
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
}
.modal__close:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.modal__body { color: var(--text-secondary); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--space-3); }
.modal__actions--left { justify-content: flex-start; }

/* Responsive */
@media (max-width: 900px) {
  .content { padding: var(--space-6) var(--space-4); }
  .stats-row { grid-template-columns: 1fr; }
  .content__header { flex-direction: column; align-items: stretch; }
}

::selection { background: var(--text-primary); color: var(--text-inverse); }

/* =============================================================================
   Workspace page additions
   ============================================================================= */
.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; color: var(--text-tertiary); margin-bottom: 6px; }
.breadcrumbs a { color: var(--text-secondary); transition: color 0.2s ease; }
.breadcrumbs a:hover { color: var(--text-primary); }
.breadcrumbs span { color: var(--text-tertiary); }

.ws-summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, auto));
  gap: var(--space-6);
  padding: var(--space-4) var(--space-6);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.ws-summary > div { display: flex; flex-direction: column; gap: 2px; }
.ws-summary b {
  font-family: var(--font-heading); font-weight: 700;
  font-size: 1.25rem; letter-spacing: -0.02em;
  color: var(--text-primary);
}

.workspace-card--clickable { cursor: pointer; }
.workspace-card__cta { color: var(--brand-accent); font-weight: 600; }

.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  display: flex; flex-direction: column; gap: var(--space-6);
}
.panel-card__header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4);
}

.sidebar__item--tab { cursor: pointer; }

.record-form { display: flex; flex-direction: column; gap: var(--space-5); }
.record-form__row-top {
  display: flex; align-items: flex-end; gap: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px dashed var(--border-light);
}
.form__field--inline { max-width: 220px; }

.table-wrap {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}
.record-table td { padding: 10px 12px; vertical-align: middle; }
.record-table td input,
.record-table td select {
  height: 36px;
  font-size: 0.875rem;
}
.record-table tfoot td {
  background: var(--bg-surface-hover);
  border-top: 1px solid var(--border-light);
}

.filters {
  display: flex; flex-wrap: wrap; gap: var(--space-4);
  align-items: flex-end;
  padding: var(--space-4);
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

.record-actions { display: flex; justify-content: flex-end; gap: var(--space-3); }

.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

@media (max-width: 900px) {
  .ws-summary { grid-template-columns: repeat(2, 1fr); }
  .content__header { flex-direction: column; align-items: stretch; }
  .panel-card { padding: var(--space-6); }
}

/* =============================================================================
   Reports & print
   ============================================================================= */
.preset-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.chip {
  height: 32px; padding: 0 12px;
  font-size: 0.8125rem; font-weight: 500;
  background: var(--bg-surface); color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  cursor: pointer; transition: var(--transition);
}
.chip:hover { border-color: var(--border-strong); color: var(--text-primary); background: var(--bg-surface-hover); }
.chip--active, .chip:focus-visible { outline: none; border-color: var(--brand-primary); color: var(--text-primary); box-shadow: 0 0 0 3px var(--focus-ring); }

.report-sheet {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-12);
  display: flex; flex-direction: column; gap: var(--space-8);
  box-shadow: var(--shadow-sm);
}
.report-sheet__header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-6);
  padding-bottom: var(--space-6);
  border-bottom: 2px solid var(--text-primary);
}
.report-sheet__title {
  font-family: var(--font-heading); font-weight: 900;
  font-size: 2rem; letter-spacing: -0.03em; line-height: 1.1;
  margin: 0 0 var(--space-2);
}
.report-sheet__subtitle {
  margin: 0; color: var(--text-secondary);
  font-family: var(--font-mono); font-size: 0.8125rem;
}
.report-sheet__meta {
  display: grid; grid-template-columns: auto auto;
  gap: 4px 16px; margin: 0;
  font-size: 0.8125rem;
}
.report-sheet__meta > div { display: contents; }
.report-sheet__meta dt {
  color: var(--text-tertiary);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.6875rem; font-weight: 600;
  align-self: center;
}
.report-sheet__meta dd { margin: 0; font-weight: 500; color: var(--text-primary); font-family: var(--font-mono); }

.report-sheet__section { display: flex; flex-direction: column; gap: var(--space-4); }
.report-sheet__footer {
  display: flex; justify-content: space-between; gap: var(--space-4);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-light);
  font-size: 0.75rem; color: var(--text-tertiary);
  font-family: var(--font-mono);
}
.report-sheet__pagenote { max-width: 520px; text-align: right; }

.report-table th, .report-table td { padding: 10px 14px; font-size: 0.875rem; }
.report-matrix th:first-child,
.report-matrix td:first-child { position: sticky; left: 0; background: var(--bg-surface); z-index: 1; }
.report-matrix thead th { background: var(--bg-surface-hover); }

/* Print-only rules
   Goal: when the user hits "Print / Save as PDF", show ONLY the report sheet
   in a clean, margin-friendly layout. */
@media print {
  @page { size: A4; margin: 14mm; }

  html, body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* Hide everything except the report sheet and its ancestors */
  body * { visibility: hidden !important; }
  #report-sheet, #report-sheet * { visibility: visible !important; }

  /* Absolutely position the sheet to occupy the page */
  #report-sheet {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    gap: 18pt;
  }

  /* Do not print the toolbar / preset filters / buttons inside reports */
  .print-hide { display: none !important; }

  /* Ensure every tab-panel that isn't reports is hidden even if dom state differs */
  .tab-panel[data-panel]:not([data-panel="reports"]) { display: none !important; }

  .report-sheet__title { font-size: 22pt; }
  .section-title { font-size: 12pt; }
  .report-sheet__subtitle,
  .report-sheet__meta dt,
  .report-sheet__meta dd,
  .report-sheet__footer { font-size: 9pt; }

  .table-wrap { border: 1px solid #000; border-radius: 0; overflow: visible; }
  .data-table__el { border-collapse: collapse; width: 100%; }
  .data-table__el th, .data-table__el td {
    border: 1px solid #333 !important;
    padding: 6pt 8pt !important;
    color: #000 !important;
    background: #fff !important;
    font-size: 9pt !important;
  }
  .data-table__el thead th {
    background: #f1f1f1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .data-table__el tfoot td { background: #fafafa !important; font-weight: 700; }
  .muted, .data-table__empty { color: #555 !important; }

  .page-break { break-before: page; page-break-before: always; }
}

/* =============================================================================
   Financial Year picker + badge
   ============================================================================= */
.fy-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--brand-primary); color: var(--text-inverse);
  font-family: var(--font-mono); font-size: 0.75rem;
  font-weight: 500; letter-spacing: 0.02em;
  vertical-align: middle;
}

.fy-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-6);
  margin-top: var(--space-4);
}
.fy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-2);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  outline: none;
}
.fy-card:hover,
.fy-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-primary);
}
.fy-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.fy-card__year {
  font-family: var(--font-heading); font-weight: 900;
  font-size: 2rem; letter-spacing: -0.04em; line-height: 1;
  color: var(--text-primary);
}
.fy-card__delete {
  background: transparent; border: none; color: var(--text-tertiary);
  padding: 4px 8px; border-radius: var(--radius-sm);
  font-size: 0.75rem; transition: var(--transition);
}
.fy-card__delete:hover { color: var(--state-error); background: var(--state-error-bg); }
.fy-card__label {
  font-family: var(--font-mono); font-size: 0.875rem; font-weight: 500;
  color: var(--text-primary);
}
.fy-card__range {
  font-family: var(--font-mono); font-size: 0.75rem;
  color: var(--text-tertiary);
}
.fy-card__cta { color: var(--brand-accent); font-size: 0.8125rem; font-weight: 600; }

/* =============================================================================
   Sidebar — Card variant (.sidebar--cards)
   Top section: Home card + User card; Bottom: Session card
   ============================================================================= */

/* Override base sidebar spacing for card layout */
.sidebar--cards {
  padding: 12px 24px;
  gap: 16px;
  overflow: visible;
}

/* ── Shared card base ─────────────────────────────────────────────────────── */
.sb-card {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg-surface);
  transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

/* ── Home card ────────────────────────────────────────────────────────────── */
.sb-card--home {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 12px;
  order: 1;
  margin-right: 20px;
}

.sb-card--home:hover {
  border-color: var(--border-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  background: var(--bg-surface-hover);
}

.sb-card__brand-mark {
  width: 30px; height: 30px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary) 55%, var(--brand-accent) 56%, var(--brand-accent) 100%);
  display: inline-block;
  flex-shrink: 0;
}

.sb-card__brand-name {
  font-family: var(--font-heading);
  font-weight: 900; font-size: 1.125rem; letter-spacing: -0.03em;
  color: var(--text-primary);
  flex: 1;
  white-space: nowrap;
}

/* ── User card ────────────────────────────────────────────────────────────── */
.sb-card--user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  cursor: pointer;
  position: relative;
  user-select: none;
  border-radius: 10px;
  order: 4;
}

.sb-card--user:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
}

.sb-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-heading);
  font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.sb-user-meta {
  display: flex; flex-direction: column; flex: 1; min-width: 0;
}

.sb-user-name {
  font-size: 0.875rem; font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}

.sb-user-role {
  font-size: 0.7rem; font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
  margin-top: 1px;
}

.sb-user-chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.sb-card--user[aria-expanded="true"] .sb-user-chevron {
  transform: rotate(180deg);
}

/* ── User card dropdown ───────────────────────────────────────────────────── */
.sidebar-user-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0; width: 220px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  overflow: hidden;
  z-index: 200;
  /* hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar-user-dropdown--open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.sidebar-user-dropdown__item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s ease;
}

.sidebar-user-dropdown__item:hover {
  background: var(--bg-surface-hover);
}

.sidebar-user-dropdown__item + .sidebar-user-dropdown__item {
  border-top: 1px solid var(--border-light);
}

.sidebar-user-dropdown__item--active {
  color: var(--brand-accent);
  font-weight: 600;
}

.sidebar-user-dropdown__item--danger {
  color: var(--state-error);
}

.sidebar-user-dropdown__item--danger:hover {
  background: var(--state-error-bg);
}

/* ── Session info inside dropdown ─────────────────────────────────────────── */
.sidebar-user-dropdown__session {
  padding: 10px 14px;
  background: var(--bg-surface-hover);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-user-dropdown__session-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.sidebar-user-dropdown__session-values {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Sidebar nav tweaks when inside cards layout ──────────────────────────── */
.sidebar--cards .sidebar__nav {
  order: 2;
  flex: 1;
}

.sidebar--cards .sidebar__nav .sidebar__section-label:first-child {
  margin-top: 0;
}

