/* ==========================================================================
   PHARMASSISTLY — DESIGN TOKENS
   Single source of truth. Used by marketing, dashboard, plugin, compliance.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ---- Neutrals (shared across all surfaces) ---- */
  --cream:        #F5EFE6;
  --cream-soft:   #FAF6EF;
  --cream-edge:   #EFE7D7;
  --ink:          #1C2624;    /* 13.59:1 on cream — headlines, body */
  --ink-soft:     #3A4A45;    /* 8.18:1 on cream — nav text, secondary body */
  --ink-mute:     #4D5754;    /* 5.90:1 on cream — page subtitles, captions (AA) */
  --stone:        #6A6457;    /* 5.16:1 / 4.72:1 / 5.47:1 on cream / cream-edge / cream-soft — eyebrows, labels, headers */
  /* --rule / --rule-strong are DECORATIVE dividers only (WCAG 1.4.11 exempt).
     For load-bearing boundaries (input borders, card edges that convey grouping)
     use --ink-soft at the edge, or apply a 1px --ink-mute border. */
  --rule:         rgba(28,38,36,0.08);
  --rule-strong:  rgba(28,38,36,0.16);

  /* ---- Brand greens ---- */
  --sage:         #5C7A68;
  --sage-ink:     #2F4A3A;
  --sage-light:   #B3C5B7;
  --sage-tint:    #E4ECDF;
  --deep:         #1F3A34;

  /* ---- Accents ---- */
  --amber:        #D4A574;
  --amber-ink:    #7A5528;      /* 5.42:1 on cream, 4.95:1 on amber-tint — badge text (AA) */
  --amber-tint:   #F5E6CC;
  --terracotta:   #C97A5C;
  --terracotta-ink:#8B4A35;
  --terracotta-tint:#F5DDD0;
  --slate:        #6B7A8C;
  --slate-tint:   #DDE3EA;

  /* ---- Type ramp ---- */
  --serif: 'Fraunces', Georgia, serif;
  --sans:  'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:  'JetBrains Mono', Menlo, monospace;

  /* ---- Spacing ---- */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap:    16px;
  --gap-md: 24px;
  --gap-lg: 40px;
  --gap-xl: 64px;
  --gap-xxl:96px;

  /* ---- Radii ---- */
  --r-sm: 4px;
  --r:    8px;
  --r-md: 12px;
  --r-lg: 16px;

  /* ---- Shadows ---- */
  --shadow-soft: 0 1px 2px rgba(28,38,36,0.04), 0 4px 12px rgba(28,38,36,0.06);
  --shadow-md:   0 4px 16px rgba(28,38,36,0.08), 0 12px 32px rgba(28,38,36,0.10);
  --shadow-lg:   0 12px 48px rgba(28,38,36,0.16);

  /* ---- Motion ---- */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* ---- Grid system (mirrors reference/product-tokens.css) ----
     Breakpoints, gutters, margins, column counts per tier. Pair with
     reference/grid.css for utilities. */
  --bp-sm: 480px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  --container-sm:    640px;
  --container-md:    768px;
  --container-lg:    1024px;
  --container-xl:    1200px;
  --container-prose: 720px;   /* editorial reading column */

  --gutter-xs: 16px; --gutter-sm: 16px; --gutter-md: 20px; --gutter-lg: 24px;
  --margin-xs: 20px; --margin-sm: 24px; --margin-md: 32px; --margin-lg: 40px; --margin-xl: 56px;

  --cols-xs: 4; --cols-md: 8; --cols-lg: 12;
}

/* ==========================================================================
   SURFACE INTENSITY MODES
   The same tokens, applied at three different intensities depending on context.
   - .surface-marketing  → full-bleed chapter blocks, accents at 100%
   - .surface-product    → cream everywhere, accents reserved for state
   - .surface-plugin     → near-neutral, single accent (sage), respects host UI
   ========================================================================== */

/* MARKETING — the persuasive surface */
.surface-marketing {
  --accent-allowed-amber: 1;
  --accent-allowed-terracotta: 1;
  --accent-allowed-slate: 1;
  --chapter-block-opacity: 1;
  background: var(--cream);
  color: var(--ink);
}

