/* =========================================================
   CLAUSAL — Design tokens
   B2B healthcare AI claims review co-pilot
   ========================================================= */

:root {
  /* ---------- Color: neutrals (cool, slight blue undertone) ---------- */
  --c-bg:           oklch(98.6% 0.004 240);   /* canvas — slightly cooler, more contrast w/ cards */
  --c-surface:      oklch(100% 0 0);          /* card */
  --c-surface-2:    oklch(98.2% 0.004 240);   /* sunken / striped */
  --c-surface-3:    oklch(96.4% 0.005 240);   /* hover */
  --c-overlay:      oklch(20% 0.01 240 / 0.45);

  --c-border:       oklch(93.5% 0.005 240);   /* hairline — softer */
  --c-border-strong:oklch(89% 0.007 240);
  --c-divider:      oklch(95% 0.004 240);

  --c-text:         oklch(22% 0.012 240);     /* primary text */
  --c-text-2:       oklch(40% 0.012 240);     /* secondary */
  --c-text-3:       oklch(55% 0.012 240);     /* tertiary / meta */
  --c-text-4:       oklch(68% 0.010 240);     /* disabled / placeholder */
  --c-text-on-accent: oklch(99% 0.003 240);

  /* ---------- Color: primary (teal — confident, accessible) ---------- */
  --c-primary-50:   oklch(97% 0.022 200);
  --c-primary-100:  oklch(93% 0.045 200);
  --c-primary-200:  oklch(86% 0.075 200);
  --c-primary-300:  oklch(76% 0.100 200);
  --c-primary-400:  oklch(64% 0.115 200);
  --c-primary-500:  oklch(54% 0.115 200);  /* base — meets 4.5:1 on white */
  --c-primary-600:  oklch(46% 0.105 200);
  --c-primary-700:  oklch(38% 0.085 200);
  --c-primary-800:  oklch(30% 0.065 200);
  --c-primary-900:  oklch(22% 0.040 200);

  /* ---------- Semantic accents (shared chroma 0.11, varying hue) ---------- */
  /* Green — agree / confirmed */
  --c-success-50:   oklch(96% 0.025 150);
  --c-success-100:  oklch(92% 0.045 150);
  --c-success-500:  oklch(62% 0.110 150);
  --c-success-600:  oklch(54% 0.105 150);
  --c-success-700:  oklch(44% 0.090 150);

  /* Amber — adjust / caution */
  --c-warning-50:   oklch(96.5% 0.030 80);
  --c-warning-100:  oklch(93% 0.060 80);
  --c-warning-500:  oklch(72% 0.130 75);
  --c-warning-600:  oklch(64% 0.130 70);
  --c-warning-700:  oklch(52% 0.115 65);

  /* Red — deny / reject */
  --c-danger-50:    oklch(96.5% 0.022 25);
  --c-danger-100:   oklch(93% 0.045 25);
  --c-danger-500:   oklch(60% 0.150 25);
  --c-danger-600:   oklch(53% 0.155 25);
  --c-danger-700:   oklch(44% 0.140 25);

  /* Info / neutral accent (used sparingly, for "in review" etc.) */
  --c-info-50:      oklch(96% 0.020 260);
  --c-info-100:     oklch(92% 0.040 260);
  --c-info-500:     oklch(60% 0.105 260);
  --c-info-700:     oklch(45% 0.090 260);

  /* ---------- Typography ---------- */
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Type scale — deliberate gaps between levels */
  --fs-11: 11px;   /* labels, captions */
  --fs-12: 12px;   /* metadata */
  --fs-13: 13px;   /* dense table body */
  --fs-14: 14px;
  --fs-15: 15px;   /* default body */
  --fs-16: 16px;
  --fs-18: 18px;   /* section heading */
  --fs-20: 20px;
  --fs-24: 24px;   /* page heading */
  --fs-30: 30px;
  --fs-36: 36px;
  --fs-48: 48px;   /* hero metric */

  --lh-tight: 1.15;
  --lh-snug:  1.35;
  --lh-base:  1.5;

  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  --tracking-tight:  -0.01em;
  --tracking-normal: 0;
  --tracking-caps:   0.04em;

  /* ---------- Spacing (4px base) ---------- */
  --s-0:  0;
  --s-1:  2px;
  --s-2:  4px;
  --s-3:  6px;
  --s-4:  8px;
  --s-5:  10px;
  --s-6:  12px;
  --s-7:  14px;
  --s-8:  16px;
  --s-10: 20px;
  --s-12: 24px;
  --s-14: 28px;
  --s-16: 32px;
  --s-20: 40px;
  --s-24: 48px;
  --s-32: 64px;

  /* ---------- Radii ---------- */
  --r-2: 2px;
  --r-4: 4px;   /* inputs, dense controls */
  --r-6: 6px;   /* buttons */
  --r-8: 8px;
  --r-10: 10px; /* small cards */
  --r-12: 12px; /* default cards */
  --r-14: 14px; /* prominent cards */
  --r-16: 16px; /* hero / metric cards */
  --r-full: 999px;

  /* ---------- Shadows (Material-inspired elevation, very soft) ---------- */
  /* sh-flat: hairline only, no shadow — for densely-packed surfaces */
  --sh-flat: none;
  /* sh-xs: barely-there ambient — for cards on canvas */
  --sh-xs: 0 1px 2px 0 oklch(25% 0.02 240 / 0.04);
  /* sh-sm: rest state for floating panels (card on canvas) */
  --sh-sm: 0 1px 2px 0 oklch(25% 0.02 240 / 0.04), 0 2px 6px -2px oklch(25% 0.02 240 / 0.05);
  /* sh-md: hovered cards, popovers */
  --sh-md: 0 2px 4px -1px oklch(25% 0.02 240 / 0.05), 0 6px 16px -4px oklch(25% 0.02 240 / 0.08);
  /* sh-lg: modals, prominent overlays */
  --sh-lg: 0 4px 8px -2px oklch(25% 0.02 240 / 0.06), 0 16px 32px -8px oklch(25% 0.02 240 / 0.14);
  --sh-focus: 0 0 0 3px oklch(54% 0.115 200 / 0.30);
  --sh-focus-ring: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--c-primary-500);

  /* ---------- Density tokens ---------- */
  --row-h-sm: 28px;
  --row-h-md: 32px;
  --row-h-lg: 36px;

  --ctrl-h-sm: 24px;
  --ctrl-h-md: 28px;
  --ctrl-h-lg: 32px;

  /* ---------- Motion ---------- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 280ms;

  /* ---------- Z ---------- */
  --z-nav: 10;
  --z-sticky: 20;
  --z-popover: 40;
  --z-modal: 60;
  --z-toast: 80;
}

