/* ============================================================
   DESIGN TOKENS — Capital Markets Tracker
   Warm cream + amber accent + deep navy
   ============================================================ */

:root, [data-theme="light"] {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem,   1.2rem  + 1.25vw, 2.25rem);

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

  /* Warm Cream Palette */
  --color-bg:              #f0ebe3;   /* warm cream page background */
  --color-surface:         #faf8f5;   /* card surface */
  --color-surface-2:       #f2ede6;   /* inner sub-card / offset */
  --color-surface-offset:  #ede7df;   /* hover / pressed */
  --color-divider:         #e5ddd4;   /* row dividers */
  --color-border:          #e0d8ce;   /* card borders */

  --color-text:            #1a2535;   /* near-black navy */
  --color-text-base:       #1a2535;
  --color-text-muted:      #6b7280;   /* medium grey */
  --color-text-faint:      #9ca3af;   /* light grey */
  --color-text-inverse:    #f8fafc;

  /* Amber accent — section labels & active nav border */
  --color-accent:          #b5864e;   /* warm amber/gold */
  --color-accent-light:    #f5ead8;   /* amber wash */

  /* Primary — keep navy for buttons */
  --color-primary:         #1a2535;
  --color-primary-hover:   #243040;
  --color-primary-active:  #0f1923;
  --color-primary-light:   #e8e2da;

  /* Sidebar — deep navy */
  --color-sidebar:         #111b27;
  --color-sidebar-hover:   #182231;
  --color-sidebar-active:  #1f2d3e;
  --color-sidebar-text:    #c8d6e5;
  --color-sidebar-muted:   #607080;

  /* Status */
  --color-success:         #2e6b47;   /* forest green */
  --color-success-bg:      #d4edda;
  --color-warning:         #c4884a;   /* warm amber */
  --color-warning-bg:      #faecd8;
  --color-error:           #a33030;   /* muted red */
  --color-error-bg:        #f5dede;
  --color-info:            #4a6b8a;   /* steel blue */
  --color-info-bg:         #dce8f0;
  --color-purple:          #6d28d9;
  --color-purple-bg:       #ede9fe;

  /* Chart colours — warm palette */
  --chart-1: #1a2535;   /* dark navy */
  --chart-2: #4a6b8a;   /* steel blue */
  --chart-3: #b5864e;   /* amber */
  --chart-4: #2e6b47;   /* forest green */
  --chart-5: #8b3a3a;   /* muted red */

  /* Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --radius-xl: 1.125rem;
  --radius-full: 9999px;

  /* Transitions */
  --transition-interactive: 160ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Shadows — warm toned */
  --shadow-sm: 0 1px 3px rgba(26,37,53,0.06), 0 1px 2px rgba(26,37,53,0.04);
  --shadow-md: 0 4px 12px rgba(26,37,53,0.08), 0 2px 4px rgba(26,37,53,0.05);
  --shadow-lg: 0 12px 32px rgba(26,37,53,0.10);

  /* Fonts — serif display + sans body */
  --font-body: 'Inter', 'DM Sans', 'Helvetica Neue', sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-width: 210px;
}

