/* ============================================================
   UNLEVERED — Base & Reset
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--type-body-md);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background: var(--surface-page);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--text-primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

hr { border: 0; border-top: 1px solid var(--border-default); margin: var(--space-8) 0; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 500; line-height: var(--leading-snug); }

/* ============================================================
   TYPOGRAPHY CLASSES
   ============================================================ */

.t-display-2xl, .t-display-xl, .t-display-lg, .t-display-md, .t-display-sm {
  font-family: var(--font-display);
  font-weight: 500;
  font-optical-sizing: auto;
  line-height: var(--leading-tight);
  letter-spacing: -0.022em;
  color: var(--text-primary);
}
.t-display-2xl { font-size: var(--type-display-2xl); }
.t-display-xl  { font-size: var(--type-display-xl); }
.t-display-lg  { font-size: var(--type-display-lg); }
.t-display-md  { font-size: var(--type-display-md); }
.t-display-sm  { font-size: var(--type-display-sm); }

.t-h-xl, .t-h-lg, .t-h-md, .t-h-sm, .t-h-xs {
  font-family: var(--font-body);
  font-weight: 500;
  line-height: var(--leading-snug);
  letter-spacing: var(--tracking-snug);
  color: var(--text-primary);
}
.t-h-xl { font-size: var(--type-heading-xl); }
.t-h-lg { font-size: var(--type-heading-lg); }
.t-h-md { font-size: var(--type-heading-md); }
.t-h-sm { font-size: var(--type-heading-sm); }
.t-h-xs { font-size: var(--type-heading-xs); }

.t-body-xl { font-size: var(--type-body-xl); line-height: var(--leading-relaxed); }
.t-body-lg { font-size: var(--type-body-lg); line-height: var(--leading-relaxed); }
.t-body-md { font-size: var(--type-body-md); line-height: var(--leading-normal); }
.t-body-sm { font-size: var(--type-body-sm); line-height: var(--leading-normal); color: var(--text-secondary); }
.t-body-xs { font-size: var(--type-body-xs); line-height: var(--leading-normal); color: var(--text-secondary); }

.t-eyebrow {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary);
}

.t-mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.t-num  { font-variant-numeric: tabular-nums; }

.t-muted { color: var(--text-secondary); }
.t-faint { color: var(--text-tertiary); }
.t-accent { color: var(--text-accent); }
.t-brand  { color: var(--text-brand); }
.t-serif  { font-family: var(--font-display); font-weight: 400; letter-spacing: var(--tracking-tight); }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  --btn-h: var(--field-h-md);
  --btn-px: 18px;
  --btn-fz: var(--type-body-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--btn-h);
  padding: 0 var(--btn-px);
  font-family: var(--font-body);
  font-size: var(--btn-fz);
  font-weight: 500;
  letter-spacing: -0.005em;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition:
    background var(--duration-fast) var(--ease-out),
    color      var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    transform  var(--duration-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:active { transform: translateY(0.5px); }
.btn[disabled], .btn.is-disabled {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}
.btn .icon { width: 16px; height: 16px; flex: none; }

.btn--sm { --btn-h: var(--field-h-sm); --btn-px: 12px; --btn-fz: var(--type-body-sm); }
.btn--lg { --btn-h: var(--field-h-lg); --btn-px: 22px; --btn-fz: var(--type-body-lg); }
.btn--icon { --btn-px: 0; width: var(--btn-h); }
.btn--block { width: 100%; }

.btn--primary {
  background: var(--action-primary-bg);
  color: var(--action-primary-fg);
  border-color: var(--action-primary-border);
}
.btn--primary:hover { background: var(--action-primary-bg-hover); border-color: var(--action-primary-bg-hover); }
.btn--primary:active { background: var(--action-primary-bg-active); }

/* Large-surface CTA: white background, forest-800 outline, forest-800 text.
   Use for hero CTAs, primary buttons >200px wide, and surfaces where copy
   lives inside a green block. See STORYBOARD §GG. */
.btn--primary-outline {
  background: var(--surface-raised);
  color: var(--action-primary-bg);
  border-color: var(--action-primary-bg);
  border-width: 1.5px;
}
.btn--primary-outline:hover { background: var(--ulv-forest-50); }
.btn--primary-outline:active { background: var(--ulv-forest-100); }

.btn--secondary {
  background: var(--action-secondary-bg);
  color: var(--action-secondary-fg);
  border-color: var(--action-secondary-border);
}
.btn--secondary:hover { background: var(--action-secondary-bg-hover); }

.btn--ghost {
  color: var(--action-ghost-fg);
  background: transparent;
}
.btn--ghost:hover { background: var(--action-ghost-bg-hover); }

.btn--danger {
  background: var(--action-danger-bg);
  color: var(--action-danger-fg);
  border-color: var(--action-danger-bg);
}
.btn--danger:hover { background: var(--action-danger-bg-hover); border-color: var(--action-danger-bg-hover); }
.btn--danger:focus-visible { box-shadow: var(--shadow-focus-danger); }

.btn--link {
  height: auto; padding: 0; border-radius: 0;
  background: transparent;
  color: var(--text-brand);
  border-bottom: 1px solid currentColor;
  border-color: transparent;
}
.btn--link:hover { color: var(--ulv-forest-700); }

/* ============================================================
   FORM FIELDS
   ============================================================ */

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: var(--type-body-sm); font-weight: 500;
  color: var(--text-primary);
}
.field-hint  { font-size: var(--type-body-xs); color: var(--text-tertiary); }
.field-error { font-size: var(--type-body-xs); color: var(--text-danger); }

