/* ============================================================
   Ideal Direct — SaaS Design System
   Extends the brand tokens with app-context tokens, component
   styles, and a full light/dark theme.
   ============================================================ */

/* The brand tokens this file extends (assets/colors_and_type.css) used to be
   pulled in with @import here. That serialised the download — the browser had
   to fetch and parse this file before it even discovered that one — and the
   @import URL couldn't carry a ?v= hash, so it revalidated on every page load.
   It's now a <link> in _base_layout.html, ordered ahead of this file to keep
   the same cascade. Keep it that way; don't reinstate the @import. */

/* ============================================================
   1. SaaS-layer tokens (LIGHT — default)
   ============================================================ */
:root {
  /* Font theme — swappable via the picker in the topbar. Default: Inter. */
  --app-font: 'Inter', 'Montserrat', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --app-font-display: var(--app-font);
  --app-font-num: var(--app-font);

  /* App type scale — distinct from marketing display scale.
     SaaS apps need denser, UI-friendly type. */
  --app-fs-display: 32px;  --app-lh-display: 40px;
  --app-fs-h1:      24px;  --app-lh-h1:      32px;
  --app-fs-h2:      18px;  --app-lh-h2:      26px;
  --app-fs-h3:      15px;  --app-lh-h3:      22px;
  --app-fs-body:    14px;  --app-lh-body:    21px;
  --app-fs-sm:      13px;  --app-lh-sm:      18px;
  --app-fs-xs:      12px;  --app-lh-xs:      16px;
  --app-fs-tiny:    11px;  --app-lh-tiny:    14px;

  /* Semantic surfaces (LIGHT) */
  --app-bg:         #FAFBFD;
  --app-bg-elev:    #FFFFFF;
  --app-bg-sunken:  #F4F6F9;
  --app-bg-hover:   #F7F9FB;
  --app-bg-active:  #E6E9EE;
  --app-overlay:    rgba(14,33,51,0.40);

  /* Sidebar / topbar (LIGHT) */
  --app-chrome:     #FFFFFF;
  --app-chrome-fg:  #0E2133;
  --app-chrome-fg-muted: #6B7688;
  --app-chrome-border:   #E6E9EE;
  --app-chrome-hover:    #F4F6F9;
  --app-chrome-active:   #E6E9EE;

  /* Text (LIGHT) */
  --app-fg:         #0E2133;
  --app-fg-2:       #3D4A5E;
  --app-fg-3:       #6B7688;
  --app-fg-muted:   #B6BDC8;
  --app-fg-inverse: #FFFFFF;
  --app-fg-accent:  #0E2133;  /* Brand accent for non-critical highlights (selected, focus). Red is reserved for danger. */
  --app-fg-link:    #393E77;

  /* Borders + dividers (LIGHT) */
  --app-border:     #E6E9EE;
  --app-border-strong: #B6BDC8;
  --app-focus:      #0E2133;
  --app-focus-ring: rgba(14,33,51,0.18);

  /* Status (LIGHT) */
  --app-success:       #1F8A5B;
  --app-success-bg:    #DCEFE5;
  --app-success-fg:    #0F4E33;
  --app-warning:       #C98A12;
  --app-warning-bg:    #FBEDD0;
  --app-warning-fg:    #6E4906;
  --app-danger:        #B82D10;
  --app-danger-bg:     #FBDFD6;
  --app-danger-fg:     #6E1B0A;
  --app-info:          #393E77;
  --app-info-bg:       #E1E3F1;
  --app-info-fg:       #1A1E40;

  /* Chart palette (LIGHT) — brand-led: navy primary; red only when explicitly needed */
  --chart-1: #0E2133;  /* Midnight Deep — primary data series */
  --chart-2: #393E77;  /* Midnight Blue */
  --chart-3: #1F8A5B;  /* Success green */
  --chart-4: #C98A12;  /* Warning gold */
  --chart-5: #6B7688;  /* Slate */
  --chart-6: #DF3918;  /* Vermillion — use only for emphasis (e.g. "alert" series) */

  /* Shadows (LIGHT) — cool-tinted to match brand */
  --app-shadow-xs: 0 1px 2px rgba(14,33,51,0.06);
  --app-shadow-sm: 0 2px 6px rgba(14,33,51,0.08);
  --app-shadow-md: 0 6px 20px rgba(14,33,51,0.10);
  --app-shadow-lg: 0 18px 40px -12px rgba(14,33,51,0.24);
  --app-shadow-pop: 0 8px 24px rgba(14,33,51,0.14), 0 2px 6px rgba(14,33,51,0.06);

  /* Motion */
  --t-fast:   120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base:   180ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow:   260ms cubic-bezier(0.4, 0, 0.2, 1);

  /* App layout */
  --sidebar-w: 280px;
  --topbar-h:  56px;

  color-scheme: light;

  /* SaaS radius override — tighter than the brand defaults (which lean
     marketing-soft). UI surfaces feel more precise with smaller corners. */
  --radius-xs: 2px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
}

/* ============================================================
   2. DARK theme — toggled via data-theme="dark" on <html>
   ============================================================ */
:root[data-theme="dark"] {
  --app-bg:         #0E1A2A;
  --app-bg-elev:    #11253A;
  --app-bg-sunken:  #060E1A;
  --app-bg-hover:   #122237;
  --app-bg-active:  #1E3A58;
  --app-overlay:    rgba(0,0,0,0.65);

  --app-chrome:        #0E2133;
  --app-chrome-fg:     #F4F6F9;
  --app-chrome-fg-muted:#6B7688;
  --app-chrome-border: #1E2A50;
  --app-chrome-hover:  #16304A;
  --app-chrome-active: #1E3A58;

  --app-fg:         #F4F6F9;
  --app-fg-2:       #B6BDC8;
  --app-fg-3:       #8893A4;
  --app-fg-muted:   #5B6678;
  --app-fg-inverse: #0E2133;
  --app-fg-accent:  #393E77;
  --app-fg-link:    #9BB8E3;

  --app-border:        #1E2A50;
  --app-border-strong: #2C3A66;
  --app-focus:         #F4F6F9;
  --app-focus-ring:    rgba(244,246,249,0.22);

  --app-success:       #4ABF85;
  --app-success-bg:    rgba(74,191,133,0.14);
  --app-success-fg:    #7DDBA9;
  --app-warning:       #E5A93C;
  --app-warning-bg:    rgba(229,169,60,0.14);
  --app-warning-fg:    #F2C977;
  --app-danger:        #FF6A47;
  --app-danger-bg:     rgba(255,106,71,0.14);
  --app-danger-fg:     #FF9678;
  --app-info:          #9BB8E3;
  --app-info-bg:       rgba(155,184,227,0.14);
  --app-info-fg:       #B7CDED;

  --chart-1: #F4F6F9;
  --chart-2: #9BB8E3;
  --chart-3: #4ABF85;
  --chart-4: #E5A93C;
  --chart-5: #8893A4;
  --chart-6: #FF7355;

  --app-shadow-xs: 0 1px 2px rgba(0,0,0,0.32);
  --app-shadow-sm: 0 2px 6px rgba(0,0,0,0.40);
  --app-shadow-md: 0 6px 20px rgba(0,0,0,0.45);
  --app-shadow-lg: 0 18px 40px -12px rgba(0,0,0,0.55);
  --app-shadow-pop: 0 12px 32px rgba(0,0,0,0.50), 0 2px 6px rgba(0,0,0,0.32);

  color-scheme: dark;
}

/* ============================================================
   3. Reset / base
   ============================================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--app-bg);
  color: var(--app-fg);
  font-family: var(--font-sans);
  font-size: var(--app-fs-body);
  line-height: var(--app-lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--t-base), color var(--t-base);
}
/* Override brand css headings — they hard-code --fg1 (light only).
   Force everything to inherit the theme-aware --app-fg. */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--app-fg);
}
button { font-family: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
code, kbd, pre { font-family: var(--font-mono); }

/* ============================================================
   4. App shell — sidebar + topbar + content
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ----- Sidebar ----- */
.sidebar {
  background: var(--app-chrome);
  border-right: 1px solid var(--app-chrome-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}
.sidebar .brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-bottom: 1px solid var(--app-chrome-border);
}
.sidebar .brand img { width: 28px; height: 28px; }
.sidebar .brand .name {
  font-weight: var(--fw-bold);
  font-size: 14px;
  letter-spacing: -0.01em;
  color: var(--app-chrome-fg);
}
.sidebar .brand .badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  background: var(--app-bg-sunken);
  color: var(--app-fg-3);
  padding: 3px 7px;
  border-radius: var(--radius-pill);
}
.sidebar .nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 32px;
}

/* Quick filter input at top of nav */
.sidebar .nav-search {
  position: relative;
  margin: 0 0 16px;
}
/* Search bars share ONE spec (see .table-search): 34px tall, radius-md,
   --app-border-strong, elevated bg, 13px text, a 15px leading icon at 11px in
   --app-fg-3, and the standard focus ring. */
.sidebar .nav-search input {
  width: 100%;
  height: 34px;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  padding: 0 12px 0 34px;
  font-size: 13px;
  color: var(--app-fg);
  outline: none;
  font-family: inherit;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.sidebar .nav-search input:focus {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.sidebar .nav-search input::placeholder { color: var(--app-fg-3); }
.sidebar .nav-search .ic {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--app-fg-3);
}
.sidebar .nav-search .kbd {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-family: var(--font-sans);
  color: var(--app-fg-3);
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: 4px;
  padding: 1px 5px;
}

/* Group header (always visible, no collapse) */
.sidebar .nav-group {
  margin-top: 20px;
  padding: 0 10px 6px;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--app-fg-3);
}
.sidebar .nav-group:first-of-type { margin-top: 0; }

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--app-fg-2);
  cursor: pointer;
  font-size: 13px;
  font-weight: var(--fw-regular);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  position: relative;
  line-height: 18px;
}
.sidebar .nav-item:hover {
  background: var(--app-chrome-hover);
  color: var(--app-fg);
}
.sidebar .nav-item.active {
  color: var(--app-fg);
  font-weight: var(--fw-medium);
  background: var(--app-chrome-active);
}
.sidebar .nav-item.active::before {
  content: "";
  position: absolute;
  left: -4px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--app-fg-accent);
  border-radius: 2px;
}
.sidebar .nav-item .count {
  margin-left: auto;
  font-size: 10px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
  font-variant-numeric: tabular-nums;
}
.sidebar .nav-item.hidden-by-filter { display: none; }

