/**
 * Ingefy Design System — Core Tokens
 * ====================================
 *
 * Visual direction: Fiscal.ai / Koyfin / Bloomberg terminal
 * Principle: density is a feature, dark is default, accent ≠ bull
 *
 * ADDING A NEW TOKEN
 * ------------------
 * 1. Add to :root (light value)
 * 2. Add to .dark (dark value)
 * 3. Use via var(--token-name) — NEVER hardcode hex in component files
 *
 * KEY DISTINCTIONS
 * ----------------
 * --color-accent  = deep editorial green (UI chrome, branding, CTAs)
 * --color-bull    = vivid financial green (positive price movements, gains)
 * These are intentionally different. A CTA must not look like a ticker in the green.
 *
 * CONVENTION: NO HARDCODED HEX IN COMPONENTS
 * -------------------------------------------
 * WRONG:  color: #1F4E3D;
 * RIGHT:  color: var(--color-accent);
 * Verify: grep -rn "#[0-9a-fA-F]\{6\}" public/ (should only hit this file)
 */

/* ── Google Fonts (typography task owns this — do not modify) ── */
@import url('https://fonts.googleapis.com/css2?family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Source+Serif+4:wght@400;600&display=swap');

/* ═══════════════════════════════════════════
   LIGHT MODE TOKENS
   ═══════════════════════════════════════════ */
:root {
  /* === Surfaces === */
  --color-ink: 14 17 22;                  /* #0E1116 — primary text, structural UI */
  --color-paper: 250 250 247;             /* #FAFAF7 — page background */
  --color-paper-elevated: 255 255 255;    /* #FFFFFF — cards, modals */
  --color-muted: 107 114 128;             /* #6B7280 — secondary text */
  --color-rule: 229 229 224;              /* #E5E5E0 — borders, dividers */

  /* === Editorial Accent (UI chrome, branding, CTAs) === */
  --color-accent: 31 78 61;              /* #1F4E3D — deep green */
  --color-accent-soft: 232 240 236;      /* #E8F0EC — accent background */
  --color-accent-fg: 255 255 255;        /* text on accent */

  /* === Financial Data (semantic — NOT for UI chrome) === */
  --color-bull: 14 124 58;               /* #0E7C3A — vivid green, positive movements */
  --color-bull-soft: 220 245 230;        /* subtle bull background */
  --color-bear: 178 58 58;               /* #B23A3A — terracotta red */
  --color-bear-soft: 248 230 230;        /* subtle bear background */
  --color-warn: 184 134 46;              /* #B8862E — old gold */
  --color-warn-soft: 250 240 215;
  --color-info: 61 90 128;               /* #3D5A80 — slate blue */
  --color-info-soft: 225 232 245;

  /* === Semantic Aliases === */
  --color-foreground: var(--color-ink);
  --color-background: var(--color-paper);
  --color-card: var(--color-paper-elevated);
  --color-border: var(--color-rule);

  /* === Raw hex values (for use with rgba) === */
  --hex-ink: #0E1116;
  --hex-paper: #FAFAF7;
  --hex-paper-elevated: #FFFFFF;
  --hex-muted: #6B7280;
  --hex-rule: #E5E5E0;
  --hex-accent: #1F4E3D;
  --hex-accent-soft: #E8F0EC;
  --hex-bull: #0E7C3A;
  --hex-bull-soft: #DCF5E6;
  --hex-bear: #B23A3A;
  --hex-bear-soft: #F8E6E6;
  --hex-warn: #B8862E;
  --hex-warn-soft: #FAF0D7;
  --hex-info: #3D5A80;
  --hex-info-soft: #E1E8F5;
  --hex-background: #FAFAF7;

  /* === Layout Constants === */
  --sidebar-width: 240px;
  --sidebar-width-collapsed: 64px;
  --content-max-width: 1440px;
  --topbar-height: 48px;
  --form-max-width: 720px;
  --prose-max-width: 680px;

  /* === Spacing Scale === */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* === Radius === */
  --radius-sm: 4px;
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* === Shadows (light mode) === */
  --shadow-sm: 0 1px 2px rgba(14, 17, 22, 0.06);
  --shadow: 0 1px 4px rgba(14, 17, 22, 0.08), 0 4px 12px rgba(14, 17, 22, 0.04);
  --shadow-md: 0 4px 16px rgba(14, 17, 22, 0.1), 0 1px 4px rgba(14, 17, 22, 0.06);
  --shadow-lg: 0 8px 32px rgba(14, 17, 22, 0.12), 0 2px 8px rgba(14, 17, 22, 0.06);

  /* === Transition === */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ═══════════════════════════════════════════
   DARK MODE TOKENS
   ═══════════════════════════════════════════
   Bloomberg-like — very dark, not pure black.
   Toggled by adding .dark class to <html>.
   ═══════════════════════════════════════════ */
.dark {
  /* === Surfaces === */
  --color-ink: 232 232 228;              /* #E8E8E4 */
  --color-paper: 10 10 15;              /* #0A0A0F — slightly warmer than pure black */
  --color-paper-elevated: 22 26 33;     /* #161A21 */
  --color-muted: 148 156 168;           /* #949CA8 */
  --color-rule: 38 43 52;               /* #262B34 */

  /* === Editorial Accent (lighter for dark bg) === */
  --color-accent: 92 168 138;           /* #5CA88A */
  --color-accent-soft: 28 50 42;        /* dark accent tint */
  --color-accent-fg: 14 17 22;

  /* === Financial Data === */
  --color-bull: 80 200 120;             /* vivid but not neon */
  --color-bull-soft: 22 50 32;
  --color-bear: 220 100 100;
  --color-bear-soft: 60 25 25;
  --color-warn: 220 175 80;
  --color-warn-soft: 60 45 15;
  --color-info: 130 165 215;
  --color-info-soft: 25 38 60;

  /* === Raw hex values for dark mode === */
  --hex-ink: #E8E8E4;
  --hex-paper: #0A0A0F;
  --hex-paper-elevated: #161A21;
  --hex-muted: #949CA8;
  --hex-rule: #262B34;
  --hex-accent: #5CA88A;
  --hex-accent-soft: #1C322A;
  --hex-bull: #50C878;
  --hex-bull-soft: #163220;
  --hex-bear: #DC6464;
  --hex-bear-soft: #3C1919;
  --hex-warn: #DCAF50;
  --hex-warn-soft: #3C2D0F;
  --hex-info: #82A5D7;
  --hex-info-soft: #19263C;
  --hex-background: #0A0A0F;

  /* === Shadows (dark mode — subtler) === */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6), 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ═══════════════════════════════════════════
   BASE STYLES
   ═══════════════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter Tight', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  background-color: var(--hex-background);
  color: var(--hex-ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  transition: background-color var(--transition), color var(--transition);
}

/* ═══════════════════════════════════════════
   LAYOUT UTILITIES
   ═══════════════════════════════════════════ */

/* App shell: sidebar + main content */
.ds-app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
.ds-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background-color: var(--hex-paper-elevated);
  border-right: 1px solid var(--hex-rule);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition), min-width var(--transition);
  flex-shrink: 0;
}