.input, .select, .textarea {
  width: 100%;
  height: var(--field-h-md);
  padding: 0 12px;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--type-body-md);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 96px; line-height: var(--leading-normal); }
.input::placeholder, .textarea::placeholder { color: var(--field-placeholder); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--field-border-hover); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--field-border-focus);
  box-shadow: var(--shadow-focus);
}
.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--field-bg-disabled); color: var(--text-disabled); cursor: not-allowed;
}
.input--sm, .select--sm { height: var(--field-h-sm); font-size: var(--type-body-sm); padding: 0 10px; }
.input--lg, .select--lg { height: var(--field-h-lg); font-size: var(--type-body-lg); padding: 0 14px; }

/* Input with leading/trailing slot */
.input-group {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  height: var(--field-h-md);
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.input-group:focus-within { border-color: var(--field-border-focus); box-shadow: var(--shadow-focus); }
.input-group .input {
  border: 0; background: transparent; height: 100%; padding: 0 8px;
}
.input-group .input:focus { box-shadow: none; }
.input-group .input-affix {
  display: inline-flex; align-items: center; padding: 0 12px;
  color: var(--text-tertiary); font-size: var(--type-body-sm);
}
.input-group .input-affix svg { width: 16px; height: 16px; }
.input-group .input-affix:last-child { padding-left: 4px; }

/* Select with chevron */
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2368716B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 32px;
}

/* Checkbox & Radio */
.checkbox, .radio {
  appearance: none;
  width: 18px; height: 18px;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  flex: none;
}
.checkbox { border-radius: var(--radius-sm); }
.radio { border-radius: var(--radius-full); }
.checkbox:hover, .radio:hover { border-color: var(--field-border-hover); }
.checkbox:checked, .radio:checked {
  background: var(--ulv-forest-800); border-color: var(--ulv-forest-800);
}
.checkbox:checked::after {
  content: "";
  width: 10px; height: 10px;
  background: no-repeat center/contain url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='20 6 9 17 4 12'/></svg>");
}
.radio:checked::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ulv-white);
}
.checkbox:focus-visible, .radio:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.choice {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--type-body-md); color: var(--text-primary);
  cursor: pointer;
}