[data-theme="dark"] {
  --color-bg:              #0b1320;
  --color-surface:         #111c2d;
  --color-surface-2:       #162034;
  --color-surface-offset:  #1a2538;
  --color-divider:         #1f2d3d;
  --color-border:          #253347;

  --color-text:            #dce8f5;
  --color-text-muted:      #7a95ae;
  --color-text-faint:      #4a637a;
  --color-text-inverse:    #0f1923;

  --color-primary:         #4b83f0;
  --color-primary-hover:   #6699f5;
  --color-primary-active:  #84aefc;
  --color-primary-light:   #1a2d4a;

  --color-sidebar:         #090e18;
  --color-sidebar-hover:   #111b2a;
  --color-sidebar-active:  #162233;
  --color-sidebar-text:    #b0c8de;
  --color-sidebar-muted:   #4a637a;

  --color-success:         #22c55e;
  --color-success-bg:      #052e16;
  --color-warning:         #f59e0b;
  --color-warning-bg:      #2d1d06;
  --color-error:           #f43f5e;
  --color-error-bg:        #2d0a14;
  --color-info:            #38bdf8;
  --color-info-bg:         #082038;
  --color-purple:          #a78bfa;
  --color-purple-bg:       #1e1040;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-bg:              #0b1320;
    --color-surface:         #111c2d;
    --color-surface-2:       #162034;
    --color-surface-offset:  #1a2538;
    --color-divider:         #1f2d3d;
    --color-border:          #253347;
    --color-text:            #dce8f5;
    --color-text-muted:      #7a95ae;
    --color-text-faint:      #4a637a;
    --color-text-inverse:    #0f1923;
    --color-primary:         #4b83f0;
    --color-primary-hover:   #6699f5;
    --color-primary-active:  #84aefc;
    --color-primary-light:   #1a2d4a;
    --color-sidebar:         #090e18;
    --color-sidebar-hover:   #111b2a;
    --color-sidebar-active:  #162233;
    --color-sidebar-text:    #b0c8de;
    --color-sidebar-muted:   #4a637a;
    --color-success:         #22c55e;
    --color-success-bg:      #052e16;
    --color-warning:         #f59e0b;
    --color-warning-bg:      #2d1d06;
    --color-error:           #f43f5e;
    --color-error-bg:        #2d0a14;
    --color-info:            #38bdf8;
    --color-info-bg:         #082038;
    --color-purple:          #a78bfa;
    --color-purple-bg:       #1e1040;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
  }
}

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: var(--space-6) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo svg { flex-shrink: 0; }

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
}

.sidebar-logo-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text-inverse);
  letter-spacing: -0.01em;
  color: #ffffff;
  line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
  font-weight: 400;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-sidebar-muted);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-interactive), color var(--transition-interactive);
}

.nav-item:hover {
  background: var(--color-sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: var(--color-sidebar-active);
  color: #ffffff;
  border-left: 3px solid #c8895a;
  padding-left: calc(var(--space-3) - 3px);
}

.nav-item svg {
  opacity: 0.7;
  flex-shrink: 0;
}

.nav-item.active svg, .nav-item:hover svg { opacity: 1; }

.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-1);
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-sidebar-text);
  line-height: 1.2;
}

.user-role {
  font-size: var(--text-xs);
  color: var(--color-sidebar-muted);
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100dvh;
  background: var(--color-bg);
}

.page-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
  overflow: hidden;
}

.page-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.page-body {
  padding: var(--space-8);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-offset); color: var(--color-text); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 0;
}
.btn-icon:hover { background: var(--color-surface-offset); color: var(--color-text); border-color: var(--color-border); }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.card-body {
  padding: var(--space-6);
}

/* ============================================================
   METRIC CARDS
   ============================================================ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.metric-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.metric-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: 600;
  margin-top: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.metric-delta.up { background: var(--color-success-bg); color: var(--color-success); }
.metric-delta.down { background: var(--color-error-bg); color: var(--color-error); }
.metric-delta.neutral { background: var(--color-surface-offset); color: var(--color-text-muted); }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-size: 0.67rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-active     { background: var(--color-success-bg); color: var(--color-success); }
.badge-pending    { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-suspended  { background: var(--color-error-bg);   color: var(--color-error); }
.badge-closed     { background: var(--color-surface-offset); color: var(--color-text-muted); }
.badge-terminated { background: #2d1515; color: #f87171; }
.badge-ipo       { background: var(--color-primary-light); color: var(--color-primary); }
.badge-reit      { background: var(--color-purple-bg); color: var(--color-purple); }
.badge-secondary { background: var(--color-info-bg); color: var(--color-info); }
.badge-high      { background: var(--color-error-bg); color: var(--color-error); }
.badge-medium    { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-low       { background: var(--color-success-bg); color: var(--color-success); }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  font-size: 0.78rem;
  table-layout: auto;
}

.data-table thead {
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  padding: 7px 10px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.data-table td {
  padding: 7px 10px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
  font-size: 0.78rem;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--color-surface-2); }

.data-table .project-name {
  font-weight: 600;
  color: var(--color-text);
  display: block;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Staff email truncation */
