/* ============================================================
   Humanlytics — prototype design tokens
   Light palette is authoritative; dark redefines tokens only.
   ============================================================ */

:root {
  /* surfaces & ink — neutrals carry a slight blue bias */
  --bg:            #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #F7FAFC;
  --surface-3:     #EBF1F7;
  --ink:           #111A22;
  --ink-2:         #39454F;
  --muted:         #63707E;
  --faint:         #8D99A6;
  --line:          #DDE5EC;
  --line-2:        #C5D0DC;

  /* brand — deep azure through pale sky */
  --primary:       #0F5B9E;
  --primary-fill:  #0F5B9E;
  --primary-hover: #0C4A84;
  --on-primary:    #FFFFFF;
  --primary-soft:  #EAF2FA;
  --primary-line:  #C9DEF2;

  /* rail — the darkest blue in the range */
  --rail-bg:       #0E2237;
  --rail-ink:      #DCE7F2;
  --rail-muted:    #8CA0B5;
  --rail-line:     #1C3549;
  --rail-active:   #1668B8;

  /* status — reserved, deliberately outside the blue range so state never
     reads as brand; validated for CVD separation on a light surface */
  --st-low:        #B01E3C;
  --st-mid:        #B07A00;
  --st-high:       #09805F;
  --st-low-soft:   #FBEBEE;
  --st-mid-soft:   #FBF2DE;
  --st-high-soft:  #E3F2ED;
  --info:          #0E6E88;
  --info-soft:     #E4F2F6;

  /* chart */
  --chart-ink:     #111A22;
  --chart-grid:    #E4EBF2;
  --chart-axis:    #7C8996;
  --chart-mark:    #0F5B9E;
  --chart-fill:    rgba(15, 91, 158, 0.13);

  /* type */
  --display: "Bricolage Grotesque", "Trebuchet MS", system-ui, sans-serif;
  --body:    "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;

  /* geometry */
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --rail-w: 252px;
  --bar-h: 48px;
  --shadow-1: 0 1px 2px rgba(26, 21, 23, .06), 0 1px 1px rgba(26, 21, 23, .04);
  --shadow-2: 0 10px 30px rgba(26, 21, 23, .12), 0 2px 6px rgba(26, 21, 23, .06);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0C1218;
    --surface:       #141C24;
    --surface-2:     #1A242E;
    --surface-3:     #212D38;
    --ink:           #EAF0F6;
    --ink-2:         #C2CDD9;
    --muted:         #93A1AF;
    --faint:         #76838F;
    --line:          #263341;
    --line-2:        #354554;

    --primary:       #7FB8ED;
    --primary-fill:  #1A6CB5;
    --primary-hover: #2280D0;
    --on-primary:    #FFFFFF;
    --primary-soft:  #14293D;
    --primary-line:  #22405B;

    --rail-bg:       #0A141E;
    --rail-ink:      #DCE7F2;
    --rail-muted:    #8194A6;
    --rail-line:     #1A2836;
    --rail-active:   #1A6CB5;

    --st-low:        #D4536E;
    --st-mid:        #B8861F;
    --st-high:       #1E9E7E;
    --st-low-soft:   #35191F;
    --st-mid-soft:   #2F2412;
    --st-high-soft:  #10281F;
    --info:          #56AFC7;
    --info-soft:     #10242B;

    --chart-ink:     #EAF0F6;
    --chart-grid:    #232F3B;
    --chart-axis:    #7E8C99;
    --chart-mark:    #6FAEE8;
    --chart-fill:    rgba(111, 174, 232, 0.15);

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 14px 34px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
  }
}