.sidebar .foot {
  padding: 12px;
  border-top: 1px solid var(--app-chrome-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .foot .avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-pill);
  background: var(--idl-gradient);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: white;
  font-weight: var(--fw-bold);
  font-size: 12px;
  letter-spacing: -0.01em;
}
.sidebar .foot .info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.sidebar .foot .info .who {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar .foot .info .role {
  font-size: 11px;
  color: var(--app-fg-3);
}
.sidebar .foot .icon-btn {
  flex-shrink: 0;
}

/* ----- Topbar ----- */
.topbar {
  height: var(--topbar-h);
  background: var(--app-chrome);
  border-bottom: 1px solid var(--app-chrome-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--app-fg-3);
}
.topbar .crumbs .sep { color: var(--app-fg-muted); }
.topbar .crumbs .current {
  color: var(--app-fg);
  font-weight: var(--fw-medium);
}
.topbar .search {
  flex: 1;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}
.topbar .search input {
  width: 100%;
  height: 32px;
  background: var(--app-bg-sunken);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0 12px 0 32px;
  font-size: 13px;
  color: var(--app-fg);
  outline: none;
  transition: all var(--t-fast);
}
.topbar .search input:focus {
  background: var(--app-bg-elev);
  border-color: var(--app-border-strong);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.topbar .search input::placeholder { color: var(--app-fg-3); }
.topbar .search .ic {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--app-fg-3);
  pointer-events: none;
}
.topbar .search .kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  color: var(--app-fg-3);
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: 4px;
  padding: 2px 6px;
}
.topbar .right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ----- Content area ----- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.content {
  padding: 24px 40px 120px;
  max-width: 1200px;
  width: 100%;
  scroll-behavior: smooth;
}

/* ----- In-page sub-tabs (within a component spec) ----- */
.subtabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 20px;
}
.subtabs .tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
  cursor: pointer;
  border: 0;
  background: transparent;
  position: relative;
  margin-bottom: -1px;
  transition: color var(--t-fast);
}
.subtabs .tab:hover { color: var(--app-fg); }
.subtabs .tab.active {
  color: var(--app-fg);
  border-bottom: 2px solid var(--app-fg-accent);
  font-weight: var(--fw-bold);
}

/* ============================================================
   5. Page header + section blocks
   ============================================================ */
.page-head .brand-lockup {
  margin: 0 0 22px;
  display: block;
}
.page-head .brand-lockup img {
  display: block;
  height: 44px;
  width: auto;
}
.page-head .brand-lockup .logo-dark { display: none; }
:root[data-theme="dark"] .page-head .brand-lockup .logo-light { display: none; }
:root[data-theme="dark"] .page-head .brand-lockup .logo-dark  { display: block; }

.page-head {
  padding: 24px 0 28px;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 40px;
}
.page-head .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
  letter-spacing: 0.04em;
  margin-bottom: 14px;
  text-transform: uppercase;
}
.page-head h1 {
  font-size: var(--app-fs-display);
  line-height: var(--app-lh-display);
  font-weight: var(--fw-black);
  letter-spacing: -0.025em;
  color: var(--app-fg);
  margin: 0 0 10px;
}
.page-head .lede {
  font-size: 15px;
  line-height: 24px;
  color: var(--app-fg-2);
  margin: 0;
  max-width: 68ch;
}
.page-head .meta {
  margin-top: 18px;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--app-fg-3);
}
.page-head .meta .k {
  font-family: var(--font-mono);
  color: var(--app-fg);
  margin-right: 6px;
}

/* Section block — one per anchor */
.spec {
  scroll-margin-top: calc(var(--topbar-h) + 16px);
  padding: 32px 0;
  border-top: 1px solid var(--app-border);
}
.spec:first-of-type { border-top: 0; padding-top: 0; }
.spec-head {
  margin-bottom: 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.spec-head h2 {
  font-size: 22px;
  line-height: 28px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--app-fg);
}
.spec-head .anchor {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
  letter-spacing: 0.04em;
}
.spec-sub {
  color: var(--app-fg-3);
  font-size: 13px;
  margin: 4px 0 24px;
  max-width: 68ch;
  line-height: 20px;
}
.spec-grid {
  display: grid;
  gap: 16px;
}
.spec-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.spec-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.spec-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Specimen card */
.specimen {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.specimen .legend {
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.specimen .legend .title {
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  letter-spacing: -0.005em;
}
.specimen .legend .meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
}
.specimen .stage {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.specimen .stage.col { flex-direction: column; align-items: stretch; }
.specimen .stage.center { justify-content: center; }
.specimen .caption {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--app-border);
  font-size: 12px;
  color: var(--app-fg-3);
  line-height: 18px;
}

/* ============================================================
   6. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-weight: var(--fw-medium);
  font-size: 13px;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 8px 14px;
  cursor: pointer;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.btn:disabled,
.btn[aria-disabled="true"] {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--app-fg-muted) !important;
  cursor: not-allowed;
  box-shadow: none !important;
}
.btn:disabled .ic,
.btn[aria-disabled="true"] .ic {
  color: var(--app-fg-muted);
  opacity: 0.6;
}
.btn:disabled:hover,
.btn[aria-disabled="true"]:hover {
  background: transparent !important;
  border-color: transparent !important;
}
.btn .ic { width: 14px; height: 14px; }

.btn-primary {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  font-weight: var(--fw-medium);
}
.btn-primary:hover:not(:disabled) {
  background: #1A3048;
}
:root[data-theme="dark"] .btn-primary {
  background: #393E77;
  color: #FFFFFF;
  font-weight: var(--fw-medium);
}
:root[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  background: #4A52A0;
}

.btn-secondary {
  background: var(--app-bg-elev);
  color: var(--app-fg);
  border-color: var(--app-border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--app-bg-hover);
  border-color: var(--app-fg-3);
}

.btn-tertiary {
  background: transparent;
  color: var(--app-fg);
}
.btn-tertiary:hover:not(:disabled) { background: var(--app-bg-hover); }

.btn-danger {
  background: transparent;
  color: var(--app-danger);
  border: 1px solid var(--app-danger);
}
.btn-danger:hover:not(:disabled) {
  background: var(--app-bg-hover);
  color: var(--app-danger);
  border-color: var(--app-danger);
}

.btn-dark {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  font-weight: var(--fw-medium);
}
.btn-dark:hover:not(:disabled) { background: #B82D10; }

.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-sm .ic { width: 12px; height: 12px; }
.btn-lg { padding: 11px 18px; font-size: 14px; border-radius: var(--radius-md); }
.btn-icon { padding: 8px; width: 32px; height: 32px; }
.btn-icon.btn-sm { width: 28px; height: 28px; padding: 6px; }

/* Icon button (chrome-fitting, used in topbar) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 0;
  color: var(--app-fg-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--app-bg-hover); color: var(--app-fg); }
.icon-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
/* A disabled icon-btn kept full contrast AND cursor:pointer, so it invited a
   click that did nothing. Match .btn:disabled's read. */
.icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}
.icon-btn:disabled:hover { background: transparent; color: var(--app-fg-2); }
.icon-btn .ic { width: 16px; height: 16px; }

/* btn-icon variant override — when used standalone (not inside a chrome
   bar or row-actions group), drop the bg and border at rest. They only
   appear on hover. */
.btn.btn-icon {
  background: transparent;
  border-color: transparent;
}
.btn.btn-icon:hover:not(:disabled) {
  background: var(--app-bg-hover);
  border-color: transparent;
}

/* Button group (segmented) */
.btn-group {
  display: inline-flex;
  background: var(--app-bg-sunken);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}
.btn-group button,
.btn-group a {
  background: transparent;
  border: 0;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--t-fast);
}
.btn-group button:hover,
.btn-group a:hover { color: var(--app-fg); }
.btn-group button.active,
.btn-group a.active {
  background: var(--app-bg-elev);
  color: var(--app-fg);
  box-shadow: var(--app-shadow-xs);
}

/* ============================================================
   7. Badges / pills / tags
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  /* Rounded rectangle, not a pill (house preference). */
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 16px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.02em;
}
.badge-success { background: var(--app-success-bg); color: var(--app-success-fg); }
.badge-warning { background: var(--app-warning-bg); color: var(--app-warning-fg); }
.badge-danger  { background: var(--app-danger-bg); color: var(--app-danger-fg); }
.badge-info    { background: var(--app-info-bg); color: var(--app-info-fg); }
.badge-neutral { background: var(--app-bg-sunken); color: var(--app-fg-2); }
.badge-accent  { background: var(--app-fg); color: var(--app-fg-inverse); }
.badge .dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-pill);
  background: currentColor;
}
/* Inline icons in a badge scale to the 11px label, not the default 16px
   (e.g. the "Not synced" warning triangle). */
.badge .ic,
.badge svg {
  width: 12px !important;
  height: 12px !important;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: var(--fw-medium);
  background: var(--app-bg-sunken);
  color: var(--app-fg);
  border: 1px solid var(--app-border);
}
.tag .x {
  width: 16px; height: 16px;
  display: grid;
  place-items: center;
  color: var(--app-fg-3);
  border-radius: 4px;
  cursor: pointer;
}
.tag .x:hover { background: var(--app-bg-active); color: var(--app-fg); }