.staff-email-cell {
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  font-size: var(--text-xs);
  color: var(--color-primary);
}

/* Deal Radar scrollable container */
.radar-scroll-wrap {
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sticky actions column so it's always visible */
#projects-table th:last-child,
#projects-table td:last-child {
  position: sticky;
  right: 0;
  background: inherit;
  z-index: 1;
}
#projects-table thead th:last-child {
  background: var(--color-surface-2);
}

.data-table .cm-number {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: var(--color-surface-offset);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  display: inline-block;
}

/* ============================================================
   SEARCH & FILTERS
   ============================================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-wrap svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
}

.search-input {
  width: 100%;
  padding: 6px var(--space-3) 6px 2.2rem;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  color: var(--color-text);
  outline: none;
}

.search-input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }
.search-input::placeholder { color: var(--color-text-faint); }

.filter-select {
  padding: 6px var(--space-2);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  color: var(--color-text);
  outline: none;
  cursor: pointer;
  appearance: auto;
  max-width: 130px;
}

.filter-select:focus { border-color: var(--color-primary); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
}

.pagination-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
}
.page-btn:hover { background: var(--color-surface-offset); color: var(--color-text); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ============================================================
   LOGIN PAGE — Two-column split layout
   ============================================================ */
.login-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: row;
}

/* ── Left panel ── */
.login-left {
  flex: 0 0 57%;
  background: #1b2b3a;
  display: flex;
  flex-direction: column;
  padding: 40px 48px;
  position: relative;
  overflow: hidden;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 48px;
}
.login-brand-icon {
  width: 36px; height: 36px;
  background: #243447;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-brand-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
}

.login-left-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 480px;
}

.login-headline {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 42px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
  margin: 0 0 18px 0;
  letter-spacing: -0.01em;
}

.login-tagline {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
  line-height: 1.65;
  margin: 0 0 20px 0;
  max-width: 400px;
}

.login-pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
  margin-bottom: 36px;
  width: fit-content;
}

.login-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-feature {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #243447;
  border-radius: 12px;
  padding: 16px 18px;
}
.login-feature-icon {
  flex-shrink: 0;
  color: #c9a96e;
  margin-top: 1px;
}
.login-feature-title {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 3px;
}
.login-feature-desc {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  line-height: 1.55;
}

/* ── Right panel ── */
.login-right {
  flex: 1;
  background: #eeeae4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.login-card {
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.10);
  width: 100%;
  max-width: 380px;
  padding: 36px 32px 28px;
}

.login-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-card-icon {
  width: 40px; height: 40px;
  background: #1b2b3a;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.login-card-brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #374151;
  text-transform: uppercase;
}
.login-card-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

.login-form-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 6px;
}
.login-form-sub {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 20px;
  line-height: 1.5;
}

.login-disclaimer {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.55;
  margin-top: 14px;
  text-align: center;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0.01em;
}

