/* shared/ui.css — design system
   World: cool light-gray ground, white hairline cards, one deep green. Oswald display, Nunito UI. */

/* Self-hosted fonts (shared/fonts/) — no external font dependency */
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/shared/fonts/nunito-latin-400-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/shared/fonts/nunito-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/shared/fonts/nunito-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/shared/fonts/nunito-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/shared/fonts/oswald-latin-500-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/shared/fonts/oswald-latin-600-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Oswald"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/shared/fonts/oswald-latin-700-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Sora"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/shared/fonts/sora-latin-700-normal.woff2") format("woff2");
}

:root {
  --bg: #efeff4;
  --card: #ffffff;
  --line: #e2e3ea;
  --line-strong: #d1d3dd;

  --ink: #1c2420;
  --ink-soft: #47504a;
  --muted: #5e6660;
  --faint: #8b938c;

  --green-950: #16362a;
  --green-900: #1e4638;
  --green-800: #2a5a47;
  --green-300: #9dbfa6;
  --green-100: #e3ede1;
  --green-100-ink: #2a5a45;

  --red-700: #a63a30;
  --red-100: #f6e4e1;

  --amber-100: #f3ecd8;
  --amber-ink: #7a5d1e;
  --blue-100: #e4ebf7;
  --blue-ink: #2f4f86;

  --radius-card: 12px;
  --radius-ctl: 10px;

  --shadow-card: 0 1px 2px rgba(28, 36, 32, 0.05);
  --shadow-pop: 0 2px 6px rgba(28, 36, 32, 0.08), 0 20px 48px -16px rgba(28, 36, 32, 0.22);

  --font-ui: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Oswald", "Nunito", sans-serif;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App shell: pill rail ───────────────────────────────── */
/* A fixed icon-only pill. Hovering (or keyboard-focusing) an item pops that
   one item's name out to the right as a pill of its own; the rail itself
   never changes size, so nothing on the page moves. */

.shell { min-height: 100vh; }

.sidebar {
  --rail-w: 72px;
  position: fixed;
  top: 14px; bottom: 14px; left: 12px;
  width: var(--rail-w);
  z-index: 50;
}

.rail {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 14px;
  border-radius: 999px;
  background: linear-gradient(172deg, #3b7c60 0%, #1f4a3a 36%, #122f24 72%, #0b2019 100%);
  box-shadow:
    0 0 0 6px rgba(42, 90, 71, 0.10),             /* soft halo ring, like the reference */
    0 14px 30px -10px rgba(13, 36, 27, 0.45);
}

.nav-brand {
  width: 50px; height: 50px; flex: 0 0 auto; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: #fff; text-decoration: none;
  transition: background-color 150ms ease;
}
.nav-brand:hover { background: rgba(255, 255, 255, 0.2); }
.nav-mark { font-family: var(--font-display); font-weight: 600; font-size: 15px; letter-spacing: 0.04em; }

.nav-item {
  position: relative;
  width: 46px; height: 46px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 0; border-radius: 999px;
  background: none; color: rgba(255, 255, 255, 0.72);
  cursor: pointer; text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}
.nav-item svg { position: relative; z-index: 2; width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item[aria-current="page"] {
  background: #fff; color: var(--green-950);
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.35);
}
.nav-item:focus-visible, .nav-brand:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.nav-spacer { flex: 1; }

/* the pop-out: a pill that grows out of the icon, to the right of the rail */
.nav-label {
  position: absolute; z-index: 1;
  left: 0; top: 0; height: 100%;
  display: flex; align-items: center;
  padding: 0 18px 0 54px;
  border-radius: 999px;
  white-space: nowrap;
  font: 700 13.5px var(--font-ui); letter-spacing: 0.01em;
  color: var(--green-950);
  background: #fff;
  border: 1.5px solid var(--green-800);                 /* outline so it reads apart from white cards */
  box-shadow: 0 0 0 3px rgba(42, 90, 71, 0.14), 0 12px 26px -8px rgba(13, 36, 27, 0.45);
  pointer-events: none;
  opacity: 0;
  clip-path: inset(0 100% 0 0 round 999px);
  transition: clip-path 140ms var(--ease-out), opacity 100ms ease;          /* exit: quick */
}
/* whichever item is hovered turns white — circle and label pill together — and
   the current page steps back to a soft tint so only one white sits on the rail */
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover {
    background: #fff; color: var(--green-950);
    box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.35);
  }
  .rail:hover .nav-item[aria-current="page"]:not(:hover) {
    background: rgba(255, 255, 255, 0.16); color: #fff; box-shadow: none;
  }
  .nav-item:hover .nav-label {
    opacity: 1;
    background: #fff; color: var(--green-950);
    clip-path: inset(-4px -4px -4px 0 round 999px);
    transition: clip-path 240ms var(--ease-out), opacity 120ms ease;       /* enter: a touch slower */
  }
}
.nav-item:focus-visible .nav-label {
  opacity: 1; clip-path: inset(-4px -4px -4px 0 round 999px);
  background: #fff; color: var(--green-950);
}

