/* Adjusted Health + Performance — the engine's layout and screens. Colours,
   type, buttons, inputs and the toast come from theme.css (one token set for
   every staff page, dark and light). Use tokens here, never raw colours. */

* { box-sizing: border-box; margin: 0; padding: 0; }

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--line);
  color: var(--text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 22px 22px 18px; border-bottom: 1px solid var(--line); }
.sidebar .brand .brand-name {
  font-family: var(--font-display); font-weight: 300; text-transform: none; letter-spacing: -0.01em;
  font-size: 22px; color: var(--text-bright); margin: 0;
}
.sidebar .brand .brand-name span { color: var(--bronze); }
.sidebar .brand p { font-size: 12px; color: var(--bronze); margin-top: 4px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; }
.sidebar nav { padding: 12px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 12px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-3); padding: 16px 12px 6px; font-weight: 600; }
.sidebar nav a, .more-nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px; min-height: var(--tap);
  padding: 8px 14px; border-radius: 12px;
  color: var(--text-2); text-decoration: none;
  font-size: 16px; margin-bottom: 2px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.sidebar nav a svg, .more-nav a svg, .bottom-bar a svg { flex: none; opacity: 0.85; }
.sidebar nav a:hover, .more-nav a:hover { background: var(--hover); color: var(--text-bright); }
.sidebar nav a.active, .more-nav a.active { background: var(--bronze-wash); color: var(--text-bright); }
.sidebar nav a.active::before, .more-nav a.active::before {
  content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--bronze);
}
.sidebar nav a .badge, .more-nav a .badge { margin-left: auto; }
.sidebar .foot { padding: 14px 22px 18px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-3); display: grid; gap: 6px; }
.sidebar .foot .help-link { display: inline-flex; align-items: center; min-height: var(--tap-sm); font-weight: 600; }

/* Main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 32px; background: rgb(var(--bg-rgb) / 0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-family: var(--font-display); font-weight: 300; font-size: 28px; letter-spacing: -0.015em; color: var(--text-bright); white-space: nowrap; margin-right: auto; }
.topbar .actions { display: flex; gap: 10px; align-items: center; }
.content { padding: 24px 32px 72px; max-width: 1280px; width: 100%; }
.content:focus { outline: none; }

/* Global search */
.top-search { position: relative; width: min(380px, 34vw); }
.top-search input[type="search"] { border-radius: 999px; padding-left: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23988562' stroke-width='2.2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 14px center; }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 6px;
}
.search-results .sr-group { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-3); padding: 10px 12px 4px; font-weight: 600; }
.search-results [role="option"] { display: flex; flex-direction: column; justify-content: center; min-height: var(--tap); padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.search-results [role="option"] .s { font-size: 14px; color: var(--text-3); }
.search-results [role="option"][aria-selected="true"], .search-results [role="option"]:hover { background: var(--bronze-wash); }
.search-results .none { padding: 14px 12px; color: var(--text-3); font-size: 15px; }

/* User menu */
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 2px 12px 2px 2px; border-radius: 999px;
  background: transparent; border: 1px solid var(--line-strong); color: var(--text); font: inherit; font-size: 15px; cursor: pointer; }
.user-btn:hover { border-color: var(--bronze); }
.user-btn .avatar { width: 38px; height: 38px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--bronze-fill); color: var(--on-accent); font-weight: 700; font-size: 14px; letter-spacing: 0.04em; }
.user-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 240px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 8px; }
.user-pop[hidden] { display: none; }
.user-pop a, .user-pop .menu-item, .user-pop .theme-switch { display: flex; align-items: center; min-height: var(--tap); padding: 6px 12px; border-radius: 10px;
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; font-size: 15px; cursor: pointer; text-align: left; width: 100%; }
.user-pop a:hover, .user-pop .menu-item:hover, .user-pop .theme-switch:hover { background: var(--hover); color: var(--text-bright); }