.form-input {
  padding: 10px 14px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 14px;
  color: #111827;
  font-family: inherit;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  border-color: #1b2b3a;
  box-shadow: 0 0 0 3px rgba(27,43,58,0.08);
  background: #fff;
}
.form-input::placeholder { color: #9ca3af; }

.btn-login {
  width: 100%;
  padding: 12px 16px;
  background: #1b2b3a;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 4px;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
.btn-login:hover { background: #243447; }
.btn-login:active { background: #111e2b; }

.login-error {
  background: #fef2f2;
  color: #dc2626;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  display: none;
  border: 1px solid #fecaca;
}
.login-error.show { display: block; }



/* ── Mobile: stack panels ── */
@media (max-width: 768px) {
  .login-page { flex-direction: column; }
  .login-left {
    flex: none;
    padding: 32px 24px;
    min-height: auto;
  }
  .login-headline { font-size: 28px; }
  .login-features { display: none; }
  .login-tagline { display: none; }
  .login-right {
    flex: none;
    padding: 32px 20px;
  }
  .login-card { padding: 28px 22px 22px; }
}

/* ============================================================
   DASHBOARD GRID
   ============================================================ */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

.dash-grid-full { grid-column: 1 / -1; }

.charts-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

/* Donut chart */
.donut-chart-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.donut-inner {
  position: relative;
  width: 120px; height: 120px;
}

.donut-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.donut-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.donut-sub {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-weight: 500;
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.legend-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-name { flex: 1; }
.legend-val { font-weight: 700; color: var(--color-text); font-variant-numeric: tabular-nums; }

/* Deal radar calendar */
.radar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}

.radar-month {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.radar-month-header {
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface-offset);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.radar-events {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.radar-event {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text);
}

.radar-event-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.radar-event-dot.filing { background: var(--color-info); }
.radar-event-dot.listing { background: var(--color-success); }

.radar-event-date {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 28px;
  color: var(--color-text-muted);
}

/* Heatmap */
.heatmap-table { width: 100%; font-size: var(--text-xs); }

.heatmap-table th {
  padding: var(--space-2) var(--space-3);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.heatmap-table th:first-child { text-align: left; width: 130px; }

.heatmap-table td {
  padding: var(--space-2) var(--space-3);
  text-align: center;
  border-bottom: 1px solid var(--color-divider);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.heatmap-table td:first-child { text-align: left; font-weight: 600; color: var(--color-text); }

.heat-cell {
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  display: inline-block;
  min-width: 28px;
}

.heat-0 { background: transparent; color: var(--color-text-faint); }
.heat-1 { background: #dbeafe; color: #1e40af; }
.heat-2 { background: #bfdbfe; color: #1d4ed8; }
.heat-3 { background: #93c5fd; color: #1e3a8a; }
.heat-4 { background: #60a5fa; color: #ffffff; }
.heat-5 { background: #3b82f6; color: #ffffff; }
.heat-6 { background: #1d4ed8; color: #ffffff; }

[data-theme="dark"] .heat-1 { background: #1e3a5f; color: #93c5fd; }
[data-theme="dark"] .heat-2 { background: #1a3260; color: #bfdbfe; }
[data-theme="dark"] .heat-3 { background: #163075; color: #60a5fa; }
[data-theme="dark"] .heat-4 { background: #1e40af; color: #ffffff; }
[data-theme="dark"] .heat-5 { background: #1d4ed8; color: #ffffff; }
[data-theme="dark"] .heat-6 { background: #2563eb; color: #ffffff; }

/* 7-day trends row */
.trends-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.trend-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.trend-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.trend-body { flex: 1; }
.trend-label { font-size: var(--text-xs); color: var(--color-text-muted); font-weight: 500; }
.trend-value { font-size: 1.5rem; font-weight: 800; color: var(--color-text); letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }

/* ============================================================
   STAFF PAGE
   ============================================================ */
.staff-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: #ffffff;
  flex-shrink: 0;
}

.staff-name-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ============================================================
   GUIDES PAGE
   ============================================================ */
.guides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-5);
}

.guide-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.guide-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.guide-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.guide-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--color-text);
}

.guide-desc {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* ============================================================
   BILLING PAGE
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  gap: var(--space-4);
  color: var(--color-text-muted);
  text-align: center;
}

.empty-icon {
  width: 64px; height: 64px;
  border-radius: var(--radius-xl);
  background: var(--color-surface-offset);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-2);
}

.empty-title { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); }
.empty-desc { font-size: var(--text-sm); max-width: 380px; }

/* ============================================================
   THEME TOGGLE
   ============================================================ */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-sidebar-muted);
  cursor: pointer;
  border: none;
  margin: var(--space-2) var(--space-3);
}
.theme-toggle:hover { background: var(--color-sidebar-hover); color: var(--color-sidebar-text); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-8);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-interactive);
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: var(--text-lg); font-weight: 700; color: var(--color-text); }

.modal-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }

.modal-footer {
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .charts-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid  { grid-template-columns: 1fr; }
  .radar-grid { grid-template-columns: repeat(2, 1fr); }
  .trends-row { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   MOBILE TOP BAR
   ============================================================ */
.mobile-topbar {
  display: none; /* hidden on desktop */
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--color-sidebar);
  z-index: 200;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-4);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.mobile-topbar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-topbar-title {
  font-size: var(--text-sm);
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-sidebar-text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.mobile-menu-btn:hover { background: var(--color-sidebar-hover); color: #fff; }

/* Sidebar backdrop overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 150;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   MOBILE — portrait phones AND landscape phones
   Triggered by: width ≤ 767px  OR  (width ≤ 1024px AND height ≤ 500px)
   The second condition catches landscape phones (e.g. 844×390)
   ============================================================ */
@media (max-width: 767px),
       (max-height: 500px) and (max-width: 1024px) {

  /* ── Top bar ── */
  .mobile-topbar { display: flex; }

  /* ── Sidebar becomes slide-in drawer ── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 160;
    top: 0;
  }
  .sidebar.mobile-open { transform: translateX(0); }

  /* ── Main content: no left offset, pad below top bar ── */
  .main-content {
    margin-left: 0;
    padding-top: 56px;
    min-width: 0;
    width: 100%;
    overflow-x: hidden;
  }

  /* ── Page header: compact, no overflow ── */
  .page-header {
    padding: var(--space-3) var(--space-4);
    flex-wrap: nowrap;
    gap: var(--space-3);
    min-width: 0;
    overflow: hidden;
  }
  .page-header > div:first-child { min-width: 0; flex: 1; overflow: hidden; }
  .page-title {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .page-subtitle { display: none; }
  .page-actions { flex-shrink: 0; }
  .page-actions .btn {
    font-size: var(--text-xs);
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
  }

  /* ── Page body: tighter padding ── */
  .page-body { padding: var(--space-3) var(--space-3); }

  /* ── Metrics: 2-column, smaller numbers ── */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  .metric-card { padding: var(--space-4); }
  .metric-label { font-size: 0.65rem; }
  .metric-value { font-size: 1.5rem; }
  .metric-delta { font-size: 0.65rem; }

  /* ── Trends: 2-column ── */
  .trends-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }
  .trend-card { padding: var(--space-3); gap: var(--space-2); }
  .trend-label { font-size: var(--text-xs); }
  .trend-value { font-size: 1.2rem; }

  /* ── Charts: single column ── */
  .charts-row { grid-template-columns: 1fr; }
  .dash-grid  { grid-template-columns: 1fr; }
  .radar-grid { grid-template-columns: 1fr; }

  /* ── Filter bar: wraps naturally ── */
  .filter-bar {
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-3);
  }
  .filter-bar .form-input { flex: 1 1 100%; min-width: 0; }
  .filter-bar .form-select { flex: 1 1 calc(50% - var(--space-1)); min-width: 0; }
  .filter-bar .form-input,
  .filter-bar .form-select { font-size: 16px; }
  .filter-bar .btn { flex-shrink: 0; align-self: flex-start; }

  /* ── Tables: card-per-row layout ── */
  .table-wrap {
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
  }
  .data-table thead { display: none; }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table tbody tr {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    position: relative;
  }
  .data-table td {
    padding: var(--space-1) 0;
    border-bottom: none;
    font-size: var(--text-sm);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    min-height: 26px;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 80px;
    flex-shrink: 0;
    padding-top: 2px;
  }
  .data-table td:last-child {
    justify-content: flex-end;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-divider);
    margin-top: var(--space-2);
  }
  .data-table td:last-child::before { display: none; }
  .data-table td.cell-name {
    font-weight: 600;
    font-size: var(--text-base);
    border-bottom: 1px solid var(--color-divider);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-1);
  }
  .data-table td.cell-name::before { display: none; }

  /* ── Modals: slide up from bottom ── */
  .modal-overlay { align-items: flex-end !important; }
  .modal-panel {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 88dvh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin: 0;
    align-self: flex-end;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Forms: single column, touch-friendly ── */
  .form-grid-2, .form-row { grid-template-columns: 1fr !important; }
  .form-input, .form-select, .form-textarea {
    font-size: 16px;
    min-height: 44px;
    padding: var(--space-3);
  }
  .form-textarea { min-height: 80px; }

  /* ── Modal footer buttons: full width ── */
  .modal-footer {
    flex-direction: column-reverse;
    gap: var(--space-2);
  }
  .modal-footer .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
    font-size: var(--text-base);
  }

  /* ── Pagination ── */
  .pagination { flex-wrap: wrap; gap: var(--space-2); justify-content: center; }

  /* ── Login page: tighter on small screens ── */
  .login-card { padding: var(--space-6) var(--space-5); margin: var(--space-4); }
}

/* ── Extra: portrait-only refinements (very narrow) ── */
@media (max-width: 430px) {
  .mobile-topbar-title { font-size: 0.8rem; }
  .metrics-grid { gap: var(--space-2); }
  .metric-card { padding: var(--space-3); }
  .trends-row { grid-template-columns: repeat(2, 1fr); }
  .page-body { padding: var(--space-3) var(--space-2); }
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  padding: var(--space-5) var(--space-8);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  text-align: right;
}
.site-footer a { color: var(--color-text-faint); }
.site-footer a:hover { color: var(--color-text-muted); }

/* ============================================================
   MEMBER AUTOCOMPLETE DROPDOWN
   ============================================================ */
.member-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  max-height: 220px;
  overflow-y: auto;
}

/* ============================================================
   DASHBOARD — Hero band
   ============================================================ */
.dash-hero {
  background: #1a2535;
  color: #fff;
  padding: var(--space-8) var(--space-8) var(--space-6);
}
.dash-hero-inner { max-width: 1400px; }
.dash-hero-top { margin-bottom: var(--space-1); }
.dash-hero-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(255,255,255,0.42);
  text-transform: uppercase;
}
.dash-hero-title {
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-display);
  color: #fff;
  margin: var(--space-2) 0 var(--space-1);
  letter-spacing: -0.01em;
}
.dash-hero-sub {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-bottom: var(--space-6);
  max-width: 560px;
  line-height: 1.5;
}
.dash-hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.dash-hero-stat {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.dash-hero-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.38);
  margin-bottom: 6px;
}
.dash-hero-stat-value {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  color: #fff;
  margin-bottom: 5px;
  font-family: var(--font-display);
  letter-spacing: -0.02em;
}
.dash-hero-stat-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.32);
  line-height: 1.4;
}

/* ============================================================
   DASHBOARD — Body layout
   ============================================================ */
.dash-body {
  padding: var(--space-6) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 1200px;
}
.dash-section-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
}
.dash-section-header {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}
.dash-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b5864e;  /* amber accent */
}
.dash-section-sub {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.dash-section-title {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  margin: var(--space-1) 0 var(--space-1);
  letter-spacing: -0.01em;
}
.dash-badge {
  margin-left: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dash-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

/* ============================================================
   DASHBOARD — Portfolio Context
   ============================================================ */
.portfolio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: start;
}
.portfolio-donut-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}
.portfolio-donut-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  text-align: center;
}
.portfolio-list-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.portfolio-list-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: var(--space-2);
}
.portfolio-bar-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.portfolio-bar-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
}
.portfolio-bar-label {
  min-width: 70px;
  max-width: 90px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.portfolio-bar-track {
  flex: 1;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.portfolio-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: #1a56db;
  transition: width 0.4s ease;
}
.portfolio-bar-fill--alt { background: #7c3aed; }
.portfolio-bar-val {
  min-width: 22px;
  text-align: right;
  font-weight: 700;
  color: var(--color-text-base);
  font-size: 11px;
}

/* ============================================================
   DASHBOARD — Movement grid
   ============================================================ */
.movement-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
.movement-stat {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  position: relative;
}
.movement-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: 6px;
}
.movement-label .mv-arrow {
  font-size: 13px;
  line-height: 1;
}
.movement-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--font-display);
  color: var(--color-text);
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -0.02em;
}
.movement-value.positive { color: #2e6b47; }
.movement-value.negative { color: #a33030; }
.movement-sub {
  font-size: 10px;
  color: var(--color-text-faint);
  line-height: 1.4;
}

/* ============================================================
   GUIDES
   ============================================================ */
.guides-wrap {
  padding: var(--space-8);
  max-width: 960px;
}
.guides-header { margin-bottom: var(--space-6); }
.guides-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-base);
  margin-bottom: var(--space-1);
}
.guides-subtitle {
  font-size: 13px;
  color: var(--color-text-muted);
}
.guides-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
}
.guide-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.15s;
}
.guide-card:hover {
  box-shadow: 0 4px 18px rgba(26,86,219,0.10);
  border-color: #1a56db;
  transform: translateY(-2px);
}
.guide-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: rgba(26,86,219,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a56db;
  margin-bottom: var(--space-3);
}
.guide-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-base);
  margin-bottom: var(--space-1);
}
.guide-card-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.guide-back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: var(--space-5);
  transition: border-color 0.15s, color 0.15s;
}
.guide-back-btn:hover { border-color: #1a56db; color: #1a56db; }
.guide-content-body {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-8);
}
.guide-content-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text-base);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.guide-content-body h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text-base);
  margin: var(--space-5) 0 var(--space-2);
}
.guide-content-body h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: var(--space-4) 0 var(--space-2);
}
.guide-content-body p, .guide-content-body li {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.7;
}
.guide-content-body ul, .guide-content-body ol {
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.guide-content-body strong { color: var(--color-text-base); }

/* ============================================================
   RESPONSIVE — Dashboard + Guides
   ============================================================ */
@media (max-width: 900px) {
  .portfolio-grid { grid-template-columns: 1fr 1fr; }
  .dash-two-col { grid-template-columns: 1fr; }
  .guides-card-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .dash-hero { padding: var(--space-5) var(--space-4) var(--space-4); }
  .dash-hero-stats { gap: var(--space-3); grid-template-columns: repeat(2, 1fr); }
  .dash-hero-stat { padding: var(--space-3) var(--space-4); }
  .dash-hero-stat-value { font-size: 22px; }
  .dash-body { padding: var(--space-4) var(--space-4); gap: var(--space-4); }
  .portfolio-grid { grid-template-columns: 1fr 1fr; gap: var(--space-3); }
  .movement-grid { grid-template-columns: 1fr 1fr; }
  .guides-wrap { padding: var(--space-5) var(--space-4); }
  .guides-card-grid { grid-template-columns: 1fr; }
  .guide-content-body { padding: var(--space-5) var(--space-4); }
}

.portfolio-donut-sub {
  font-size: 10px;
  color: var(--color-text-faint);
  text-align: center;
  margin-bottom: var(--space-2);
}

/* ============================================================
   PORTFOLIO CONTEXT — sub-cards 2×2
   ============================================================ */
.portfolio-sub-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.portfolio-sub-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
}
.portfolio-sub-title {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  margin-bottom: 4px;
}
.portfolio-sub-desc {
  font-size: 11px;
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
  line-height: 1.4;
}
.portfolio-donut-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.portfolio-legend-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.portfolio-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  gap: var(--space-2);
}
.portfolio-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.portfolio-legend-name {
  flex: 1;
  color: var(--color-text-muted);
  font-size: 12px;
}
.portfolio-legend-val {
  font-weight: 700;
  color: var(--color-text);
  font-size: 12px;
  min-width: 24px;
  text-align: right;
}