.ds-sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
  min-width: var(--sidebar-width-collapsed);
}

/* Main area */
.ds-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Topbar */
.ds-topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background-color: var(--hex-paper-elevated);
  border-bottom: 1px solid var(--hex-rule);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
}

/* Content area */
.ds-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.ds-content-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
}

/* ═══════════════════════════════════════════
   COMPONENT TOKENS
   All components reference these; no hardcoded values
   ═══════════════════════════════════════════ */

/* Buttons */
.ds-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 14px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.ds-btn:focus-visible {
  outline: 2px solid var(--hex-accent);
  outline-offset: 2px;
}

/* Primary */
.ds-btn-primary {
  background-color: var(--hex-accent);
  color: white;
  border-color: var(--hex-accent);
}
.ds-btn-primary:hover {
  opacity: 0.88;
}

/* Secondary */
.ds-btn-secondary {
  background-color: var(--hex-paper-elevated);
  color: var(--hex-ink);
  border-color: var(--hex-rule);
}
.ds-btn-secondary:hover {
  background-color: var(--hex-accent-soft);
}

/* Ghost */
.ds-btn-ghost {
  background-color: transparent;
  color: var(--hex-muted);
  border-color: transparent;
}
.ds-btn-ghost:hover {
  background-color: var(--hex-accent-soft);
  color: var(--hex-ink);
}