/* Section tabs under the top bar (People: Clients / Patients, and so on) */
.subnav { display: flex; gap: 4px; padding: 0 32px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.subnav[hidden] { display: none; }
.subnav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border-bottom: 2px solid transparent;
  color: var(--text-2); text-decoration: none; font-size: 15px; font-weight: 600; white-space: nowrap; }
.subnav a:hover { color: var(--text-bright); }
.subnav a[aria-current="page"] { color: var(--text-bright); border-bottom-color: var(--bronze); }

/* Phone bar (hidden on wide screens) */
.bottom-bar { display: none; }

/* Mode pill */
.mode-pill {
  font-size: 12px; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase;
  min-height: var(--tap-sm); padding: 7px 14px; border-radius: 999px; cursor: pointer; border: none; font-family: var(--font-body);
}
.mode-pill.dry { background: transparent; color: var(--bronze); border: 1px solid var(--bronze); }
.mode-pill.live { background: var(--good); color: var(--on-accent); }

/* Cards & grids */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px;
}
.card h3 { font-family: var(--font-display); font-weight: 300; font-size: 21px; letter-spacing: -0.01em; color: var(--text-bright); margin-bottom: 12px; }
.card h3 .sub { font-family: var(--font-body); font-weight: 400; font-size: 14px; letter-spacing: 0; color: var(--text-3); margin-left: 8px; }
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } .grid.cols-3 { grid-template-columns: 1fr; } }

/* KPI tiles */
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi .label { font-size: 12px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--bronze); font-weight: 600; }
.kpi .value { font-family: var(--font-body); font-size: 32px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; color: var(--text-bright); }
.kpi .hint { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.kpi.gold { border-color: rgb(var(--bronze-rgb) / 0.45); background: linear-gradient(160deg, rgb(var(--bronze-rgb) / 0.12), var(--surface) 60%); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px; border-bottom: 1px solid var(--line-strong); font-weight: 600; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text); }
tr:hover td { background: rgb(var(--ink-rgb) / 0.025); }
td strong { color: var(--text-bright); font-weight: 600; }

/* Badges */
.badge {
  display: inline-block; font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  background: rgb(var(--ink-rgb) / 0.07); color: var(--text-2); border: 1px solid var(--line);
}
.badge.blue { background: rgb(var(--steel-rgb) / 0.18); color: var(--steel); border-color: rgb(var(--steel-rgb) / 0.3); }
.badge.gold { background: var(--bronze-wash); color: var(--bronze-ink); border-color: rgb(var(--bronze-rgb) / 0.35); }
.badge.stone { background: rgb(var(--ink-rgb) / 0.07); color: var(--text-2); }
.badge.green { background: var(--good-wash); color: var(--good); border-color: rgb(var(--good-rgb) / 0.3); }
.badge.red { background: var(--bad-wash); color: var(--bad); border-color: rgb(var(--bad-rgb) / 0.3); }
.badge:empty { display: none; }
.badge.navy { background: var(--bronze-fill); color: var(--on-accent); border-color: var(--bronze-fill); }

/* Playbook cards */
.playbook { position: relative; display: flex; flex-direction: column; }
.playbook .tagline { color: var(--text); font-size: 15px; margin-bottom: 8px; }
.playbook .why { font-size: 14px; color: var(--text-2); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; }
.playbook .items { font-size: 14px; color: var(--text-3); margin-bottom: 14px; }
.playbook .items li { margin-left: 16px; margin-bottom: 3px; }
.playbook footer { margin-top: auto; display: flex; align-items: center; gap: 10px; }
.playbook.premium { border-color: rgb(var(--bronze-rgb) / 0.45); }