/* PRODUCT — the working surface */
.surface-product {
  --accent-allowed-amber: 1;     /* state only */
  --accent-allowed-terracotta: 1;/* state only */
  --accent-allowed-slate: 0;
  --chapter-block-opacity: 0;    /* no chapter blocks */
  background: var(--cream-soft);
  color: var(--ink);
}

/* PLUGIN — the polite overlay */
.surface-plugin {
  --accent-allowed-amber: 0;
  --accent-allowed-terracotta: 0;
  --accent-allowed-slate: 0;
  --chapter-block-opacity: 0;
  background: var(--cream);
  color: var(--ink);
}

/* ==========================================================================
   GLOBAL RESET + BASE
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

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

.serif       { font-family: var(--serif); font-variation-settings: 'opsz' 144; font-weight: 400; letter-spacing: -0.015em; }
.serif-h     { font-family: var(--serif); font-variation-settings: 'opsz' 144; font-weight: 400; letter-spacing: -0.015em; line-height: 1.05; }
.serif-italic{ font-family: var(--serif); font-variation-settings: 'opsz' 144; font-weight: 400; font-style: italic; }
.mono        { font-family: var(--mono); font-feature-settings: 'tnum' 1, 'zero' 1; }
.eyebrow     { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--stone); }
.tnum        { font-variant-numeric: tabular-nums; }

/* ==========================================================================
   COMPONENT PRIMITIVES (used across surfaces)
   ========================================================================== */

/* --- Buttons ---
   Semantic roles — use these in markup:
     .btn-primary     main CTA ("See a demo", "Start pilot")
     .btn-secondary   brand-weighted secondary action (sage)
     .btn-tertiary    outlined, low-emphasis (was .btn-outline)
     .btn-ghost       flat, no border (inline actions, table rows)
     .btn-accent      amber — sparingly, for promotional moments
     .btn-destructive terracotta — irreversible / negative actions
     .btn-link        inline text-link styled as a button
   Size modifiers: .btn-sm, .btn-lg
   Color-named aliases (.btn-sage, .btn-outline, .btn-gold) are retained
   for backwards compatibility — prefer the semantic names in new work.
*/
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r);
  font-family: var(--sans); font-size: 14px; font-weight: 500;
  border: 1px solid transparent; background: transparent;
  transition: all .15s var(--ease);
  cursor: pointer; white-space: nowrap;
}
.btn-primary       { background: var(--ink); color: var(--cream); }
.btn-primary:hover { background: var(--sage-ink); }

.btn-secondary,
.btn-sage          { background: var(--sage-ink); color: var(--cream); }
.btn-secondary:hover,
.btn-sage:hover    { background: var(--ink); }

