/*
 * The app shell — Jampack-style SaaS console layout.
 *
 * Shared by ALL THREE signed-in surfaces: the admin console, the member
 * portal and the provider portal. One shell, three navs. A member and a
 * clinician get the same bones as staff because they are doing the same kind
 * of thing - working through a small set of screens they return to - and two
 * different chassis would drift apart within a month.
 *
 * The PUBLIC marketing pages deliberately keep the horizontal header in
 * layouts/base.blade.php. A landing page with an app sidebar is a landing page
 * that looks like software somebody already bought.
 *
 * The STRUCTURE follows the Jampack pattern language: fixed left sidebar with
 * grouped nav, slim topbar, soft-bordered cards on a tinted canvas, KPI widgets
 * with a delta chip and a sparkline, pill badges, micro-caps table headers.
 *
 * The PALETTE and TYPEFACES stay Inspiration Health's. SCOPE 13 lifts the brand
 * tokens verbatim from inspirationhealth.org and says they were "not invented";
 * rendering a gold-and-cream health brand in a generic SaaS blue-grey would
 * discard the one thing that section locked down. So: Jampack's bones, this
 * product's skin.
 */

/* ── Shell ───────────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
  background: var(--shell-bg);
}

/* Sidebar */

.side {
  background: var(--navy);
  color: #dce6f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.side-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.side-brand .wordmark {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .01em;
  line-height: 1.15;
  display: block;
}
.side-brand .sub {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #9db4cf;
  margin-top: 3px;
  display: block;
}

.side-nav { padding: 12px 10px 24px; flex: 1; }

.side-group {
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #7f99b8;
  padding: 14px 10px 6px;
  font-weight: 600;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  color: #c9d8e8;
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.3;
  transition: background .12s ease, color .12s ease;
}
.side-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }

.side-link.on {
  background: rgba(217, 154, 31, .17);
  color: #fff;
  font-weight: 550;
  box-shadow: inset 2px 0 0 var(--gold);
}

.side-link .ico { width: 17px; height: 17px; flex: none; opacity: .9; }
.side-link .count {
  margin-left: auto;
  background: var(--gold);
  color: #2a2008;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}

.side-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  font-size: 11.5px;
  color: #93a9c2;
}

/* Topbar */

.main { min-width: 0; display: flex; flex-direction: column; }

.top {
  background: var(--shell-raised);
  border-bottom: 1px solid var(--shell-hair);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.top h1 { font-size: 19px; margin: 0; font-family: var(--serif); }
.top .crumb { font-size: 12px; color: var(--shell-muted); }
.top .spacer { flex: 1; }

.top-search {
  position: relative;
  max-width: 300px;
  flex: 1;
}
.top-search input {
  padding: 8px 12px 8px 32px;
  font-size: 13.5px;
  border-radius: 8px;
}
.top-search .ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  opacity: .45;
  pointer-events: none;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--gold-light, #e8ad33), var(--gold-deep));
  color: #2a2008;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12.5px;
  flex: none;
}