/* Destructive */
.ds-btn-destructive {
  background-color: transparent;
  color: var(--hex-bear);
  border-color: var(--hex-rule);
}
.ds-btn-destructive:hover {
  background-color: var(--hex-bear-soft);
  border-color: var(--hex-bear);
}

/* Cards */
.ds-card {
  background-color: var(--hex-paper-elevated);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.ds-card-padded {
  padding: var(--space-5) var(--space-6);
}

/* Badges */
.ds-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 100px;
  letter-spacing: 0.02em;
}

.ds-badge-bull {
  background-color: var(--hex-bull-soft);
  color: var(--hex-bull);
}

.ds-badge-bear {
  background-color: var(--hex-bear-soft);
  color: var(--hex-bear);
}

.ds-badge-warn {
  background-color: var(--hex-warn-soft);
  color: var(--hex-warn);
}

.ds-badge-info {
  background-color: var(--hex-info-soft);
  color: var(--hex-info);
}

.ds-badge-neutral {
  background-color: var(--hex-accent-soft);
  color: var(--hex-muted);
}

/* Inputs */
.ds-input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.ds-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--hex-muted);
}

.ds-input {
  padding: 8px 12px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 14px;
  background-color: var(--hex-paper-elevated);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius);
  color: var(--hex-ink);
  width: 100%;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.ds-input::placeholder {
  color: var(--hex-muted);
}

.ds-input:focus {
  border-color: var(--hex-accent);
  box-shadow: 0 0 0 3px var(--hex-accent-soft);
}

/* Financial Table */
.ds-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ds-table thead th {
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--hex-muted);
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--hex-rule);
  white-space: nowrap;
}

.ds-table thead th:first-child {
  text-align: left;
}

.ds-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--hex-rule);
  color: var(--hex-ink);
  text-align: right;
}

.ds-table tbody td:first-child {
  text-align: left;
  font-weight: 500;
}

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

.ds-table tbody tr:hover {
  background-color: var(--hex-accent-soft);
}

.ds-numeric {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.ds-bull { color: var(--hex-bull); }
.ds-bear { color: var(--hex-bear); }
.ds-warn { color: var(--hex-warn); }
.ds-info { color: var(--hex-info); }
.ds-muted { color: var(--hex-muted); }

/* ═══════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════ */
.ds-theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background-color: var(--hex-paper);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius);
  padding: 3px;
}

.ds-theme-toggle button {
  padding: 4px 10px;
  font-family: 'Inter Tight', sans-serif;
  font-size: 11px;
  font-weight: 500;
  color: var(--hex-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1;
}

.ds-theme-toggle button.active {
  background-color: var(--hex-paper-elevated);
  color: var(--hex-ink);
  box-shadow: var(--shadow-sm);
}

.ds-theme-toggle button:hover:not(.active) {
  color: var(--hex-ink);
}

/* ═══════════════════════════════════════════
   SIDEBAR NAV
   ═══════════════════════════════════════════ */
.ds-sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--hex-rule);
  text-decoration: none;
  color: var(--hex-ink);
  min-height: 56px;
  overflow: hidden;
}

.ds-sidebar-logo-mark {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  background-color: var(--hex-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  font-family: 'Inter Tight', sans-serif;
}

.ds-sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.5px;
  white-space: nowrap;
  transition: opacity var(--transition), width var(--transition);
}

.ds-sidebar.collapsed .ds-sidebar-logo-text {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.ds-sidebar-nav {
  flex: 1;
  padding: var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.ds-nav-section-label {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--hex-muted);
  padding: var(--space-3) var(--space-3) var(--space-2);
  white-space: nowrap;
  transition: opacity var(--transition);
}

.ds-sidebar.collapsed .ds-nav-section-label {
  opacity: 0;
}

.ds-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius);
  color: var(--hex-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  min-height: 36px;
}

.ds-nav-item:hover {
  background-color: var(--hex-accent-soft);
  color: var(--hex-ink);
}

.ds-nav-item.active {
  background-color: var(--hex-accent-soft);
  color: var(--hex-accent);
}

.ds-nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ds-nav-item-label {
  white-space: nowrap;
  transition: opacity var(--transition), width var(--transition);
}

.ds-sidebar.collapsed .ds-nav-item-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.ds-sidebar-footer {
  padding: var(--space-4) var(--space-2);
  border-top: 1px solid var(--hex-rule);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  overflow: hidden;
}

