/*
 * Tokens and rules follow the CX Portal design system (frontend/DESIGN.md, platform doc 08) so
 * these screens look native when they move into the portal shell, and drop out cleanly when the
 * portal's own tokens replace these. Light only, deliberately: no dark palette, no
 * prefers-color-scheme handling (design system §3.5).
 */
:root {
  color-scheme: light;
  --background: rgba(255, 255, 255, 1);
  --card: rgba(255, 255, 255, 1);
  --foreground: rgba(10, 13, 20, 1);
  --muted: rgba(246, 248, 250, 1);
  --muted-foreground: rgba(82, 88, 102, 1);
  --primary: rgba(55, 93, 251, 1);
  --primary-hover: rgba(38, 73, 220, 1);
  --primary-foreground: rgba(255, 255, 255, 1);
  --accent: rgba(235, 241, 255, 1);
  --border: rgba(226, 228, 233, 1);
  --border-strong: rgba(195, 200, 210, 1);
  --destructive: rgba(223, 28, 65, 1);
  --success: rgba(56, 199, 147, 1);
  --amber-warning: rgba(180, 120, 10, 1);

  /* Performance ramp: solid = strong, emptier = weaker. Never red/green (design system §2.1). */
  --ramp-1: rgba(55, 93, 251, 1);
  --ramp-2: rgba(55, 93, 251, 0.72);
  --ramp-3: rgba(55, 93, 251, 0.42);
  --ramp-4: rgba(55, 93, 251, 0.16);

  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --text-xs: 10px; --text-sm: 12px; --text-base: 14px; --text-lg: 16px; --text-xl: 20px; --text-2xl: 24px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px; --space-6: 32px;
  --radius: 8px; --radius-card: 16px; --radius-modal: 20px;
  --card-pad: 24px;
  --elevation-card: 0 1px 2px rgba(10, 13, 20, 0.04), 0 1px 3px rgba(10, 13, 20, 0.04);
  --elevation-2: 0 4px 12px rgba(10, 13, 20, 0.08), 0 1px 3px rgba(10, 13, 20, 0.06);
  --elevation-3: 0 16px 48px rgba(10, 13, 20, 0.18);
  --ease: 140ms ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--muted); color: var(--foreground); }
body { font-family: var(--font-sans); font-size: var(--text-base); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted, .sub { color: var(--muted-foreground); }
.small, .sub { font-size: var(--text-sm); }
.num { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: var(--space-4); }
.login .panel { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); padding: var(--space-6); box-shadow: var(--elevation-card); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; font-size: var(--text-lg); color: var(--foreground); }
.brand svg { width: 24px; height: 24px; color: var(--primary); }
.brand .product { color: var(--muted-foreground); font-weight: 500; }
.login h1 { margin: var(--space-5) 0 var(--space-1); font-size: var(--text-xl); }
.login form { display: grid; gap: var(--space-4); margin-top: var(--space-5); }
.hint { margin-top: var(--space-4); padding: var(--space-3); background: var(--muted); border-radius: var(--radius); font-size: var(--text-sm); color: var(--muted-foreground); }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--card); border-right: 1px solid var(--border); padding: var(--space-5) var(--space-3); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brand { padding: 0 var(--space-2) var(--space-1); }
.side .org { padding: 0 var(--space-2) var(--space-5); font-size: var(--text-sm); color: var(--muted-foreground); }
.nav-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); padding: var(--space-4) var(--space-2) var(--space-2); font-weight: 500; }
.nav a { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2); border-radius: var(--radius); color: var(--foreground); font-weight: 500; transition: background var(--ease); }
.nav a:hover { background: var(--muted); text-decoration: none; }
.nav a.active { background: var(--accent); color: var(--primary); }
.nav a svg { width: 18px; height: 18px; flex: none; }
.side .me { margin-top: auto; padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--border); display: flex; align-items: center; gap: var(--space-2); }
.side .me .person { flex: 1; min-width: 0; }
.main { padding: var(--space-6); min-width: 0; }
.topbar { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; margin-bottom: var(--space-5); }
.topbar .grow { flex: 1; min-width: 0; }
.page-sub { color: var(--muted-foreground); font-size: var(--text-sm); margin-top: 2px; }
.btn.menu-btn, .icon-btn.menu-btn { display: none; }

/* Embedded in a host shell: the host draws navigation and the page header. */
html:has(body.embedded), body.embedded { background: transparent; }
body.embedded .shell { display: block; min-height: 0; }
body.embedded .side, body.embedded .page-title { display: none; }
body.embedded .main { padding: 0; }
body.embedded .topbar { justify-content: flex-end; }

/* ---------------------------------------------------------------- cards (§5.1) */
.stack { display: flex; flex-direction: column; gap: var(--space-5); }
.grid { display: grid; gap: var(--space-5); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--elevation-card); padding: var(--card-pad); min-width: 0; }
.card-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); flex-wrap: wrap; }
.card-head .grow { flex: 1; }
/* a tile inside a card: border only, never a shadow */
.tile { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4); background: var(--card); }
.tile + .tile { margin-top: var(--space-3); }

.stat { cursor: default; }
.stat .label { font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground); }
.stat .value { font-size: var(--text-xl); font-weight: 600; margin-top: var(--space-1); }
.stat .hero { font-size: var(--text-2xl); font-weight: 600; margin-top: var(--space-1); }
.stat .sub { margin-top: 2px; }