/* Toggle */
.toggle {
  position: relative;
  appearance: none;
  width: 36px; height: 20px;
  background: var(--ulv-stone-200);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
  flex: none;
}
.toggle::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ulv-white);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-out);
}
.toggle:checked { background: var(--ulv-forest-700); }
.toggle:checked::after { transform: translateX(16px); }
.toggle:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card--flat   { box-shadow: none; }
.card--raised { box-shadow: var(--shadow-sm); }
.card--lifted { box-shadow: var(--shadow-md); }

.card-header, .card-body, .card-footer { padding: var(--space-7); }
.card-header { padding-bottom: var(--space-5); display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-body   { padding-top: 0; }
.card-footer {
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.card-title { font-size: var(--type-heading-md); font-weight: 500; letter-spacing: var(--tracking-snug); }
.card-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary); font-weight: 500;
  margin-bottom: 4px;
}

/* Stat card */
.stat {
  display: flex; flex-direction: column; gap: 6px;
  padding: var(--space-7);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}
.stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary); font-weight: 500;
}
.stat-value {
  font-family: var(--font-display);
  font-size: 38px; line-height: 1.05; letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--type-body-sm);
  color: var(--text-success);
}
.stat-delta--down { color: var(--text-danger); }

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  height: 22px;
  font-size: var(--type-body-xs); font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--ulv-stone-100);
  color: var(--text-secondary);
  letter-spacing: 0;
}
.badge--success { background: var(--ulv-forest-100); color: var(--ulv-forest-700); }
.badge--warning { background: #FAEFD7; color: #8A6418; }
.badge--danger  { background: var(--ulv-terra-100); color: var(--ulv-terra-700); }
.badge--info    { background: #E2EBF3; color: var(--ulv-info); }
.badge--brand   { background: var(--ulv-forest-800); color: var(--ulv-white); }
.badge--outline { background: transparent; border: 1px solid var(--border-default); color: var(--text-secondary); }
.badge--dot::before {
  content: ""; width: 7px; height: 7px;
  background: currentColor;
}

/* ============================================================
   ALERTS / TOASTS
   ============================================================ */

.alert {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--ulv-stone-300);
}
.alert-icon { width: 18px; height: 18px; color: var(--text-tertiary); margin-top: 2px; }
.alert-title { font-weight: 500; font-size: var(--type-body-md); }
.alert-body  { font-size: var(--type-body-sm); color: var(--text-secondary); margin-top: 2px; }
.alert-close { color: var(--text-tertiary); padding: 4px; border-radius: var(--radius-sm); }
.alert-close:hover { background: var(--ulv-stone-100); }

.alert--success { border-left-color: var(--ulv-forest-600); background: var(--ulv-forest-50); }
.alert--success .alert-icon { color: var(--ulv-forest-600); }
.alert--warning { border-left-color: #C28A2C; background: #FAEFD7; }
.alert--warning .alert-icon { color: #8A6418; }
.alert--danger  { border-left-color: var(--ulv-terra-600); background: var(--ulv-terra-100); }
.alert--danger  .alert-icon { color: var(--ulv-terra-700); }
.alert--info    { border-left-color: var(--ulv-forest-700); background: var(--ulv-forest-100); }
.alert--info    .alert-icon { color: var(--ulv-forest-700); }

[data-theme="dark"] .alert--success { background: rgba(47, 111, 88, 0.15); }
[data-theme="dark"] .alert--warning { background: rgba(194, 138, 44, 0.15); }
[data-theme="dark"] .alert--danger  { background: rgba(181, 85, 43, 0.15); }
[data-theme="dark"] .alert--info    { background: rgba(47, 111, 88, 0.15); }

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: inline-flex;
  gap: var(--space-7);
  border-bottom: 1px solid var(--border-default);
}
.tab {
  position: relative;
  padding: 10px 0;
  font-size: var(--type-body-md);
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  cursor: pointer;
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab[aria-selected="true"], .tab.is-active {
  color: var(--text-primary);
  border-bottom-color: var(--ulv-forest-800);
}

/* Pill tabs */
.tabs--pill { gap: 4px; border: 0; padding: 4px; background: var(--ulv-stone-100); border-radius: var(--radius-md); }
.tabs--pill .tab {
  padding: 6px 14px; border-radius: var(--radius-sm); border: 0; margin: 0;
}
.tabs--pill .tab.is-active { background: var(--surface-raised); color: var(--text-primary); box-shadow: var(--shadow-xs); }
[data-theme="dark"] .tabs--pill { background: var(--ulv-stone-800); }

/* ============================================================
   ACCORDION
   ============================================================ */

.accordion-item { border-bottom: 1px solid var(--border-default); }
.accordion-item:first-child { border-top: 1px solid var(--border-default); }
.accordion-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 18px 4px;
  font-size: var(--type-body-lg); font-weight: 500;
  color: var(--text-primary); text-align: left;
}
.accordion-trigger .icon { transition: transform var(--duration-normal) var(--ease-out); color: var(--text-tertiary); }
.accordion-item[open] .accordion-trigger .icon { transform: rotate(180deg); color: var(--text-primary); }
.accordion-body { padding: 0 4px 22px; color: var(--text-secondary); }

/* ============================================================
   MODAL & DRAWER
   ============================================================ */

.modal-backdrop {
  position: fixed; inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  z-index: 100;
}
.modal {
  width: min(540px, calc(100vw - 32px));
  background: var(--surface-raised);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}
.modal-header {
  padding: 22px 24px 6px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.modal-title { font-size: var(--type-heading-lg); font-weight: 500; letter-spacing: var(--tracking-snug); }
.modal-body { padding: 6px 24px 20px; color: var(--text-secondary); font-size: var(--type-body-md); }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-canvas);
}

.drawer-backdrop {
  position: fixed; inset: 0;
  background: var(--surface-overlay);
  z-index: 100;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(440px, 100vw);
  background: var(--surface-raised);
  box-shadow: var(--shadow-xl);
  border-left: 1px solid var(--border-subtle);
  display: flex; flex-direction: column;
  z-index: 101;
}
.drawer-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
}
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-footer {
  padding: 16px 22px; border-top: 1px solid var(--border-subtle);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-raised);
}
table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--type-body-sm);
  font-variant-numeric: tabular-nums;
}
.table thead th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary);
  background: var(--surface-canvas);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-canvas); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .tot td {
  font-weight: 500; background: var(--surface-sunken);
  border-top: 1px solid var(--border-default); border-bottom: 0;
}