:root[data-theme="dark"] {
  --bg:            #0C1218;
  --surface:       #141C24;
  --surface-2:     #1A242E;
  --surface-3:     #212D38;
  --ink:           #EAF0F6;
  --ink-2:         #C2CDD9;
  --muted:         #93A1AF;
  --faint:         #76838F;
  --line:          #263341;
  --line-2:        #354554;

  --primary:       #7FB8ED;
  --primary-fill:  #1A6CB5;
  --primary-hover: #2280D0;
  --on-primary:    #FFFFFF;
  --primary-soft:  #14293D;
  --primary-line:  #22405B;

  --rail-bg:       #0A141E;
  --rail-ink:      #DCE7F2;
  --rail-muted:    #8194A6;
  --rail-line:     #1A2836;
  --rail-active:   #1A6CB5;

  --st-low:        #D4536E;
  --st-mid:        #B8861F;
  --st-high:       #1E9E7E;
  --st-low-soft:   #35191F;
  --st-mid-soft:   #2F2412;
  --st-high-soft:  #10281F;
  --info:          #56AFC7;
  --info-soft:     #10242B;

  --chart-ink:     #EAF0F6;
  --chart-grid:    #232F3B;
  --chart-axis:    #7E8C99;
  --chart-mark:    #6FAEE8;
  --chart-fill:    rgba(111, 174, 232, 0.15);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 14px 34px rgba(0, 0, 0, .55), 0 2px 8px rgba(0, 0, 0, .4);
}

/* ---------- base ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

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

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.012em;
  text-wrap: balance;
  margin: 0;
}

a { color: var(--primary); text-decoration-thickness: 1px; text-underline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

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

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- prototype bar ---------- */

.protobar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 60;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--rail-bg);
  color: var(--rail-ink);
  border-bottom: 1px solid var(--rail-line);
}

.mark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: #fff;
}

.mark svg { display: block; }

.protobar .spacer { flex: 1; }

.proto-tag {
  font-size: 10.5px;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--rail-muted);
  border: 1px solid var(--rail-line);
  border-radius: 999px;
  padding: 3px 9px;
  white-space: nowrap;
}

.seg {
  display: inline-flex;
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--rail-line);
  border-radius: 999px;
  padding: 2px;
}

.seg button {
  border: 0;
  background: transparent;
  color: var(--rail-muted);
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.seg button[aria-pressed="true"] { background: var(--rail-active); color: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  min-width: 30px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--rail-line);
  background: rgba(255, 255, 255, .06);
  color: var(--rail-ink);
  font-size: 12.5px;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255, 255, 255, .12); }
.icon-btn[aria-pressed="true"] { background: var(--rail-active); border-color: var(--rail-active); color: #fff; }

.icon-btn .count {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--primary-fill);
  color: #fff;
  border-radius: 999px;
  padding: 0 5px;
  line-height: 15px;
}

.icon-btn[aria-pressed="true"] .count { background: rgba(0, 0, 0, .3); }

#navToggle { display: none; }

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
  align-items: start;
}

/* ---------- rail ---------- */

.rail {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + var(--bar-h));
  height: calc(100vh - var(--bar-h));
  overflow-y: auto;
  background: var(--rail-bg);
  color: var(--rail-ink);
  padding: 14px 10px 24px;
  border-right: 1px solid var(--rail-line);
}

.rail-org {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 14px;
  border-bottom: 1px solid var(--rail-line);
  margin-bottom: 12px;
}

.rail-org .avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--rail-active);
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
}

.rail-org .nm { font-weight: 600; font-size: 13.5px; line-height: 1.2; }
.rail-org .sub { font-size: 11.5px; color: var(--rail-muted); }

.navgroup { margin-bottom: 14px; }

.navgroup > h4 {
  font-family: var(--body);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--rail-muted);
  padding: 0 10px 6px;
}

.navitem {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--rail-ink);
  text-align: left;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.navitem:hover { background: rgba(255, 255, 255, .07); }

.navitem[aria-current="page"] {
  background: var(--rail-active);
  color: #fff;
  font-weight: 600;
}

.navitem .ico { width: 16px; flex: none; opacity: .85; display: grid; place-items: center; }
.navitem[aria-current="page"] .ico { opacity: 1; }
.navitem .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.navitem .tag {
  font-size: 9.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--rail-muted);
  border: 1px solid var(--rail-line);
  border-radius: 4px;
  padding: 1px 4px;
}