.ds-sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-3);
  border-radius: var(--radius);
  color: var(--hex-muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Inter Tight', sans-serif;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: all var(--transition-fast);
  min-height: 36px;
}

.ds-sidebar-collapse-btn:hover {
  background-color: var(--hex-accent-soft);
  color: var(--hex-ink);
}

.ds-sidebar-collapse-btn-label {
  transition: opacity var(--transition), width var(--transition);
}

.ds-sidebar.collapsed .ds-sidebar-collapse-btn-label {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* Tooltip for collapsed sidebar items */
.ds-sidebar.collapsed .ds-nav-item {
  position: relative;
}

.ds-sidebar.collapsed .ds-nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-width-collapsed) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background-color: var(--hex-ink);
  color: var(--hex-paper);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 100;
}

.ds-sidebar.collapsed .ds-nav-item:hover::after {
  opacity: 1;
}

/* ═══════════════════════════════════════════
   ANTI-FLASH: applied by inline script before render
   ═══════════════════════════════════════════ */
/* (handled via JS in <head>) */

/* ═══════════════════════════════════════════
   CONTROL SIZE TOKENS
   ═══════════════════════════════════════════ */
:root {
  --control-height: 36px;
  --control-height-sm: 28px;
  --control-height-lg: 44px;
  --control-px: 12px;
  --control-font-size: 14px;

  /* Elevated / modal shadows (Ingefy DS) */
  --shadow-elevated: 0 1px 2px rgba(14, 17, 22, 0.04), 0 4px 12px rgba(14, 17, 22, 0.06);
  --shadow-modal: 0 4px 24px rgba(14, 17, 22, 0.12);

  /* Animation */
  --ease-ingefy: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dark {
  --shadow-elevated: 0 1px 2px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-modal: 0 4px 24px rgba(0, 0, 0, 0.5);
}

/* ── Focus ring utility ─────────────────────── */
.focus-ring:focus-visible {
  outline: 2px solid var(--hex-accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════
   BUTTON — size variants
   ═══════════════════════════════════════════ */

/* Standard control height */
.ds-btn-default {
  height: var(--control-height);
  padding: 0 16px;
  font-size: 14px;
}

.ds-btn-sm {
  height: var(--control-height-sm);
  padding: 0 12px;
  font-size: 12px;
}

.ds-btn-lg {
  height: var(--control-height-lg);
  padding: 0 24px;
  font-size: 16px;
}

.ds-btn-icon {
  height: var(--control-height);
  width: var(--control-height);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════
   SELECT — native <select> styled to match input
   ═══════════════════════════════════════════ */
.ds-select {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  height: var(--control-height);
  width: 100%;
  align-items: center;
  padding: 0 32px 0 var(--control-px);
  font-family: 'Inter Tight', sans-serif;
  font-size: var(--control-font-size);
  background-color: var(--hex-paper-elevated);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius);
  color: var(--hex-ink);
  cursor: pointer;
  transition: border-color var(--transition-fast) var(--ease-ingefy),
              box-shadow var(--transition-fast) var(--ease-ingefy);
  outline: none;
}

.ds-select:focus-visible {
  border-color: var(--hex-accent);
  box-shadow: 0 0 0 2px var(--hex-accent-soft);
  outline: 2px solid var(--hex-accent);
  outline-offset: 2px;
}

.ds-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ds-select[aria-invalid="true"] {
  border-color: var(--hex-bear);
}

/* Custom select wrapper (for styled dropdown trigger+panel) */
.ds-select-wrapper {
  position: relative;
  width: 100%;
}

/* ═══════════════════════════════════════════
   DROPDOWN MENU
   ═══════════════════════════════════════════ */
.ds-dropdown {
  position: relative;
  display: inline-block;
}

.ds-dropdown-content {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 180px;
  background-color: var(--hex-paper-elevated);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.97) translateY(-4px);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 150ms var(--ease-ingefy),
              transform 150ms var(--ease-ingefy);
}

.ds-dropdown-content.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.ds-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: 'Inter Tight', sans-serif;
  color: var(--hex-ink);
  text-decoration: none;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background-color 150ms var(--ease-ingefy);
}

.ds-dropdown-item:hover {
  background-color: var(--hex-accent-soft);
}

.ds-dropdown-item:focus-visible {
  outline: 2px solid var(--hex-accent);
  outline-offset: -2px;
  background-color: var(--hex-accent-soft);
}

.ds-dropdown-item.destructive {
  color: var(--hex-bear);
}

.ds-dropdown-item.destructive:hover {
  background-color: var(--hex-bear-soft);
}

.ds-dropdown-separator {
  height: 1px;
  background-color: var(--hex-rule);
  margin: 4px 0;
}

.ds-dropdown-label {
  padding: 6px 12px 4px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--hex-muted);
}