/* ---------------------------------------------------------------- tabs, segmented */
.tabs { display: flex; gap: var(--space-5); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: var(--space-3) 0; font: inherit; font-weight: 500; color: var(--muted-foreground); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color var(--ease); }
.tabs button:hover { color: var(--foreground); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.seg { display: inline-flex; background: var(--muted); border: 1px solid var(--border); border-radius: var(--radius); padding: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: var(--text-sm); font-weight: 500; padding: 6px var(--space-3); border-radius: 6px; color: var(--muted-foreground); cursor: pointer; transition: background var(--ease); }
.seg button:hover:not(.active) { background: var(--border); }
.seg button.active { background: var(--card); color: var(--primary); box-shadow: var(--elevation-card); }

/* ---------------------------------------------------------------- forms & buttons (§5.2: fill change only) */
label.field { display: grid; gap: 6px; font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground); }
input, select, textarea { font: inherit; font-size: var(--text-base); color: var(--foreground); background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px var(--space-3); width: 100%; transition: border-color var(--ease); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--accent); }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.btn { font: inherit; font-size: var(--text-base); font-weight: 500; border: 1px solid transparent; border-radius: var(--radius); padding: 8px var(--space-4); cursor: pointer; background: var(--primary); color: var(--primary-foreground); display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; transition: background var(--ease); }
.btn:hover { background: var(--primary-hover); }
.btn.ghost { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn.ghost:hover { background: var(--muted); }
.btn.subtle { background: var(--muted); color: var(--foreground); }
.btn.subtle:hover { background: var(--border); }
.btn.danger { background: var(--card); color: var(--destructive); border-color: var(--border); }
.btn.danger:hover { background: rgba(223, 28, 65, 0.06); }
.btn.sm { padding: 5px var(--space-3); font-size: var(--text-sm); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted-foreground); cursor: pointer; transition: background var(--ease); flex: none; }
.icon-btn:hover { background: var(--muted); color: var(--foreground); }
.icon-btn svg { width: 18px; height: 18px; }
.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: var(--space-2); color: var(--foreground); font-weight: 400; font-size: var(--text-base); }
.error { color: var(--destructive); font-size: var(--text-sm); margin-top: var(--space-2); }
.error:empty { display: none; }

/* ---------------------------------------------------------------- tables (§5.5) */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-foreground); font-weight: 500; padding: var(--space-2) var(--space-3); background: var(--muted); white-space: nowrap; }
th:first-child { border-radius: var(--radius) 0 0 var(--radius); }
th:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
td { padding: var(--space-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--muted); }
.person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.person-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-text { min-width: 0; }
/* initials are a placeholder, not a status: neutral grey, always (§5.7) */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--muted); border: 1px solid var(--border); color: var(--muted-foreground); display: grid; place-items: center; font-weight: 500; font-size: var(--text-sm); flex: none; }

/* ---------------------------------------------------------------- chips, dots, ramp */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--space-2); border-radius: 999px; font-size: var(--text-sm); font-weight: 500; background: var(--muted); border: 1px solid var(--border); color: var(--foreground); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.band-exceeding { background: var(--ramp-1); }
.dot.band-on_track { background: var(--ramp-2); }
.dot.band-needs_attention { background: var(--ramp-3); }
/* the attention channel: amber, as a dot, never a fill (§2.2) */
.dot.band-at_risk { background: var(--amber-warning); }
.dot.band-none { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
.dot.ok { background: var(--success); }
.dot.err { background: var(--destructive); }
.dot.wait { background: var(--amber-warning); }
.dot.neutral { background: var(--border-strong); }
.bar { height: 8px; background: var(--muted); border-radius: 999px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--ramp-1); }
.bar > .band-on_track { background: var(--ramp-2); }
.bar > .band-needs_attention { background: var(--ramp-3); }
.bar > .band-at_risk { background: var(--ramp-4); }
.hbar { display: grid; grid-template-columns: minmax(100px, 180px) 1fr 56px; gap: var(--space-3); align-items: center; padding: 6px 0; font-size: var(--text-sm); }
.hbar .num { text-align: right; }
.legend { display: flex; gap: var(--space-4); flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted-foreground); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- KPI goal tiles */
.goal .top { display: flex; gap: var(--space-3); align-items: flex-start; }
.goal .top .grow { flex: 1; min-width: 0; }
.goal .figures { display: flex; gap: var(--space-5); margin: var(--space-3) 0 var(--space-2); flex-wrap: wrap; }
.goal .figures .v { font-size: var(--text-lg); font-weight: 600; }
.history { margin-top: var(--space-3); border-top: 1px solid var(--border); padding-top: var(--space-2); font-size: var(--text-sm); }
.history div { display: flex; gap: var(--space-3); padding: 4px 0; flex-wrap: wrap; }
.group-title { font-size: var(--text-sm); font-weight: 500; color: var(--muted-foreground); margin: var(--space-4) 0 var(--space-2); }
.group-title:first-child { margin-top: 0; }