.page { padding: 24px; flex: 1; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side-nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .side-group { display: none; }
  .page { padding: 16px; }
  .top { padding: 0 16px; }
}

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--shell-raised);
  border: 1px solid var(--shell-hair);
  border-radius: 12px;
  padding: 18px 20px;
  color: var(--ink);
}
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 15.5px; font-family: var(--sans); font-weight: 600; }
.card-head .more { font-size: 12.5px; color: var(--gold-deep); text-decoration: none; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(212px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

/* ── KPI widget ──────────────────────────────────────────────────────────── */

.kpi {
  background: var(--shell-raised);
  border: 1px solid var(--shell-hair);
  border-radius: 12px;
  padding: 16px 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color .14s ease, transform .14s ease, box-shadow .14s ease;
}
a.kpi:hover {
  border-color: var(--hair-firm);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -16px rgba(36, 31, 26, .45);
}

.kpi-label {
  font-size: 11.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}
.kpi-value {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.05;
  font-weight: 600;
  color: var(--ink);
}
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 4px; }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
}
.delta-up   { background: #eef6ec; color: var(--c-ok); }
.delta-down { background: #faecec; color: var(--c-danger); }
.delta-flat { background: var(--cream-deep); color: var(--ink-mid); }

.kpi-note { font-size: 11.5px; color: var(--ink-soft); line-height: 1.4; }

/* An action-needed KPI is outlined, not shouted. */
.kpi-action { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }

/* ── Bits ────────────────────────────────────────────────────────────────── */

.stat-row { display: flex; gap: 22px; flex-wrap: wrap; }
.stat { min-width: 118px; }
.stat .lbl { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); font-weight: 600; }
.stat .val { font-family: var(--serif); font-size: 22px; font-weight: 600; }

.side-link .ico, .top-search .ico { stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ── Theme toggle ────────────────────────────────────────────────────────── */
/* Three states — Light / Dark / System — because a two-state switch silently
   overrides the OS choice with no way back to "follow my device". */





/* In dark mode the track has to sit on the raised surface, not the light cream,
   or the whole control glows. */

/* ── Brand mark ──────────────────────────────────────────────────────────── */

.side-brand { display: flex; align-items: center; gap: 11px; }
.side-brand .mark { width: 34px; height: 34px; flex: none; }
.side-brand .mark img { width: 100%; height: 100%; display: block; }

.brand-mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand-mark img { display: block; }

/* ── Notification bell ───────────────────────────────────────────────────── */
/* <details> rather than JS: it opens, closes on Escape, and is keyboard
   reachable with no script at all. */

.bell { position: relative; }
.bell summary { list-style: none; cursor: pointer; }
.bell summary::-webkit-details-marker { display: none; }

.bell-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 36px; height: 36px;
  border-radius: 9px;
  border: 1px solid var(--shell-hair);
  background: var(--shell-raised);
  color: var(--ink-mid);
}
.bell-trigger:hover { color: var(--ink); border-color: var(--hair-firm); }
.bell-trigger svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.bell-count {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--c-danger);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--shell-raised);
}

.bell-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--shell-raised);
  border: 1px solid var(--shell-hair);
  border-radius: 12px;
  box-shadow: 0 18px 40px -20px rgba(36, 31, 26, .5);
  z-index: 40;
  overflow: hidden;
}

.bell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--hair);
  font-size: 13.5px;
  color: var(--ink);
}

.bell-item {
  display: flex;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  color: inherit;
}
.bell-item:hover { background: var(--cream); }
.bell-item.unread { background: rgba(228, 162, 13, .07); }

.bell-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none; }
.bell-info    { background: var(--c-info); }
.bell-success { background: var(--c-ok); }
.bell-warning { background: var(--c-warn); }
.bell-danger  { background: var(--c-danger); }

.bell-title { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.bell-body  { display: block; font-size: 12.5px; color: var(--ink-mid); line-height: 1.4; margin-top: 2px; }
.bell-when  { display: block; font-size: 11px; color: var(--ink-soft); margin-top: 3px; }

.bell-empty { padding: 18px 14px; margin: 0; font-size: 13px; color: var(--ink-soft); }

.bell-all {
  display: block;
  padding: 10px 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--gold-deep);
  text-decoration: none;
}
.bell-all:hover { background: var(--cream); }

@media (max-width: 560px) {
  .bell-panel { position: fixed; left: 12px; right: 12px; width: auto; top: 64px; }
}

/* ── Settings tabs ───────────────────────────────────────────────────────── */
/* Real links, one URL per tab. Scrolls horizontally on a narrow screen rather
   than wrapping into a block that pushes the form off the fold. */

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--shell-hair);
  scrollbar-width: thin;
}

.tab {
  flex: none;
  padding: 9px 14px;
  border-radius: 9px 9px 0 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-mid);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: var(--cream); }

.tab.on {
  color: var(--gold-deep);
  background: var(--shell-raised);
  border-color: var(--shell-hair);
  font-weight: 600;
}

/* The live figures a tab's settings move, shown next to the fields. This is the
   phase-10 gate made visible: a setting whose effect cannot be shown is a
   setting nothing reads. */
.impact {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 26px;
  padding: 13px 15px;
  margin: 0 0 16px;
  border-radius: 11px;
  background: var(--cream);
  border: 1px solid var(--hair);
}
.impact-item .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.impact-item .val { font-size: 18px; font-weight: 600; color: var(--ink); }