/* ============================================================
   8. Forms
   ============================================================ */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.field-label .req {
  color: var(--app-danger);
  font-weight: var(--fw-bold);
  margin-left: 2px;
}
.field-label .opt {
  color: var(--app-fg-3);
  font-weight: var(--fw-regular);
  font-size: 11px;
  margin-left: 6px;
}
.field-hint {
  font-size: 12px;
  color: var(--app-fg-3);
  line-height: 16px;
}
.field-error {
  font-size: 12px;
  color: var(--app-danger);
  line-height: 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.input,
.textarea,
.select {
  width: 100%;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  /* 6px vertical + 20px line + 2px border = one global 34px control height,
     matching .drbtn / .combobox .select / .table-search. .textarea keeps this
     padding but overrides height via its own min-height (multi-line). */
  padding: 6px 12px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 20px;
  color: var(--app-fg);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--app-fg-3); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.input[aria-invalid="true"] {
  border-color: var(--app-danger);
  box-shadow: 0 0 0 3px var(--app-danger-bg);
}
.input[disabled],
.combobox .select:disabled,
.combobox .select[aria-disabled="true"] {
  background: var(--app-bg-sunken);
  color: var(--app-fg-3);
  cursor: not-allowed;
}
.textarea { min-height: 96px; resize: vertical; }

/* Strip the browser-default number-input spinners (the small up/down
   arrows). They steal padding next to .input-group affixes and nobody
   uses them — keyboard typing and the up/down arrow keys still work. */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

.select {
  appearance: none;
  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='%236B7688' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

/* Input with affix */
.input-group {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  background: var(--app-bg-elev);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  overflow: hidden;
}
.input-group:focus-within {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.input-group .affix {
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: var(--app-bg-sunken);
  color: var(--app-fg-3);
  font-size: 13px;
  border-right: 1px solid var(--app-border-strong);
}
.input-group .affix.r {
  border-right: 0;
  border-left: 1px solid var(--app-border-strong);
}
.input-group .input {
  border: 0;
  background: transparent;
  border-radius: 0;
}
.input-group .input:focus { box-shadow: none; }
.input-group .ic {
  width: 14px; height: 14px;
  color: var(--app-fg-3);
}

/* Checkbox / radio / switch */
.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--app-fg);
}
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check .box {
  width: 16px; height: 16px;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--app-border-strong);
  background: var(--app-bg-elev);
  display: grid;
  place-items: center;
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.check .box svg { width: 11px; height: 11px; color: #fff; opacity: 0; }
.check input:checked ~ .box {
  background: var(--app-fg-accent);
  border-color: var(--app-fg-accent);
}
.check input:checked ~ .box svg { opacity: 1; }
/* The real input is opacity:0 and absolutely positioned, so the UA focus ring
   lands on something invisible — a keyboard user tabbing onto a checkbox got
   NO indication at all. Put the standard control ring on the visible .box. */
.check input:focus-visible ~ .box {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.check.radio .box { border-radius: var(--radius-pill); }
.check.radio .box::after {
  content: "";
  width: 6px; height: 6px;
  border-radius: var(--radius-pill);
  background: #fff;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.check.radio input:checked ~ .box::after { opacity: 1; }
.check.radio input:checked ~ .box svg { display: none; }

.switch {
  position: relative;
  width: 32px; height: 18px;
  flex-shrink: 0;
}
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--app-border-strong);
  border-radius: var(--radius-pill);
  transition: background var(--t-fast);
  cursor: pointer;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: var(--radius-pill);
  transition: transform var(--t-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked ~ .track { background: var(--app-fg-accent); }
.switch input:checked ~ .track::after { transform: translateX(14px); }

/* Tone variants — for representing "active/running" state in success green, etc. */
.switch.switch-success input:checked ~ .track { background: var(--app-success); }
.switch.switch-warning input:checked ~ .track { background: var(--app-warning); }
.switch.switch-danger  input:checked ~ .track { background: var(--app-danger); }
.switch.lg { width: 40px; height: 22px; }
.switch.lg .track::after { width: 18px; height: 18px; }
.switch.lg input:checked ~ .track::after { transform: translateX(18px); }

/* Slider */
.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--app-border);
  border-radius: var(--radius-pill);
  outline: none;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--app-fg-accent);
  cursor: pointer;
  border: 2px solid var(--app-bg-elev);
  box-shadow: var(--app-shadow-sm);
}
.slider::-moz-range-thumb {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--app-fg-accent);
  cursor: pointer;
  border: 2px solid var(--app-bg-elev);
}

/* File upload */
.file-drop {
  border: 1.5px dashed var(--app-border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  background: var(--app-bg-sunken);
  cursor: pointer;
  transition: all var(--t-fast);
}
.file-drop:hover {
  border-color: var(--app-fg-accent);
  background: var(--app-bg-elev);
}
.file-drop .ic {
  width: 32px; height: 32px;
  color: var(--app-fg-3);
  margin: 0 auto 12px;
}
.file-drop .head {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  margin-bottom: 4px;
}
.file-drop .sub {
  font-size: 12px;
  color: var(--app-fg-3);
}

/* Date input visual */
.date-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236B7688' stroke-width='2'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============================================================
   9. Cards
   ============================================================ */
.card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.card.compact { padding: 16px; }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 14px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  letter-spacing: -0.005em;
}
.card-sub {
  font-size: 12px;
  color: var(--app-fg-3);
  margin-top: 2px;
}

/* KPI tile */
.kpi {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.kpi .label {
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
}
.kpi .value {
  font-size: 28px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.02em;
  color: var(--app-fg);
  margin-top: 8px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi .trend {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.kpi .trend.up { color: var(--app-success); }
.kpi .trend.down { color: var(--app-danger); }
.kpi .trend .vs { color: var(--app-fg-3); font-weight: var(--fw-regular); }

/* ============================================================
   10. Table
   ============================================================ */
.table-wrap {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  /* clip (not hidden) so rounded corners still mask overflow but a
     scroll context is NOT created — sticky thead binds to the viewport,
     which is what users expect on long tables. */
  overflow: clip;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-border);
  background: var(--app-bg-elev);
}
.table-toolbar .left { display: flex; gap: 8px; align-items: center; flex: 1; }
.table-toolbar .right { display: flex; gap: 8px; align-items: center; }
/* Search bar — sits in a table toolbar next to combobox filters. Same
   height, border, and radius as the combobox triggers so they line up
   cleanly. White background by default (sunken/borderless reads as
   muted next to bordered dropdowns). */
.table-search {
  position: relative;
  flex: 1;
  max-width: 320px;
  display: flex;
  align-items: center;
}
.table-search input {
  width: 100%;
  height: 34px;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  padding: 0 12px 0 34px;
  font-size: 13px;
  color: var(--app-fg);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.table-search input::placeholder { color: var(--app-fg-3); }
.table-search input:hover { border-color: var(--app-fg-3); }
.table-search input:focus {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.table-search .ic {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--app-fg-3);
  pointer-events: none;
}
/* Clear (×) button injected into every .table-search by app.js — shows only
   when there's text. Icon-only, transparent at rest, subtle gray on hover
   (house rule 4). The native type=search clear is suppressed so there's one ×. */
.table-search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.table-search-clear {
  position: absolute;
  right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 22px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--app-fg-3);
  cursor: pointer;
  transition: color var(--t-fast), background var(--t-fast);
}
.table-search-clear.is-visible { display: inline-flex; }
.table-search-clear:hover { color: var(--app-fg); background: var(--app-bg-sunken); }
.table-search-clear svg, .table-search-clear .ic { width: 14px; height: 14px; }
/* Reserve room for the × only while it's shown, so the empty state is unchanged. */
.table-search:has(.table-search-clear.is-visible) input { padding-right: 30px; }

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Header — sticky to the wrap's scroll context (or the viewport if the
   wrap doesn't scroll). Modern compact look: 12px, medium weight, tight
   tracking — no uppercase shouty caps. */
table.data thead th {
  text-align: left;
  font-weight: var(--fw-medium);
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--app-fg-2);
  padding: 7px 16px;
  background: var(--app-bg-sunken);
  border-bottom: 1px solid var(--app-border);
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data thead th.sortable { cursor: pointer; }
table.data thead th.sortable:hover { color: var(--app-fg); }
table.data thead th .sort-ic {
  display: inline-block;
  margin-left: 4px;
  width: 12px; height: 12px;
  vertical-align: -2px;
  opacity: 0.4;
}
table.data thead th.sort-asc .sort-ic,
table.data thead th.sort-desc .sort-ic { opacity: 1; color: var(--app-fg-accent); }

/* Body cells. Borders use the lighter --app-border-soft (falls back to
   --app-border if undefined) so wide tables don't feel ladder-heavy. */
table.data tbody td {
  padding: 6px 16px;
  border-bottom: 1px solid var(--app-border);
  color: var(--app-fg);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

table.data tbody tr:hover td { background: var(--app-bg-hover); }
table.data tbody tr.selected td { background: #F2F6FC; }
:root[data-theme="dark"] table.data tbody tr.selected td { background: rgba(155,184,227,0.07); }
table.data tbody tr:last-child td { border-bottom: 0; }

/* Compact density modifier — opt-in via `<table class="data dense">`.
   Denser still than the default row, for power-user tables (admin lists,
   audit logs): smaller font + tighter gutters on top of a shorter row.
   Header tightens proportionally. */
table.data.dense thead th { padding: 6px 12px; font-size: 11px; }
table.data.dense tbody td  { padding: 5px 12px; font-size: 12px; }

table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .cell-strong { font-weight: var(--fw-medium); }
table.data .cell-muted  { color: var(--app-fg-3); }
/* Row-action icons — the platform-standard treatment (Idealytics model,
   codified here so every data-table matches — Repricer, FIP, Idealytics).
   Compact + low-contrast at rest, lifting on row hover, full-strength with
   the accent colour on the button itself. Icon-only buttons are transparent
   at rest per the house rule. */
table.data .row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  align-items: center;
}
table.data .row-actions .icon-btn {
  width: auto; height: auto;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--app-fg-3);
  opacity: 0.4;
  transition: opacity var(--t-fast), color var(--t-fast), background var(--t-fast);
}
table.data .row-actions .icon-btn svg,
table.data .row-actions .icon-btn .ic {
  width: 15px !important;
  height: 15px !important;
}
/* Whole row gently lifts the icons; the hovered button goes full-strength. */
table.data tbody tr:hover .row-actions .icon-btn { opacity: 0.8; }
table.data .row-actions .icon-btn:hover {
  opacity: 1;
  color: var(--app-fg-accent);
  background: var(--app-bg-sunken);
}
table.data .row-actions .icon-btn-danger:hover { color: var(--app-danger); }

/* Actions column pinned to the right edge of the scroll container so row
   actions stay reachable when a wide table scrolls horizontally. The header
   cell also pins to the top (corner). Cells need an opaque bg so scrolled
   content doesn't show through; the soft left shadow reads as "pinned". */
table.data th.rep-col-actions,
table.data td.rep-col-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--app-bg-elev);
  box-shadow: -6px 0 8px -6px rgba(11, 18, 32, 0.10);
}
table.data thead th.rep-col-actions {
  top: 0;
  z-index: 3;
  background: var(--app-bg-sunken);
}
table.data tbody tr:hover td.rep-col-actions { background: var(--app-bg-hover); }
:root[data-theme="dark"] table.data th.rep-col-actions,
:root[data-theme="dark"] table.data td.rep-col-actions {
  box-shadow: -6px 0 8px -6px rgba(0, 0, 0, 0.4);
}