/* Message preview */
.msg-body { white-space: pre-wrap; font-size: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-top: 6px; max-width: 640px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
pre.snippet {
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; overflow-x: auto;
  font-size: 13px; line-height: 1.5; margin: 8px 0 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap; word-break: break-all;
}

/* Modal */
.modal-back {
  position: fixed; inset: 0; background: var(--scrim); z-index: 50;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 20px;
  animation: fade-in 0.22s var(--ease);
}
.modal {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 28px;
  box-shadow: var(--shadow-pop);
  width: 620px; max-width: 100%; max-height: 86vh; overflow-y: auto; padding: 28px;
  animation: rise-in 0.32s var(--ease);
}
.modal h3 { font-family: var(--font-display); font-weight: 300; font-size: 26px; letter-spacing: -0.015em; color: var(--text-bright); margin-bottom: 16px; }
.modal .row { display: flex; gap: 12px; }
.modal .row > * { flex: 1; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal.wide { width: 1080px; }
.modal h4.cp-h {
  font-family: var(--font-body); font-weight: 600; font-size: 12px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--bronze);
  margin: 26px 0 12px; display: flex; align-items: center;
}
.modal details summary { color: var(--text-3); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px) scale(0.985); } }

/* Dropzone */
.drop {
  border: 1.5px dashed rgb(var(--bronze-rgb) / 0.45); border-radius: var(--radius);
  padding: 28px; text-align: center; color: var(--text-3);
  background: rgb(var(--bronze-rgb) / 0.04); cursor: pointer; transition: background 0.2s var(--ease);
}
.drop.over, .drop:hover { background: rgb(var(--bronze-rgb) / 0.1); }
.drop strong { color: var(--text-bright); display: block; font-family: var(--font-display); font-weight: 400; font-size: 18px; margin-bottom: 4px; }

.muted { color: var(--text-3); font-size: 14px; }

/* Auth screen */
#auth-root:empty { display: none; }
.auth-back {
  position: fixed; inset: 0; z-index: 200; background: radial-gradient(ellipse at 30% 20%, var(--surface-3), var(--bg) 60%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 28px; padding: 38px 36px;
  width: 410px; max-width: 100%; box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9);
}
.auth-card .mark { font-family: var(--font-display); font-weight: 300; font-size: 26px; color: var(--text-bright); margin-bottom: 4px; }
.auth-card .mark span { color: var(--bronze); }
.auth-card .sub { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--bronze); margin-bottom: 24px; font-weight: 600; }
.auth-card .err { background: var(--bad-wash); color: var(--bad); font-size: 14px; border-radius: 12px; padding: 9px 12px; margin-bottom: 12px; }
.auth-card .btn { width: 100%; padding: 12px; font-size: 14px; margin-top: 4px; }
.user-chip { font-size: 14px; color: var(--text-3); font-weight: 600; letter-spacing: 0.02em; }
.spacer { flex: 1; }