/* ============================================================
   DEADLINE VISIBILITY — Calendar grid
   ============================================================ */
.deadline-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.deadline-badges {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}
.deadline-badge {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}
.cal-month {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-3);
}
.cal-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  gap: var(--space-1);
}
.cal-month-name {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
}
.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 4px;
}
.cal-weekday {
  text-align: center;
  font-size: 9px;
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 0;
}
.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 28px;
  padding: 3px 2px;
  border-radius: var(--radius-sm);
  cursor: default;
  position: relative;
}
.cal-day.has-event { cursor: pointer; }
.cal-day.has-event:hover { background: var(--color-surface-2); }
.cal-day.is-today .cal-day-num {
  background: #1a2535;
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day-num {
  font-size: 11px;
  color: var(--color-text-muted);
  line-height: 1;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day.empty .cal-day-num { color: transparent; }
.cal-dots {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 2px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #1a2535;
  flex-shrink: 0;
}
.cal-dot.listing { background: #4a6b8a; }

/* ============================================================
   UPCOMING MATTERS — Table
   ============================================================ */
.upcoming-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  gap: var(--space-3);
}
.upcoming-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
}
.upcoming-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.upcoming-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.upcoming-table th {
  background: var(--color-surface-2);
  padding: 8px 12px;
  text-align: left;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}
.upcoming-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-divider);
  color: var(--color-text-muted);
  vertical-align: top;
  line-height: 1.4;
}
.upcoming-table tr:last-child td { border-bottom: none; }
.upcoming-table .td-project {
  font-weight: 600;
  color: var(--color-text);
}
.upcoming-table .td-date { color: var(--color-text); font-weight: 600; white-space: nowrap; }
.type-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}
.type-pill.filing  { color: #1a2535; background: #e8e2da; border-color: #ccc2b5; }
.type-pill.listing { color: #1a5c80; background: #dce8f0; border-color: #b0c8d8; }
.show-more-btn {
  display: block;
  width: 100%;
  padding: var(--space-3);
  background: none;
  border: none;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}
.show-more-btn:hover { background: var(--color-surface-2); color: var(--color-text); }

/* ============================================================
   CAPACITY REVIEW — Heatmap grid
   ============================================================ */
.heatmap-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.heatmap-section-title {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text);
  margin: var(--space-1) 0 var(--space-1);
}
.heatmap-section-sub {
  font-size: 12px;
  color: var(--color-text-muted);
}
.heatmap-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.heatmap-ctrl-btn {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.heatmap-ctrl-btn:hover { background: var(--color-surface); color: var(--color-text); }
.heatmap-groups-badge {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.heatmap-group {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-3);
  overflow: hidden;
}
.heatmap-group-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 16px;
  background: var(--color-surface-2);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  user-select: none;
}
.heatmap-group-header:hover { background: var(--color-surface-offset); }
.heatmap-group-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}
.heatmap-group-badge {
  background: var(--color-border);
  color: var(--color-text-muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 600;
}
.heatmap-group-chevron {
  margin-left: auto;
  color: var(--color-text-faint);
  transition: transform 0.2s;
  font-size: 12px;
}
.heatmap-group.collapsed .heatmap-group-chevron { transform: rotate(-90deg); }
.heatmap-group.collapsed .heatmap-group-body { display: none; }
.heatmap-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.heatmap-table th {
  background: var(--color-surface-2);
  padding: 8px 12px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}
.heatmap-table th:first-child { text-align: left; min-width: 130px; }
.heatmap-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-divider);
  text-align: center;
  vertical-align: middle;
}
.heatmap-table td:first-child {
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  font-size: 12px;
}
.heatmap-table tr:last-child td { border-bottom: none; }
.hm-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  cursor: default;
}
.hm-cell.empty {
  background: #e5ddd4;
  color: transparent;
}
.hm-cell.load-light  { background: #8ba8c0; color: #fff; }  /* 1-2 */
.hm-cell.load-medium { background: #b85c5c; color: #fff; }  /* 3-4 */
.hm-cell.load-high   { background: #8b2e2e; color: #fff; }  /* 5+ */

/* ============================================================
   FONT IMPORT — add Playfair Display
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&display=swap');

/* ============================================================
   PORTFOLIO CONTEXT — plain list (sectors / side)
   ============================================================ */
.portfolio-plain-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: var(--space-2);
}

/* ============================================================
   RESPONSIVE UPDATES for portfolio-sub-grid + cal-grid
   ============================================================ */
@media (max-width: 900px) {
  .portfolio-sub-grid { grid-template-columns: 1fr 1fr; }
  .cal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .portfolio-sub-grid { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: 1fr; }
  .heatmap-table { font-size: 10px; }
  .hm-cell { width: 22px; height: 22px; font-size: 9px; }
  .upcoming-table { font-size: 11px; }
  .upcoming-table th, .upcoming-table td { padding: 6px 8px; }
}

/* ── Refresh button spin animation ─────────────────────────── */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