/* Row-action overflow (⋯) menu. The trigger sits inline with the primary
   icon buttons; JS positions the menu fixed at the trigger so the table's
   overflow:auto scroll container can't clip it. */
.row-actions-more { display: inline-flex; }
/* The menu reuses the design-system .popover chrome; JS positions it fixed. */
.row-actions-menu { min-width: 184px; padding: 4px; }
.row-actions-menu .menu-item,
.row-actions-menu form { width: 100%; }
.row-actions-menu form .menu-item { width: 100%; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--app-border);
  font-size: 12px;
  color: var(--app-fg-3);
}

/* ============================================================
   11. Avatar
   ============================================================ */
.avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-pill);
  background: var(--idl-gradient);
  display: inline-grid;
  place-items: center;
  color: #fff;
  font-weight: var(--fw-bold);
  font-size: 12px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  overflow: hidden;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.xl { width: 56px; height: 56px; font-size: 18px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-stack {
  display: inline-flex;
}
.avatar-stack .avatar {
  border: 2px solid var(--app-bg-elev);
  margin-left: -8px;
}
.avatar-stack .avatar:first-child { margin-left: 0; }
.avatar-stack .more {
  background: var(--app-bg-sunken);
  color: var(--app-fg-2);
  font-size: 10px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.user-chip .name {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
}
.user-chip .sub {
  font-size: 11px;
  color: var(--app-fg-3);
}

/* ============================================================
   12. Overlays — modal / drawer / popover / tooltip / toast
   ============================================================ */
.overlay-backdrop {
  position: fixed;
  inset: 0;
  background: var(--app-overlay);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
.overlay-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%);
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--app-shadow-lg);
  z-index: 101;
  width: 480px;
  max-width: calc(100vw - 32px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
}

/* Confirmation modal — large centered icon, dedicated success/fail states */
.modal.confirm {
  width: 420px;
  text-align: center;
}
.modal.confirm .icon-orb {
  width: 56px; height: 56px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  margin: 28px auto 16px;
  border: 1px solid;
}
.modal.confirm .icon-orb.success { background: var(--app-success-bg); color: var(--app-success); border-color: transparent; }
.modal.confirm .icon-orb.danger  { background: var(--app-danger-bg); color: var(--app-danger); border-color: transparent; }
.modal.confirm .icon-orb.warning { background: var(--app-warning-bg); color: var(--app-warning); border-color: transparent; }
.modal.confirm .icon-orb svg { width: 28px; height: 28px; }
.modal.confirm h3 {
  font-size: 18px;
  font-weight: var(--fw-bold);
  margin: 0 0 8px;
  padding: 0 24px;
}
.modal.confirm p {
  font-size: 13px;
  color: var(--app-fg-3);
  margin: 0 0 24px;
  padding: 0 32px;
  line-height: 20px;
}
.modal.confirm .modal-foot {
  justify-content: center;
}
.modal.open {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}
.modal-head {
  padding: 20px 24px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal-head h3 {
  font-size: 16px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  margin: 0;
}
.modal-head p {
  font-size: 13px;
  color: var(--app-fg-3);
  margin: 4px 0 0;
}
.modal-body {
  padding: 0 24px 20px;
  font-size: 13px;
  color: var(--app-fg-2);
  line-height: 20px;
}
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--app-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: 440px;
  max-width: 100vw;
  background: var(--app-bg-elev);
  border-left: 1px solid var(--app-border);
  box-shadow: var(--app-shadow-lg);
  z-index: 101;
  transform: translateX(100%);
  transition: transform var(--t-slow);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.drawer-head h3 {
  font-size: 14px;
  font-weight: var(--fw-bold);
  margin: 0;
}
.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.drawer-foot {
  padding: 16px 20px;
  border-top: 1px solid var(--app-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Popover / dropdown menu */
.popover {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  box-shadow: var(--app-shadow-pop);
  padding: 4px;
  min-width: 200px;
  z-index: 200;
}
.popover .menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  /* Explicit tight leading so menu rows land at 30px like .combobox-item,
     instead of relying on the UA button default line-height. */
  line-height: var(--app-lh-xs);
  color: var(--app-fg);
  cursor: pointer;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
}
.popover .menu-item:hover { background: var(--app-bg-hover); }
.popover .menu-item .ic { width: 14px; height: 14px; color: var(--app-fg-3); }
.popover .menu-item.danger { color: var(--app-danger); }
.popover .menu-item.danger .ic { color: var(--app-danger); }
.popover .menu-item .kbd-hint { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--app-fg-3); }
.popover .menu-sep { height: 1px; background: var(--app-border); margin: 4px 0; }
.popover .menu-label {
  padding: 6px 10px 4px;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-fg-3);
}

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
}
.tooltip .bubble {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  line-height: 14px;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  box-shadow: var(--app-shadow-md);
  pointer-events: none;
}
.tooltip .bubble::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  margin-left: -4px;
  border: 4px solid transparent;
  border-top-color: var(--app-fg);
}

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  box-shadow: var(--app-shadow-lg);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--app-fg);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 280px;
  max-width: 360px;
  pointer-events: auto;
  border-left: 3px solid var(--app-fg-accent);
}
.toast.success { border-left-color: var(--app-success); }
.toast.danger  { border-left-color: var(--app-danger); }
.toast.warning { border-left-color: var(--app-warning); }
.toast .ic { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.toast.success .ic { color: var(--app-success); }
.toast.danger  .ic { color: var(--app-danger); }
.toast.warning .ic { color: var(--app-warning); }
.toast .body { flex: 1; }
.toast .title { font-weight: var(--fw-bold); margin-bottom: 2px; }
.toast .desc { color: var(--app-fg-3); font-size: 12px; line-height: 16px; }
.toast .close { color: var(--app-fg-3); cursor: pointer; padding: 2px; }

/* ============================================================
   13. Feedback — alerts, banners, empty states, skeletons
   ============================================================ */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 18px;
}
.alert .ic { width: 18px; height: 18px; flex-shrink: 0; }
.alert .body { flex: 1; }
.alert .title { font-weight: var(--fw-bold); margin-bottom: 2px; }
.alert .desc { line-height: 18px; }
.alert.success { background: var(--app-success-bg); color: var(--app-success-fg); }
.alert.warning { background: var(--app-warning-bg); color: var(--app-warning-fg); }
.alert.danger  { background: var(--app-danger-bg); color: var(--app-danger-fg); }
.alert.info    { background: var(--app-info-bg); color: var(--app-info-fg); }

.banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.banner .ic { width: 18px; height: 18px; flex-shrink: 0; }
.banner .body { flex: 1; }
.banner .actions { display: flex; gap: 6px; }

.empty {
  text-align: center;
  padding: 56px 24px;
  border: 1px dashed var(--app-border-strong);
  border-radius: var(--radius-lg);
  background: var(--app-bg-elev);
}
.empty .ic-wrap {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--app-bg-sunken);
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--app-fg-3);
}
.empty .ic-wrap .ic { width: 24px; height: 24px; }
.empty h4 {
  font-size: 14px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  margin: 0 0 6px;
}
.empty p {
  font-size: 13px;
  color: var(--app-fg-3);
  margin: 0 auto 16px;
  max-width: 42ch;
  line-height: 18px;
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg,
    var(--app-bg-sunken) 0%,
    var(--app-bg-hover) 50%,
    var(--app-bg-sunken) 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  display: block;
}
.skeleton.text { height: 12px; margin: 4px 0; }
.skeleton.title { height: 18px; width: 60%; }
.skeleton.avatar { width: 32px; height: 32px; border-radius: var(--radius-pill); }
.skeleton.bar { height: 8px; }
@keyframes skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* Spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--app-border-strong);
  border-top-color: var(--app-fg-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
.spinner.lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Progress */
.progress {
  background: var(--app-bg-sunken);
  border-radius: var(--radius-pill);
  height: 6px;
  overflow: hidden;
}
.progress .bar {
  height: 100%;
  background: var(--app-fg-accent);
  border-radius: var(--radius-pill);
  transition: width var(--t-slow);
}

/* ============================================================
   14. Tabs (in-page) + segmented control
   ============================================================ */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--app-border);
}
.tabs .tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
  cursor: pointer;
  border: 0;
  background: transparent;
  position: relative;
  margin-bottom: -1px;
  transition: color var(--t-fast);
}
.tabs .tab:hover { color: var(--app-fg); }
.tabs .tab.active {
  color: var(--app-fg);
  border-bottom: 2px solid var(--app-fg-accent);
  font-weight: var(--fw-bold);
}
.tabs .tab .count {
  margin-left: 6px;
  font-size: 11px;
  background: var(--app-bg-sunken);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  color: var(--app-fg-3);
  font-weight: var(--fw-medium);
}