.navitem[aria-current="page"] .tag { color: rgba(255, 255, 255, .85); border-color: rgba(255, 255, 255, .3); }

.navitem .fbdot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--st-mid);
  flex: none;
}

/* ---------- main ---------- */

.main { min-width: 0; padding: 0 0 56px; }

.pagehead {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.pagehead .ph-text { flex: 1 1 320px; min-width: 0; }
.pagehead h1 { font-size: 26px; line-height: 1.15; }
.pagehead p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; max-width: 62ch; }
.pagehead .ph-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.content { padding: 20px 26px 0; display: grid; gap: 18px; }

/* ---------- chips, pills, badges ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: nowrap;
}

.chip strong { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.chip.credits { border-color: var(--primary-line); background: var(--primary-soft); color: var(--primary); }
.chip.credits strong { color: var(--primary); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.ok    { color: var(--st-high); background: var(--st-high-soft); border-color: var(--st-high-soft); }
.pill.warn  { color: var(--st-mid);  background: var(--st-mid-soft);  border-color: var(--st-mid-soft); }
.pill.crit  { color: var(--st-low);  background: var(--st-low-soft);  border-color: var(--st-low-soft); }
.pill.info  { color: var(--info);    background: var(--info-soft);    border-color: var(--info-soft); }
.pill.idle  { color: var(--muted);   background: var(--surface-3);    border-color: var(--surface-3); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { background: var(--surface-2); border-color: var(--muted); }

.btn.primary {
  background: var(--primary-fill);
  border-color: var(--primary-fill);
  color: var(--on-primary);
  font-weight: 600;
}

.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- cards & panels ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}

.card > header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.card > header h3 { font-size: 14.5px; font-weight: 600; flex: 1; min-width: 0; }
.card > header .sub { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 14px; }
.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)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* KPI tiles — deliberately flat, no card chrome; the numbers are the point */
.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.tile {
  padding: 14px 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.tiles .tile:nth-child(4n) { border-right: 0; }
.tiles .tile:nth-last-child(-n+4) { border-bottom: 0; }

.tile .k {
  font-size: 11px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.tile .v {
  font-family: var(--display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-top: 4px;
}

.tile .d { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.tile .d.up { color: var(--st-high); }
.tile .d.down { color: var(--st-low); }

/* ---------- tables ---------- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }

.tbl th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}

.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl td.id { font-family: var(--mono); font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.tbl td .who { display: flex; align-items: center; gap: 9px; }

.ava {
  width: 26px; height: 26px; flex: none;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
  border: 1px solid var(--primary-line);
}

.tbl .email { color: var(--primary); }
.tbl .nowrap { white-space: nowrap; }

.rowact { display: flex; gap: 4px; }

.iconact {
  width: 28px; height: 28px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
}

.iconact:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line); }
.iconact.danger:hover { color: var(--st-low); background: var(--st-low-soft); border-color: var(--st-low-soft); }

select.inline {
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}

/* ---------- toolbar / filters ---------- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar .grow { flex: 1 1 200px; min-width: 0; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 8px;
  padding: 0 10px;
  height: 36px;
}

.search svg { flex: none; color: var(--faint); }
.search input { border: 0; outline: 0; background: transparent; width: 100%; font-size: 13px; }

.sel, .inp, textarea.inp {
  height: 36px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  border-radius: 8px;
  padding: 0 10px;
  font-size: 13px;
  min-width: 0;
}

textarea.inp { height: auto; padding: 9px 10px; line-height: 1.5; resize: vertical; width: 100%; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

.tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}

.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- empty states ---------- */

.empty {
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 44px 20px;
  text-align: center;
  color: var(--muted);
}

.empty h4 { font-size: 15px; color: var(--ink); }
.empty p { margin: 0; font-size: 13px; max-width: 42ch; }

/* ---------- assessment catalog ---------- */

.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }

.acard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.acard .top { display: flex; gap: 10px; align-items: flex-start; }

.acard .glyph {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-line);
  color: var(--primary);
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: 12px;
}

.acard h4 { font-size: 14px; line-height: 1.25; }
.acard .meta { display: flex; flex-wrap: wrap; gap: 6px; }
.acard .desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; flex: 1; }
.acard .btn { width: 100%; }

.mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}