.gauge { display: grid; place-items: center; }
.gauge svg { width: 100%; max-width: 220px; }
.gauge-label { font-size: 12px; fill: var(--muted-foreground); font-weight: 500; font-family: var(--font-sans); }
.gauge-value { font-size: 24px; fill: var(--foreground); font-weight: 600; font-family: var(--font-sans); }
.empty { text-align: center; padding: var(--space-6) var(--space-3); color: var(--muted-foreground); font-size: var(--text-sm); }
.loading { min-height: 160px; }
.stars { display: inline-flex; gap: var(--space-1); }
.stars button { border: 1px solid var(--border); background: var(--card); color: var(--foreground); width: 32px; height: 32px; border-radius: var(--radius); font: inherit; font-weight: 500; cursor: pointer; transition: background var(--ease); }
.stars button:hover:not(.on) { background: var(--muted); }
.stars button.on { background: var(--accent); color: var(--primary); border-color: var(--primary); }
.rating-num { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.rating-row { border-bottom: 1px solid var(--border); padding-bottom: var(--space-3); }

/* ---------------------------------------------------------------- modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 13, 20, 0.4); display: grid; place-items: center; padding: var(--space-4); z-index: 50; }
.modal { background: var(--card); border-radius: var(--radius-modal); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto; padding: var(--space-5); box-shadow: var(--elevation-3); }
.modal.wide { max-width: 880px; }
.modal-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.modal-head h2 { flex: 1; }
.modal .actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-5); }
.toast { position: fixed; bottom: var(--space-5); left: 50%; transform: translateX(-50%); background: var(--foreground); color: var(--background); padding: var(--space-3) var(--space-4); border-radius: var(--radius); z-index: 60; box-shadow: var(--elevation-2); max-width: calc(100vw - 32px); font-size: var(--text-base); }
.toast.err { background: var(--destructive); }

.perm-matrix td, .perm-matrix th { padding: 6px var(--space-2); }
.perm-matrix select { padding: 4px 6px; font-size: var(--text-sm); min-width: 80px; }
.perm-group td { background: var(--muted); font-weight: 500; font-size: var(--text-sm); color: var(--muted-foreground); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: var(--text-sm); background: var(--muted); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
ul.plain { margin: 0; padding-left: var(--space-4); color: var(--muted-foreground); }

@media (prefers-reduced-motion: no-preference) { .modal { animation: rise 140ms ease; } }
@keyframes rise { from { transform: translateY(4px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--elevation-3); }
  .shell.open .side { transform: none; }
  .btn.menu-btn, .icon-btn.menu-btn { display: inline-grid; }
  .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  :root { --card-pad: 16px; }
  .main { padding: var(--space-4); }
  .hbar { grid-template-columns: 96px 1fr 48px; }
}

/* ---------------------------------------------------------------- gift card store */
.store-card { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.store-card .grow { flex: 1; min-width: 220px; }
.store-overlay { position: fixed; inset: 0; z-index: 70; background: var(--background); display: flex; flex-direction: column; }
.store-bar { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted-foreground); }
.store-bar .grow { flex: 1; }
.store-frame { flex: 1; width: 100%; border: 0; }
.store-status { flex: 1; display: grid; place-items: center; color: var(--muted-foreground); text-align: center; padding: var(--space-5); }
.store-status[hidden], .store-frame[hidden] { display: none; }
.pace-bar { position: relative; }
.pace-mark { position: absolute; top: -3px; width: 2px; height: 14px; background: var(--foreground); border-radius: 1px; transform: translateX(-1px); }

/* ---------------------------------------------------------------- sheet import */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.import-steps { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.import-steps .tile + .tile { margin-top: 0; }
.import-table { max-height: 360px; overflow-y: auto; }
.error-text { color: var(--destructive); }
label.btn { cursor: pointer; }
@media (max-width: 640px) { .import-steps { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- habits × performance */
.scatter { width: 100%; height: auto; display: block; }
.scatter .grid { stroke: var(--border); stroke-width: 1; }
.scatter .threshold { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 4 4; }
.scatter .tick, .scatter .quad, .scatter .axis { font-family: var(--font-sans); fill: var(--muted-foreground); }
.scatter .tick { font-size: 11px; }
.scatter .quad { font-size: 11px; font-weight: 500; }
.scatter .axis { font-size: 12px; }
.scatter .dot-mark { fill: var(--ramp-2); stroke: var(--card); stroke-width: 2; }
.scatter .dot-mark:hover, .scatter .dot-mark:focus { fill: var(--ramp-1); outline: none; r: 7; }
.scatter .trend-line { stroke: var(--foreground); stroke-width: 2; opacity: 0.5; }
ul.findings { margin: 0; padding-left: var(--space-4); display: grid; gap: var(--space-2); }

/* ---------------------------------------------------------------- notifications, check-ins, cycles */
.bell-wrap { position: relative; }
.bell { position: relative; }
.bell-badge { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-size: 10px; font-weight: 600; display: grid; place-items: center; }
.bell-badge[hidden] { display: none; }
.bell-panel { position: absolute; right: 0; top: 40px; width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow-y: auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--elevation-3); z-index: 45; padding: var(--space-2); }
.bell-panel[hidden] { display: none; }
.bell-head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2); }
.bell-item { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; padding: var(--space-2); border-radius: var(--radius); cursor: pointer; color: var(--foreground); }
.bell-item:hover { background: var(--muted); }
.bell-item.unread .bell-title { font-weight: 600; }
.bell-item.unread { box-shadow: inset 3px 0 0 var(--primary); }
.callout-quiet { margin-top: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--muted); border-radius: var(--radius); font-size: var(--text-sm); }
.action-item .done { text-decoration: line-through; color: var(--muted-foreground); }
.steps { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.step { font-size: var(--text-sm); padding: 4px var(--space-3); border-radius: 999px; border: 1px solid var(--border); color: var(--muted-foreground); }
.step.done { background: var(--muted); color: var(--foreground); }
.step.current { background: var(--accent); border-color: var(--primary); color: var(--primary); font-weight: 500; }

/* ---------------------------------------------------------------- phones: header wraps, tables become cards */
@media (max-width: 640px) {
  .topbar { row-gap: var(--space-2); }
  .topbar .page-title { flex: 1 1 calc(100% - 48px); }
  .topbar .page-sub { display: none; }
  table.stackable thead { display: none; }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: 100%; }
  table.stackable tr { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); }
  table.stackable td { border: 0; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); text-align: right; }
  table.stackable td[data-label]::before { content: attr(data-label); color: var(--muted-foreground); font-size: var(--text-sm); text-align: left; flex: none; max-width: 45%; }
  table.stackable td:not([data-label]) { justify-content: flex-start; }
  table.stackable td .person { text-align: left; }
  .table-wrap { overflow-x: visible; }
}
.habit-teaser .value { font-size: var(--text-xl); font-weight: 600; }
.bell-foot { display: block; text-align: center; padding: var(--space-2); margin-top: var(--space-1); border-top: 1px solid var(--border); font-size: var(--text-sm); }
.check-list { max-height: 380px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-top: var(--space-2); }
.check-list .check { display: flex; gap: var(--space-2); align-items: center; padding: 4px 0; }
.tt-bar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.tt-search { flex: 1 1 220px; max-width: 360px; }
.tt-count { margin-left: auto; }
.tt-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2) var(--space-3); padding: var(--space-3); margin-bottom: var(--space-2); border: 1px solid var(--border); border-radius: var(--radius); background: var(--muted); }
.tt-panel[hidden], .tt-bar [hidden] { display: none; }
.tt-filter { margin: 0; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable::after { content: ' ↕'; opacity: .35; font-size: .85em; }
th.sortable[aria-sort="ascending"]::after { content: ' ↑'; opacity: .8; }
th.sortable[aria-sort="descending"]::after { content: ' ↓'; opacity: .8; }
tr[hidden] { display: none; }
/* Drawer: a panel sliding in from the right */
.drawer-bg { position: fixed; inset: 0; background: rgba(10, 13, 20, 0); z-index: 60; transition: background 180ms ease; }
.drawer-bg.open { background: rgba(10, 13, 20, .35); }
.drawer { position: absolute; top: 0; right: 0; height: 100%; width: min(var(--drawer-w, 640px), 100vw); background: var(--card); box-shadow: -8px 0 32px rgba(10,13,20,.18);
  display: flex; flex-direction: column; transform: translateX(100%); transition: transform 180ms ease; }
.drawer-bg.open .drawer { transform: none; }
.drawer-head { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: var(--text-lg, 18px); }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-4) var(--space-5); }
.drawer-foot { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--border); margin: var(--space-4) calc(-1 * var(--space-5)) calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-5); display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
/* Tables: serial numbers and pager */
th.sno, td.sno { width: 44px; color: var(--muted-foreground); text-align: right; }
.tt-pager { display: flex; gap: var(--space-2); align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-top: var(--space-3); }
.tt-pager select { width: auto; }
/* Rating form */
.rate-progress { height: 6px; background: var(--muted); border-radius: 99px; overflow: hidden; margin: var(--space-2) 0 var(--space-4); }
.rate-progress > span { display: block; height: 100%; background: var(--primary); transition: width 160ms ease; }
.rate-card { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); }
.rate-card.done { border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.rate-card.missing { border-color: #f2b8b5; background: #fff8f7; }
.rate-card .title { display: flex; gap: var(--space-2); align-items: baseline; }
.rate-card .title b { font-weight: 600; flex: 1; }
.rate-scale { display: flex; flex-wrap: wrap; gap: 6px; margin: var(--space-2) 0; align-items: center; }
.rate-chip { min-width: 40px; height: 34px; border: 1px solid var(--border); background: var(--card); border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer; }
.rate-chip:hover { background: var(--muted); }
.rate-chip.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.rate-fine { display: flex; gap: var(--space-2); align-items: center; }
.rate-fine input[type=range] { flex: 1; accent-color: var(--primary); }
.rate-fine .val { min-width: 48px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.rate-card textarea { min-height: 54px; }
.rate-meta { font-size: var(--text-xs, 12px); color: var(--muted-foreground); }
.metric-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--space-2); margin-top: var(--space-2); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 500; background: var(--muted); }
.status-pill.done { background: #e7f6ec; color: #1a7f45; } .status-pill.in_progress { background: #fff4e0; color: #9a5b00; } .status-pill.not_started { background: #fdecec; color: #b42318; }
td.actions-cell { text-align: right; white-space: nowrap; }
.month-bar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.kpi-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-3); }
.trend { width: 100%; height: auto; }
.trend .grid { stroke: var(--border); stroke-width: 1; }
.trend .tick { font-size: 11px; fill: var(--muted-foreground); }
.trend-score { fill: none; stroke: var(--primary); stroke-width: 2.5; }
.trend-habit { fill: none; stroke: #2ea06b; stroke-width: 2; stroke-dasharray: 4 4; }
.pt-score { fill: var(--primary); } .pt-history { fill: #fff; stroke: var(--primary); stroke-width: 2; }
.legend { display: inline-block; width: 14px; height: 4px; border-radius: 2px; vertical-align: middle; margin-left: 8px; }
.legend.score { background: var(--primary); } .legend.habit { background: #2ea06b; } .legend.hist { border: 2px solid var(--primary); width: 8px; height: 8px; border-radius: 50%; }
a.person-link { color: var(--foreground); text-decoration: none; } a.person-link:hover b, a.person-link:hover .person-name { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
td.actions-cell { position: sticky; right: 0; background: var(--card); box-shadow: -8px 0 8px -8px rgba(10,13,20,.12); }
tr:hover td.actions-cell { background: inherit; }
.trend { max-height: 260px; }
table.matrix th[scope=row] { text-align: left; font-weight: 500; white-space: nowrap; }
table.matrix td.cell { padding: 4px; }
table.matrix td.unused { opacity: .55; }
.cell-btn { width: 100%; min-width: 92px; text-align: left; border: 1px solid var(--border); background: var(--card); border-radius: 8px; padding: 6px 8px; cursor: pointer; font: inherit; }
.cell-btn:hover { border-color: var(--primary); }
.preview-bar { position: sticky; top: 0; z-index: 30; display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; padding: 10px var(--space-5); background: #fff4e0; color: #7a4b00; border-bottom: 1px solid #f1d29a; }
.preview-bar .btn { margin-left: auto; }
ol.steps { margin: 8px 0 0 18px; line-height: 1.8; }

/* ---------------------------------------------------------------- onboarding: checklists, wizard, tour, action lists */
.ring { --p: 0; width: 48px; height: 48px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--primary) calc(var(--p) * 1%), var(--muted) 0); }
.ring span { width: 38px; height: 38px; border-radius: 50%; background: var(--card); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.checklist .card-head { gap: var(--space-3); align-items: center; }
.check-items { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: 2px; }
.check-items li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2); border-radius: var(--radius); }
.check-items li:hover { background: var(--muted); }
.check-items .title { font-weight: 500; }
.check-items li.done .title { color: var(--muted-foreground); text-decoration: line-through; }
.check-items .tick { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--border); flex: none; display: grid; place-items: center; }
.check-items li.done .tick { background: var(--primary); border-color: var(--primary); color: #fff; }
.check-items .tick svg { width: 14px; height: 14px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--space-3); }
.kv { display: flex; flex-direction: column; gap: 2px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-2); }
.check.feature { align-items: flex-start; padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); }
.check.feature input { margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--space-3); }
.summary-list { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.action-list { display: grid; gap: 2px; }
.action-row { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-2); border-top: 1px solid var(--border); }
.action-row:first-child { border-top: 0; }
.action-row > .dot { margin-top: 7px; flex: none; }
.action-row .title { font-weight: 500; }
.action-row.level-high .title { color: var(--destructive, #c0262d); }
.people-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.person-chip { cursor: pointer; font: inherit; font-size: var(--text-sm); }
.person-chip:hover { border-color: var(--primary); color: var(--primary); }
.flag { white-space: nowrap; }
.tour { position: fixed; inset: 0; z-index: 80; }
.tour.dim { background: rgba(10, 13, 20, .45); }
.tour-spot { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(10, 13, 20, .45); pointer-events: none; transition: all 200ms ease; outline: 2px solid var(--primary); }
.tour-pop { position: fixed; background: var(--card); border-radius: var(--radius-modal, 12px); padding: var(--space-4); box-shadow: var(--elevation-3); max-width: calc(100vw - 24px); width: 340px; }
.tour-pop h3 { margin: 4px 0 6px; font-size: 16px; }
.tour-pop p { margin: 0; }
@media (max-width: 720px) { .tour-pop { left: 12px !important; right: 12px; width: auto !important; top: auto !important; bottom: 16px; transform: none !important; } }
.check-items li > .grow, .action-row > .grow, .checklist .card-head > .grow { flex: 1; min-width: 0; }
@media (max-width: 720px) {
  .action-row { flex-wrap: wrap; }
  .action-row > .btn { margin-left: 22px; }
  .check-items li { flex-wrap: wrap; }
  .check-items li > .btn { margin-left: 34px; }
}

/* ---------------------------------------------------------------- info tips, performance builder */
.label-row { display: inline-flex; align-items: center; gap: 6px; }
.tip { position: relative; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); background: var(--card); color: var(--muted-foreground);
  font: italic 600 11px/16px Georgia, serif; padding: 0; cursor: help; flex: none; display: inline-grid; place-items: center; }
.tip:hover, .tip.open, .tip:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }
.tip-pop { display: none; position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: 280px; z-index: 90;
  background: #0a0d14; color: #fff; font: 400 12.5px/1.45 Inter, system-ui, sans-serif; padding: 8px 10px; border-radius: 8px; text-align: left; white-space: normal; box-shadow: var(--elevation-3); }
.tip:hover .tip-pop, .tip.open .tip-pop, .tip:focus-visible .tip-pop { display: block; }
@media (max-width: 720px) { .tip-pop { left: auto; right: -8px; transform: none; max-width: 240px; } }
.group-title.full { grid-column: 1 / -1; margin-top: 4px; }
.kpi-preview { margin-top: 0; }
.builder-steps { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.kra-card .card-head { align-items: flex-start; }
.kpi-list { display: grid; gap: 2px; margin-top: 8px; }
.kpi-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-2); border-top: 1px solid var(--border); }
.kpi-row:first-child { border-top: 0; }
.kpi-row > .grow { flex: 1; min-width: 0; }
.kpi-row .title { font-weight: 500; }
.kpi-weight { text-align: right; min-width: 72px; }
@media (max-width: 720px) { .kpi-row { flex-wrap: wrap; } .kpi-weight { text-align: left; } }