/* Pagination */
.pagination {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pagination button {
  min-width: 28px; height: 28px;
  border: 0;
  background: transparent;
  color: var(--app-fg-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: var(--fw-medium);
  cursor: pointer;
  padding: 0 8px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
}
.pagination button:hover:not(:disabled) { background: var(--app-bg-hover); color: var(--app-fg); }
.pagination button.active {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
}
:root[data-theme="dark"] .pagination button.active {
  background: #393E77;
  color: #FFFFFF;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination .gap { color: var(--app-fg-3); padding: 0 4px; }

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  width: 100%;
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.stepper .step .ix {
  width: 24px; height: 24px;
  border-radius: var(--radius-pill);
  background: var(--app-bg-sunken);
  color: var(--app-fg-3);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: var(--fw-bold);
  font-variant-numeric: tabular-nums;
}
.stepper .step.done .ix {
  background: var(--app-success);
  color: white;
}
.stepper .step.active .ix {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  box-shadow: 0 0 0 4px var(--app-focus-ring);
}
.stepper .step .lbl {
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-3);
}
.stepper .step.active .lbl,
.stepper .step.done .lbl { color: var(--app-fg); }
.stepper .bar {
  flex: 1;
  height: 1px;
  background: var(--app-border);
  margin: 0 12px;
}
.stepper .bar.done { background: var(--app-success); }

/* ============================================================
   15. Charts (SVG-based, styled placeholders)
   ============================================================ */
.chart-card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.chart-card .legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--app-fg-3);
}
.chart-card .legend .item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-card .legend .sw {
  width: 10px; height: 10px;
  border-radius: 2px;
}

/* ============================================================
   16. Editor primitives
   ============================================================ */
code.inline {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--app-bg-sunken);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-xs);
  padding: 1px 5px;
  color: var(--app-fg);
}
pre.code-block {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 18px;
  background: var(--app-bg-sunken);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 0;
  overflow-x: auto;
  color: var(--app-fg);
}
kbd.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-family: var(--font-sans);
  font-weight: var(--fw-bold);
  font-size: 11px;
  color: var(--app-fg-2);
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
}

/* ============================================================
   17. Token + foundation specific
   ============================================================ */
.color-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--app-border);
  font-size: 12px;
}
.color-row:last-child { border-bottom: 0; }
.color-row .sw {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--app-border);
}
.color-row .name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--app-fg);
}
.color-row .role {
  font-size: 12px;
  color: var(--app-fg-3);
}
.color-row .hex {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-2);
}
.token-table {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.token-table .group-title {
  padding: 12px 16px;
  background: var(--app-bg-sunken);
  border-bottom: 1px solid var(--app-border);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-fg-3);
}
.token-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 60px;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--app-border);
  font-size: 12px;
  gap: 12px;
}
.token-row:last-child { border-bottom: 0; }
.token-row .nm { font-family: var(--font-mono); color: var(--app-fg); }
.token-row .vl { font-family: var(--font-mono); color: var(--app-fg-3); font-size: 11px; }
.token-row .dsc { color: var(--app-fg-3); font-size: 12px; }
.token-row .prev {
  height: 24px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--app-border);
}

/* Type specimen list */
.type-spec {
  display: grid;
  grid-template-columns: 100px 130px 1fr;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--app-border);
  align-items: baseline;
}
.type-spec:last-child { border-bottom: 0; }
.type-spec .nm {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.type-spec .spec {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
}
.type-spec .sample {
  color: var(--app-fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Radius / shadow / spacing micro-grids */
.radius-grid, .shadow-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.radius-tile {
  aspect-ratio: 1;
  background: var(--app-bg-sunken);
  border: 1px solid var(--app-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--app-fg-3);
}
.radius-tile .nm { font-weight: var(--fw-bold); color: var(--app-fg); font-size: 11px; }
.radius-tile .vl { margin-top: 2px; }
.shadow-tile {
  aspect-ratio: 1;
  background: var(--app-bg-elev);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--app-fg-3);
}
.shadow-tile .nm { font-weight: var(--fw-bold); color: var(--app-fg); font-size: 11px; }

.spacing-row {
  display: grid;
  grid-template-columns: 60px 80px 1fr;
  gap: 16px;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--app-border);
  font-family: var(--font-mono);
  font-size: 11px;
}
.spacing-row:last-child { border-bottom: 0; }
.spacing-row .bar {
  background: var(--app-fg-accent);
  height: 12px;
  border-radius: 2px;
}

/* ============================================================
   18. Pattern cards (large composed previews)
   ============================================================ */
.pattern {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 32px;
}
.pattern-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.pattern-head .title {
  font-size: 14px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
}
.pattern-head .desc {
  font-size: 12px;
  color: var(--app-fg-3);
  margin-top: 2px;
}
.pattern-body {
  padding: 24px;
  background: var(--app-bg);
}

/* Group of related specs (e.g. all of Foundations) */
.spec-group {
  scroll-margin-top: calc(var(--topbar-h) + 16px);
  padding: 56px 0 8px;
  border-top: 2px solid var(--app-fg);
}
.spec-group:first-of-type { padding-top: 0; border-top: 0; }
.spec-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 24px;
}
.spec-group-head .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.spec-group-head h2 {
  font-size: 24px;
  line-height: 32px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
  margin: 4px 0 0;
}
.spec-group-head .desc {
  color: var(--app-fg-3);
  font-size: 13px;
  max-width: 56ch;
  margin: 6px 0 0;
  line-height: 20px;
}
/* ----- Split button (button + dropdown chevron) ----- */
.split-btn {
  display: inline-flex;
  align-items: stretch;
  position: relative;
}
.split-btn > .btn {
  margin: 0;
}
.split-btn > .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.split-btn > .split-chev {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  padding-left: 8px;
  padding-right: 8px;
  margin-left: 1px;
}
.split-btn > .btn-primary.split-chev {
  border-left: 1px solid rgba(255,255,255,0.18);
  margin-left: 0;
}
:root[data-theme="dark"] .split-btn > .btn-primary.split-chev {
  border-left: 1px solid rgba(14,33,51,0.18);
}
.split-btn > .btn-secondary.split-chev {
  border-left: 0;
  margin-left: -1px;
}

/* In split buttons, hover only changes background — never border colour, so
   the two halves stay visually joined. */
.split-btn > .btn-secondary:hover:not(:disabled) {
  background: var(--app-bg-hover);
  border-color: var(--app-border-strong);
}

/* ============================================================
   19. Combobox (typeahead select)
   ============================================================ */
.combobox {
  position: relative;
}

/* Combobox trigger — overrides the generic .select rule when the combobox
   sits in a table toolbar, so the trigger lines up vertically with the
   search bar (same 34px height, same radius, same padding). */
.combobox .select {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  height: 34px;
  padding: 0 32px 0 12px;
  font-size: 13px;
  line-height: 20px;
  background-color: var(--app-bg-elev);
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  color: var(--app-fg);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.combobox .select:hover { border-color: var(--app-fg-3); }
.combobox .select:focus,
.combobox .select:focus-visible {
  outline: none;
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}
.combobox[data-open="true"] .select,
.combobox .select[aria-expanded="true"] {
  border-color: var(--app-focus);
  box-shadow: 0 0 0 3px var(--app-focus-ring);
}

/* Disabled trigger — whole-field lock (e.g. a role/route select frozen for
   the current user). Shares .input[disabled]'s muted background + no
   pointer affordance (see above); the higher-specificity :hover override
   below beats .combobox .select:hover so hovering a locked trigger reveals
   nothing. */
.combobox .select:disabled:hover,
.combobox .select[aria-disabled="true"]:hover {
  border-color: var(--app-border-strong);
}

/* Dropdown panel — elevated shadow, gentler corners, modern compact
   density. Auto-width opens at least as wide as the trigger; can grow
   to fit longer items. */
.combobox .combobox-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  box-shadow: var(--app-shadow-pop), 0 8px 24px rgba(11,18,32,0.08);
  max-height: 280px;
  overflow-y: auto;
  z-index: 20;
  padding: 4px;
  white-space: nowrap;
}
:root[data-theme="dark"] .combobox .combobox-list {
  box-shadow: var(--app-shadow-pop), 0 8px 24px rgba(0,0,0,0.32);
}
.combobox .combobox-list .group-title {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-fg-3);
}
.combobox .combobox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  /* Tight leading so single-line rows sit at the same height whether their
     label is a bare <span> (single-select rows, the multi "Select all" row)
     or wrapped in .ms-txt (multi options, which already set 16px). Without
     this, bare-span rows inherit the 21px body line-height and read taller. */
  line-height: var(--app-lh-xs);
  color: var(--app-fg);
  cursor: pointer;
  transition: background-color var(--t-fast);
}
.combobox .combobox-item:hover { background: var(--app-bg-hover); }
.combobox .combobox-item.selected { background: var(--app-bg-hover); color: var(--app-fg); }
.combobox .combobox-item .ic { width: 14px; height: 14px; color: var(--app-fg-3); }
.combobox .combobox-item .check-ic {
  margin-left: auto;
  width: 14px; height: 14px;
  color: var(--app-fg-accent);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.combobox .combobox-item.selected .check-ic { opacity: 1; }
.combobox .combobox-item .sub { color: var(--app-fg-3); font-size: 11px; margin-left: 4px; }

/* "Reset" row at the top of a combobox list — single-select dropdowns
   mark it with an empty data-value (e.g. <div data-value="">All
   regions</div>); multi-select dropdowns use .combobox-item-reset.
   The divider sets the reset option apart from the actual choices. */
.combobox .combobox-list .combobox-item[data-value=""],
.combobox .combobox-list .combobox-item.combobox-item-reset {
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 4px;
  padding-bottom: 9px;
}

/* Combobox bulk-action header (Select all / Clear) */
.combobox-list .bulk-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid var(--app-border);
  margin-bottom: 4px;
}
.combobox-list .bulk-row .count {
  font-size: 11px;
  color: var(--app-fg-3);
  font-variant-numeric: tabular-nums;
}
.combobox-list .bulk-row .links {
  display: flex;
  gap: 12px;
}
.combobox-list .bulk-row .link {
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg-link);
  cursor: pointer;
  background: 0;
  border: 0;
  padding: 0;
}
.combobox-list .bulk-row .link:hover { text-decoration: underline; }
.combobox-list .bulk-row .link:disabled {
  color: var(--app-fg-muted);
  cursor: not-allowed;
  text-decoration: none;
}
.cmdk {
  position: fixed;
  top: 96px; left: 50%;
  transform: translateX(-50%) scale(0.98);
  width: 600px;
  max-width: calc(100vw - 32px);
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--app-shadow-lg);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base), transform var(--t-base);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  overflow: hidden;
}
.cmdk.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) scale(1);
}
.cmdk-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--app-border);
}
.cmdk-head .ic {
  width: 16px; height: 16px;
  color: var(--app-fg-3);
}
.cmdk-head input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: var(--app-fg);
}
.cmdk-head input::placeholder { color: var(--app-fg-3); }
.cmdk-head .kbd {
  font-size: 10px;
  font-family: var(--font-sans);
  color: var(--app-fg-3);
  background: var(--app-bg-sunken);
  padding: 2px 6px;
  border-radius: 4px;
}
.cmdk-body {
  overflow-y: auto;
  padding: 8px;
  flex: 1;
}
.cmdk-group {
  padding: 4px 0;
}
.cmdk-group .group-title {
  padding: 8px 10px 4px;
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--app-fg-3);
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--app-fg);
  cursor: pointer;
}
.cmdk-item:hover, .cmdk-item.highlight {
  background: var(--app-bg-hover);
}
.cmdk-item .ic { width: 14px; height: 14px; color: var(--app-fg-3); }
.cmdk-item .sub { color: var(--app-fg-3); font-size: 11px; margin-left: auto; }
.cmdk-foot {
  border-top: 1px solid var(--app-border);
  padding: 8px 14px;
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--app-fg-3);
}
.cmdk-foot .key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cmdk-foot .key kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  background: var(--app-bg-sunken);
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--app-fg-2);
}