.btn-tertiary,
.btn-outline       { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-tertiary:hover,
.btn-outline:hover { background: var(--cream-edge); border-color: var(--ink); }

.btn-ghost         { background: transparent; color: var(--ink-soft); border-color: transparent; }
.btn-ghost:hover   { background: var(--cream-edge); color: var(--ink); }

.btn-accent,
.btn-gold          { background: var(--amber); color: var(--ink); }
.btn-accent:hover,
.btn-gold:hover    { background: var(--amber-ink); color: var(--cream); }

.btn-destructive       { background: var(--terracotta-ink); color: var(--cream); }
.btn-destructive:hover { background: var(--ink); }

.btn-link     { padding: 0; background: transparent; color: var(--sage-ink); text-decoration: underline; text-underline-offset: 3px; border-color: transparent; }
.btn-link:hover { color: var(--ink); }

.btn-sm       { padding: 6px 12px; font-size: 13px; }
.btn-lg       { padding: 14px 22px; font-size: 15px; }

.btn[disabled], .btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* --- Status badges (the only place plugin allows colour) --- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  border: 1px solid transparent;
}
.badge-sage      { background: var(--sage-tint); color: var(--sage-ink); border-color: rgba(47,74,58,0.18); }
.badge-amber     { background: var(--amber-tint); color: var(--amber-ink); border-color: rgba(139,99,50,0.20); }
.badge-terra     { background: var(--terracotta-tint); color: var(--terracotta-ink); border-color: rgba(139,74,53,0.20); }
.badge-slate     { background: var(--slate-tint); color: #3D4856; border-color: rgba(61,72,86,0.18); }
.badge-ghost     { background: transparent; color: var(--stone); border-color: var(--rule-strong); }

/* --- Card --- */
.card {
  background: var(--cream-soft);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 24px;
}
.card-flat {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  padding: 20px;
}

/* --- KPI tile --- */
.kpi { display: flex; flex-direction: column; gap: 8px; }
.kpi-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--stone); }
.kpi-value { font-family: var(--serif); font-variation-settings: 'opsz' 144; font-weight: 400; font-size: 40px; line-height: 1; letter-spacing: -0.02em; color: var(--ink); }
.kpi-delta { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.kpi-delta.up   { color: var(--sage-ink); }
.kpi-delta.down { color: var(--terracotta-ink); }

/* --- Table --- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--stone);
  padding: 12px 16px; border-bottom: 1px solid var(--rule);
}
.tbl td {
  padding: 14px 16px; border-bottom: 1px solid var(--rule); vertical-align: middle;
}
.tbl tr:hover td { background: var(--cream-soft); }
.tbl .num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.tbl .drug { font-weight: 500; }
.tbl .ndc  { font-family: var(--mono); font-size: 11px; color: var(--stone); }

/* --- Header / nav --- */
.hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--rule);
  background: var(--cream);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(6px);
}
.hdr-lockup { display: flex; align-items: center; gap: 10px; }
.hdr-lockup img { height: 32px; width: auto; }
.hdr-lockup .wm { font-family: var(--serif); font-variation-settings: 'opsz' 32; font-weight: 500; font-size: 22px; letter-spacing: -0.01em; color: var(--ink); }
.hdr-nav { display: flex; align-items: center; gap: 28px; }
.hdr-nav a { font-size: 14px; font-weight: 500; color: var(--ink-soft); }
.hdr-nav a:hover, .hdr-nav a.active { color: var(--ink); }

/* --- Sidebar --- */
.side {
  background: var(--cream);
  border-right: 1px solid var(--rule);
  padding: 24px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.side-section { font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--stone); padding: 16px 12px 8px; }
.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--r-sm);
  font-size: 14px; color: var(--ink-soft);
  transition: background .12s var(--ease);
}
.side a:hover { background: var(--cream-edge); color: var(--ink); }
.side a.active { background: var(--ink); color: var(--cream); }
.side a.active .ic { opacity: 1; }
.side .ic { width: 16px; height: 16px; opacity: .65; flex-shrink: 0; }

/* --- Page chrome --- */
.page-title {
  font-family: var(--serif); font-variation-settings: 'opsz' 144; font-weight: 400;
  font-size: 36px; line-height: 1.1; letter-spacing: -0.02em; color: var(--ink);
  margin: 0 0 8px;
}
.page-sub {
  font-size: 15px; color: var(--ink-mute); margin: 0 0 32px; max-width: 60ch;
}

/* --- Sparkline / mini chart --- */
.spark { width: 100%; height: 36px; }
.spark path.area { fill: var(--sage-tint); }
.spark path.line { fill: none; stroke: var(--sage-ink); stroke-width: 1.5; }

/* --- Toast / notification stripe --- */
.stripe-amber {
  background: var(--amber-tint);
  border: 1px solid rgba(139,99,50,0.18);
  border-left: 3px solid var(--amber);
  padding: 14px 18px; border-radius: var(--r);
  font-size: 14px; color: var(--ink);
  display: flex; align-items: center; gap: 12px;
}
.stripe-sage {
  background: var(--sage-tint);
  border: 1px solid rgba(47,74,58,0.18);
  border-left: 3px solid var(--sage-ink);
  padding: 14px 18px; border-radius: var(--r);
  font-size: 14px; color: var(--ink);
}

/* --- Utility --- */
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: var(--gap); }
.col { display: flex; flex-direction: column; gap: var(--gap); }
.between { justify-content: space-between; }
.grow { flex: 1; }
.tac { text-align: center; }
.tar { text-align: right; }