/* Chips — filters and section switches */
.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap-sm);
  font-size: 14px; font-weight: 600; letter-spacing: 0.04em; padding: 6px 16px; border-radius: 999px;
  border: 1px solid var(--control); background: transparent; cursor: pointer; color: var(--text-2);
  font-family: var(--font-body); transition: all 0.2s var(--ease);
}
.chip:hover { color: var(--text-bright); border-color: rgb(var(--bronze-rgb) / 0.5); }
.chip.on { background: var(--bronze-fill); color: var(--on-accent); border-color: var(--bronze-fill); }
.chip:disabled { opacity: 0.4; cursor: default; }
.empty { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty strong { display: block; font-family: var(--font-display); font-weight: 300; font-size: 22px; color: var(--text-bright); margin-bottom: 6px; }

/* ---------- Charts (Club Dashboard) ---------- */
.viz-hero { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 16px; margin-bottom: 16px; }
.hero-figure .eyebrow { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--bronze); font-weight: 600; }
.hero-figure .num { font-family: var(--font-body); font-weight: 600; font-size: 54px; letter-spacing: -0.035em; line-height: 1.05; margin: 10px 0 6px; color: var(--text-bright); }
.hero-figure .delta { font-size: 15px; font-weight: 600; }
.hero-figure .delta.up { color: var(--good); }
.hero-figure .delta.down { color: var(--bad); }
.hero-figure .delta.flat { color: var(--text-3); }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
@media (max-width: 1100px) { .stat-row { grid-template-columns: repeat(2, 1fr); } .viz-hero { grid-template-columns: 1fr; } }
.stat .value { font-variant-numeric: normal; }
.stat svg.spark { display: block; width: 100%; height: auto; margin-top: 10px; overflow: visible; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-text { fill: var(--text-3); font-size: 13px; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart .value-text { fill: var(--text-2); font-size: 13px; font-weight: 600; font-family: var(--font-body); font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity 0.2s var(--ease), filter 0.2s var(--ease); }
.chart .bar.dim { opacity: 0.35; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 2px 0 12px; font-size: 14px; color: var(--text-2); }
.legend .key { display: inline-flex; align-items: center; gap: 7px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend .ln { width: 14px; height: 2px; border-radius: 2px; display: inline-block; }
.viz-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 150px;
  background: var(--text-bright); color: var(--bg); border-radius: 12px; padding: 9px 12px;
  font-size: 14px; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, 0.7);
  opacity: 0; transform: translateY(4px); transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}
.viz-tip.on { opacity: 1; transform: none; }
.viz-tip .t { font-weight: 600; margin-bottom: 4px; }
.viz-tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.viz-tip .r b { font-variant-numeric: tabular-nums; }
.viz-tip .r .k { display: inline-flex; align-items: center; gap: 6px; color: inherit; opacity: .8; }
.viz-tip .r .k i { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }
.tier-bars .tier { display: grid; grid-template-columns: 92px 1fr 34px; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 15px; }
.tier-bars .track { height: 10px; border-radius: 999px; background: rgb(var(--ink-rgb) / 0.06); overflow: hidden; }
.tier-bars .fill { height: 100%; border-radius: 999px; background: var(--series-1); transform-origin: left; }
.tier-bars .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-bright); font-weight: 600; }

/* Motion — the dashboard draws itself in, once per month viewed */
.viz-animate .bar-grow { transform-box: fill-box; transform-origin: 50% 100%; animation: bar-grow 0.8s var(--ease) both; }
.viz-animate .line-draw { animation: line-draw 1.1s var(--ease) both; }
.viz-animate .area-fade { animation: fade-in 0.9s var(--ease) 0.35s both; }
.viz-animate .dot-pop { transform-box: fill-box; transform-origin: center; animation: dot-pop 0.45s var(--ease) both; }
.viz-animate .tier-bars .fill { animation: tier-grow 0.9s var(--ease) both; }
.viz-animate .rise { animation: rise-in 0.6s var(--ease) both; }
@keyframes bar-grow { from { transform: scaleY(0); } }
@keyframes line-draw { from { stroke-dashoffset: var(--len, 1000); } to { stroke-dashoffset: 0; } }
@keyframes dot-pop { from { transform: scale(0); opacity: 0; } }
@keyframes tier-grow { from { transform: scaleX(0); } }