/* ============================================================
   21. Calendar / date picker
   ============================================================ */
.calendar {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  padding: 16px;
  width: 280px;
}
.calendar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.calendar-head .title {
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
}
.calendar-head .nav {
  display: flex;
  gap: 2px;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.calendar-grid .wd {
  text-align: center;
  font-size: 10px;
  font-weight: var(--fw-bold);
  color: var(--app-fg-3);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 0;
}
.calendar-grid .day {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--app-fg);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast);
}
.calendar-grid .day:hover { background: var(--app-bg-hover); }
.calendar-grid .day.muted { color: var(--app-fg-muted); }
.calendar-grid .day.today {
  border: 1px solid var(--app-fg-accent);
  font-weight: var(--fw-bold);
}
.calendar-grid .day.selected {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
}
.calendar-grid .day.in-range {
  background: var(--app-info-bg);
  border-radius: 0;
}
.calendar-grid .day.range-start { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.calendar-grid .day.range-end   { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* Inline mini-select for calendar header */
.calendar-head .picker {
  display: flex;
  gap: 4px;
  align-items: center;
}
.calendar-head .picker select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  padding: 4px 18px 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236B7688' stroke-width='2.5' 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 4px center;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: background-color var(--t-fast);
}
.calendar-head .picker select:hover { background-color: var(--app-bg-hover); }
.calendar-head .picker select:focus { background-color: var(--app-bg-hover); }

/* ============================================================
   22. Messages / chat bubbles
   ============================================================ */
.messages {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.msg-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg-row.me {
  flex-direction: row-reverse;
}
.msg-body {
  max-width: 70%;
}
.msg-meta {
  font-size: 11px;
  color: var(--app-fg-3);
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
}
.msg-row.me .msg-meta { justify-content: flex-end; }
.msg-meta .who { font-weight: var(--fw-medium); color: var(--app-fg-2); }
.msg-bubble {
  background: var(--app-bg-sunken);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 19px;
  color: var(--app-fg);
}
.msg-row.me .msg-bubble {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  border-color: transparent;
}
.msg-bubble.system {
  background: transparent;
  border: 1px dashed var(--app-border);
  color: var(--app-fg-3);
  font-size: 12px;
}

/* ============================================================
   23. History log / timeline
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 20px;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 1px;
  background: var(--app-border);
}
.timeline-item {
  position: relative;
  padding: 4px 0 20px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -18px; top: 8px;
  width: 8px; height: 8px;
  border-radius: var(--radius-pill);
  background: var(--app-bg-elev);
  border: 2px solid var(--app-border-strong);
}
.timeline-item.success::before { border-color: var(--app-success); }
.timeline-item.danger::before  { border-color: var(--app-danger); }
.timeline-item.accent::before  { border-color: var(--app-fg-accent); }
.timeline-item .meta {
  font-size: 11px;
  color: var(--app-fg-3);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.timeline-item .head {
  font-size: 13px;
  color: var(--app-fg);
  font-weight: var(--fw-medium);
}
.timeline-item .head .who {
  font-weight: var(--fw-bold);
  margin-right: 4px;
}
.timeline-item .desc {
  font-size: 12px;
  color: var(--app-fg-3);
  margin-top: 2px;
  line-height: 18px;
}

/* ============================================================
   24. Accessibility checklist
   ============================================================ */
.a11y-list {
  display: grid;
  gap: 8px;
}
.a11y-item {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 12px;
  padding: 14px 16px;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
}
.a11y-item .mark {
  width: 20px; height: 20px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.a11y-item.pass .mark { background: var(--app-success-bg); color: var(--app-success); }
.a11y-item.warn .mark { background: var(--app-warning-bg); color: var(--app-warning); }
.a11y-item.fail .mark { background: var(--app-danger-bg); color: var(--app-danger); }
.a11y-item .mark svg { width: 12px; height: 12px; }
.a11y-item .body .title {
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
}
.a11y-item .body .desc {
  font-size: 12px;
  color: var(--app-fg-3);
  margin-top: 2px;
  line-height: 18px;
}
.a11y-item .status {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: var(--fw-bold);
  align-self: center;
}
.a11y-item.pass .status { color: var(--app-success); }
.a11y-item.warn .status { color: var(--app-warning); }
.a11y-item.fail .status { color: var(--app-danger); }

.pattern-tools {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Grid view (compact tiles) */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.tile {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  position: relative;
}
.tile:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-sm);
}
.tile .tile-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tile .tile-id {
  font-size: 12px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  font-variant-numeric: tabular-nums;
}
.tile .tile-line {
  font-size: 13px;
  color: var(--app-fg);
  line-height: 18px;
}
.tile .tile-meta {
  font-size: 11px;
  color: var(--app-fg-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-variant-numeric: tabular-nums;
  margin-top: auto;
}
.tile .tile-meta .price {
  color: var(--app-fg);
  font-weight: var(--fw-medium);
}

/* List view (horizontal card list) */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.list-card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1.6fr) 140px 120px 110px 80px;
  gap: 20px;
  align-items: center;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.list-card:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-sm);
}
.list-card .thumb {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--app-bg-sunken), var(--app-bg-hover));
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  color: var(--app-fg-muted);
  flex-shrink: 0;
}
.list-card .main .id {
  font-size: 11px;
  color: var(--app-fg-3);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.list-card .main .title {
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  line-height: 18px;
}
.list-card .col-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.list-card .col-stack .k {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--app-fg-3);
  font-weight: var(--fw-bold);
}
.list-card .col-stack .v {
  font-size: 13px;
  color: var(--app-fg);
  font-variant-numeric: tabular-nums;
}
.list-card .price-right {
  font-size: 14px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.list-card .badge {
  justify-self: start;
}
.list-card .actions-right {
  display: flex;
  gap: 4px;
}
@media (max-width: 900px) {
  .list-card {
    grid-template-columns: 48px 1fr auto;
  }
  .list-card .col-stack { display: none; }
  .list-card .actions-right { display: none; }
}

/* Card view (rich, image-led) */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.record-card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  display: flex;
  flex-direction: column;
}
.record-card:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-sm);
}
.record-card .cover {
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, var(--app-bg-sunken), var(--app-bg-hover));
  display: grid;
  place-items: center;
  color: var(--app-fg-muted);
  border-bottom: 1px solid var(--app-border);
  position: relative;
}
.record-card .cover .badge {
  position: absolute;
  top: 10px; left: 10px;
}
.record-card .cover .actions {
  position: absolute;
  top: 8px; right: 8px;
}
.record-card .body {
  padding: 14px 16px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.record-card .body .id {
  font-size: 11px;
  color: var(--app-fg-3);
  font-variant-numeric: tabular-nums;
}
.record-card .body .title {
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--app-fg);
  line-height: 20px;
}
.record-card .body .sub {
  font-size: 12px;
  color: var(--app-fg-3);
  line-height: 18px;
}
.record-card .foot {
  padding: 10px 16px;
  border-top: 1px solid var(--app-border);
  background: var(--app-bg-sunken);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--app-fg-2);
  font-variant-numeric: tabular-nums;
}
.record-card .foot .price {
  color: var(--app-fg);
  font-weight: var(--fw-bold);
  font-size: 13px;
}