.main { min-width: 0; margin-left: 96px; padding: 28px 32px 40px; }

.page-head {
  display: flex;
  flex-wrap: wrap; /* one line when it fits; when it doesn't, controls drop to a second line instead of running under the logo */
  align-items: center;
  gap: 16px;
  row-gap: 12px;
  margin-bottom: 24px;
}
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: 0.005em;
  margin: 0;
}
.page-head .grow { flex: 1; }

.whoami { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 12px; }

/* ── Controls ──────────────────────────────────────────── */

.btn {
  font: 500 14px/1 var(--font-ui);
  border: 0;
  border-radius: var(--radius-ctl);
  padding: 10px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, box-shadow 150ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--green-800); outline-offset: 2px; }
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--green-900); color: #fff; }
.btn-primary:hover { background: var(--green-800); }

.btn-ghost { background: transparent; color: var(--ink-soft); border: 1px solid var(--line-strong); }
.btn-ghost:hover { background: rgba(30, 70, 56, 0.05); color: var(--ink); }

.select-pill {
  appearance: none;
  font: 500 13px/1 var(--font-ui);
  color: var(--ink-soft);
  background: var(--card) 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='%2368716a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 9px 32px 9px 14px;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.select-pill:hover { border-color: var(--faint); }
.select-pill:focus-visible { outline: 2px solid var(--green-800); outline-offset: 2px; }

.input {
  font: 400 14px/1.4 var(--font-ui);
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-ctl);
  padding: 10px 12px;
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.input:focus { outline: none; border-color: var(--green-800); box-shadow: 0 0 0 3px rgba(42, 90, 71, 0.15); }
.input::placeholder { color: var(--faint); }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

/* ── Cards & chips ─────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}
.chip-green { background: var(--green-100); color: var(--green-100-ink); }
.chip-neutral { background: rgba(28, 36, 32, 0.06); color: var(--ink-soft); }
.chip-red { background: var(--red-100); color: var(--red-700); }
.chip-amber { background: var(--amber-100); color: var(--amber-ink); }
/* interest mark (hot / warm / cold): a word, never colour alone */
.temp-tag { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; border-radius: 999px; padding: 1px 7px 1px 6px; font: 700 10.5px/1.5 var(--font-ui); white-space: nowrap; }
.temp-tag::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.temp-tag.hot { background: var(--red-100); color: var(--red-700); }
.temp-tag.warm { background: var(--amber-100); color: var(--amber-ink); }
.temp-tag.cold { background: var(--blue-100); color: var(--blue-ink); }

.avatar {
  width: 24px; height: 24px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-100-ink);
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

/* ── KPI cards (dashboard, funnels) ─────────────────────── */
/* label + big number on top, a hairline, then two detail rows; the second
   row compares with the previous period (▲▼ + %, colored by good/bad). */
:root { --ok: #2a7a52; --warn: #a9661a; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.kpi { padding: 18px 20px 16px; box-shadow: 0 1px 2px rgba(28, 36, 32, 0.05), 0 10px 24px -18px rgba(28, 36, 32, 0.28); }
.kpi-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); } /* the number drops under its label when a card is too narrow for both */
.kpi-lbl { font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); white-space: nowrap; }
.kpi-val { font-family: var(--font-display); font-weight: 600; font-size: 31px; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 10px; font-size: 13.5px; color: var(--ink-soft); }
.kpi-row b { color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-row + .kpi-row { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.kpi-row .r { text-align: right; white-space: nowrap; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--warn); }
.delta.flat { color: var(--muted); }
@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .kpi-val { font-size: 27px; }
}