/* =========================================================
   Base resets / defaults
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-14);
  line-height: var(--lh-base);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01", "ss03";
}
button { font-family: inherit; }

/* =========================================================
   Typography roles
   ========================================================= */
.t-display {
  font-size: var(--fs-30);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  color: var(--c-text);
}
.t-h1 { font-size: var(--fs-24); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); line-height: var(--lh-tight); }
.t-h2 { font-size: var(--fs-18); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.t-h3 { font-size: var(--fs-15); font-weight: var(--fw-semibold); line-height: var(--lh-snug); }
.t-body { font-size: var(--fs-14); font-weight: var(--fw-regular); line-height: var(--lh-base); }
.t-body-strong { font-size: var(--fs-14); font-weight: var(--fw-medium); line-height: var(--lh-base); }
.t-small { font-size: var(--fs-13); line-height: var(--lh-snug); color: var(--c-text-2); }
.t-meta { font-size: var(--fs-12); line-height: var(--lh-snug); color: var(--c-text-3); }
.t-caps {
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--c-text-3);
}
.t-mono {
  font-family: var(--font-mono);
  font-size: var(--fs-13);
  font-feature-settings: "zero", "ss01";
  letter-spacing: -0.01em;
}
.t-num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "ss01";
}

/* =========================================================
   Components — Buttons
   ========================================================= */