/* Dashboard summary card — app tile with status + meta rows */
.dv-card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-xl);
  padding: 18px 18px 16px;
  width: 340px;
  box-shadow: var(--app-shadow-xs);
  transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
  cursor: pointer;
  font-family: var(--font-sans);
  display: block;
  text-decoration: none;
}
.dv-card:hover {
  box-shadow: var(--app-shadow-md);
  border-color: var(--app-border-strong);
  transform: translateY(-2px);
}
.dv-card .app-ic {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius-lg);
  background: var(--app-bg-sunken); color: var(--app-fg); flex-shrink: 0;
}
.dv-card .app-ic .ic { width: 20px; height: 20px; }
.dv-card .app-name {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--app-fg); line-height: 1.2;
}
.dv-card .app-sub {
  font-size: 12px; color: var(--app-fg-3); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.dv-card .st {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px 0 8px;
  border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}
.dv-card .st .st-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex-shrink: 0; }
.dv-card .st.neutral { background: var(--app-bg-sunken); color: var(--app-fg-3); }
.dv-card .st.success { background: var(--app-success-bg); color: var(--app-success-fg); }
.dv-card .st.warning { background: var(--app-warning-bg); color: var(--app-warning-fg); }
.dv-card .st.danger { background: var(--app-danger-bg); color: var(--app-danger-fg); }

.dv-card .meta-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--app-fg-2); font-variant-numeric: tabular-nums;
}
.dv-card .meta-row .ic { width: 15px; height: 15px; color: var(--app-fg-3); flex-shrink: 0; }
.dv-card .meta-row .strong { color: var(--app-fg); font-weight: 600; }

.dv-card .hair { height: 1px; background: var(--app-border); border: 0; margin: 14px 0; }

.dv-card .card-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; font-weight: 600; color: var(--app-fg-2);
}
.dv-card .card-foot .go { display: inline-flex; align-items: center; gap: 6px; color: var(--app-fg-3); }
.dv-card:hover .card-foot .go { color: var(--app-fg); }
.dv-card .card-foot .go .ic { width: 16px; height: 16px; transition: transform var(--t-base); }
.dv-card:hover .card-foot .go .ic { transform: translateX(3px); }

/* ============================================================
   25. Principles cards
   ============================================================ */
.principles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.principle {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 24px;
}
.principle .n {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--app-fg-accent);
  letter-spacing: 0.06em;
  font-weight: var(--fw-bold);
}
.principle .t {
  font-size: 15px;
  font-weight: var(--fw-bold);
  color: var(--app-fg);
  margin: 6px 0 6px;
  letter-spacing: -0.005em;
}
.principle .d {
  font-size: 13px;
  color: var(--app-fg-3);
  line-height: 19px;
  margin: 0;
}

/* Sidebar collapse small screens */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .content { padding: 24px; }
  .spec-grid.cols-2,
  .spec-grid.cols-3,
  .spec-grid.cols-4 { grid-template-columns: 1fr; }
  .principles { grid-template-columns: 1fr; }
}

/* Icon library grid for the iconography section */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 4px;
}
.icon-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 16px 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  text-align: center;
}
.icon-tile:hover {
  background: var(--app-bg-hover);
  border-color: var(--app-border);
}
.icon-tile.hidden-by-filter { display: none; }
.icon-tile .lbl {
  font-size: 10.5px;
  color: var(--app-fg-3);
  line-height: 14px;
  word-break: break-all;
}
.icon-tile:hover .lbl { color: var(--app-fg); }
.icon-tile svg, .icon-tile i { flex-shrink: 0; }

/* ============================================================
   26. Type theme picker
   ============================================================ */
.type-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.type-card {
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  text-align: left;
  font-family: inherit;
}
.type-card:hover {
  border-color: var(--app-border-strong);
  box-shadow: var(--app-shadow-sm);
}
.type-card.active {
  border-color: var(--app-fg);
  box-shadow: 0 0 0 1px var(--app-fg) inset;
}
.type-card .meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--app-fg-3);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.type-card .check-pill {
  width: 16px; height: 16px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--app-border-strong);
  display: grid; place-items: center;
  color: var(--app-bg-elev);
  flex-shrink: 0;
}
.type-card.active .check-pill {
  background: var(--app-fg);
  border-color: var(--app-fg);
}
.type-card.active .check-pill svg { display: block; }
.type-card .check-pill svg { display: none; width: 10px; height: 10px; }
.type-card .display {
  font-size: 22px;
  line-height: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--app-fg);
  margin-bottom: 6px;
}
.type-card .body {
  font-size: 12px;
  line-height: 18px;
  color: var(--app-fg-3);
  margin-bottom: 12px;
}
.type-card .desc {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--app-fg-3);
  border-top: 1px solid var(--app-border);
  padding-top: 10px;
  line-height: 14px;
}
.type-card .desc b { color: var(--app-fg); font-weight: var(--fw-bold); }

/* Applied font families — controlled by data-typeface on <html>.
   Note: --font-mono is intentionally aliased to the sans face — no
   monospace is used anywhere in the UI per the design system rules.
   Tabular-numeric is achieved via `font-variant-numeric: tabular-nums`. */
:root[data-typeface="modern"]    { --font-display: "Geist", "Inter", sans-serif;          --font-sans: "Inter", system-ui, sans-serif;           --font-mono: "Inter", system-ui, sans-serif; }
:root[data-typeface="geist"]     { --font-display: "Geist", "Inter", sans-serif;          --font-sans: "Geist", "Inter", sans-serif;             --font-mono: "Geist", "Inter", sans-serif; }
:root[data-typeface="editorial"] { --font-display: "Fraunces", Georgia, serif;            --font-sans: "Inter", system-ui, sans-serif;           --font-mono: "Inter", system-ui, sans-serif; }
:root[data-typeface="swiss"]     { --font-display: "Space Grotesk", system-ui, sans-serif;--font-sans: "Space Grotesk", system-ui, sans-serif;   --font-mono: "Space Grotesk", system-ui, sans-serif; }
:root[data-typeface="brand"]     { --font-display: "Montserrat", system-ui, sans-serif;   --font-sans: "Montserrat", system-ui, sans-serif;      --font-mono: "Montserrat", system-ui, sans-serif; }

/* ============================================================
   27. App shell pattern (sidebar + topbar layout demo)
   ============================================================ */