/* ── Modal ─────────────────────────────────────────────── */

dialog.modal {
  border: 0; /* elevation only — it floats over a backdrop, no hairline */
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-pop);
  padding: 26px 26px 22px;
  width: min(420px, calc(100vw - 32px));
  background: var(--card);
  color: var(--ink);
}
dialog.modal::backdrop { background: rgba(28, 36, 32, 0.35); }
dialog.modal[open] { animation: modal-in 200ms var(--ease-out); }
@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.modal-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: 0.01em; margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
@media (pointer: coarse) { .modal-actions .btn { min-height: 44px; } } /* finger-sized on phones and tablets */

/* ── Toast ─────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  translate: -50% 0;
  background: var(--green-950);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
  pointer-events: none;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red-700); }

/* ── Utilities ─────────────────────────────────────────── */

[hidden] { display: none !important; } /* components set display; hidden must still win */
a.btn { text-decoration: none; }
.muted { color: var(--muted); }
.mono-num { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Responsive shell ──────────────────────────────────── */

@media (max-width: 640px) {
  .page-head { flex-wrap: wrap; row-gap: 12px; }
  .page-title { width: 100%; font-size: 21px; }
  .page-head .grow { display: none; }
}

@media (max-width: 640px) {
  /* rail becomes a bottom tab bar on phones */
  .sidebar { top: auto; left: 12px; right: 12px; bottom: 12px; width: auto; height: 62px; }
  .rail { flex-direction: row; justify-content: space-around; align-items: center; padding: 0 4px; gap: 0; } /* eight items fit at 375 */
  .nav-brand, .nav-spacer, .nav-label { display: none; }
  .nav-item { width: 42px; height: 42px; }
  .main { margin-left: 0; padding: 20px 16px 96px; }
}


/* ── Showline brand ────────────────────────────────────── */
/* The mark: four stops on one line — call, deposit, show, close — ending in the check.
   Wordmark in Sora; "line" carries the rail's green gradient. */
:root { --brand-grad: linear-gradient(135deg, #3b7c60 0%, #1f4a3a 100%); }
.brand-mark { display: block; flex: 0 0 auto; }
.brand-word { font-family: "Sora", "Avenir Next", system-ui, sans-serif; font-weight: 700; letter-spacing: -0.035em; line-height: 1; color: var(--ink); white-space: nowrap; }
.brand-word .ln { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav-brand .brand-mark { width: 32px; height: 26px; color: #fff; }

/* top-right lockup on every page: pinned to one spot so it never moves between pages or while a page loads.
   The page's header row keeps a lane clear for it. */
.brand-lockup { position: absolute; z-index: 40; top: 33px; right: 32px; display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--ink); border-radius: 8px; }
.brand-lockup .brand-mark { width: 38px; height: 31px; }
.brand-lockup .brand-word { font-size: 25px; }
.brand-lockup:focus-visible { outline: 2px solid var(--green-800); outline-offset: 4px; }
body.has-lockup .main .page-head, body.has-lockup .main .lead-head, body.has-lockup .main .ed-top { padding-right: 184px; }
@media (max-width: 640px) {
  .brand-lockup { top: 22px; right: 16px; }
  .brand-lockup .brand-word { font-size: 20px; }
  .brand-lockup .brand-mark { width: 30px; height: 25px; }
  /* phones: only the title's line needs the lane; the controls under it keep the full width */
  body.has-lockup .main .page-head, body.has-lockup .main .ed-top { padding-right: 0; }
  body.has-lockup .main .page-head .page-title { width: calc(100% - 140px); margin-right: 140px; } /* fills its line, so nothing sits beside it */
  body.has-lockup .main .lead-head > :not(.back) { flex-basis: 100%; } /* back button shares the logo's line; the name gets the full width below */
  body.has-lockup .main .ed-top ~ .brand-lockup, body.has-lockup:has(.ed-top) .brand-lockup { display: none; } /* the editor asks for a wider screen here */
}

/* Feature flags from GET /api/auth/me (set on <body> by shared/nav.js).
   Elements marked data-needs="sms" / "telephony" are hidden until the matching
   org feature flag is on. */
body:not([data-feat-sms="true"]) [data-needs="sms"] { display: none !important; }
body:not([data-feat-telephony="true"]) [data-needs="telephony"] { display: none !important; }