.btn {
  --btn-h: var(--ctrl-h-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  height: var(--btn-h);
  padding: 0 var(--s-7);
  border-radius: var(--r-6);
  font-size: var(--fs-13);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--c-text);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--sh-focus); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }

.btn--sm { --btn-h: var(--ctrl-h-md); padding: 0 var(--s-5); font-size: var(--fs-12); }
.btn--lg { --btn-h: 36px; padding: 0 var(--s-10); font-size: var(--fs-14); }

.btn--primary {
  background: var(--c-primary-600);
  color: var(--c-text-on-accent);
  border-color: var(--c-primary-700);
  box-shadow: var(--sh-xs);
}
.btn--primary:hover { background: var(--c-primary-700); }
.btn--primary:active { background: var(--c-primary-800); }

.btn--secondary {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border-strong);
  box-shadow: var(--sh-xs);
}
.btn--secondary:hover { background: var(--c-surface-3); }

.btn--ghost { background: transparent; color: var(--c-text-2); }
.btn--ghost:hover { background: var(--c-surface-3); color: var(--c-text); }

.btn--success {
  background: var(--c-success-600);
  color: var(--c-text-on-accent);
  border-color: var(--c-success-700);
}
.btn--success:hover { background: var(--c-success-700); }

.btn--warning {
  background: var(--c-warning-600);
  color: oklch(20% 0.02 80);
  border-color: var(--c-warning-700);
}
.btn--warning:hover { background: var(--c-warning-700); color: var(--c-text-on-accent); }

.btn--danger {
  background: var(--c-danger-600);
  color: var(--c-text-on-accent);
  border-color: var(--c-danger-700);
}
.btn--danger:hover { background: var(--c-danger-700); }

.btn--icon {
  width: var(--btn-h);
  padding: 0;
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  margin-left: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Solid status badges — high-contrast, never color-alone */
.badge--solid-success { background: var(--c-success-700); color: #fff; border-color: transparent; }
.badge--solid-warning { background: var(--c-warning-700); color: #fff; border-color: transparent; }
.badge--solid-danger  { background: var(--c-danger-700);  color: #fff; border-color: transparent; }
.badge--solid-neutral { background: var(--c-text); color: #fff; border-color: transparent; }

/* Sr-only — visually hidden but available to assistive tech */
.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;
}

/* Visible focus ring on every interactive element by default */
a:focus-visible, button:focus-visible, [tabindex]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--sh-focus);
  border-radius: var(--r-4);
}
.btn--primary .kbd { background: oklch(46% 0.090 195); border-color: oklch(38% 0.070 195); color: var(--c-text-on-accent); }

/* =========================================================
   Components — Badges / Pills
   ========================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-4);
  font-size: var(--fs-11);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  background: var(--c-surface-3);
  color: var(--c-text-2);
  border: 1px solid var(--c-border);
}
.badge--neutral  { background: var(--c-surface-3); color: var(--c-text-2); }
.badge--primary  { background: var(--c-primary-50); color: var(--c-primary-700); border-color: var(--c-primary-100); }
.badge--success  { background: var(--c-success-50); color: var(--c-success-700); border-color: var(--c-success-100); }
.badge--warning  { background: var(--c-warning-50); color: var(--c-warning-700); border-color: var(--c-warning-100); }
.badge--danger   { background: var(--c-danger-50);  color: var(--c-danger-700);  border-color: var(--c-danger-100); }
.badge--info     { background: var(--c-info-50);    color: var(--c-info-700);    border-color: var(--c-info-100); }

.badge--solid.badge--primary { background: var(--c-primary-600); color: #fff; border-color: transparent; }
.badge--solid.badge--success { background: var(--c-success-600); color: #fff; border-color: transparent; }
.badge--solid.badge--warning { background: var(--c-warning-500); color: oklch(20% 0.02 80); border-color: transparent; }
.badge--solid.badge--danger  { background: var(--c-danger-600);  color: #fff; border-color: transparent; }

.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.dot--success { background: var(--c-success-500); }
.dot--warning { background: var(--c-warning-500); }
.dot--danger  { background: var(--c-danger-500); }
.dot--info    { background: var(--c-info-500); }
.dot--neutral { background: var(--c-text-3); }

/* =========================================================
   Components — Inputs
   ========================================================= */
.input,
.select,
.textarea {
  display: inline-flex;
  align-items: center;
  height: var(--ctrl-h-lg);
  padding: 0 var(--s-5);
  font-size: var(--fs-13);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-4);
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
  width: 100%;
  font-family: inherit;
}
.input::placeholder { color: var(--c-text-4); }
.input:hover { border-color: oklch(80% 0.01 240); }
.input:focus { outline: none; border-color: var(--c-primary-500); box-shadow: var(--sh-focus); }
.textarea { height: auto; padding: var(--s-5) var(--s-5); line-height: var(--lh-snug); }

.field-label {
  display: block;
  font-size: var(--fs-12);
  font-weight: var(--fw-medium);
  color: var(--c-text-2);
  margin-bottom: 4px;
}
.field-help {
  font-size: var(--fs-11);
  color: var(--c-text-3);
  margin-top: 4px;
}

/* =========================================================
   Components — Cards / Panels
   ========================================================= */
/* Cards — soft floating panels.
   Default: hairline border + no shadow. Use .card--raised for soft shadow + no border. */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-12);
  box-shadow: var(--sh-flat);
}
.card--raised {
  border: 1px solid transparent;
  box-shadow: var(--sh-sm);
}
.card--lg { border-radius: var(--r-14); }
.card--xl { border-radius: var(--r-16); }
.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-12) var(--s-16);
}
.card__body { padding: var(--s-16); }
.card__body--lg { padding: var(--s-20) var(--s-24); }