.mini.units { color: var(--primary); background: var(--primary-soft); font-family: var(--mono); font-weight: 600; }

/* ---------- charts ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover ~ .crosshair { opacity: 1; }
.gridline { stroke: var(--chart-grid); stroke-width: 1; }
.axistext { fill: var(--chart-axis); font-size: 10px; font-family: var(--mono); }
.marklabel { fill: var(--chart-ink); font-size: 10.5px; font-family: var(--mono); font-weight: 600; }

.tip {
  position: absolute;
  z-index: 20;
  pointer-events: none;
  background: var(--ink);
  color: var(--surface);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: nowrap;
  box-shadow: var(--shadow-2);
  transform: translate(-50%, -125%);
  opacity: 0;
  transition: opacity .1s;
}

.tip strong { font-family: var(--mono); }
.tip[data-on="1"] { opacity: 1; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- activity log ---------- */

.feed { display: grid; gap: 0; }

.feed li {
  list-style: none;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.feed li:last-child { border-bottom: 0; }
.feed .who { font-weight: 600; font-size: 12.5px; }
.feed .when { font-size: 11.5px; color: var(--faint); font-family: var(--mono); }
.feed .what { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.feed .what b { color: var(--ink-2); font-weight: 600; }

/* ---------- AI agent cards ---------- */

.agents { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }

.agent {
  border: 1px solid var(--primary-line);
  background: linear-gradient(160deg, var(--primary-soft), var(--surface) 70%);
  border-radius: var(--r-lg);
  padding: 14px;
  display: grid;
  gap: 8px;
}

.agent h4 { font-size: 13.5px; }
.agent p { margin: 0; font-size: 12.5px; color: var(--muted); }

/* ---------- report ---------- */

.report { display: grid; gap: 18px; }

.report-head {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 20px;
  display: grid;
  gap: 14px;
}

.report-head .meta { display: flex; flex-wrap: wrap; gap: 10px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.prose { font-size: 13.5px; line-height: 1.65; color: var(--ink-2); max-width: 68ch; }
.prose p { margin: 0 0 10px; }
.prose ul { margin: 0 0 10px; padding-left: 18px; }
.prose li { margin-bottom: 5px; }
.prose strong { color: var(--ink); }

.callout {
  border-left: 3px solid var(--st-mid);
  background: var(--st-mid-soft);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
}

.callout h4 { font-family: var(--body); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--st-mid); margin-bottom: 5px; }

.validity { display: grid; gap: 8px; }

.vrow { display: grid; grid-template-columns: minmax(120px, 160px) 1fr auto; gap: 12px; align-items: center; font-size: 12.5px; }

.vbar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.vbar i { display: block; height: 100%; border-radius: 999px; }

/* ---------- spec notes ---------- */

.note {
  border: 1px dashed var(--info);
  background: var(--info-soft);
  border-radius: var(--r);
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-2);
  display: grid;
  gap: 6px;
}

.note h4 {
  font-family: var(--body);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--info);
  font-weight: 700;
}

.note ul { margin: 0; padding-left: 17px; }
.note li { margin-bottom: 3px; }
.note .q { color: var(--st-mid); font-weight: 600; }

body:not([data-notes="1"]) .note { display: none; }