/* ============================================================
   AVATAR & USER MENU
   ============================================================ */

.avatar {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ulv-forest-100); color: var(--ulv-forest-800);
  font-size: var(--type-body-sm); font-weight: 500;
  border-radius: var(--radius-full);
  flex: none;
}
.avatar--sm { width: 28px; height: 28px; font-size: var(--type-body-xs); }
.avatar--lg { width: 48px; height: 48px; font-size: var(--type-body-lg); }
.avatar--square { border-radius: var(--radius-md); }
.avatar--terra { background: var(--ulv-terra-100); color: var(--ulv-terra-700); }
[data-theme="dark"] .avatar { background: var(--ulv-forest-700); color: var(--ulv-forest-100); }

/* ============================================================
   ICON BUTTON (utility shape)
   ============================================================ */

.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.icon-btn:hover { background: var(--ulv-stone-100); color: var(--text-primary); }
[data-theme="dark"] .icon-btn:hover { background: var(--ulv-stone-800); }
.icon-btn svg { width: 18px; height: 18px; }

/* ============================================================
   DIVIDERS, KBD, CODE
   ============================================================ */

.divider { height: 1px; background: var(--border-default); }
.divider--v { width: 1px; height: 24px; background: var(--border-default); }

kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--surface-canvas);
  border: 1px solid var(--border-default);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

code, .code {
  font-family: var(--font-mono); font-size: 0.92em;
  background: var(--surface-canvas);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
}