.metric { padding: var(--s-20) var(--s-24); }
.metric__label { font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--c-text-3); letter-spacing: 0; text-transform: none; }
.metric__value { font-family: var(--font-sans); font-size: 40px; font-weight: var(--fw-semibold); letter-spacing: -0.025em; font-variant-numeric: tabular-nums; line-height: 1.05; margin-top: var(--s-6); color: var(--c-text); }
.metric__delta { font-size: var(--fs-12); font-variant-numeric: tabular-nums; margin-top: var(--s-4); color: var(--c-text-3); font-weight: var(--fw-regular); }
.metric__delta--up { color: var(--c-success-700); }
.metric__delta--down { color: var(--c-danger-700); }

/* =========================================================
   Components — Table (dense)
   ========================================================= */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-13);
}
.table th {
  text-align: left;
  font-size: var(--fs-11);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--c-text-3);
  padding: 6px 10px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td {
  padding: 0 10px;
  height: var(--row-h-md);
  border-bottom: 1px solid var(--c-divider);
  color: var(--c-text);
  vertical-align: middle;
}
.table tr:hover td { background: var(--c-surface-2); }
.table tr.is-selected td { background: var(--c-primary-50); }

/* =========================================================
   Utility
   ========================================================= */
.u-row { display: flex; align-items: center; gap: var(--s-4); }
.u-col { display: flex; flex-direction: column; gap: var(--s-4); }
.u-stack { display: flex; flex-direction: column; }
.u-spacer { flex: 1; }
.u-divider { height: 1px; background: var(--c-divider); width: 100%; }
.u-divider--v { width: 1px; background: var(--c-divider); align-self: stretch; }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-mono { font-family: var(--font-mono); font-feature-settings: "zero"; letter-spacing: -0.01em; }
.u-num { font-variant-numeric: tabular-nums; }
.u-muted { color: var(--c-text-3); }
.u-text-2 { color: var(--c-text-2); }

/* Subtle striped placeholder for imagery */
.placeholder-img {
  background-image: repeating-linear-gradient(
    45deg,
    var(--c-surface-2) 0 8px,
    var(--c-surface-3) 8px 16px
  );
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--fs-12);
  color: var(--c-text-3);
}
