/* Crestwood app kit: one stylesheet for every Crestwood client app.
   Tokens, base styles and the shared components. App-specific styles go in the app, after this file,
   and use these tokens rather than raw colors. The client's brand color fills one slot (--brand),
   set by the client's client.js; everything else stays the same across clients. Version 1, 2026-10-03. */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&family=Space+Grotesk:wght@500;600;700&display=swap");

/* ---- Tokens ------------------------------------------------------------------------------------------ */
:root {
  /* Client brand. Crestwood orange until client.js sets the client's own. */
  --brand: #c2410c;
  --brand-ink: #ffffff;
  --brand-dark: #fb923c;
  --brand-dark-ink: #1c0a02;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --sunk: #f7f9fb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --line-control: #8794a8;   /* edges of fields and buttons: 3:1 against white, as WCAG asks of controls */

  --accent: var(--brand);
  --accent-ink: var(--brand-ink);
  --accent-soft: color-mix(in srgb, var(--accent) 9%, var(--surface));
  --ok: #15803d;      --ok-soft: #ecfdf3;
  --warn: #a15c07;    --warn-soft: #fff6e5;
  --danger: #b42318;  --danger-soft: #fef3f2;
  --focus: #2563eb;
  --link: #1d4ed8;

  /* The frame: the header every app shares. Crestwood's deep navy, the same for every client. */
  --frame: #162544;
  --frame-2: #22355f;
  --frame-ink: #ffffff;
  --frame-muted: #a7b3cc;
  --frame-line: rgba(255, 255, 255, 0.14);

  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 12px 32px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.08);
  --page-max: 1280px;
  --gutter: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0f1a; --surface: #111827; --sunk: #0d1422; --ink: #e5e9f0; --ink-2: #c3cad6; --muted: #8e98aa;
    --line: #1f2a3a; --line-strong: #334155; --line-control: #5b6b82;
    --accent: var(--brand-dark); --accent-ink: var(--brand-dark-ink);
    --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1414;
    --focus: #7aa2ff; --link: #93b4ff;
    --frame: #0d1730; --frame-2: #1a2950; --frame-muted: #8f9cb8;
    --shadow-sm: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0f1a; --surface: #111827; --sunk: #0d1422; --ink: #e5e9f0; --ink-2: #c3cad6; --muted: #8e98aa;
  --line: #1f2a3a; --line-strong: #334155; --line-control: #5b6b82;
  --accent: var(--brand-dark); --accent-ink: var(--brand-dark-ink);
  --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #fbbf24; --warn-soft: #2a2110; --danger: #f87171; --danger-soft: #2c1414;
  --focus: #7aa2ff; --link: #93b4ff;
  --frame: #0d1730; --frame-2: #1a2950; --frame-muted: #8f9cb8;
  --shadow-sm: none; --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--line);
  color-scheme: dark;
}