/* ---------------------------------------------------------------- reports */
.report-title h2 { margin: 0; }
.report-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.report-table th, .report-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.report-table thead th { background: var(--muted); font-weight: 600; text-align: left; }
.report-table th.num, .report-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.report-table tbody th { text-align: left; font-weight: 500; }
.report-table td.total, .report-table tfoot td, .report-table tfoot th { font-weight: 600; }
.report-table tfoot tr:first-child td, .report-table tfoot tr:first-child th { border-top: 2px solid var(--border); }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .side, .topbar, .no-print, .preview-bar, .toast, .tt-tools, .tt-pager { display: none !important; }
  .shell, .main { display: block !important; padding: 0 !important; margin: 0 !important; }
  body { background: #fff !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; margin-bottom: 8px !important; }
  .report-pair { display: block !important; }
  .report-table { font-size: 10px; }
}
.redeem-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin-top: 8px; }
.redeem-item { text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); padding: 10px 12px; cursor: pointer; font: inherit; }
.redeem-item:hover { border-color: var(--primary); }
.redeem-item.on { border-color: var(--primary); background: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* ---------------------------------------------------------------- links, role groups
   Blue is kept for actions (buttons, the active page, "Open" style calls to action). Links to
   records (people, designations, parameters) read as normal text with a faint underline, and turn
   blue on hover, so a list full of names stays calm but every name is still visibly clickable. */
a.link, table a:not(.btn):not(.chip) { color: var(--foreground); font-weight: 500; text-decoration: underline; text-decoration-color: var(--border-strong, #cdd0d5); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a.link:hover, table a:not(.btn):not(.chip):hover { color: var(--primary); text-decoration-color: var(--primary); }
a.link .sub { text-decoration: none; }
.role-head a.link { text-decoration: none; font-size: 15px; }
.role-head a.link:hover { text-decoration: underline; }
.chip-link { color: var(--foreground); background: var(--muted); border-color: transparent; text-decoration: none; cursor: pointer; font-weight: 400; }
.chip-link:hover { color: var(--primary); border-color: var(--primary); background: var(--card); text-decoration: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; letter-spacing: .02em; }
.tag-metric { background: transparent; color: #1a7f45; border: 1px solid #b9e2c8; }
.tag-beh { background: transparent; color: var(--muted-foreground); border: 1px solid var(--border); }
.role-group { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.role-group.empty-role { border-style: dashed; }
.role-head { display: flex; align-items: center; gap: var(--space-2); margin-bottom: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; }
.chosen-block { background: var(--muted); border-radius: var(--radius); padding: 6px 10px; margin-bottom: 8px; }
.site-rule { border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }
.band-edit input { width: 100%; }
.chip-own { border-color: var(--primary); color: var(--primary); }
.callout-warn { background: #fff7e6; border-color: #f5c76a; }

/* ---------------------------------------------------------------- overview charts */
.chart-wrap { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
svg.chart .grid { stroke: var(--border); stroke-width: 1; }
svg.chart .grid.ref { stroke-dasharray: 4 4; stroke: var(--border-strong); }
svg.chart .tick { fill: var(--muted-foreground); font-size: 11px; }
svg.chart .line { fill: none; stroke: var(--ramp-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .dot-mark { fill: var(--ramp-1); stroke: var(--card); stroke-width: 2; }
svg.chart .value-label { fill: var(--foreground); font-size: 12px; font-weight: 600; }
svg.chart .hit { fill: transparent; cursor: crosshair; }
svg.chart .hit:hover { fill: rgba(10, 13, 20, .04); }
svg.chart .seg { rx: 3px; }
.band-fill-exceeding { fill: var(--ramp-1); background: var(--ramp-1); }
.band-fill-on_track { fill: var(--ramp-2); background: var(--ramp-2); }
.band-fill-needs_attention { fill: var(--ramp-3); background: var(--ramp-3); }
.band-fill-at_risk { fill: var(--amber-warning); background: var(--amber-warning); }
.chart-tip { position: absolute; z-index: 5; pointer-events: none; background: #0a0d14; color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45; box-shadow: var(--elevation-3); white-space: nowrap; }
.chart-tip .sub { color: #d0d4dc; }
.chart-tip .tip-title { font-weight: 600; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: var(--text-sm); color: var(--muted-foreground); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.cell-bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.up { color: #1a7f45; font-weight: 500; }
.down { color: var(--destructive); font-weight: 500; }
.risk-num { color: var(--amber-warning); }
.stat-risk .value { color: var(--amber-warning); }
.meter { height: 6px; background: var(--muted); border-radius: 99px; overflow: hidden; margin: 6px 0 4px; }
.meter > span { display: block; height: 100%; background: var(--ramp-1); border-radius: 99px; }
.done-fold { margin-top: 4px; }
.done-fold summary { cursor: pointer; padding: 4px 8px; }

/* ---------------------------------------------------------------- shorter pages, flatter cards */
.side .brand { white-space: nowrap; font-size: 16px; }
.side .brand .product { white-space: nowrap; }
.dept-group { border-top: 1px solid var(--border); }
.dept-group:first-child { border-top: 0; }
.dept-group > summary { cursor: pointer; padding: 10px 4px; list-style: none; display: flex; align-items: center; gap: 2px; }
.dept-group > summary::-webkit-details-marker { display: none; }
.dept-group > summary::before { content: '▸'; color: var(--muted-foreground); width: 16px; display: inline-block; transition: transform 120ms; }
.dept-group[open] > summary::before { transform: rotate(90deg); }
.role-row { padding: 8px 4px 10px 20px; border-top: 1px dashed var(--border); }
.role-row.empty-role .role-head .sub { color: var(--amber-warning); }
.sticky-head { position: sticky; top: 0; z-index: 3; background: var(--card); padding-bottom: 8px; }
.slim-link { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
@media (max-width: 720px) {
  table.compact-mobile td[data-label="Type"], table.compact-mobile td[data-label="Designation"], table.compact-mobile td[data-label="Site"],
  table.compact-mobile td[data-label="Last month"], table.compact-mobile td[data-label="This month"] { display: none; }
  .slim-link { flex-direction: column; align-items: flex-start; }
}
/* Rows a table's search, filters or paging hide stay hidden in the phone (card) layout too. */
table tr[hidden] { display: none !important; }

/* ---------------------------------------------------------------- brand */
.brand { gap: 10px; align-items: flex-end; }
.brand-logo { height: 26px; width: auto; display: block; }
.brand .product { font-size: 15px; font-weight: 500; color: var(--muted-foreground); padding-left: 10px; border-left: 1px solid var(--border-strong); line-height: 18px; margin-bottom: 2px; }
.login .brand-logo { height: 32px; }
.fb-picker { max-height: 46vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; }
.fb-group { border-top: 1px solid var(--border); }
.fb-group:first-child { border-top: 0; }
.fb-group > summary { cursor: pointer; padding: 8px 0; }
.fb-group .check { display: flex; align-items: center; gap: 8px; }
.side .org { display: flex; align-items: center; gap: 8px; }
.org-logo { max-height: 22px; max-width: 64px; object-fit: contain; }
.org-logo-preview { max-height: 56px; max-width: 220px; object-fit: contain; }
.logo-drop { border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 16px; display: grid; place-items: center; min-height: 80px; }

/* 360° feedback: frequency answers and the question editor */
.rate-chip.freq { padding: 0 12px; font-size: 13px; }
.rate-chip.freq.na { color: var(--muted-fg, #667085); border-style: dashed; }
.rate-chip.freq.na.on { background: var(--muted); color: inherit; border-color: var(--border); border-style: solid; }
.q360-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q360-row input[type=text], .q360-row input:not([type]) { flex: 1; min-width: 180px; }
@media (max-width: 640px) { .q360-row input { max-width: none !important; } }

/* Joiners & leavers chart */
.mv-join { fill: var(--primary); background: var(--primary); }
.mv-leave { fill: #c2410c; background: #c2410c; }
tr.total-row td { border-top: 1px solid var(--border); }

/* Who needs what: segment tiles */
.seg-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.seg-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); font: inherit; cursor: pointer; border-top: 3px solid var(--seg-c, var(--border)); }
.seg-tile .n { font-size: 26px; font-weight: 600; line-height: 1.1; }
.seg-tile.on { background: var(--muted); border-color: var(--seg-c); }
.seg-tile:hover { background: var(--muted); }
.seg-act { --seg-c: #c2410c; } .seg-coach { --seg-c: #b7791f; } .seg-push { --seg-c: var(--primary); } .seg-celebrate { --seg-c: #15803d; }
@media (max-width: 700px) { .seg-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Frameworks */
.section-title { font-size: 16px; font-weight: 600; margin: 20px 0 10px; }
.fw-card h3 { font-size: 15px; font-weight: 600; margin: 0; }
.fw-card p { margin: 6px 0 0; }
.fw-card.on { border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.fw-why { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--muted); }
.fw-evidence { font-style: italic; }

/* Person form */
.form-section { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); }
.form-grid > .form-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.field-hint { font-size: 12px; color: var(--muted-fg, #667085); min-height: 16px; margin-top: 3px; }
.field-hint.new { color: #b45309; }
.mgr-picker { display: flex; flex-direction: column; gap: 6px; }
.mgr-select { width: 100%; min-height: 150px; }
.role-checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* Platform admin: health, action items */
.health-cell { display: flex; align-items: center; gap: 8px; }
.health-cell .bar { flex: 1; min-width: 60px; }
.bar.g-healthy span, .dist-seg.g-healthy { background: #15803d; }
.bar.g-watch span, .dist-seg.g-watch { background: #b7791f; }
.bar.g-at_risk span, .dist-seg.g-at_risk { background: #c2410c; }
.bar.g-unknown span, .dist-seg.g-unknown { background: var(--border); color: inherit; }
.dist { display: flex; gap: 2px; border-radius: 8px; overflow: hidden; margin-bottom: 12px; }
.dist-seg { color: #fff; font-size: 12px; font-weight: 600; padding: 6px 8px; white-space: nowrap; overflow: hidden; }
.dot.bad { background: #c2410c; }
.tile.item { border-left: 3px solid var(--border); }
.tile.item.sev-high { border-left-color: #c2410c; } .tile.item.sev-medium { border-left-color: #b7791f; }
b.risk, td.risk { color: #c2410c; }
.hbar-row { display: grid; grid-template-columns: 200px 1fr 60px; gap: 8px; align-items: center; font-size: 13px; }
.stack-bar { display: flex; gap: 1px; height: 20px; }
.stack-bar span { color: #fff; font-size: 11px; text-align: center; line-height: 20px; overflow: hidden; }
.sb-exceeding { background: #15803d; } .sb-on { background: var(--primary); } .sb-att { background: #b7791f; } .sb-risk { background: #c2410c; }
.tabs a .count { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px; background: #c2410c; color: #fff; font-size: 11px; line-height: 18px; text-align: center; }
@media (max-width: 640px) { .hbar-row { grid-template-columns: 1fr 1fr 50px; } }
.tabs a { padding: var(--space-3) 0; font-weight: 500; color: var(--muted-foreground); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--foreground); }
.tabs a.active { color: var(--foreground); border-bottom-color: var(--primary); }

/* Admin: digest preview and the customer health report */
.digest-preview { width: 100%; height: 520px; border: 1px solid var(--border); border-radius: var(--radius); background: #f6f8fa; }
.report { max-width: 820px; margin: 0 auto; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 40px; }
.report h1 { font-size: 24px; margin: 18px 0 4px; }
.report h2 { font-size: 17px; margin: 26px 0 8px; }
.r-head { display: flex; justify-content: space-between; align-items: center; }
.r-logo { max-height: 44px; max-width: 160px; object-fit: contain; }
.r-sub { color: var(--muted-foreground); font-size: 13px; }
.r-hero { display: flex; gap: 24px; align-items: center; margin-top: 18px; padding: 16px 20px; border-radius: var(--radius); background: var(--muted); border-left: 5px solid var(--border); }
.r-hero.g-healthy { border-left-color: #15803d; } .r-hero.g-watch { border-left-color: #b7791f; } .r-hero.g-at_risk { border-left-color: #c2410c; }
.r-score b { font-size: 44px; line-height: 1; } .r-score span { color: var(--muted-foreground); margin-left: 4px; }
.r-grade { font-size: 18px; font-weight: 600; }
.r-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 16px; }
.r-num { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; }
.r-label { font-size: 12px; color: var(--muted-foreground); } .r-value { font-size: 22px; font-weight: 600; margin: 2px 0; }
.r-actions li { margin-bottom: 10px; } .r-actions li div { color: var(--muted-foreground); font-size: 14px; }
.r-table { width: 100%; border-collapse: collapse; font-size: 13px; } .r-table th, .r-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.r-table .r { text-align: right; }
.r-foot { margin-top: 24px; font-size: 12px; color: var(--muted-foreground); }
@media (max-width: 760px) { .r-grid { grid-template-columns: 1fr 1fr; } .report { padding: 20px; } }
@media print {
  body.printing-report .side, body.printing-report .topbar, body.printing-report .platform-band, body.printing-report .no-print { display: none !important; }
  body.printing-report, body.printing-report .shell, body.printing-report .main { background: #fff !important; }
  body.printing-report .main { padding: 0 !important; margin: 0 !important; }
  body.printing-report .report { border: 0; max-width: none; padding: 0; }
  .report h2 { break-after: avoid; } .r-table tr { break-inside: avoid; }
  .stack-bar span, .r-hero { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Rating on a phone: thumb-sized buttons, compact header, one-row footer, fine-tune on request */
.drawer-head .grow { flex: 1; min-width: 0; }
.fine-toggle { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 12px; color: var(--muted-foreground); text-decoration: underline; cursor: pointer; }
@media (pointer: coarse) { .rate-chip { min-width: 44px; height: 44px; font-size: 16px; } }
@media (max-width: 640px) {
  .rate-head-tiles { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .rate-head-tiles .rate-meta { display: inline; margin-right: 4px; }
  .rate-head-tiles b { font-size: 14px; }
  .rate-card:not(.show-fine) .rate-fine { display: none; }
  .rate-card { padding: 12px; }
  .rate-card textarea { min-height: 44px; }
  .rate-foot { flex-wrap: nowrap; }
  .rate-foot .grow, .rate-foot .submit-only { display: none; }
  .rate-foot .btn { flex: 1; justify-content: center; min-height: 44px; }
}

.rate-now { display: flex; gap: 16px; align-items: center; border-left: 4px solid var(--primary); }
@media (max-width: 640px) { .rate-now { flex-direction: column; align-items: stretch; } .rate-now .btn { min-height: 44px; justify-content: center; } }

/* People & roles: select many */
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; margin: 8px 0; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--card); }
.bulk-bar.on { border-style: solid; border-color: var(--primary); background: color-mix(in srgb, var(--primary) 6%, var(--card)); position: sticky; top: 0; z-index: 3; }
td.sel { width: 36px; cursor: default; }
td.sel input { width: 18px; height: 18px; }