/* ═══════════════════════════════════════════
   TOOLTIP
   ═══════════════════════════════════════════ */
.ds-tooltip-wrapper {
  position: relative;
  display: inline-flex;
}

.ds-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.96);
  background-color: var(--hex-ink);
  color: var(--hex-paper);
  font-size: 12px;
  font-family: 'Inter Tight', sans-serif;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  max-width: 320px;
  white-space: normal;
  text-align: center;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  transition: opacity 150ms var(--ease-ingefy),
              transform 150ms var(--ease-ingefy);
}

/* Position variants */
.ds-tooltip.bottom {
  bottom: auto;
  top: calc(100% + 6px);
  transform: translateX(-50%) scale(0.96);
}

.ds-tooltip.bottom.visible {
  transform: translateX(-50%) scale(1);
}

.ds-tooltip.left {
  bottom: auto;
  top: 50%;
  left: auto;
  right: calc(100% + 6px);
  transform: translateY(-50%) scale(0.96);
}

.ds-tooltip.left.visible {
  transform: translateY(-50%) scale(1);
}

.ds-tooltip.right {
  bottom: auto;
  top: 50%;
  left: calc(100% + 6px);
  transform: translateY(-50%) scale(0.96);
}

.ds-tooltip.right.visible {
  transform: translateY(-50%) scale(1);
}

.ds-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.ds-tooltip-wrapper:hover .ds-tooltip {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.ds-tooltip-wrapper:hover .ds-tooltip.bottom {
  transform: translateX(-50%) scale(1);
}

/* ═══════════════════════════════════════════
   MODAL / DIALOG
   ═══════════════════════════════════════════ */
.ds-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms var(--ease-ingefy);
}

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

.ds-modal {
  position: relative;
  width: 100%;
  max-width: 640px;
  background-color: var(--hex-paper-elevated);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-modal);
  padding: 24px;
  transform: scale(0.97) translateY(-8px);
  opacity: 0;
  transition: transform 200ms var(--ease-ingefy),
              opacity 200ms var(--ease-ingefy);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.ds-modal-overlay.open .ds-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.ds-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.ds-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--hex-ink);
  line-height: 1.3;
}

.ds-modal-description {
  font-size: 13px;
  color: var(--hex-muted);
  margin-top: 4px;
  line-height: 1.5;
}

.ds-modal-body {
  margin-bottom: 24px;
}

.ds-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--hex-rule);
}

.ds-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius);
  background: none;
  border: none;
  color: var(--hex-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms var(--ease-ingefy),
              color 150ms var(--ease-ingefy);
}

.ds-modal-close:hover {
  background-color: var(--hex-accent-soft);
  color: var(--hex-ink);
}

.ds-modal-close:focus-visible {
  outline: 2px solid var(--hex-accent);
  outline-offset: 2px;
}

/* Modal size variants */
.ds-modal.lg { max-width: 768px; }
.ds-modal.xl { max-width: 960px; }
.ds-modal.sm { max-width: 440px; }

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */
.ds-toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
  width: calc(100vw - 48px);
  pointer-events: none;
}

.ds-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  background-color: var(--hex-paper-elevated);
  border: 1px solid var(--hex-rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-elevated);
  pointer-events: auto;
  transform: translateX(calc(100% + 32px));
  opacity: 0;
  transition: transform 250ms var(--ease-ingefy),
              opacity 200ms var(--ease-ingefy);
}

.ds-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.ds-toast.hide {
  transform: translateX(calc(100% + 32px));
  opacity: 0;
}

/* Variant accent borders */
.ds-toast.success { border-left: 3px solid var(--hex-bull); }
.ds-toast.error   { border-left: 3px solid var(--hex-bear); }
.ds-toast.warn    { border-left: 3px solid var(--hex-warn); }
.ds-toast.info    { border-left: 3px solid var(--hex-info); }