/* ---------- modal ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 16, .55);
  backdrop-filter: blur(2px);
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  width: min(560px, 100%);
  max-height: 86vh;
  overflow: auto;
}

.modal > header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal > header h3 { font-size: 17px; flex: 1; }
.modal > header p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); }
.modal .body { padding: 16px 20px; display: grid; gap: 14px; }
.modal > footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.field { display: grid; gap: 5px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 11.5px; color: var(--faint); }
.fieldrow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.costbox {
  border: 1px solid var(--primary-line);
  background: var(--primary-soft);
  border-radius: var(--r);
  padding: 11px 13px;
  display: grid;
  gap: 5px;
  font-size: 12.5px;
}

.costbox .row { display: flex; justify-content: space-between; gap: 12px; }
.costbox .row.total { border-top: 1px solid var(--primary-line); padding-top: 5px; font-weight: 700; color: var(--primary); }

.rte {
  border: 1px solid var(--line-2);
  border-radius: 8px;
  overflow: hidden;
}

.rte .tools { display: flex; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }

.rte .tools button {
  border: 0; background: transparent; color: var(--muted);
  width: 28px; height: 26px; border-radius: 5px; cursor: pointer;
  font-size: 12.5px; font-weight: 700;
}

.rte .tools button:hover { background: var(--surface-3); color: var(--ink); }
.rte textarea { border: 0; outline: 0; width: 100%; min-height: 120px; padding: 10px; background: transparent; resize: vertical; font-size: 13px; line-height: 1.6; }

/* ---------- feedback drawer ---------- */

.fbdrawer {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + var(--bar-h));
  right: 0;
  bottom: 0;
  width: min(380px, 100%);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  z-index: 70;
  display: flex;
  flex-direction: column;
}

.fbdrawer > header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 10px; }
.fbdrawer > header h3 { font-size: 15px; flex: 1; }
.fbdrawer > header p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }
.fblist { flex: 1; overflow-y: auto; padding: 14px 16px; display: grid; gap: 10px; align-content: start; }

.fbitem {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  background: var(--surface-2);
  font-size: 12.5px;
  display: grid;
  gap: 5px;
}

.fbitem .hd { display: flex; gap: 8px; align-items: baseline; }
.fbitem .au { font-weight: 700; font-size: 12px; }
.fbitem .tm { font-size: 11px; color: var(--faint); font-family: var(--mono); margin-left: auto; }
.fbitem .sc { font-size: 11px; color: var(--primary); }
.fbitem .tx { color: var(--ink-2); line-height: 1.55; white-space: pre-wrap; }

.fbform { border-top: 1px solid var(--line); padding: 12px 16px; display: grid; gap: 9px; background: var(--surface-2); }
.fbstatus { font-size: 11.5px; color: var(--muted); min-height: 16px; }

/* ---------- candidate portal tweaks ---------- */

.profile-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }

.profile-hero .big {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--primary-soft);
  border: 2px solid var(--primary-line);
  color: var(--primary);
  display: grid; place-items: center;
  font-family: var(--display); font-weight: 700; font-size: 24px;
}

.dropzone {
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--surface-2);
}

.dropzone .t { flex: 1; min-width: 160px; font-size: 13px; color: var(--muted); }

.reportcard {
  display: grid;
  grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 16px;
  align-items: center;
}

.reportcard .thumb { border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--surface-2); }

/* ---------- sign in ---------- */

.signin {
  min-height: calc(100vh - var(--bar-h));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 40px;
  padding: 40px 26px;
  background: var(--surface);
}