/* ---- Base -------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--link); text-underline-offset: 2px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Layout ------------------------------------------------------------------------------------------ */
/* .page centers content. .bar is the strip under the header for the app's own context controls. */
.page { max-width: var(--page-max); margin: 0 auto; padding-inline: var(--gutter); }
.bar { background: var(--surface); border-bottom: 1px solid var(--line); }
.bar > .page { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; padding-block: 12px; }
.bar .grow { flex: 1 1 auto; }
.pane {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); min-width: 0; display: flex; flex-direction: column;
}
.pane-h {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 50px;
}
.pane-h h2 { font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.pane-h .sub { color: var(--muted); font-size: 12.5px; }
.pane-b { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.pane-f { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.foot { color: var(--muted); font-size: 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; padding-block: 8px 16px; }

/* ---- Buttons ----------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 5px 12px; border-radius: var(--r);
  border: 1px solid var(--line-control); background: var(--surface); color: var(--ink);
  font-size: 13px; font-weight: 600; line-height: 1.2; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); text-decoration: none;
}
.btn:hover { background: var(--sunk); border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 86%, #000); border-color: transparent; }
.btn.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.quiet:hover { background: var(--sunk); border-color: var(--line); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 28px; padding: 4px 10px; font-size: 12px; }
.btn.lg { min-height: 40px; padding: 8px 18px; font-size: 14px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn.primary:disabled:hover { background: var(--accent); }
.icon-btn {
  display: inline-grid; place-items: center; width: 28px; height: 28px; flex: none;
  border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--muted);
  cursor: pointer; font-size: 12px; line-height: 1;
}
.icon-btn:hover { background: var(--sunk); border-color: var(--line); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: transparent; border-color: transparent; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- Form controls ----------------------------------------------------------------------------------- */
/* Native inputs are styled everywhere, at zero specificity so an app can override them. */
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"]), select, textarea) {
  min-height: 34px; padding: 6px 10px; min-width: 0; max-width: 100%;
  border: 1px solid var(--line-control); border-radius: var(--r); background: var(--surface); color: var(--ink);
}
:where(textarea) { resize: vertical; line-height: 1.45; }
:where(input, select, textarea):hover { border-color: var(--muted); }
:where(input, select, textarea):focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
:where(input, select, textarea):disabled { opacity: 0.5; cursor: not-allowed; }
:where(input)::placeholder, :where(textarea)::placeholder { color: var(--muted); opacity: 0.8; }
:where(select) {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer; font-weight: 500;
  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='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
:where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--accent); width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.field .hint { font-size: 12px; color: var(--muted); }
.field .readout {
  padding: 7px 10px; border: 1px dashed var(--line-strong); border-radius: var(--r);
  font-size: 13px; font-weight: 500; background: var(--sunk); overflow-wrap: anywhere;
}
.field.inline { flex-direction: column; gap: 3px; }
.field.inline > label, .field.inline > .label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.search {
  padding-left: 32px !important;
  background: var(--sunk) 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='%2364748b' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 11px center;
}

/* ---- Tags, notices, empty and loading states --------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  background: var(--sunk); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.tag.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.notice {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--sunk); font-size: 12.5px; color: var(--ink-2);
  border-left-width: 3px;
}
.notice b { color: var(--ink); font-weight: 600; font-size: 13px; }
.notice.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); border-left-color: var(--warn); }
.notice.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); border-left-color: var(--ok); }
.notice.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); border-left-color: var(--danger); }
.notice.danger b { color: var(--danger); }
.empty { color: var(--muted); font-size: 13px; padding: 10px 0; }
.empty-state {
  display: flex; flex-direction: column; gap: 4px; padding: 20px 16px; text-align: center; align-items: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--sunk);
  color: var(--muted); font-size: 13px;
}
.empty-state b { color: var(--ink); font-size: 14px; font-weight: 600; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; vertical-align: -3px;
  border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor;
  animation: cw-spin 0.7s linear infinite;
}
.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunk), var(--line), var(--sunk)); background-size: 200% 100%; animation: cw-shimmer 1.2s ease-in-out infinite; min-height: 12px; }
@keyframes cw-spin { to { transform: rotate(360deg); } }
@keyframes cw-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---- Steps and segmented controls -------------------------------------------------------------------- */
.steps { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.step {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer;
}
.step:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.step .n, .num-badge {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--sunk); border: 1px solid var(--line-strong); color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
}
.step[aria-current="step"] { color: var(--ink); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.step[aria-current="step"] .n, .num-badge.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step:disabled { opacity: 0.5; cursor: default; }
.steps .sep { width: 16px; height: 1px; background: var(--line-strong); }
/* A finished step (data-done) shows a check instead of its number, and the line after it turns green. */
.step[data-done] { color: var(--ink-2); }
.step[data-done] .n { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); font-size: 0; }
.step[data-done] .n::before { content: "✓"; font-size: 12px; font-family: var(--font-ui); font-weight: 700; }
.steps .step[data-done] + .sep { background: var(--ok); height: 2px; }
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--sunk); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: var(--r-sm); font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"], .seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

/* ---- Header (rendered by app-header.js) -------------------------------------------------------------- */
/* Stays at the top while the page scrolls. Anything else sticky in an app sits below it: top: var(--cw-header-h). */
:root { --cw-header-h: 52px; }
.cw-header { background: var(--frame); color: var(--frame-ink); position: sticky; top: 0; z-index: 40; }
.cw-header-in {
  max-width: var(--page-max); margin: 0 auto; padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 10px; min-height: var(--cw-header-h);
}
.cw-client { display: inline-flex; align-items: center; gap: 9px; min-width: 0; color: inherit; text-decoration: none; }
.cw-mark {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; flex: none;
  background: var(--brand); color: var(--brand-ink); font-family: var(--font-display); font-weight: 700; font-size: 13px;
}
.cw-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.cw-client-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: -0.005em; white-space: nowrap; }
.cw-sep { color: var(--frame-muted); opacity: 0.6; font-size: 18px; font-weight: 300; }
.cw-switch { position: relative; min-width: 0; }
.cw-app {
  display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 10px 4px 8px; max-width: 100%;
  border: 1px solid transparent; border-radius: var(--r); background: transparent; color: var(--frame-ink);
  font-weight: 600; font-size: 14px; cursor: pointer;
}
.cw-app:hover, .cw-app[aria-expanded="true"] { background: var(--frame-2); border-color: var(--frame-line); }
.cw-app:focus-visible { outline-color: #fff; }
.cw-app[disabled] { cursor: default; background: transparent; border-color: transparent; }
.cw-app .cw-chev { color: var(--frame-muted); flex: none; transition: transform 0.15s; }
.cw-app[aria-expanded="true"] .cw-chev { transform: rotate(180deg); }
.cw-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 5px; background: var(--frame-2); color: var(--frame-ink); }
.cw-ico svg { width: 14px; height: 14px; }
.cw-menu {
  position: absolute; top: calc(100% + 6px); left: 0; width: min(340px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.cw-menu-h { padding: 8px 10px 6px; }
.cw-menu a {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 16px; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: var(--r); color: var(--ink); text-decoration: none;
}
.cw-menu a:hover, .cw-menu a:focus-visible { background: var(--sunk); outline: none; }
.cw-menu a[aria-disabled="true"] { opacity: 0.55; cursor: default; background: transparent; }
.cw-menu a:focus-visible { box-shadow: 0 0 0 2px var(--focus) inset; }
.cw-menu a .cw-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
.cw-menu a .cw-ico svg { width: 16px; height: 16px; }
.cw-menu a b { display: block; font-size: 13.5px; font-weight: 600; }
.cw-menu a small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; }
.cw-menu a .cw-check { color: var(--accent); visibility: hidden; }
.cw-menu a[aria-current="page"] .cw-check { visibility: visible; }
.cw-menu-sep { border-top: 1px solid var(--line); margin: 4px 0; }
a.cw-client:hover .cw-client-name { text-decoration: underline; text-underline-offset: 3px; }
.cw-menu-f { border-top: 1px solid var(--line); margin-top: 4px; padding: 8px 10px 4px; font-size: 11.5px; color: var(--muted); }
.cw-spacer { flex: 1 1 auto; }
.cw-env {
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap;
  padding: 3px 8px; border-radius: 999px; color: #fde68a; background: rgba(251, 191, 36, 0.14); border: 1px solid rgba(251, 191, 36, 0.35);
}
.cw-help {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: var(--r);
  color: var(--frame-ink); font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
  border: 1px solid transparent;
}
.cw-help:hover { background: var(--frame-2); border-color: var(--frame-line); }
.cw-help:focus-visible { outline-color: #fff; }
.cw-help svg { color: var(--frame-muted); }
.cw-help-by { color: var(--frame-muted); font-weight: 500; }
.cw-footer { border-top: 1px solid var(--line); margin-top: 8px; }
.cw-footer-in {
  max-width: var(--page-max); margin: 0 auto; padding: 14px var(--gutter) 20px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 18px; font-size: 12px; color: var(--muted);
}
.cw-footer a { color: var(--ink-2); font-weight: 600; text-decoration: none; }
.cw-footer a:hover { text-decoration: underline; }
.cw-user { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; color: var(--frame-muted); min-width: 0; }
.cw-user .cw-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.cw-user button {
  border: 1px solid var(--frame-line); background: transparent; color: var(--frame-ink); border-radius: var(--r);
  padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer;
}
.cw-user button:hover { background: var(--frame-2); }

/* ---- Toasts (CW.toast) ------------------------------------------------------------------------------- */
.cw-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.cw-toast {
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-pop);
  font-size: 13px; font-weight: 500; border-left: 3px solid var(--frame-muted);
}
.cw-toast.ok { border-left-color: var(--ok); }
.cw-toast.warn { border-left-color: var(--warn); }
.cw-toast.danger { border-left-color: var(--danger); }

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .cw-client-name, .cw-sep { display: none; }
  .cw-user .cw-email { display: none; }
  .cw-help span { display: none; }
  .cw-help { padding: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton { animation: none; }
  .cw-app .cw-chev { transition: none; }
}

/* ---- "Not turned on for you" (rendered by app-header.js) ------------------------------------------- */
.cw-denied { padding-block: 64px; }
.cw-denied-card { max-width: 460px; margin: 0 auto; text-align: center; }
.cw-denied-ico { display: inline-grid; place-items: center; width: 52px; height: 52px; margin-bottom: 16px; border-radius: var(--r-lg); background: var(--accent-soft); color: var(--accent); }
.cw-denied-card h1 { margin: 0 0 8px; font-family: var(--font-display); font-size: 24px; line-height: 1.2; color: var(--ink); }
.cw-denied-card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.cw-denied-acts { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 22px 0 14px; }
.cw-denied-card .cw-denied-note { font-size: 13px; }