/* ============================================================
   PROGRESS
   ============================================================ */

.progress {
  height: 6px;
  background: var(--ulv-stone-100);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: var(--ulv-forest-700);
  border-radius: inherit;
  transition: width var(--duration-slow) var(--ease-out);
}
[data-theme="dark"] .progress { background: var(--ulv-stone-800); }

/* Stepper */
.steps {
  display: flex; align-items: center; gap: 12px;
  font-size: var(--type-body-sm);
}
.step { display: inline-flex; align-items: center; gap: 8px; color: var(--text-tertiary); }
.step-bullet {
  width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid var(--border-default);
  display: inline-grid; place-items: center;
  font-size: 11px; color: var(--text-tertiary);
  background: var(--surface-raised);
}
.step.is-done .step-bullet { background: var(--ulv-forest-700); border-color: var(--ulv-forest-700); color: var(--ulv-white); }
.step.is-active { color: var(--text-primary); font-weight: 500; }
.step.is-active .step-bullet { border-color: var(--ulv-forest-700); color: var(--ulv-forest-700); }
.step-divider { flex: 1; height: 1px; background: var(--border-default); min-width: 24px; }

/* ============================================================
   APP SHELL
   ============================================================ */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--surface-page);
}
.app-sidebar {
  border-right: 1px solid var(--border-subtle);
  background: var(--surface-raised);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.app-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.app-brand-mark {
  width: 32px; height: 32px;
  background: var(--ulv-forest-800);
  color: var(--ulv-white);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 19px; line-height: 1;
}
.app-brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: var(--tracking-tight);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary);
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: var(--type-body-md);
  color: var(--text-secondary);
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.nav-item:hover { background: var(--ulv-stone-100); color: var(--text-primary); text-decoration: none; }
[data-theme="dark"] .nav-item:hover { background: var(--ulv-stone-800); }
.nav-item.is-active {
  background: var(--ulv-forest-100); color: var(--ulv-forest-800); font-weight: 500;
}
[data-theme="dark"] .nav-item.is-active { background: rgba(47,111,88,0.20); color: #C9DDD3; }
.nav-item .icon { width: 18px; height: 18px; flex: none; }
.nav-item-badge {
  margin-left: auto;
  background: var(--ulv-stone-100); color: var(--text-secondary);
  font-size: 11px; padding: 1px 6px; border-radius: var(--radius-sm);
}
.nav-item.is-active .nav-item-badge { background: var(--ulv-forest-200); color: var(--ulv-forest-800); }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-topbar {
  position: sticky; top: 0; z-index: 5;
  height: var(--topbar-h);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border-subtle);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 520px) auto;
  align-items: center;
  gap: 24px;
  padding: 0 28px;
}
.app-content { padding: 32px 36px 64px; max-width: 1400px; width: 100%; align-self: center; }

/* ============================================================
   PAGE HEADER (in-app)
   ============================================================ */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--type-body-sm); color: var(--text-secondary);
  margin-bottom: 8px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 44px; line-height: 1.05; letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}
.page-sub { color: var(--text-secondary); margin-top: 6px; font-size: var(--type-body-md); }

/* ============================================================
   UTILITIES
   ============================================================ */

.row { display: flex; }
.col { display: flex; flex-direction: column; }
.center { display: flex; align-items: center; justify-content: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-end { justify-content: flex-end; }

.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }

.grid { display: grid; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.hide { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}


/* ═══════════════════════════════════════════════════════════════
   APP-SHELL & DASHBOARD STYLES
   Relocated from src/app/app/app.css on 2026-05-27.
   Next.js 15 nested-layout CSS injection was unreliable — keeping
   these in components.css guarantees they load site-wide via the
   root layout. The /app/* routes consume them via class names only.
   ═══════════════════════════════════════════════════════════════ */

/* App-shell page-specific styles. Most primitives (.app, .app-sidebar,
   .app-topbar, .app-main, .app-content, .nav-item, .card*, .avatar, etc.)
   already live in public/styles/components.css. This file holds the
   dashboard- and shell-specific rules that don't belong in the shared
   library — extracted from design-handoff/app/dashboard.html. */

/* Sidebar footer (account chip) + workspace help card */
.help-card {
  margin-top: auto;
  padding: 14px;
  background: var(--ulv-stone-25);
  border: 1px solid var(--border-subtle);
  font-size: var(--type-body-sm);
  color: var(--text-secondary);
  line-height: 1.45;
}

.ufoot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-top: 1px solid var(--border-subtle);
}