/* ── Dropdowns ───────────────────────────────────────────────────────────── */
/*
 * One pattern for the language chooser, the theme menu and anything else that is
 * a short list of mutually exclusive choices.
 *
 * Built on <details>: it opens, closes on Escape and is keyboard reachable with
 * no script at all. That matters here because these controls sit in the topbar of
 * every page, so any script behind them runs everywhere.
 *
 * This replaced two segmented controls that between them took about 300px of a
 * topbar which also holds a page title, a bell and a user block.
 */

.drop { position: relative; flex: none; }
.drop summary { list-style: none; cursor: pointer; }
.drop summary::-webkit-details-marker { display: none; }

.drop-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--shell-hair);
  background: var(--shell-raised);
  color: var(--ink-mid);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.drop-trigger:hover { color: var(--ink); border-color: var(--hair-firm); }
.drop[open] .drop-trigger { color: var(--ink); border-color: var(--gold-deep); }

.drop-trigger svg {
  width: 17px; height: 17px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* Icon-only: a square button, no label, no chevron. The theme menu uses this -
   the trigger IS the current mode.

   overflow:hidden is a guard, not decoration. The trigger is a fixed 36px and
   holds three stacked icons; anything that fails to hide two of them spills
   them out across the topbar, which is exactly the bug this replaced. */
.drop-icon .drop-trigger { width: 36px; padding: 0; justify-content: center; overflow: hidden; }

/* ── Which theme icon shows ──────────────────────────────────────────────
 *
 * Driven entirely from the `data-theme` attribute the inline head script puts
 * on <html> before first paint, so the right icon is right on the FIRST FRAME
 * with no JavaScript involved in revealing it.
 *
 * This replaced the `hidden` attribute on the two inactive SVGs. That was a
 * real bug: `hidden` is an HTML global attribute and an SVG element is not an
 * HTML element, so browsers do not reliably apply display:none to one. All
 * three icons rendered and two escaped the button.
 *
 * No attribute means SYSTEM, which is the default and stores nothing.
 */
.theme-ico { display: none; }
:root .theme-ico[data-theme-icon="system"]                  { display: block; }
:root[data-theme="light"] .theme-ico[data-theme-icon="system"] { display: none; }
:root[data-theme="light"] .theme-ico[data-theme-icon="light"]  { display: block; }
:root[data-theme="dark"]  .theme-ico[data-theme-icon="system"] { display: none; }
:root[data-theme="dark"]  .theme-ico[data-theme-icon="dark"]   { display: block; }

/* The chosen row in the menu, ticked from the same attribute rather than from
   a class the script has to add. Correct before the script runs. */
:root .drop-item[data-theme-set="system"] { color: var(--gold-deep); font-weight: 600; }
:root[data-theme="light"] .drop-item[data-theme-set="system"],
:root[data-theme="dark"]  .drop-item[data-theme-set="system"] { color: var(--ink-mid); font-weight: 400; }
:root[data-theme="light"] .drop-item[data-theme-set="light"],
:root[data-theme="dark"]  .drop-item[data-theme-set="dark"]   { color: var(--gold-deep); font-weight: 600; }

:root .drop-item[data-theme-set="system"] .drop-tick,
:root[data-theme="light"] .drop-item[data-theme-set="light"] .drop-tick,
:root[data-theme="dark"]  .drop-item[data-theme-set="dark"] .drop-tick {
  background: var(--gold-deep);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="%23000" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.5 4.5L19 7.5"/></svg>') center/14px no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="%23000" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.5 4.5L19 7.5"/></svg>') center/14px no-repeat;
}
:root[data-theme="light"] .drop-item[data-theme-set="system"] .drop-tick,
:root[data-theme="dark"]  .drop-item[data-theme-set="system"] .drop-tick { background: none; }

.drop-chev { width: 13px !important; height: 13px !important; opacity: .6; }
.drop[open] .drop-chev { transform: rotate(180deg); }

.drop-label { letter-spacing: .01em; }

/* ── The menu ───────────────────────────────────────────────────────────── */

.drop-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 176px;
  padding: 6px;
  background: var(--shell-raised);
  border: 1px solid var(--shell-hair);
  border-radius: 12px;
  box-shadow: 0 16px 38px -18px rgba(20, 16, 12, .45);
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.drop-menu-right { left: auto; right: 0; }

.drop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink-mid);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.drop-item:hover { background: var(--cream); color: var(--ink); }