.shell-demo {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 560px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: grid-template-columns var(--t-slow);
}
.shell-demo.collapsed {
  grid-template-columns: 60px 1fr;
}
.shell-demo .s-side {
  background: var(--idl-midnight-deep);
  border-right: 1px solid #1E2A50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #F4F6F9;
}
.shell-demo .s-side .s-item { color: #C4CCD9; }
.shell-demo .s-side .s-item .ic,
.shell-demo .s-side .s-app .ic-app { color: #8893A4; }
.shell-demo .s-side .s-item:hover,
.shell-demo .s-side .s-app:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}
.shell-demo .s-side .s-item:hover .ic,
.shell-demo .s-side .s-app:hover .ic-app { color: #FFFFFF; }
/* Section/group headers (.s-app) — single source of truth for the header
   colour. Hardcoded (not --app-chrome-fg) because the sidebar is always dark
   while that token flips with the page theme. */
.shell-demo .s-side .s-app { color: #F4F6F9; }
.shell-demo .s-side .s-app .chev { color: #8893A4; }
.shell-demo .s-side .s-sub { border-left-color: rgba(255,255,255,0.10); }
.shell-demo .s-side .s-subitem { color: #C4CCD9; }
.shell-demo .s-side .s-subitem:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #FFFFFF;
}
.shell-demo .s-side .s-subitem.active {
  background: rgba(255, 255, 255, 0.10);
  color: #FFFFFF;
}
.shell-demo .s-side .s-subitem.active::before {
  background: #FFFFFF;
}
/* The brand bar and the page-head bottom border must sit at the same Y
   position so the sidebar's right edge and the page divider align. */
.shell-demo .s-brand {
  height: 48px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: var(--fw-bold);
  font-size: 13px;
  color: #FFFFFF;
  flex-shrink: 0;
}
.shell-demo .s-brand .logo-img {
  height: 32px;
  width: 32px;
  flex-shrink: 0;
  display: block;
  border-radius: var(--radius-pill);
  object-fit: cover;
}
.shell-demo .s-brand .name {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  opacity: 1;
  transition: opacity var(--t-fast);
  color: #FFFFFF;
}
.shell-demo.collapsed .s-brand .name { display: none; }
.shell-demo .s-brand .name .sub {
  color: rgba(255,255,255,0.5);
  font-weight: var(--fw-regular);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Collapse toggle — lives in the brand bar when expanded, on its own row
   above the nav when collapsed. */
.shell-demo .s-brand-collapse {
  margin-left: auto;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.6);
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: transparent;
  border: 0;
  flex-shrink: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.shell-demo .s-brand-collapse:hover { background: rgba(255,255,255,0.08); color: #FFFFFF; }
.shell-demo .s-brand-collapse svg { width: 14px; height: 14px; }
.shell-demo.collapsed .s-brand-collapse { display: none; }

.shell-demo .s-collapse-row {
  display: none;
  padding: 8px;
  justify-content: center;
  flex-shrink: 0;
}
.shell-demo.collapsed .s-collapse-row { display: flex; }
.shell-demo .s-collapse-btn {
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  color: #8893A4;
  border-radius: var(--radius-xs);
  cursor: pointer;
  background: transparent;
  border: 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.shell-demo .s-collapse-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #FFFFFF;
}
.shell-demo .s-collapse-btn svg { width: 16px; height: 16px; }

.shell-demo .s-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  overflow-x: hidden;
}
.shell-demo .s-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: var(--app-lh-xs);
  color: var(--app-fg-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  white-space: nowrap;
}
.shell-demo .s-item:hover { background: var(--app-chrome-hover); color: var(--app-fg); }
.shell-demo .s-item .ic { width: 16px; height: 16px; color: var(--app-fg-3); flex-shrink: 0; }
.shell-demo .s-app {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--app-fg);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--t-fast);
  user-select: none;
  white-space: nowrap;
}
.shell-demo .s-app:hover { background: var(--app-chrome-hover); }
.shell-demo .s-app .ic-app {
  width: 16px; height: 16px;
  color: var(--app-fg-2);
  flex-shrink: 0;
}
.shell-demo .s-app .label {
  flex: 1;
  line-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.shell-demo .s-app .chev {
  width: 12px; height: 12px;
  color: var(--app-fg-3);
  transition: transform var(--t-fast);
  flex-shrink: 0;
}
.shell-demo .s-app[aria-expanded="true"] .chev { transform: rotate(180deg); }
.shell-demo.collapsed .s-item span,
.shell-demo.collapsed .s-app .label,
.shell-demo.collapsed .s-app .chev,
.shell-demo.collapsed .s-sub,
.shell-demo.collapsed .s-app[aria-expanded="true"] + .s-sub { display: none; }
.shell-demo.collapsed .s-item,
.shell-demo.collapsed .s-app { justify-content: center; padding: 9px 0; gap: 0; }
.shell-demo.collapsed .s-brand { padding: 0; justify-content: center; }
.shell-demo.collapsed .s-brand .logo-img { margin: 0 auto; }

.shell-demo .s-sub {
  display: none;
  padding: 2px 0 4px 32px;
  margin-left: 12px;
  border-left: 1px solid var(--app-border);
  position: relative;
}
.shell-demo .s-app[aria-expanded="true"] + .s-sub { display: block; }
.shell-demo .s-subitem {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: var(--app-lh-xs);
  color: var(--app-fg-2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  user-select: none;
  position: relative;
  white-space: nowrap;
}
.shell-demo .s-subitem:hover { background: var(--app-chrome-hover); color: var(--app-fg); }
.shell-demo .s-subitem.active {
  background: var(--app-chrome-active);
  color: var(--app-fg);
  font-weight: var(--fw-medium);
}
.shell-demo .s-subitem.active::before {
  content: "";
  position: absolute;
  left: -33px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--app-fg-accent);
  border-radius: 2px;
}

.shell-demo .s-foot {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.shell-demo.collapsed .s-foot { justify-content: center; padding: 10px 0; }
.shell-demo.collapsed .s-foot .who,
.shell-demo.collapsed .s-foot .icon-btn { display: none; }
.shell-demo .s-foot .who {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.shell-demo .s-foot .who .name { font-size: 12px; font-weight: var(--fw-medium); color: #FFFFFF; }
.shell-demo .s-foot .who .role { font-size: 11px; color: #8893A4; }
.shell-demo .s-foot .icon-btn { color: #8893A4; }
.shell-demo .s-foot .icon-btn:hover { background: rgba(255,255,255,0.08); color: #FFFFFF; }

.shell-demo .s-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--app-bg);
}
/* page-head height = s-brand height + 1px border, so the sidebar's right
   border and the page divider meet at the same Y. */
.shell-demo .s-page-head {
  height: 49px;
  padding: 0 28px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}
.shell-demo .s-page-head h1 {
  font-size: 16px;
  line-height: 22px;
  font-weight: var(--fw-bold);
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--app-fg);
}
.shell-demo .s-body {
  flex: 1;
  padding: 24px 28px;
  overflow: auto;
}
.col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--app-fg-3); }
/* Inter has true tabular figures — use this anywhere numbers
   need to column-align (no monospace font in the UI). */
.mono, .nums {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.spacer { flex: 1; }
.hidden { display: none !important; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex { display: flex; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.center { align-items: center; }

/* ============================================================
   29. Logo section
   ============================================================ */
.logo-stage {
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
}
.specimen .logo-stage img {
  display: block;
  max-width: 100%;
}

/* Clear-space diagram */
.logo-clearspace {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
}
.cs-wrap {
  position: relative;
  padding: 56px 70px; /* x = 56px (mirrors logo glyph height ~56) */
  border: 1px dashed var(--idl-vermillion);
  border-radius: var(--radius-sm);
  display: inline-block;
}
.cs-logo {
  height: 56px;
  width: auto;
  display: block;
}
.cs-tick {
  position: absolute;
  background: var(--idl-vermillion);
}
.cs-tick-t, .cs-tick-b { left: 50%; width: 1px; height: 14px; transform: translateX(-0.5px); }
.cs-tick-t { top: -7px; }
.cs-tick-b { bottom: -7px; }
.cs-tick-l, .cs-tick-r { top: 50%; height: 1px; width: 14px; transform: translateY(-0.5px); }
.cs-tick-l { left: -7px; }
.cs-tick-r { right: -7px; }
.cs-label {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 10px;
  font-style: italic;
  color: var(--idl-vermillion);
  background: var(--app-bg);
  padding: 0 4px;
}
.cs-label-t { top: -19px; left: 50%; transform: translateX(-50%); }
.cs-label-r { right: -22px; top: 50%; transform: translateY(-50%); }

/* Minimum size caption */
.min-size-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--app-fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Don't tiles */
.logo-dont .logo-stage {
  min-height: 110px;
  padding: 18px;
  border-radius: var(--radius-md);
}
.logo-dont .dont-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--app-border);
  font-size: 12px;
  line-height: 16px;
  color: var(--app-fg-2);
}
.logo-dont .dont-x {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--app-danger-bg);
  color: var(--app-danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--fw-bold);
}

/* File list */
.logo-files {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 8px;
}
.logo-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--app-bg-elev);
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  transition: border-color var(--t-fast);
}
.logo-file:hover { border-color: var(--app-border-strong); }
.logo-file .ic { width: 16px; height: 16px; color: var(--app-fg-3); flex-shrink: 0; }
.logo-file .lf-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--app-fg);
}
.logo-file .lf-sub {
  font-size: 11px;
  color: var(--app-fg-3);
}
.logo-file .lf-fmt {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--app-fg-3);
  letter-spacing: 0.05em;
  padding: 3px 7px;
  background: var(--app-bg-sunken);
  border-radius: var(--radius-xs);
}

/* ============================================================
   30. Date range picker (extends .calendar)
   ============================================================ */
.specimen.specimen-wide {
  grid-column: 1 / -1;
}

/* Closed-state trigger pill */
.dr-trigger {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  margin-bottom: 14px;
  background: #FFFFFF;
  border: 1px solid var(--app-border-strong);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--app-fg);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.dr-trigger:hover { border-color: var(--app-fg-3); }
.dr-trigger .ic { width: 14px; height: 14px; color: var(--app-fg-3); }
.dr-trigger-range {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}
.dr-trigger-arrow {
  display: inline-block;
  margin: 0 4px;
  color: var(--app-fg-3);
}
.dr-trigger-chev {
  margin-left: 6px;
}

.daterange {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  background: #FFFFFF;
  border: 1px solid var(--app-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--app-shadow-sm);
}

.dr-top {
  display: flex;
  align-items: stretch;
}

.dr-presets {
  flex: 0 0 132px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 12px 8px;
  background: #FFFFFF;
  border-right: 1px solid var(--app-border);
}
.dr-preset {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 12.5px;
  color: var(--app-fg-2);
  text-align: left;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.dr-preset:hover { background: var(--app-bg-hover); color: var(--app-fg); }
.dr-preset.active {
  color: var(--app-fg);
  font-weight: var(--fw-bold);
}
.dr-preset .ic { width: 13px; height: 13px; color: var(--app-fg-3); }
.dr-preset-custom {
  margin-top: 6px;
  border-top: 1px solid var(--app-border);
  border-radius: 0;
  padding-top: 12px;
  color: var(--app-fg-2);
  font-weight: var(--fw-medium);
}
.dr-preset-custom:hover { border-radius: 0; }

.dr-cals {
  flex: 0 0 auto;
  display: flex;
  gap: 0;
}
.dr-cal {
  border: 0;
  border-radius: 0;
  width: 260px;
  background: #FFFFFF;
  padding: 14px 14px 12px;
  flex-shrink: 0;
}
.dr-cal + .dr-cal {
  border-left: 1px solid var(--app-border);
}
.dr-cal .calendar-head {
  margin-bottom: 10px;
}
.dr-cal .calendar-head .nav .icon-btn {
  width: 24px; height: 24px;
}
.dr-cal .calendar-head .nav .icon-btn .ic {
  width: 13px; height: 13px;
}
.dr-cal .calendar-head .picker select {
  font-size: 12.5px;
  font-weight: var(--fw-bold);
}
.dr-cal .calendar-grid .wd {
  font-size: 10px;
  padding: 4px 0 8px;
  color: var(--app-fg-3);
  font-weight: var(--fw-medium);
}
.dr-cal .calendar-grid .day {
  aspect-ratio: 1;
  height: auto;
  font-size: 12px;
  border-radius: var(--radius-sm);
  font-weight: var(--fw-medium);
}
.dr-cal .calendar-grid .day.in-range {
  background: #F2F6FC;
  color: var(--app-fg-2);
  border-radius: 0;
}
.dr-cal .calendar-grid .day.selected {
  background: var(--app-fg);
  color: var(--app-fg-inverse);
  border-radius: var(--radius-sm);
  z-index: 1;
  position: relative;
}
.dr-cal .calendar-grid .day.range-start {
  background: linear-gradient(to right, #F2F6FC 50%, #F2F6FC 50%);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.dr-cal .calendar-grid .day.range-end {
  background: linear-gradient(to left, #F2F6FC 50%, #F2F6FC 50%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
/* Start/end keep their dark fill on top */
.dr-cal .calendar-grid .day.range-start.selected,
.dr-cal .calendar-grid .day.range-end.selected {
  background: var(--app-fg);
  border-radius: var(--radius-sm);
}

.dr-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 16px;
  background: #FFFFFF;
  border-top: 1px solid var(--app-border);
}
.dr-range-label {
  font-size: 13px;
  color: var(--app-fg);
}
.dr-range-key {
  color: var(--app-fg-3);
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-right: 6px;
}
.dr-actions {
  display: flex;
  gap: 6px;
}

@media (max-width: 900px) {
  .dr-top { flex-direction: column; }
  .dr-presets {
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
  }
  .dr-cals { flex-direction: column; }
  .dr-cal + .dr-cal { border-left: 0; border-top: 1px solid var(--app-border); }
}