.theme-mini {
  display: inline-flex;
  background: var(--ulv-stone-50);
  border: 1px solid var(--border-subtle);
}

.theme-mini button {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 0;
  color: var(--text-tertiary);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.theme-mini button.is-active {
  background: var(--surface-raised);
  color: var(--text-primary);
}

/* Greeting */
.greeting {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.greeting em {
  font-style: italic;
  color: var(--text-accent, var(--ulv-terra-600));
}

.greeting-sub {
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Quick actions */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

@media (max-width: 980px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .quick-actions {
    grid-template-columns: 1fr;
  }
}

.qa {
  position: relative;
  text-align: left;
  padding: 20px;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast)
    var(--ease-out), background var(--duration-fast) var(--ease-out);
  min-height: 132px;
  font: inherit;
  color: inherit;
  text-decoration: none;
}

.qa:hover {
  border-color: var(--ulv-forest-600);
  transform: translateY(-1px);
}

.qa-ico {
  width: 36px;
  height: 36px;
  background: var(--ulv-forest-100);
  color: var(--ulv-forest-800);
  display: grid;
  place-items: center;
}

.qa-title {
  font-weight: 500;
  font-size: var(--type-body-md);
  color: var(--text-primary);
}

.qa-sub {
  font-size: var(--type-body-sm);
  color: var(--text-tertiary);
  line-height: 1.45;
  margin-top: 4px;
}

.qa--primary {
  background: var(--ulv-forest-800);
  border-color: var(--ulv-forest-800);
}

.qa--primary:hover {
  background: var(--ulv-forest-700);
  border-color: var(--ulv-forest-700);
}

.qa--primary .qa-title {
  color: var(--ulv-white);
}

.qa--primary .qa-sub {
  color: rgba(255, 255, 255, 0.7);
}

.qa--primary .qa-ico {
  background: rgba(255, 255, 255, 0.12);
  color: var(--ulv-white);
}

/* KPI strip — "action-focused", no $ YTD per round 3 G */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

@media (max-width: 980px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi {
  padding: 18px 20px;
  border-right: 1px solid var(--border-subtle);
}

.kpi:last-child {
  border-right: 0;
}

@media (max-width: 980px) {
  .kpi:nth-child(2n) {
    border-right: 0;
  }
  .kpi:nth-child(-n + 2) {
    border-bottom: 1px solid var(--border-subtle);
  }
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: var(--tracking-eyebrow);
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.kpi-delta {
  margin-top: 6px;
  font-size: var(--type-body-xs);
  color: var(--text-tertiary);
}

/* Dashboard 2-column grid */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
}

/* Activity feed */
.activity-list {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-ring {
  width: 26px;
  height: 26px;
  background: var(--ulv-stone-50);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  color: var(--text-tertiary);
  border-radius: 50%;
}

.activity-ring--done {
  background: var(--ulv-forest-50);
  border-color: var(--ulv-forest-200);
  color: var(--ulv-forest-700);
}

.activity-ring--alert {
  background: var(--ulv-terra-100);
  border-color: var(--ulv-terra-200);
  color: var(--ulv-terra-700);
}

.activity-title {
  font-size: var(--type-body-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.activity-meta {
  font-size: var(--type-body-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.activity-time {
  font-size: var(--type-body-xs);
  color: var(--text-tertiary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Studies list specifics */
.studies-table {
  width: 100%;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-collapse: collapse;
}

.studies-table thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  font-weight: 500;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--ulv-stone-25);
}

.studies-table thead th.num {
  text-align: right;
}

.studies-table tbody tr {
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out);
}

.studies-table tbody tr:hover {
  background: var(--ulv-stone-25);
}

.studies-table tbody tr:last-child td {
  border-bottom: 0;
}

.studies-table td {
  padding: 14px 16px;
  font-size: var(--type-body-sm);
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}

.studies-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.studies-table .property-cell strong {
  display: block;
  color: var(--text-primary);
  font-weight: 500;
}

.studies-table .property-cell .sub {
  display: block;
  font-size: var(--type-body-xs);
  color: var(--text-tertiary);
  margin-top: 2px;
}

.num-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.num-cell.is-faint {
  color: var(--text-tertiary);
}

.empty-state {
  background: var(--surface-raised);
  border: 1px dashed var(--border-default);
  padding: 64px 32px;
  text-align: center;
  color: var(--text-tertiary);
}

/* Study detail */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--type-body-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  margin-bottom: 12px;
}

.page-back:hover {
  color: var(--text-primary);
}

.page-title {
  font-family: var(--font-display);
  font-size: 36px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text-primary);
  margin: 0;
}

.page-sub {
  color: var(--text-secondary);
  font-size: var(--type-body-sm);
  margin-top: 6px;
}

/* Hero row */
.hero-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 980px) {
  .hero-row {
    grid-template-columns: 1fr;
  }
}

.summary-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  padding: 28px 32px;
}

.summary-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.summary-value {
  font-family: var(--font-display);
  font-size: 52px;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text-primary);
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}

.summary-sub {
  color: var(--text-secondary);
  font-size: var(--type-body-sm);
}

.summary-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.summary-meta-item .lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.summary-meta-item .val {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.timeline-card {
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* Tabs (visual only in V1) */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 16px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-tertiary);
  font-size: var(--type-body-sm);
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.is-active {
  color: var(--ulv-forest-800);
  border-bottom-color: var(--ulv-forest-800);
}

/* Study grid (main 2-col under hero) */
.study-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .study-grid {
    grid-template-columns: 1fr;
  }
}

/* Verdict card (engineer agent) */
.verdict-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

.verdict-pill.PASS {
  background: var(--ulv-forest-100);
  color: var(--ulv-forest-800);
}

.verdict-pill.ESCALATE_CPA,
.verdict-pill.ESCALATE_ADMIN {
  background: #e2ebf3;
  color: var(--ulv-info);
}

.verdict-pill.FAIL {
  background: var(--ulv-terra-100);
  color: var(--ulv-terra-700);
}

.check-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--type-body-sm);
}