.drop-item.on { color: var(--gold-deep); font-weight: 600; }

.drop-item svg {
  width: 16px; height: 16px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* The two-letter code, for the language menu. Monospaced-feeling and fixed width
   so the labels beside it line up. */
.drop-code {
  flex: none;
  width: 22px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--ink-soft);
}
.drop-item.on .drop-code { color: var(--gold-deep); }

/* The check, on the chosen row. Pushed right, and drawn with a mask so it needs
   no icon font. */
.drop-tick { margin-left: auto; width: 14px; height: 14px; flex: none; }
.drop-item.on .drop-tick {
  background: var(--gold-deep);
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="%23000" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.5 4.5L19 7.5"/></svg>') center/14px no-repeat;
          mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="none" stroke="%23000" stroke-width="3.2" stroke-linecap="round" stroke-linejoin="round" d="M5 12.5l4.5 4.5L19 7.5"/></svg>') center/14px no-repeat;
}

/* On a narrow screen the menu anchors to the viewport rather than sliding off
   the right edge of it. */
@media (max-width: 560px) {
  .drop-menu { position: fixed; left: 12px; right: 12px; min-width: 0; top: 62px; }
}

/* The topbar carries more on the portals than in the admin - a language switch
   AND a theme toggle AND a bell AND the user block. It wraps rather than
   overflowing, and the user block keeps its own line on a narrow screen. */
.top { flex-wrap: wrap; row-gap: 8px; }

@media (max-width: 1080px) {
}

@media (max-width: 720px) {
  .top { padding-top: 10px; padding-bottom: 10px; }
  .top-user > div { display: none; }   /* the avatar and sign-out carry it */
}

/* The office number in the sidebar foot. The sidebar shells have no page footer,
   so this is where "how do I call them" lives - always on screen. */
.side-foot-call {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .09);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-foot-call a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .01em;
}
.side-foot-call a:hover { text-decoration: underline; }
.side-foot-call span { opacity: .72; }

/* ── The card-treatment picker ────────────────────────────────────────────── */
/*
 * Nine rendered cards, each with its own "offer this" and "default" controls.
 *
 * Replaced a checkbox list of words and a dropdown of the same words. Both asked
 * somebody to choose a card design without showing them a card - on the one
 * screen where the design is the subject. The member's chooser had always
 * previewed the real thing; staff were the only people picking blind.
 */

.stylegrid {
  display: grid;
  /* 300px minimum. At 232px the card was a swatch: the ID row was unreadable
     and the whole point of the grid is that staff can SEE what they are
     offering. Fewer per row, each one an actual card. */
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  margin: 6px 0 18px;
}

.styletile {
  border: 2px solid var(--shell-hair);
  border-radius: 14px;
  padding: 13px 13px 11px;
  background: var(--shell-raised);
  transition: border-color .16s ease, opacity .16s ease, box-shadow .16s ease;
}

/* The one in force. A single ring rather than a badge: nine badges is noise, and
   the border is already doing the job of saying "this one". */
.styletile.is-default {
  border-color: var(--gold-deep);
  box-shadow: 0 0 0 3px rgba(208, 155, 20, .16);
}

/* Not on offer. Dimmed rather than hidden, because the point of the grid is to
   see everything that EXISTS and pick from it - hiding a retired treatment would
   make it hard to bring back. */
.styletile.is-off { opacity: .46; }
.styletile.is-off:hover { opacity: .8; }

.styletile-art { pointer-events: none; }

.styletile-name {
  margin-top: 11px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

/* The two facts that distinguish the treatments beyond colour, so a person can
   tell why they are choosing one. */
.styletile-meta {
  display: block;
  font-size: 11.5px;
  font-weight: 400;
  color: var(--ink-soft);
  margin-top: 2px;
}

.styletile-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--hair);
}
.styletile-controls .check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-mid);
  cursor: pointer;
  margin: 0;
}
.styletile-controls .check:hover { color: var(--ink); }
.styletile-controls input { margin: 0; cursor: pointer; }

.styletile.is-default .styletile-controls .check:last-child { color: var(--gold-deep); font-weight: 600; }

/* One per row on a narrow screen: a card at less than ~210px stops being a
   preview and becomes a swatch. */
@media (max-width: 560px) {
  .stylegrid { grid-template-columns: 1fr; max-width: 320px; }
}