.signin-form { max-width: 380px; justify-self: end; width: 100%; display: grid; gap: 14px; }
.signin-art { justify-self: start; max-width: 460px; width: 100%; }
.signin h1 { font-size: 30px; }
.signin .lead { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .g-main, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tiles .tile:nth-child(4n) { border-right: 1px solid var(--line); }
  .tiles .tile:nth-child(2n) { border-right: 0; }
  .tiles .tile:nth-last-child(-n+4) { border-bottom: 1px solid var(--line); }
  .tiles .tile:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 860px) {
  #navToggle { display: inline-flex; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + var(--bar-h));
    left: 0;
    bottom: 0;
    width: 260px;
    height: auto;
    z-index: 80;
    transform: translateX(-102%);
    transition: transform .18s ease;
    box-shadow: var(--shadow-2);
  }
  .rail[data-open="1"] { transform: none; }
  .pagehead, .content { padding-left: 16px; padding-right: 16px; }
  .g2, .g3, .g-main, .g4 { grid-template-columns: minmax(0, 1fr); }
  .reportcard { grid-template-columns: minmax(0, 1fr); }
  .signin { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .signin-form, .signin-art { justify-self: stretch; max-width: 100%; }
  .signin-art { order: -1; }
  .fieldrow { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 520px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .tiles .tile { border-right: 0 !important; border-bottom: 1px solid var(--line) !important; }
  .tiles .tile:last-child { border-bottom: 0 !important; }
  .pagehead h1 { font-size: 22px; }
  .proto-tag { display: none; }
  .mark { font-size: 0; gap: 0; }
  .protobar { gap: 8px; padding: 0 10px; }
}

/* ============================================================
   Scope v1 additions — four user types, projects, participant flow
   ============================================================ */

.seg-sel {
  display: none;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--rail-line);
  background: rgba(255, 255, 255, .06);
  color: var(--rail-ink);
  font-size: 12.5px;
  padding: 0 8px;
}
.seg-sel option { color: #111A22; }

.shell[data-bare="1"] { grid-template-columns: minmax(0, 1fr); }

.linkish {
  border: 0; background: none; padding: 0;
  color: var(--primary); cursor: pointer; text-align: start;
  font-size: inherit;
}
.linkish:hover { text-decoration: underline; text-underline-offset: 2px; }
.linkish strong { color: var(--ink); }

.qrow {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 0; border-top: 1px solid var(--line);
}

.tbl tr.flagrow td { background: var(--st-mid-soft); }
.tbl tr.totalrow td { background: var(--surface-2); font-weight: 700; }

.brandlogo {
  width: 38px; height: 38px; flex: none; border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-family: var(--display); font-weight: 700; font-size: 13px;
}
.brandlogo.sm { width: 28px; height: 28px; border-radius: 7px; font-size: 11px; }

.routeopts { display: grid; gap: 6px; }
.ropt {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13px; font-weight: 400; color: var(--ink-2);
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2);
}
.ropt small { color: var(--muted); font-size: 11.5px; }
.ropt input { margin-top: 3px; }

.parkedbanner { border-left-color: var(--muted); background: var(--surface-3); }
.parkedbanner h4 { color: var(--muted); }

.card.featured { border-color: var(--primary); box-shadow: var(--shadow-1); }
.routenum {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  font-family: var(--mono); font-weight: 600; font-size: 12px; flex: none;
}

/* version timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--line);
}
.timeline li:first-child { border-top: 0; padding-top: 0; }
.vtag {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--primary); background: var(--primary-soft);
  border-radius: 6px; padding: 2px 6px; align-self: start; text-align: center;
}

/* build plan */
.phases { display: grid; gap: 12px; }
.phase {
  display: grid; grid-template-columns: 170px minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
.phase-when { background: var(--surface-2); border-right: 1px solid var(--line); padding: 14px 16px; }
.phase-when .pn { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--primary); }
.phase-when .pd { font-family: var(--display); font-size: 17px; font-weight: 600; margin-top: 2px; }
.phase-when .pw { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.phase-body { padding: 14px 16px; font-size: 13px; }
.phase-body ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.phase-body li { margin-bottom: 3px; }
.gate {
  margin-top: 10px; padding: 8px 10px; border-left: 2px solid var(--primary);
  background: var(--primary-soft); border-radius: 0 6px 6px 0; font-size: 12.5px;
}
.gate b { display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--primary); }
.phase-links { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 10px; font-size: 12px; color: var(--muted); }
.phase-links .btn { color: var(--primary); }