/* Client profile — tabs, pinned notes, perks */
.ptabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 4px; overflow-x: auto; scrollbar-width: none; }
.ptabs::-webkit-scrollbar { display: none; }
.ptab {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; min-height: var(--tap); cursor: pointer; white-space: nowrap;
  font-family: var(--font-body); font-size: 12px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3);
}
.ptab:hover { color: var(--text-bright); }
.ptab.on { color: var(--text-bright); border-bottom-color: var(--bronze); }
.ptab .n { display: inline-block; min-width: 16px; margin-left: 5px; padding: 0 5px; border-radius: 999px; background: var(--bronze-wash); color: var(--bronze-ink); font-size: 12px; letter-spacing: 0; }
.pin-note { border-left: 3px solid var(--bronze); background: var(--bronze-wash); border-radius: 0 12px 12px 0; padding: 9px 12px; margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.pin-note .muted { font-size: 13px; }
.perk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.perk { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.perk .t { font-size: 15px; color: var(--text-bright); }
.perk .s { font-size: 14px; color: var(--text-3); margin-top: 2px; }
.perk.used { opacity: 0.7; }
.bday-ring { flex: none; }
.tone-green { color: var(--good); }
.tone-yellow { color: var(--warn); }
.tone-red { color: var(--bad); }
.hist-rollover td { color: var(--good); }
.hist-expired td { color: var(--bad); }
.hist-perk td { color: var(--bronze); }
.today-row { display: grid; grid-template-columns: 92px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.today-row:last-child { border-bottom: 0; }
.today-row .time { font-variant-numeric: tabular-nums; color: var(--text-bright); font-size: 16px; }
.nurture-reason { display: inline-block; margin: 0 6px 4px 0; }
.dup-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.dup-cols .card { margin: 0; box-shadow: none; }
.dup-diff { background: rgb(var(--warn-rgb) / 0.12); border-radius: 4px; padding: 0 3px; }

.more-nav { display: grid; margin: 0 -8px; }
.more-nav .nav-section { padding-left: 14px; }
.more-foot { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 8px; }
.more-foot a { display: inline-flex; align-items: center; min-height: var(--tap); font-weight: 600; }
.placeholder { max-width: 620px; }
.placeholder p { color: var(--text-2); margin-bottom: 10px; }

/* ---------- Today ---------- */
.day-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; border: 1px solid var(--control); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { min-height: var(--tap-sm); padding: 0 16px; border-radius: 999px; border: 0; background: transparent; color: var(--text-2);
  font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--bronze-fill); color: var(--on-accent); }
.day-summary { color: var(--text-2); font-size: 15px; }
.day-list { display: grid; gap: 0; }
.day-row { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: 0; }
.day-row.past { opacity: 0.86; }
.day-row.cancelled .who { text-decoration: line-through; text-decoration-color: var(--text-3); }
.day-row .time { font-variant-numeric: tabular-nums; color: var(--text-bright); font-size: 17px; font-weight: 600; }
.day-row .time .muted { font-weight: 400; }
.day-row .who { font-size: 17px; color: var(--text-bright); font-weight: 600; }
.day-row .who a { color: inherit; text-decoration: none; }
.day-row .who a:hover { text-decoration: underline; }
.day-row .what { color: var(--text-2); font-size: 15px; margin-top: 2px; }
.day-row .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.day-row .acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.src-jane { border-color: rgb(var(--steel-rgb) / 0.45); color: var(--steel); background: rgb(var(--steel-rgb) / 0.12); }
.now-line { display: flex; align-items: center; gap: 10px; color: var(--bronze); font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; padding: 6px 0; }
.now-line::after { content: ''; flex: 1; height: 1px; background: var(--bronze); }

/* ---------- Activity ---------- */
.act-filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) auto; gap: 10px; align-items: end; margin-bottom: 16px; }
.act-filters label.field { margin: 0; }
.act-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.act-row .when { color: var(--text-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.act-row .sum { color: var(--text-bright); }
.act-row .meta { color: var(--text-3); font-size: 14px; margin-top: 2px; }
.act-row .changes { margin-top: 6px; font-size: 14px; color: var(--text-2); display: grid; gap: 2px; }
.act-row .changes s { color: var(--text-3); }

/* ---------- Dialog chrome ---------- */
.modal { position: relative; }
.modal-x { position: absolute; top: 14px; right: 14px; z-index: 2; }
.modal > .modal-x + * { padding-right: 52px; }
.modal-open { overflow: hidden; }
.ask-back { z-index: 60; align-items: center; }
.ask { width: 460px; padding: 26px 26px 22px; }
.ask .ask-title { font-family: var(--font-display); font-weight: 400; font-size: 22px; line-height: 1.3; color: var(--text-bright); margin-bottom: 8px; }
.ask .ask-msg p { color: var(--text-2); margin-bottom: 8px; }
.ask label.field { margin-top: 12px; }

@media (max-width: 1100px) {
  .act-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top-search { width: min(300px, 30vw); }
}
@media (max-width: 900px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: 1fr; }
  .sidebar { width: 210px; }
  .content { padding: 20px 18px 60px; }
  .topbar { padding: 12px 18px; }
  .subnav { padding: 0 18px; }
  .book-pay .label { display: none; }
  .user-btn .name { display: none; }
  .user-btn { padding: 2px; }
}

/* ---------- Phone (≤ 720 px): bottom bar, stacked rows, full-screen sheets ---------- */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  .sidebar { display: none; }
  .layout { min-height: 100dvh; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar h1 { font-size: 24px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .top-search { order: 3; width: 100%; }
  .mode-pill { padding: 6px 10px; letter-spacing: 0.12em; }
  .subnav { padding: 0 8px; }
  .content { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }
  .card { padding: 18px 16px; border-radius: 18px; }
  .grid.cols-4, .grid.cols-2, .stat-row, .dup-cols { grid-template-columns: 1fr; }
  .modal .row { flex-direction: column; gap: 0; }
  /* Screens written for the desktop: let their inline flex rows wrap, long
     words (emails) break, and buttons take two lines rather than run off. */
  .card, .modal { overflow-wrap: anywhere; }
  .card *, .modal * { min-width: 0; }
  .ptabs > *, .filters > *, .subnav > *, .seg > * { flex: none; min-width: auto; }
  #content [style*="display:flex"], .modal [style*="display:flex"], .row { flex-wrap: wrap; }
  .row > * { flex: 1 1 100%; }
  .btn { white-space: normal; text-align: center; }
  #content [style*="width:"]:is(input, select, textarea) { width: 100% !important; max-width: 100%; }
  #content [style*="grid-template-columns"], .modal [style*="grid-template-columns"] { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important; }

  .bottom-bar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--bg-deep); border-top: 1px solid var(--line-strong);
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
  }
  .bottom-bar a, .bottom-bar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
    color: var(--text-2); text-decoration: none; font: inherit; font-size: 13px; font-weight: 600; background: none; border: 0; border-radius: 12px; cursor: pointer; position: relative; }
  .bottom-bar [aria-current="page"] { color: var(--text-bright); background: var(--bronze-wash); }
  .bottom-bar .badge { position: absolute; top: 4px; right: 12%; padding: 1px 6px; font-size: 12px; }

  /* Tables become stacked, labelled rows */
  table:not(.keep-table), table:not(.keep-table) tbody, table:not(.keep-table) tr, table:not(.keep-table) td { display: block; width: 100%; }
  table:not(.keep-table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table:not(.keep-table) tr { border-bottom: 1px solid var(--line-strong); padding: 10px 0; }
  table:not(.keep-table) td { border: 0; padding: 4px 0; white-space: normal !important; display: grid; grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); gap: 10px; }
  table:not(.keep-table) td::before { content: attr(data-label); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-3); font-weight: 600; padding-top: 3px; }
  table:not(.keep-table) td[data-label=""]::before, table.no-head td::before { content: none; }
  table:not(.keep-table) td[data-label=""], table.no-head td { grid-template-columns: minmax(0, 1fr); }
  tr:hover td { background: none; }

  /* Modals become full-screen sheets */
  .modal-back { padding: 0; align-items: stretch; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: none; height: 100dvh; border-radius: 0; border: 0;
    padding: max(18px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
  .modal footer { position: sticky; bottom: calc(-24px - env(safe-area-inset-bottom)); background: var(--surface); padding: 12px 0; margin-top: 12px; flex-wrap: wrap; }
  .ask-back { align-items: flex-end; }
  .ask { height: auto; border-radius: 22px 22px 0 0; }

  .day-row { grid-template-columns: 64px minmax(0, 1fr); }
  .day-row .acts { grid-column: 1 / -1; justify-content: flex-start; }
  .act-filters { grid-template-columns: 1fr 1fr; }
  .act-row { grid-template-columns: 1fr; gap: 4px; }
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .filters::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}