.ds-toast-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.ds-toast-icon.success { color: var(--hex-bull); }
.ds-toast-icon.error   { color: var(--hex-bear); }
.ds-toast-icon.warn    { color: var(--hex-warn); }
.ds-toast-icon.info    { color: var(--hex-info); }

.ds-toast-content {
  flex: 1;
  min-width: 0;
}

.ds-toast-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--hex-ink);
  line-height: 1.3;
}

.ds-toast-description {
  font-size: 12px;
  color: var(--hex-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.ds-toast-close {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--hex-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background-color 150ms var(--ease-ingefy),
              color 150ms var(--ease-ingefy);
  padding: 0;
  margin-left: 4px;
}

.ds-toast-close:hover {
  background-color: var(--hex-accent-soft);
  color: var(--hex-ink);
}

/* ═══════════════════════════════════════════
   BADGE — updated with outline variant
   ═══════════════════════════════════════════ */
.ds-badge-outline {
  background-color: transparent;
  color: var(--hex-muted);
  border: 1px solid var(--hex-rule);
}

.ds-badge-accent {
  background-color: var(--hex-accent-soft);
  color: var(--hex-accent);
}

/* ═══════════════════════════════════════════
   AVATAR
   ═══════════════════════════════════════════ */
.ds-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: var(--hex-accent-soft);
  overflow: hidden;
  flex-shrink: 0;
  /* default size */
  width: 32px;
  height: 32px;
  font-size: 13px;
}

.ds-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.ds-avatar-fallback {
  font-weight: 500;
  color: var(--hex-accent);
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
  font-family: 'Inter Tight', sans-serif;
}

/* Avatar size variants */
.ds-avatar-sm  { width: 24px; height: 24px; font-size: 10px; }
.ds-avatar-md  { width: 32px; height: 32px; font-size: 13px; }
.ds-avatar-lg  { width: 40px; height: 40px; font-size: 16px; }
.ds-avatar-xl  { width: 56px; height: 56px; font-size: 20px; }

/* ═══════════════════════════════════════════
   TABLE — data-numeric and data-tone attributes
   ═══════════════════════════════════════════ */

/* Numeric cells: right-align + mono */
.ds-table td[data-numeric],
.ds-table th[data-numeric] {
  text-align: right;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

/* Financial tone on cells */
.ds-table td[data-tone="bull"] { color: var(--hex-bull); }
.ds-table td[data-tone="bear"] { color: var(--hex-bear); }
.ds-table td[data-tone="warn"] { color: var(--hex-warn); }
.ds-table td[data-tone="info"] { color: var(--hex-info); }
.ds-table td[data-tone="muted"] { color: var(--hex-muted); }

/* Sticky table header */
.ds-table-sticky thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--hex-paper-elevated);
}

/* Selected row state */
.ds-table tbody tr[data-selected="true"] {
  background-color: var(--hex-accent-soft);
}

/* ═══════════════════════════════════════════
   INPUT — enhanced states
   ═══════════════════════════════════════════ */

/* Height token on inputs */
.ds-input {
  height: var(--control-height);
  padding: 0 var(--control-px);
  font-size: var(--control-font-size);
}

.ds-input[aria-invalid="true"] {
  border-color: var(--hex-bear);
}

.ds-input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px var(--hex-bear-soft);
}

.ds-input:read-only {
  background-color: var(--hex-paper);
  cursor: default;
}

/* ═══════════════════════════════════════════
   FORM INPUT GROUP — error message
   ═══════════════════════════════════════════ */
.ds-input-error {
  font-size: 12px;
  color: var(--hex-bear);
  margin-top: 4px;
}

/* ═══════════════════════════════════════════
   CARD — elevated variant
   ═══════════════════════════════════════════ */
.ds-card-elevated {
  box-shadow: var(--shadow-elevated);
}

/* ═══════════════════════════════════════════
   DIVIDER UTILITY
   ═══════════════════════════════════════════ */
.ds-divider {
  height: 1px;
  background-color: var(--hex-rule);
  border: none;
  margin: 0;
}

/* ═══════════════════════════════════════════
   KEYBOARD FOCUS OUTLINE (global, accessible)
   ═══════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--hex-accent);
  outline-offset: 2px;
}

/* Suppress default focus outline on mouse clicks */
:focus:not(:focus-visible) {
  outline: none;
}