.check-row:last-child {
  border-bottom: 0;
}

.check-row .ok {
  color: var(--ulv-forest-700);
}

.check-row .fail {
  color: var(--ulv-terra-700);
}

.check-row .label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
}

/* State banners shown at the top of study-detail */
.state-banner {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border-subtle);
  background: var(--surface-raised);
}

.state-banner-icon {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  background: var(--ulv-stone-50);
  color: var(--text-secondary);
}

.state-banner-body {
  flex: 1;
  min-width: 0;
}

.state-banner-title {
  font-weight: 500;
  font-size: var(--type-body-md);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.state-banner-msg {
  font-size: var(--type-body-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.state-banner.banner-info {
  border-color: #b9d0e3;
  background: #e8f0f7;
}
.state-banner.banner-info .state-banner-icon {
  background: var(--ulv-info, #1e40af);
  color: #fff;
}

.state-banner.banner-warn {
  border-color: #f0d8a5;
  background: #fdf6e3;
}
.state-banner.banner-warn .state-banner-icon {
  background: #92400e;
  color: #fff;
}

.state-banner.banner-success {
  border-color: var(--ulv-forest-200);
  background: var(--ulv-forest-50);
}
.state-banner.banner-success .state-banner-icon {
  background: var(--ulv-forest-700);
  color: #fff;
}