/* assessor */
.minihead { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.checks label { display: flex; gap: 8px; align-items: flex-start; }
.checks input { margin-top: 3px; }

.rating { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.rpick {
  position: relative; display: grid; gap: 2px; justify-items: center; text-align: center;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 6px; cursor: pointer; background: var(--surface);
}
.rpick input { position: absolute; opacity: 0; pointer-events: none; }
.rpick .rn { font-family: var(--display); font-weight: 700; font-size: 18px; }
.rpick .rl { font-size: 11px; color: var(--muted); line-height: 1.3; }
.rpick:has(input:checked) { border-color: var(--primary-fill); background: var(--primary-soft); box-shadow: inset 0 0 0 1px var(--primary-fill); }
.rpick:has(input:checked) .rn { color: var(--primary); }
.rpick:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.score {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  font-family: var(--mono); font-weight: 600; font-size: 13px;
  background: var(--surface-3); color: var(--ink);
}
.score.final { background: var(--primary-fill); color: var(--on-primary); }

/* participant */
.pstrip {
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.steps { display: flex; flex-wrap: wrap; gap: 4px; }
.step {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 999px; padding: 4px 10px 4px 5px; font-size: 12.5px; cursor: pointer;
}
.step .n {
  width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); font-family: var(--mono); font-size: 10.5px;
}
.step[aria-current="step"] { border-color: var(--primary-fill); color: var(--primary); background: var(--primary-soft); font-weight: 600; }
.step[aria-current="step"] .n { background: var(--primary-fill); color: var(--on-primary); }

.pctl { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.seg.light { background: var(--surface-3); border-color: var(--line); }
.seg.light button { color: var(--muted); }
.seg.light button[aria-pressed="true"] { background: var(--primary-fill); color: var(--on-primary); }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }

.pnote { padding: 14px 16px 0; max-width: 760px; margin: 0 auto; }
.pwrap { padding: 18px 16px 40px; display: grid; justify-items: center; }
.pframe {
  width: 100%; max-width: 420px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow-2);
  padding: 20px 20px 24px; display: grid; gap: 16px;
}
.pframe[dir="rtl"] { font-family: "IBM Plex Sans Arabic", var(--body); }
.pbrand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.ptitle { font-size: 24px; line-height: 1.2; }
.pframe[dir="rtl"] .ptitle { font-family: "IBM Plex Sans Arabic", var(--display); font-weight: 700; }
.pframe .field > label { font-size: 14px; }
.inp.big { height: 48px; font-size: 16px; width: 100%; }
.inp.mono { font-family: var(--mono); letter-spacing: .12em; }
.btn.big { height: 50px; font-size: 16px; width: 100%; }
.phelp { margin: 0; font-size: 13px; color: var(--muted); }
.pfacts { margin: 0; display: grid; gap: 12px; }
.pfacts dt { font-weight: 700; font-size: 14px; }
.pfacts dd { margin: 2px 0 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.55; }
.pprog { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.pprog .saved { display: inline-flex; gap: 5px; align-items: center; color: var(--st-high); font-weight: 600; }
.pitem { font-size: 19px; line-height: 1.45; margin: 4px 0; font-weight: 500; }
.likert { display: grid; gap: 8px; }
.lk {
  position: relative; display: flex; align-items: center; min-height: 50px;
  border: 1px solid var(--line-2); border-radius: 12px; padding: 0 16px; font-size: 15.5px; cursor: pointer;
}
.lk input { position: absolute; opacity: 0; pointer-events: none; }
.lk:has(input:checked) { border-color: var(--primary-fill); background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 0 0 0 1px var(--primary-fill); }
.lk:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }
.pnav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.pdone { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 18px 0 6px; color: var(--muted); }
.pdone.ok svg { color: var(--st-high); }
.pdone p { margin: 0; font-size: 15px; line-height: 1.55; color: var(--ink-2); }

@media (max-width: 1180px) {
  .seg { display: none; }
  .seg-sel { display: inline-block; }
  .pctl .seg.light { display: inline-flex; }
}

@media (max-width: 860px) {
  .phase { grid-template-columns: minmax(0, 1fr); }
  .phase-when { border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
  .phase-when .pw { margin-top: 0; }
  .rating { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .rpick .rl { display: none; }
}

.content > *, .grid > *, .card { min-width: 0; }
