/* CTCP design system — tokens from the reference design (build plan §4.1). */

@font-face { font-family: "Urbanist"; font-weight: 400; font-display: swap; src: url("../lib/fonts/urbanist-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Urbanist"; font-weight: 500; font-display: swap; src: url("../lib/fonts/urbanist-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Urbanist"; font-weight: 600; font-display: swap; src: url("../lib/fonts/urbanist-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Urbanist"; font-weight: 700; font-display: swap; src: url("../lib/fonts/urbanist-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Urbanist"; font-weight: 800; font-display: swap; src: url("../lib/fonts/urbanist-latin-800-normal.woff2") format("woff2"); }

:root {
  --brand-900: #3D0A44;
  --brand-700: #5A1766;
  --brand-500: #B444CC;
  --brand-100: #F3E6F6;
  --brand-50: #FAF4FB;
  --canvas: #F7F3F8;
  --surface: #FFFFFF;
  --border: #ECE4EE;
  --text: #16161A;
  --text-2: #6E6E7A;
  --text-3: #8B8B96;
  --success: #1F9D55;
  --warning: #B7791F;
  --info: #2F7ED8;
  --error: #C8102E;
  --shadow: 0 8px 24px rgba(61, 10, 68, .08);
  --shadow-lg: 0 18px 48px rgba(61, 10, 68, .14);
  --r-sheet: 28px;
  --r-card: 16px;
  --r-tile: 12px;
  --r-pill: 999px;
  --rail: 232px;
  --font: "Urbanist", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; border-radius: 6px; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; min-height: 100vh; }
/* Wide screens: labelled sidebar. 761–1080px: icon rail with hover labels. Phones: bottom bar (below). */
.rail {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; align-items: stretch; gap: 2px;
  padding: 18px 12px; background: var(--brand-900); color: #E9D9EE;
}
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; margin-bottom: 18px; }
.rail-logo { width: 40px; height: 40px; flex: none; padding: 3px; border-radius: 12px; background: #fff; }
.rail-brand-name { font-size: 18px; font-weight: 800; letter-spacing: .04em; color: #fff; }
.rail a.rail-item {
  position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
  border-radius: 12px; color: #CDB5D4; font-weight: 600; transition: background .15s, color .15s;
}
.rail a.rail-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.rail a.rail-item.active { background: rgba(180, 68, 204, .28); color: #fff; }
.rail a.rail-item.active::after { content: ""; position: absolute; left: -12px; width: 4px; height: 24px; border-radius: 4px; background: var(--brand-500); }
.rail .rail-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.rail .badge-dot { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand-500); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.rail-spacer { flex: 1; min-height: 12px; }
.rail .avatar { width: 32px; height: 32px; font-size: 12px; margin-left: -4px; }
@media (min-width: 761px) and (max-width: 1080px) {
  :root { --rail: 84px; }
  .rail { align-items: center; gap: 6px; padding: 18px 0; overflow: visible; }
  .rail-brand { padding: 0; }
  .rail-logo { width: 48px; height: 48px; border-radius: 14px; }
  .rail-brand-name { display: none; }
  .rail a.rail-item { display: grid; place-items: center; width: 52px; height: 52px; padding: 0; border-radius: 16px; }
  .rail a.rail-item.active::after { left: -16px; }
  .rail .rail-label { position: absolute; left: 64px; padding: 4px 10px; border-radius: 8px; background: var(--text); color: #fff; font-size: 12px; font-weight: 500; overflow: visible; opacity: 0; pointer-events: none; transform: translateX(-4px); transition: .12s; z-index: 30; }
  .rail a.rail-item:hover .rail-label, .rail a.rail-item:focus-visible .rail-label { opacity: 1; transform: none; }
  .rail .badge-dot { top: 9px; right: 9px; transform: none; }
  .rail .avatar { width: 40px; height: 40px; font-size: 13px; margin: 0; }
}

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 10px 28px;
  background: var(--brand-900); color: #fff; font-size: 12px; letter-spacing: .04em;
}
.topbar .marking { font-weight: 800; }
.topbar .env { margin-left: auto; padding: 2px 10px; border-radius: var(--r-pill); background: rgba(255,255,255,.14); font-weight: 600; }
.content { flex: 1; padding: 24px 28px 40px; min-width: 0; }

/* ---------- Cards / layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head .actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.grid-2 { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 20px; border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: transform .08s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand-900); color: #fff; box-shadow: 0 8px 18px rgba(61,10,68,.24); }
.btn-primary:hover { background: #4f0f58; }
.btn-accent { background: var(--brand-700); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--brand-500); color: var(--brand-700); }
.btn-danger { background: #fff; border-color: #F2C4CC; color: var(--error); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn .arrow { display: grid; place-items: center; width: 30px; height: 30px; margin-right: -12px; border-radius: 50%; background: #fff; color: var(--brand-900); }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text);
}
.icon-btn:hover { border-color: var(--brand-500); color: var(--brand-700); }
/* Waiting for the server (js/busy.js): the spinner takes the icon's place, and the button can't be pressed again. */
.is-busy { cursor: progress; pointer-events: none; }
.btn.is-busy, .icon-btn.is-busy { opacity: .85; }
.is-busy > svg, .is-busy > .icon { display: none; }
.btn-spinner {
  display: inline-block; flex: none; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn-spinner { animation: btn-spin-calm 1.4s ease-in-out infinite; border-right-color: currentColor; } }
@keyframes btn-spin-calm { 50% { opacity: .35; } }

/* ---------- Avatars / hexagons ---------- */
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: var(--brand-900);
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.tint-0 { background: #FDE7C7; } .tint-1 { background: #F9D5DC; } .tint-2 { background: #D9E4F5; }
.tint-3 { background: #DDF1E4; } .tint-4 { background: #EADCF5; } .tint-5 { background: #F5E3D3; }
.hex {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; color: var(--brand-700);
  background: var(--brand-100);
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
  font-weight: 800; font-size: 12px;
}
.hex.emergency { background: #FCE4E7; color: var(--error); }
.hex.national { background: var(--brand-900); color: #fff; }

/* ---------- Tabs / segmented ---------- */
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); padding: 0 4px; }
.tabs a { position: relative; padding: 10px 0 12px; font-weight: 600; color: var(--text-2); }
.tabs a.active { color: var(--brand-500); }
.tabs a.active::after { content: ""; position: absolute; left: 20%; right: 20%; bottom: -1px; height: 3px; border-radius: 3px; background: var(--brand-500); }
.segmented { display: inline-flex; padding: 5px; border-radius: var(--r-pill); background: var(--brand-900); }
.segmented a { padding: 8px 18px; border-radius: var(--r-pill); color: #EBD8F0; font-weight: 600; font-size: 13px; }
.segmented a.active { background: #fff; color: var(--brand-900); box-shadow: 0 2px 8px rgba(0,0,0,.18); }

/* ---------- Chips: TLP (FIRST TLP 2.0), PAP, severity, status ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.tlp { background: #000; }
.tlp-red { color: #FF2B2B; }
.tlp-amber, .tlp-amber-strict { color: #FFC000; }
.tlp-green { color: #33FF00; }
.tlp-clear { color: #FFFFFF; }
.pap { background: transparent; border: 1px solid #C9C0CC; color: #4A4452; }
.sev { color: #fff; }
.sev-S1 { background: #C8102E; } .sev-S2 { background: #E8590C; } .sev-S3 { background: #F2C200; color: #2A2100; }
.sev-S4 { background: #2F7ED8; } .sev-S5 { background: #6B7280; }
.status { background: var(--brand-100); color: var(--brand-700); }
.status-Closed, .status-Resolved { background: #E3F4EA; color: #17693C; }
.status-Contained, .status-Recovering { background: #E6EEFA; color: #1F5AA0; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; }
.deadline { background: #EEF6F1; color: #17693C; font-variant-numeric: tabular-nums; }
.deadline.warn { background: #FFF4D6; color: #7A5200; }
.deadline.crit { background: #FCE4E7; color: var(--error); }
.deadline.over { background: var(--error); color: #fff; }
.count-badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--brand-700); color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }

/* ---------- Marking banner (FR-024) ---------- */
.marking-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px; border-radius: 12px; background: #16121A; color: #EDE6F0; font-size: 12px;
}
.marking-banner .handling { color: #CFC4D6; }

/* ---------- Alerts / flash ---------- */
.flash { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 500; }
.flash-error { background: #FDECEF; color: #8E0B21; border: 1px solid #F5C6CF; }
.flash-ok { background: #E8F6EE; color: #17693C; border: 1px solid #C4E8D3; }
.flash-info { background: var(--brand-50); color: var(--brand-900); border: 1px solid var(--brand-100); }
.flash-warn { background: #FFF4D6; color: #7A5200; border: 1px solid #F2DDA0; }
.assistant-answer { white-space: pre-wrap; line-height: 1.55; }

/* ---------- Forms ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--text-3); font-size: 12px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--border); background: #fff;
}
textarea.input { resize: vertical; min-height: 96px; }
.input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(180,68,204,.16); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
fieldset.plain { border: 0; margin: 0; padding: 0; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--brand-50); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- Messages: streams + conversation ---------- */
.collab { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; height: calc(100vh - 36px - 48px); }
.pane { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 8px; }
.pane-head h1 { font-size: 20px; }
.pane-body { flex: 1; overflow-y: auto; padding: 6px 8px 12px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: 14px; }
.list-row:hover { background: var(--brand-50); }
.list-row.active { background: var(--brand-100); }
.list-row .body { flex: 1; min-width: 0; }
.list-row .title { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.list-row .title span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .restricted { font-style: italic; color: var(--text-3); }
.list-row .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 11px; color: var(--text-3); }
.filter-chips { display: flex; gap: 6px; padding: 10px 18px 4px; flex-wrap: wrap; }
.filter-chips a { padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--border); font-size: 12px; font-weight: 600; color: var(--text-2); }
.filter-chips a.active { background: var(--brand-900); border-color: var(--brand-900); color: #fff; }

/* Conversation card: stream header, topics column, thread */
.pane-conversation { padding: 0; }
.convo-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.convo-head .back-btn { display: none; }
.convo-title { min-width: 0; }
.convo-title h2, .convo-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 232px minmax(0, 1fr); }

.topics { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border); background: var(--brand-50); }
.topics-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 8px 18px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.topic-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.topic { display: flex; flex-direction: column; gap: 2px; padding: 9px 10px; border-radius: 10px; color: var(--text-2); }
.topic:hover { background: #fff; color: var(--text); }
.topic.active { background: #fff; color: var(--brand-900); box-shadow: inset 3px 0 0 var(--brand-500), 0 2px 8px rgba(61,10,68,.06); }
.topic-name { font-weight: 700; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.topic-meta { font-size: 11px; color: var(--text-3); }
.topic-empty { padding: 8px 10px; }

.thread-wrap { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.topic-bar { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.topic-bar-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.topic-bar-title h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marking-strip { display: flex; align-items: center; gap: 6px; flex: none; }

.thread { flex: 1; overflow-y: auto; padding: 8px 22px 18px; display: flex; flex-direction: column; gap: 2px; background: linear-gradient(180deg, #fff 0, var(--canvas) 100%); }
.thread-empty { margin: auto; }
.day-sep { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.day-sep span { padding: 3px 10px; border-radius: var(--r-pill); background: #fff; border: 1px solid var(--border); }

.msg { display: flex; gap: 10px; max-width: min(720px, 86%); margin-top: 12px; }
.msg.continued { margin-top: 4px; }
.msg .avatar-gap { width: 32px; flex: none; }
.msg-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.msg .who { display: flex; align-items: baseline; gap: 8px; font-size: 12px; padding: 0 4px; }
.msg .who b { font-size: 13px; }
.msg .bubble { position: relative; background: #fff; border: 1px solid var(--border); border-radius: 4px 18px 18px 18px; padding: 10px 14px; min-width: 0; box-shadow: 0 1px 2px rgba(61,10,68,.04); }
.msg.continued .bubble { border-radius: 18px; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.5; }
.msg .named { display: flex; align-items: center; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.msg-meta { display: flex; align-items: center; gap: 6px; padding: 0 4px; font-size: 11px; color: var(--text-3); }
.msg-meta .chip { height: 18px; padding: 0 6px; font-size: 10px; border-radius: 5px; }
.msg-meta .chip.pap { border: 1px solid var(--border); }
.msg.withdrawn .text { font-style: italic; color: var(--text-3); }
.msg.mine { align-self: flex-end; }
.msg.mine .avatar-gap { display: none; }
.msg.mine .msg-main { align-items: flex-end; }
.msg.mine .who { justify-content: flex-end; }
.msg.mine .bubble { background: var(--brand-900); border-color: var(--brand-900); color: #fff; border-radius: 18px 4px 18px 18px; }
.msg.mine.continued .bubble { border-radius: 18px; }
.msg.mine .named { color: #E4CFEA; }
.msg.mine .attachment { color: var(--text); }
.msg.mine.withdrawn .bubble { background: var(--brand-50); border-color: var(--brand-100); color: var(--text-3); }


/* Popovers built on <details> (no script needed to open them) */
.popover { position: relative; }
.popover > summary { list-style: none; cursor: pointer; }
.popover > summary::-webkit-details-marker { display: none; }
.popover .panel { position: absolute; z-index: 30; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.popover .panel h3 { margin-bottom: 4px; }
.members-pop .panel { right: 0; top: 46px; width: 300px; max-height: 360px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.new-topic .panel { left: 0; top: 36px; width: 260px; }
.person-line { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 10px; }
.person-line.pick { cursor: pointer; }
.person-line.pick:hover { background: var(--brand-50); }
.avatar-stack { display: flex; align-items: center; padding: 2px; border-radius: var(--r-pill); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.avatar-stack .avatar.more { background: var(--brand-100); font-size: 11px; }
.avatar-stack:hover { background: var(--brand-50); }
.icon-btn-sm { width: 34px; height: 34px; }
.icon-xs { width: 13px; height: 13px; }

/* Composer: one compact box; marking, recipients and attachment live in popovers */
.composer { padding: 12px 18px 16px; background: var(--canvas); }
.composer-box { border: 1px solid var(--border); border-radius: 20px; background: #fff; box-shadow: var(--shadow); padding: 8px 8px 8px 14px; transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(180,68,204,.14), var(--shadow); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; resize: none; min-height: 24px; max-height: 200px; padding: 6px 0; background: transparent; font-size: 14.5px; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 4px; }
.composer-bar > .send-btn { margin-left: auto; } /* stays on the right when a narrow bar wraps */
.composer-bar .icon-btn { border-color: transparent; background: transparent; color: var(--text-2); }
.composer-bar .icon-btn:hover, .composer-bar details[open] > summary.icon-btn { background: var(--brand-50); color: var(--brand-700); }
.recipients > summary { position: relative; }
.dot-count { position: absolute; top: 2px; right: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--brand-500); color: #fff; font-size: 10px; font-weight: 800; display: grid; place-items: center; }
.recipients .panel { bottom: 44px; left: 0; width: 320px; max-height: 320px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.marking-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r-pill); border: 1px dashed #D9C4DF; color: var(--brand-700); font-size: 13px; font-weight: 700; }
.marking-btn:hover, .marking-pick[open] > .marking-btn { background: var(--brand-50); border-color: var(--brand-500); }
.marking-btn.is-set { border-style: solid; border-color: var(--border); }
.marking-btn.needs { border-color: var(--error); color: var(--error); background: #FDF3F5; }
.marking-empty, .marking-set { display: inline-flex; align-items: center; gap: 6px; }
.marking-btn .caret { transform: rotate(-90deg); opacity: .6; }
.marking-pick .panel { bottom: 44px; left: 0; width: 380px; }
.marking-pick legend { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.choice-grid { display: grid; gap: 6px; }
.choice-row { display: grid; gap: 6px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.choice-row .choice { justify-content: center; }
.choice { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; }
.choice.compact { padding: 6px; }
.choice:hover { border-color: var(--brand-500); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) { border-color: var(--brand-700); background: var(--brand-50); box-shadow: 0 0 0 2px rgba(90,23,102,.18); }
.choice:has(input:focus-visible) { outline: 3px solid var(--brand-500); outline-offset: 1px; }
.composer-error { color: var(--error); font-weight: 600; }
.kbd-hint { margin-right: 4px; }
.send-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--brand-900); color: #fff; cursor: pointer; box-shadow: 0 6px 14px rgba(61,10,68,.28); transition: transform .08s, background .15s; }
.send-btn:hover { background: #4f0f58; }
.send-btn:active { transform: scale(.96); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; margin: 2px 0 4px; padding: 5px 6px 5px 10px; border-radius: 10px; background: var(--brand-50); border: 1px solid var(--brand-100); font-size: 13px; font-weight: 600; max-width: 100%; }
.file-chip #file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { width: 22px; height: 22px; border-radius: 50%; border: 0; background: #fff; cursor: pointer; font-size: 15px; line-height: 1; color: var(--text-2); }
/* Recording a voice note: the bar takes the text box's place; marking and recipients stay to hand */
.composer.editing #mic-btn { display: none; }
.composer.recording textarea, .composer.recording .file-chip,
.composer.recording .composer-bar > :not(.popover):not(.composer-error):not(.spacer) { display: none; }
.rec-bar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.rec-bar .rec-cancel { border-color: transparent; background: transparent; color: var(--text-2); }
.rec-bar .rec-cancel:hover { background: #FDF3F5; color: var(--error); }
.rec-dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--error); animation: rec-pulse 1.2s ease-in-out infinite; }
.rec-bar.stopped .rec-dot { animation: none; background: var(--text-3); }
.rec-time { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rec-state { min-width: 0; }
.rec-bar .send-btn[disabled], .rec-bar .rec-cancel[disabled] { opacity: .5; cursor: progress; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(200,16,46,.4); } 50% { opacity: .55; box-shadow: 0 0 0 6px rgba(200,16,46,0); } }
@media (prefers-reduced-motion: reduce) { .rec-dot { animation: none; } }

/* Streams pane extras */
.tabs-spread { margin: 0 14px; }
.stream-filter { position: relative; margin: 12px 14px 0; color: var(--text-3); }
.stream-filter .icon { position: absolute; left: 12px; top: 12px; }
.stream-filter .input { min-height: 38px; padding: 8px 12px 8px 34px; border-radius: var(--r-pill); background: var(--canvas); }
.empty-filter { padding: 12px 14px; }
.list-row .restricted { display: inline-flex; align-items: center; gap: 4px; }
.empty-hero { height: 100%; align-content: center; }
.empty-hero p { max-width: 360px; }
.hex-trio { position: relative; width: 210px; height: 170px; margin-bottom: 8px; }
.hex-trio .hex-tile { width: 78px; height: 78px; }
.hex-trio .hex-tile .icon { width: 28px; height: 28px; }
.hex-trio .t1 { left: 66px; top: 0; }
.hex-trio .t2 { left: 8px; top: 86px; }
.hex-trio .t3 { left: 124px; top: 86px; }
.empty { display: grid; place-items: center; gap: 12px; text-align: center; padding: 48px 24px; color: var(--text-3); }
.empty .hex { width: 64px; height: 64px; }

/* ---------- Alerts screen (adapted "Stories") ---------- */
.ack-hero { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: 18px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); }
.ack-hero .body { flex: 1; min-width: 0; }
.tile-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile { display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 16px; background: #fff; border: 1px solid var(--border); transition: box-shadow .15s, border-color .15s; }
.tile:hover { border-color: var(--brand-500); box-shadow: var(--shadow); }
.tile .title { font-weight: 700; font-size: 15px; }
.tile .foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-3); }

/* ---------- Incident timeline ---------- */
.timeline { position: relative; display: flex; flex-direction: column; gap: 18px; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--brand-100); }
.timeline .item { position: relative; }
.timeline .item::before { content: ""; position: absolute; left: -22px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--brand-500); }
.timeline .item .when { font-size: 12px; color: var(--text-3); }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat { padding: 18px; border-radius: 16px; background: #fff; border: 1px solid var(--border); }
.stat .value { font-size: 30px; font-weight: 800; color: var(--brand-900); }
.stat .label { color: var(--text-2); font-weight: 600; }
.stat.alert .value { color: var(--error); }

/* ---------- Admin sub-navigation ---------- */

/* Hexagon tiles (used by .hex-trio) */
.hex-tile {
  position: absolute; width: 104px; height: 104px; display: grid; place-items: center; color: var(--brand-700);
  background: #fff; clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
  filter: drop-shadow(0 10px 18px rgba(61,10,68,.14));
}
.hex-tile::before { content: ""; position: absolute; inset: 3px; clip-path: inherit; background: var(--brand-50); }
.hex-tile .icon { position: relative; width: 38px; height: 38px; stroke-width: 1.6; }

/* ---------- Sign-in ---------- */
.login-body { background: radial-gradient(90% 60% at 50% 0%, var(--brand-50) 0%, var(--canvas) 70%); }
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 48px 16px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-logo { width: 72px; height: 72px; padding: 6px; border-radius: 20px; background: #fff; box-shadow: var(--shadow-lg); }
.login-product { font-size: 28px; font-weight: 800; letter-spacing: .08em; color: var(--text); }
.login-card { display: flex; flex-direction: column; gap: 18px; width: 100%; max-width: 400px; padding: 32px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.login-card-head h1 { font-size: 22px; margin: 0 0 4px; }
.login-card .flash { margin: 0; }
.btn-block { width: 100%; }
.login-dev { padding: 16px; border-radius: 16px; background: var(--brand-50); border: 1px dashed var(--brand-100); }
.login-dev-chip { background: #FFF4D6; color: #7A5200; }
.login-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.login-code::placeholder { letter-spacing: .04em; }
.login-alt { font-size: 14px; }
.login-alt summary { cursor: pointer; text-align: center; color: var(--brand-500); font-weight: 600; }
.login-alt[open] summary { margin-bottom: 14px; }
.login-notice { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; color: var(--text-3); text-align: center; }

@media (max-width: 760px) {
  .login { justify-content: flex-start; padding: 32px 16px; }
  .login-card { padding: 24px 20px; border-radius: 20px; }
}

/* ---------- Calls ---------- */
.rec-banner { display: none; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); background: var(--error); font-weight: 800; font-size: 12px; }
.rec-banner.on { display: inline-flex; }
.rec-banner::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

@media (max-width: 1280px) {
  .collab { grid-template-columns: 300px minmax(0, 1fr); }
  .convo-body { grid-template-columns: 200px minmax(0, 1fr); }
  .kbd-hint { display: none; }
}
@media (max-width: 1080px) {
  .collab { grid-template-columns: 280px minmax(0, 1fr); }
  /* Topics become a scrollable strip above the thread */
  .convo-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .topics { flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .topics-head { padding: 8px 4px 8px 14px; }
  .topics-head > span { display: none; }
  .topic-list { flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 8px 12px 8px 4px; gap: 6px; }
  .topic { flex: none; flex-direction: row; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); background: #fff; border: 1px solid var(--border); }
  .topic.active { box-shadow: none; border-color: var(--brand-500); }
  .topic-name { -webkit-line-clamp: 1; max-width: 220px; white-space: nowrap; display: block; text-overflow: ellipsis; }
  .new-topic .panel { top: 40px; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  :root { --rail: 0px; }
  .shell { grid-template-columns: 1fr; }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: 66px; flex-direction: row; align-items: center; justify-content: space-around; padding: 6px 8px; overflow: visible; z-index: 40; }
  .rail-brand, .rail-spacer, .rail .rail-label { display: none; }
  .rail a.rail-item { display: grid; place-items: center; width: 48px; height: 48px; min-height: 0; padding: 0; border-radius: 14px; }
  .rail .badge-dot { top: 6px; right: 6px; transform: none; }
  .rail .avatar { margin: 0; }
  .rail a.rail-item.active::after { display: none; }
  .content { padding: 16px 16px 90px; }
  .collab { grid-template-columns: 1fr; height: auto; }
  .collab .pane-conversation { display: none; }
  .collab.show-thread .pane-conversation { display: flex; height: calc(100dvh - 150px); }
  .collab.show-thread .pane-streams { display: none; }
  .collab .pane-streams { min-height: calc(100dvh - 150px); }
  .convo-head { padding: 10px 12px; gap: 10px; }
  .convo-head .back-btn { display: grid; }
  .convo-head .hex, .convo-head > .avatar { display: none; }
  .members-pop .panel { width: min(300px, calc(100vw - 48px)); }
  .topic-bar { padding: 10px 14px; }
  .marking-strip > .muted, .topic-bar-title .muted { display: none; }
  .avatar-stack .avatar:not(.more) { display: none; }
  .avatar-stack .avatar.more { margin-left: 0; }
  .convo-title h2 { font-size: 16px; }
  .thread { padding: 4px 12px 14px; }
  .msg { max-width: 94%; }
  .composer { padding: 8px 10px 10px; }
  .marking-pick .panel, .recipients .panel { position: fixed; left: 12px; right: 12px; bottom: 84px; width: auto; max-height: 60dvh; overflow: auto; }
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.narrow-center { max-width: 560px; margin: 40px auto; }
.narrow { max-width: 760px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }
.mx-18 { margin: 0 18px 4px; }
.grow { flex: 1; min-width: 200px; }
.text-body { white-space: pre-wrap; font-size: 15px; line-height: 1.6; }

/* PAP chips on the dark marking banner */
.marking-banner .pap { border-color: #6F6478; color: #EDE6F0; }
/* Keep previews inside the row so they never run under the badge */
.list-row .sub { display: block; }
.list-row .meta { flex: none; }
.label-line { display: flex; gap: 6px; align-items: baseline; }

/* ---------- Attachments and files ---------- */
.attachment { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 8px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--border); max-width: 460px; }
.attachment .body { flex: 1; min-width: 0; }
.attachment .name { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment.state-rejected { border-color: #F5C6CF; background: #FDF3F5; }
/* Voice notes: play/pause, a seekable bar and the time. The audio loads only when played. */
.voice-note { gap: 10px; width: 300px; max-width: 100%; padding: 8px 12px 8px 8px; }
.msg .bubble > .voice-note:first-child { margin-top: 0; }
.vn-play { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--brand-900); color: #fff; cursor: pointer; transition: background .15s; }
.vn-play:hover { background: var(--brand-700); }
.vn-play[aria-disabled="true"] { background: var(--brand-100); color: var(--brand-700); }
.vn-play[disabled] { background: var(--border); color: var(--text-3); cursor: not-allowed; }
.voice-note.is-loading .vn-play { cursor: progress; opacity: .7; }
.vn-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.vn-track { position: relative; height: 18px; cursor: pointer; touch-action: none; border-radius: 4px; }
.vn-track::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 4px; border-radius: 2px; background: var(--border); }
.vn-fill { position: absolute; left: 0; top: 7px; width: 0; height: 4px; border-radius: 2px; background: var(--brand-500); }
.vn-fill::after { content: ""; position: absolute; right: -6px; top: -4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-700); box-shadow: 0 1px 3px rgba(61,10,68,.3); }
.voice-note.state-quarantined .vn-track, .voice-note.state-rejected .vn-track { opacity: .5; }
.voice-note.state-rejected .vn-track { cursor: not-allowed; }
.vn-meta { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12px; color: var(--text-3); }
.vn-time { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text-2); }
.vn-meta .chip { height: 18px; padding: 0 6px; font-size: 10px; border-radius: 5px; }
.vn-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: #7A5200; }
.voice-note.state-rejected .vn-status { color: var(--error); }
@media (max-width: 760px) { .voice-note { width: min(300px, calc(100vw - 120px)); } }
.file-pick { cursor: pointer; }
.preview-frame { width: 100%; min-height: 520px; border: 1px solid var(--border); border-radius: 12px; background: #fff; }
.preview-image { max-width: 100%; border-radius: 12px; border: 1px solid var(--border); }
.hash { word-break: break-all; }
select.input.narrow-select, input.input.narrow-select { width: auto; min-height: 34px; padding: 4px 10px; flex: none; }
.check-grid { display: grid; gap: 6px 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checklist li { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.checklist li.met { color: var(--success); }
details.report { border-top: 1px solid var(--border); padding-top: 10px; }
details.report summary { cursor: pointer; }
h4 { margin: 8px 0 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); }
a.link { color: var(--brand-700); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar .input { font-size: 16px; }
.hit { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.hit:last-child { border-bottom: 0; }
.hit:hover { background: var(--brand-50); }
.hit .body { flex: 1; min-width: 0; }
.hit .snippet { color: var(--text-2); overflow-wrap: anywhere; }
.people-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.person { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 16px; background: #fff; border: 1px solid var(--border); }
.person .body { flex: 1; min-width: 0; }
.dash-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.article-body { white-space: pre-wrap; line-height: 1.7; font-size: 15px; }
.report-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.reply { padding: 12px 14px; border-radius: 12px; background: var(--canvas); border: 1px solid var(--border); }
.reply.support { background: var(--brand-50); border-color: var(--brand-100); }
textarea.tall { min-height: 280px; }
.report-grid td.mono { white-space: nowrap; text-align: right; }

/* ---------- Wizard (step-by-step forms) ---------- */
.wizard-layout { display: grid; grid-template-columns: minmax(0, 860px) 300px; gap: 20px; align-items: start; }
.wizard { padding: 0; overflow: hidden; }
.wizard-top { padding: 18px 24px 0; }
.wizard-step { border: 0; margin: 0; padding: 22px 24px 8px; display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.wizard-step > legend { float: left; width: 100%; padding: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.wizard-step > legend:focus { outline: none; }
.wizard-step > legend + * { clear: both; }
.wizard-on .wizard-step { display: none; }
.wizard-on .wizard-step.current { display: flex; animation: step-in .18s ease-out; }
@keyframes step-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.wizard:not(.wizard-on) .wizard-step + .wizard-step { border-top: 1px solid var(--border); }
.wizard-nav { position: sticky; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 16px 24px; margin-top: 12px; border-top: 1px solid var(--border); background: rgba(255,255,255,.96); backdrop-filter: blur(6px); }
.icon.flip { transform: rotate(180deg); }
.wizard-aside { position: sticky; top: 20px; }

.stepper { list-style: none; margin: 0; padding: 0 0 18px; display: flex; gap: 6px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.stepper li { flex: 1; min-width: 0; position: relative; }
.stepper li.done .step-dot .num::after { content: ""; }
.step-dot { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 12px; background: transparent; cursor: pointer; color: var(--text-3); text-align: left; }
.step-dot:hover { background: var(--brand-50); }
.step-dot .num { flex: none; width: 26px; height: 26px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: var(--text-3); background: var(--canvas); clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }
.step-dot .name { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper li.active .step-dot { color: var(--brand-900); }
.stepper li.active .num { background: var(--brand-900); color: #fff; }
.stepper li.done .step-dot { color: var(--text-2); }
.stepper li.done .num { background: var(--brand-100); color: var(--brand-700); }

/* Option cards: radios and checkboxes shown as selectable tiles */
.opt-grid { display: grid; gap: 10px; }
.opt-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt-card { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 14px; border-radius: 16px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 400; transition: border-color .12s, box-shadow .12s, background .12s; }
.opt-card:hover { border-color: var(--brand-500); }
.opt-card input, .sev-card input, .pick input { position: absolute; opacity: 0; pointer-events: none; }
.opt-card .hex { width: 38px; height: 38px; }
.opt-card .hex .icon { width: 18px; height: 18px; }
.opt-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.opt-body b { font-size: 14px; }
.opt-card::after { content: ""; position: absolute; top: 12px; right: 12px; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); background: #fff; }
.opt-card:has(input[type=checkbox])::after { border-radius: 6px; }
.opt-card:has(input:checked) { border-color: var(--brand-700); background: var(--brand-50); box-shadow: 0 0 0 2px rgba(90,23,102,.14); }
.opt-card:has(input:checked)::after { border-color: var(--brand-700); background: var(--brand-700); box-shadow: inset 0 0 0 3px #fff; }
.opt-card.danger:has(input:checked) { border-color: var(--error); background: #FDF3F5; box-shadow: 0 0 0 2px rgba(200,16,46,.12); }
.opt-card.danger:has(input:checked)::after { border-color: var(--error); background: var(--error); }
.opt-card:has(input:focus-visible), .sev-card:has(input:focus-visible), .pick:has(input:focus-visible) { outline: 3px solid var(--brand-500); outline-offset: 2px; }
.opt-card .opt-body { padding-right: 24px; }

.sev-list { display: flex; flex-direction: column; gap: 8px; }
.sev-card { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--border); cursor: pointer; font-weight: 400; }
.sev-card:hover { border-color: var(--brand-500); }
.sev-card .opt-body { flex: 1; }
.sev-card .chip { width: 34px; justify-content: center; }
.sev-card:has(input:checked) { border-color: var(--brand-700); background: var(--brand-50); box-shadow: 0 0 0 2px rgba(90,23,102,.14); }

.chip-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { position: relative; cursor: pointer; font-weight: 600; font-size: 13px; }
.pick span { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border); background: #fff; color: var(--text-2); transition: .12s; }
.pick:hover span { border-color: var(--brand-500); color: var(--brand-700); }
.pick:has(input:checked) span { background: var(--brand-900); border-color: var(--brand-900); color: #fff; }
.pick:has(input:checked) span::before { content: "✓"; font-size: 12px; }

.choice-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-row .choice span:only-of-type { font-weight: 700; font-size: 13px; }
.narrow-input { max-width: 280px; }
.static-value { padding: 10px 14px; border-radius: 12px; background: var(--canvas); font-weight: 600; }
.self-start { align-self: flex-start; }
label.is-required::after, .req-mark { content: "required"; margin-left: 0; font-size: 11px; font-weight: 700; color: var(--brand-700); }
.req-mark { padding: 1px 6px; border-radius: 6px; background: var(--brand-100); }
label.field.is-required { position: relative; }
label.field.is-required::after { position: absolute; top: 0; right: 0; padding: 1px 6px; border-radius: 6px; background: var(--brand-100); }

.review-block { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--border); margin-bottom: 10px; }
.review-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.review-block .kv { grid-template-columns: 180px 1fr; font-size: 13px; }
.review-block .kv dd { white-space: pre-wrap; overflow-wrap: anywhere; }
.kv.compact { grid-template-columns: 90px 1fr; font-size: 13px; gap: 6px 10px; }
.next-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; font-size: 13px; color: var(--text-2); }
.next-steps li { display: flex; gap: 10px; align-items: flex-start; }
.next-steps .num { flex: none; width: 24px; height: 24px; display: grid; place-items: center; font-size: 11px; font-weight: 800; color: var(--brand-700); background: var(--brand-100); clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }

@media (max-width: 1080px) {
  .wizard-layout { grid-template-columns: 1fr; }
  .wizard-aside { position: static; }
  .stepper .step-dot .name { display: none; }
  .stepper li.active .step-dot .name { display: block; }
}
@media (max-width: 760px) {
  .wizard-top, .wizard-step, .wizard-nav { padding-left: 16px; padding-right: 16px; }
  .opt-grid.two, .opt-grid.three, .choice-grid.two-col { grid-template-columns: 1fr; }
  .wizard-nav { bottom: 66px; }
  .wizard-nav [data-wizard-counter] { display: none; }
  .sev-card .pill { display: none; }
  .review-block .kv { grid-template-columns: 1fr; gap: 2px; }
  .review-block .kv dd { margin-bottom: 8px; }
}

/* ---------- Directory ---------- */
.view-toggle { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--brand-900); }
.view-toggle a { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r-pill); color: #EBD8F0; font-weight: 700; font-size: 13px; }
.view-toggle a.active { background: #fff; color: var(--brand-900); box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.dir-search { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 16px; border-radius: var(--r-pill); background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); margin-bottom: 14px; color: var(--text-3); }
.dir-search:focus-within { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(180,68,204,.14), var(--shadow); }
.dir-search .input { border: 0; box-shadow: none; min-height: 38px; padding: 6px 4px; font-size: 15px; background: transparent; }
.sector-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: thin; }
.sector-chips a { flex: none; height: 32px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--border); background: #fff; font-size: 13px; font-weight: 600; color: var(--text-2); }
.sector-chips a:hover { border-color: var(--brand-500); color: var(--brand-700); }
.sector-chips a.active { background: var(--brand-100); border-color: var(--brand-500); color: var(--brand-900); }
.dir-note { display: flex; align-items: center; gap: 6px; }

.avatar.xl { width: 72px; height: 72px; font-size: 22px; border-width: 3px; box-shadow: 0 0 0 2px var(--brand-100), 0 8px 18px rgba(61,10,68,.12); }
.people-cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.person-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 22px 18px 18px; border-radius: 20px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s; }
.person-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.person-card .avatar { margin-bottom: 8px; }
.person-card h3 { font-size: 16px; }
.person-card .role { color: var(--text-2); font-size: 13px; }
.person-card .org { font-weight: 600; font-size: 13px; }
.person-card .sector-tags { justify-content: center; margin: 8px 0 12px; }
.person-card .person-action { margin-top: auto; width: 100%; }
.person-card .person-action .btn { width: 100%; }
.sector-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--brand-50); color: var(--brand-700); font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.more { background: var(--canvas); color: var(--text-2); cursor: help; }

.people-list { padding: 6px 0; }
.people-list .letter { position: sticky; top: 0; z-index: 1; padding: 8px 20px 4px; font-size: 12px; font-weight: 800; color: var(--brand-500); background: rgba(255,255,255,.96); }
.person-row { display: grid; grid-template-columns: 44px minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.2fr) 40px; align-items: center; gap: 14px; padding: 10px 20px; border-bottom: 1px solid var(--border); }
.person-row:last-child { border-bottom: 0; }
.person-row:hover { background: var(--brand-50); }
.person-row .who { display: flex; flex-direction: column; min-width: 0; }
.person-row .who b, .person-row .org { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-row .org { font-size: 13px; font-weight: 600; }

@media (max-width: 760px) {
  .view-toggle a span { display: none; }
  .view-toggle a { padding: 0 12px; }
  .person-row { grid-template-columns: 40px minmax(0, 1fr) 40px; padding: 10px 14px; }
  .person-row .org, .person-row .sector-tags { display: none; }
  .people-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .person-card { padding: 16px 10px 12px; }
  .avatar.xl { width: 56px; height: 56px; font-size: 18px; }
  .dir-search .btn span, .dir-search .btn { padding: 0 12px; }
}

/* ---------- Assistant ---------- */
.assistant { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; min-height: calc(100vh - 36px - 64px); }
.assistant-head { display: flex; align-items: center; gap: 14px; }
.ai-badge { flex: none; width: 46px; height: 46px; display: grid; place-items: center; font-weight: 800; font-size: 14px; letter-spacing: .04em; color: #fff; background: linear-gradient(135deg, var(--brand-500), var(--brand-900)); clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%); }
.ai-badge.sm { width: 30px; height: 30px; font-size: 10px; }
.assistant-feed { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.assistant-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 28px 12px 8px; }
.assistant-hero h2 { font-size: 28px; font-weight: 500; letter-spacing: -.01em; }
.assistant-hero h2 b { font-weight: 800; }
.suggestions { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; margin-top: 14px; }
.suggestion { text-align: left; padding: 14px 16px; border-radius: 16px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-weight: 600; color: var(--text-2); box-shadow: var(--shadow); transition: .12s; }
.suggestion:hover { border-color: var(--brand-500); color: var(--brand-900); transform: translateY(-1px); }
.q-bubble { align-self: flex-end; max-width: 80%; }
.exchange { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 80px; }
.q-bubble .q-time { display: block; margin-top: 4px; text-align: right; }
.answer-withheld { padding: 12px 16px; }
.q-bubble span { display: block; padding: 12px 16px; border-radius: 18px 4px 18px 18px; background: var(--brand-900); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.answer-card { background: #fff; border: 1px solid var(--border); border-radius: 4px 20px 20px 20px; box-shadow: var(--shadow); padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.answer-head { display: flex; align-items: center; gap: 10px; }
.answer-head b { font-size: 13px; color: var(--brand-700); }
.answer-text { white-space: pre-wrap; line-height: 1.65; font-size: 15px; overflow-wrap: anywhere; }
.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 4px; margin: 0 2px; border-radius: 6px; background: var(--brand-100); color: var(--brand-700); font-size: 11px; font-weight: 800; vertical-align: 2px; text-decoration: none; }
.cite:hover { background: var(--brand-700); color: #fff; }
.answer-insufficient { display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: var(--canvas); }
.answer-insufficient .icon { color: var(--brand-500); margin-top: 2px; }
.sources-title { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.source-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.source-card { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: #fff; transition: .12s; }
.source-card:hover { border-color: var(--brand-500); background: var(--brand-50); }
.source-card:target { border-color: var(--brand-700); box-shadow: 0 0 0 3px rgba(180,68,204,.2); }
.source-card .hex { width: 36px; height: 36px; }
.source-num { position: absolute; top: -8px; left: -8px; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--brand-900); color: #fff; font-size: 11px; font-weight: 800; }
.source-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.source-title { font-weight: 700; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.source-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.source-meta .chip { height: 18px; font-size: 10px; padding: 0 6px; }
.answer-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); }
.answer-foot > .muted { display: inline-flex; align-items: center; gap: 6px; }
.report-pop .panel { right: 0; bottom: 44px; width: 360px; }
.assistant-composer { position: sticky; bottom: 16px; }
.assistant-composer textarea { display: block; width: 100%; border: 0; outline: none; resize: none; min-height: 26px; max-height: 180px; padding: 6px 0; background: transparent; font-size: 15px; line-height: 1.5; }
.assistant-composer .composer-bar > .muted { display: inline-flex; align-items: center; gap: 6px; }
.send-btn[disabled] { opacity: .6; cursor: progress; }
.thinking { display: flex; align-items: center; gap: 10px; justify-content: center; margin-top: 10px; color: var(--brand-700); font-weight: 600; font-size: 13px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-500); animation: dot 1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.assistant-off { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 24px; }
.assistant-off .hex { width: 64px; height: 64px; }
@media (prefers-reduced-motion: reduce) { .dots i, .wizard-on .wizard-step.current { animation: none; } }
@media (max-width: 760px) {
  .suggestions { grid-template-columns: 1fr; }
  .assistant-hero h2 { font-size: 22px; }
  .assistant-composer { bottom: 76px; }
  .assistant-composer .composer-bar > .muted:first-child { display: none; }
  .report-pop .panel { position: fixed; left: 12px; right: 12px; bottom: 84px; width: auto; }
  .answer-card { padding: 14px; }
}

/* Typing indicator and live topic marker */
.typing-line { display: flex; align-items: center; gap: 8px; min-height: 22px; padding: 0 6px 6px; font-size: 12px; font-weight: 600; color: var(--brand-700); }
.topic.has-new .topic-name { color: var(--brand-900); }
.topic.has-new .topic-name::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--brand-500); vertical-align: middle; }

/* ---------- Message actions (reactions, reply, forward, info, delete) ---------- */
svg[hidden] { display: none; }
.msg .bubble:focus { outline: none; }
.msg .bubble:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 2px; }

/* Hover toolbar beside the bubble */
.msg-tools { position: absolute; top: 4px; left: calc(100% + 6px); display: flex; gap: 2px; padding: 2px; border-radius: var(--r-pill); background: #fff; border: 1px solid var(--border); box-shadow: 0 4px 12px rgba(61,10,68,.10); opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 2; }
.msg.mine .msg-tools { left: auto; right: calc(100% + 6px); }
.msg:hover .msg-tools, .msg.menu-open .msg-tools, .msg-tools:focus-within, .bubble:focus-visible .msg-tools { opacity: 1; pointer-events: auto; }
.tool-btn { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.tool-btn:hover, .tool-btn[aria-expanded="true"] { background: var(--brand-50); color: var(--brand-700); }
.tool-btn:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 1px; }
@media (hover: none) {
  .msg-tools { opacity: 1; pointer-events: auto; }
  .msg-tools .tool-react { display: none; }
}

/* Forwarded label and quoted reply inside the bubble */
.fwd-label { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: 11.5px; font-style: italic; font-weight: 600; color: var(--text-3); }
.msg.mine .fwd-label { color: #D5BCDD; }
.reply-quote { display: flex; flex-direction: column; gap: 1px; width: 100%; min-width: min(220px, 100%); margin: 2px 0 6px; padding: 6px 10px; border: 0; border-left: 3px solid var(--brand-500); border-radius: 8px; background: var(--brand-50); text-align: left; cursor: pointer; transition: background .12s; }
.reply-quote:hover { background: var(--brand-100); }
.reply-quote b { font-size: 12.5px; color: var(--brand-700); }
.reply-quote .q { display: flex; align-items: flex-start; gap: 4px; font-size: 12.5px; color: var(--text-2); }
.reply-quote .q > span { padding-right: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.reply-quote .q .icon { margin-top: 2px; }
.reply-quote.is-muted .q { font-style: italic; color: var(--text-3); }
.msg.mine .reply-quote { background: rgba(255,255,255,.10); border-left-color: #E7B6F2; }
.msg.mine .reply-quote:hover { background: rgba(255,255,255,.16); }
.msg.mine .reply-quote b { color: #F2C9FA; }
.msg.mine .reply-quote .q { color: #E4CFEA; }
.msg.flash .bubble { animation: msg-flash 1.6s ease-out; }
@keyframes msg-flash { 0%, 35% { box-shadow: 0 0 0 4px rgba(180,68,204,.45); } 100% { box-shadow: 0 0 0 0 rgba(180,68,204,0); } }

/* Reaction pills under the bubble */
.reactions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px; margin-top: -10px; padding: 0 10px; }
.msg.mine .reactions { justify-content: flex-end; }
.react-pill { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px 0 7px; border-radius: var(--r-pill); border: 1px solid var(--border); background: #fff; box-shadow: 0 2px 6px rgba(61,10,68,.08); font-size: 14px; line-height: 1; cursor: pointer; transition: border-color .12s, transform .08s; }
.react-pill:hover { border-color: var(--brand-500); }
.react-pill:active { transform: scale(.95); }
.react-pill .n { font-size: 11.5px; font-weight: 700; color: var(--text-2); }
.react-pill.mine { background: var(--brand-100); border-color: var(--brand-500); }
.react-pill.mine .n { color: var(--brand-700); }

/* Floating menus (message actions, chat options) */
.action-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 232px; padding: 6px; border-radius: 16px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.action-menu[hidden], .emoji-picker[hidden], .chat-toast[hidden], .sheet-backdrop[hidden], .reply-strip[hidden], .fwd-search[hidden], .fwd-list[hidden], .fwd-results[hidden], .quick-react[hidden] { display: none; }
.quick-react { display: flex; align-items: center; gap: 2px; padding: 2px 2px 6px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.qr { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; font-size: 21px; line-height: 1; cursor: pointer; transition: transform .1s, background .12s; }
.qr:hover, .qr:focus-visible { background: var(--brand-50); transform: scale(1.14); outline: none; }
.qr.on { background: var(--brand-100); box-shadow: inset 0 0 0 2px var(--brand-500); }
.qr-more { color: var(--text-2); background: var(--canvas); }
.action-menu.react-only .menu-items { display: none; }
.action-menu.react-only .quick-react { padding-bottom: 2px; margin-bottom: 0; border-bottom: 0; }
.menu-items { display: flex; flex-direction: column; }
.menu-items button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer; }
.menu-items button[hidden] { display: none; }
.menu-items button .icon { color: var(--text-3); }
.menu-items button:hover, .menu-items button:focus-visible { background: var(--brand-50); color: var(--brand-900); outline: none; }
.menu-items button:hover .icon, .menu-items button:focus-visible .icon { color: var(--brand-700); }
.menu-items button.danger, .menu-items button.danger .icon { color: var(--error); }
.menu-items button.danger:hover, .menu-items button.danger:focus-visible { background: #FDF3F5; }
.menu-sep { display: block; height: 1px; margin: 4px 8px; background: var(--border); }
.menu-label { padding: 6px 12px 2px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }

/* Phones: menus and the emoji picker open as bottom sheets */
.sheet-backdrop { position: fixed; inset: 0; z-index: 65; background: rgba(35, 8, 40, .32); }
.action-menu.sheet, .emoji-picker.sheet { left: 0; right: 0; top: auto; bottom: 0; z-index: 70; width: auto; border-radius: 22px 22px 0 0; padding: 18px 10px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -12px 40px rgba(61,10,68,.18); }
.action-menu.sheet::before, .emoji-picker.sheet::before { content: ""; position: absolute; top: 7px; left: 50%; width: 38px; height: 4px; margin-left: -19px; border-radius: 2px; background: #DCCFE0; }
.action-menu.sheet .quick-react { justify-content: space-between; }
.action-menu.sheet .qr { width: 42px; height: 42px; font-size: 24px; }
.action-menu.sheet .menu-items button { padding: 12px 14px; font-size: 15px; }

/* Emoji picker */
.emoji-picker { position: fixed; z-index: 60; display: flex; flex-direction: column; width: 332px; height: 348px; border-radius: 16px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow: hidden; }
.emoji-picker.sheet { height: min(420px, 60dvh); padding: 16px 6px 0; }
.ep-tabs { display: flex; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.ep-tab { display: grid; place-items: center; width: 36px; height: 34px; border: 0; border-radius: 10px; background: transparent; font-size: 18px; cursor: pointer; }
.ep-tab:hover, .ep-tab:focus-visible { background: var(--brand-50); outline: none; }
.ep-scroll { flex: 1; overflow-y: auto; padding: 0 8px 10px; }
.ep-section h4 { position: sticky; top: 0; z-index: 1; margin: 0; padding: 8px 4px 4px; background: #fff; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.ep-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; }
.ep-e { aspect-ratio: 1; display: grid; place-items: center; padding: 0; border: 0; border-radius: 10px; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; }
.ep-e:hover, .ep-e:focus-visible { background: var(--brand-50); outline: none; }
.ep-e:focus-visible { box-shadow: inset 0 0 0 2px var(--brand-500); }

/* Composer: reply strip */
.reply-strip { display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; padding: 7px 8px 7px 12px; border-radius: 12px; background: var(--brand-50); border-left: 3px solid var(--brand-500); color: var(--brand-700); }
.reply-strip-body { flex: 1; min-width: 0; }
.reply-strip-body b { display: block; font-size: 12.5px; }
.reply-strip-body span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }

/* Dialogs */
dialog.modal { width: min(520px, calc(100vw - 24px)); max-height: min(700px, calc(100dvh - 32px)); padding: 20px; border: 0; border-radius: 22px; background: #fff; color: var(--text); box-shadow: var(--shadow-lg); }
dialog.modal[open] { display: flex; flex-direction: column; gap: 14px; }
dialog.modal::backdrop { background: rgba(35, 8, 40, .42); }
dialog.modal-sm { width: min(440px, calc(100vw - 24px)); }
.modal-head { display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; font-size: 18px; }
.modal-head .icon-btn { border-color: transparent; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding-top: 2px; }
.btn-danger-solid { background: var(--error); color: #fff; box-shadow: 0 8px 18px rgba(200,16,46,.22); }
.btn-danger-solid:hover { background: #A60D26; }

.fwd-marking { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--brand-50); font-size: 13px; font-weight: 600; color: var(--brand-900); }
.fwd-marking .chip { height: 20px; padding: 0 7px; font-size: 10.5px; }
.fwd-search { position: relative; color: var(--text-3); }
.fwd-search .icon { position: absolute; left: 13px; top: 12px; }
.fwd-search .input { min-height: 40px; padding: 8px 14px 8px 36px; border-radius: var(--r-pill); background: var(--canvas); }
.fwd-list { display: flex; flex-direction: column; gap: 10px; min-height: 160px; max-height: 46dvh; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.fwd-empty { padding: 28px 12px; text-align: center; color: var(--text-3); }
.fwd-group-head { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.fwd-group-name { display: flex; flex-direction: column; min-width: 0; }
.fwd-group-name b { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hex-xs { width: 32px; height: 32px; font-size: 13px; }
.fwd-item { position: relative; display: flex; align-items: center; gap: 10px; margin-left: 42px; padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.fwd-item:hover { background: var(--brand-50); }
.fwd-item input { position: absolute; opacity: 0; pointer-events: none; }
.fwd-item:has(input:focus-visible) { outline: 3px solid var(--brand-500); outline-offset: -1px; }
.fwd-check { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; border: 2px solid #D4C5D9; background: #fff; transition: background .12s, border-color .12s; }
.fwd-item.is-checked .fwd-check { background: var(--brand-900); border-color: var(--brand-900); }
.fwd-item.is-checked .fwd-check::after { content: ""; width: 5px; height: 10px; margin-top: -2px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.fwd-item.is-checked { background: var(--brand-50); }
.fwd-item.is-disabled { opacity: .45; cursor: not-allowed; }
.fwd-topic { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13.5px; }
.fwd-results { display: flex; flex-direction: column; gap: 8px; }
.fwd-result { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--border); }
.fwd-result b, .fwd-result span { display: block; }
.fwd-result.ok { background: #F1FAF4; border-color: #CFEBD9; }
.fwd-result.ok .icon { color: var(--success); }
.fwd-result.fail { background: #FDF3F5; border-color: #F5C6CF; color: var(--error); }

.info-preview .info-text { max-height: 140px; overflow: auto; padding: 12px 14px; border-radius: 14px; background: var(--canvas); white-space: pre-wrap; overflow-wrap: anywhere; }
.info-list { display: flex; flex-direction: column; margin: 0; }
.info-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: 0; }
.info-row dt { font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.info-row dd { margin: 0; overflow-wrap: anywhere; }
.info-chips { display: inline-flex; gap: 6px; }

.chat-toast { position: fixed; left: 50%; bottom: 128px; z-index: 80; pointer-events: none; max-width: calc(100vw - 32px); padding: 10px 18px; border-radius: var(--r-pill); background: var(--brand-900); color: #fff; font-weight: 600; box-shadow: var(--shadow-lg); transform: translateX(-50%); }
.chat-toast.error { background: var(--error); }

/* Chat list: options button, pin and mute flags */
.row-wrap { position: relative; }
.row-wrap.menu-open .list-row { background: var(--brand-50); }
.meta-line { display: flex; align-items: center; gap: 6px; min-height: 22px; }
.meta-line .icon { color: var(--text-3); }
.meta-line .flag-pinned { color: var(--brand-500); }
.count-badge.muted-badge { background: #B6A9BB; }
.row-more { position: absolute; top: 9px; right: 8px; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: #fff; color: var(--text-2); cursor: pointer; opacity: 0; transition: opacity .12s; }
.row-more:hover, .row-more[aria-expanded="true"] { color: var(--brand-700); border-color: var(--brand-500); }
.row-wrap:hover .row-more, .row-wrap.menu-open .row-more, .row-more:focus-visible { opacity: 1; }
.row-wrap:hover .when, .row-wrap.menu-open .when, .row-wrap:has(.row-more:focus-visible) .when { visibility: hidden; }
@media (hover: none) {
  .row-more { top: 50%; margin-top: -14px; opacity: 1; border-color: transparent; background: transparent; }
  .row-wrap .list-row { padding-right: 42px; }
  .row-wrap:hover .when { visibility: visible; }
}

@media (max-width: 760px) {
  /* The ⋯ button sits inside the bubble; the menu has the reactions */
  .msg .bubble { padding-right: 38px; }
  .msg-tools { top: 5px; right: 5px; left: auto; padding: 0; border: 0; background: transparent; box-shadow: none; opacity: 1; pointer-events: auto; }
  .msg.mine .msg-tools { right: 5px; }
  .msg-tools .tool-react { display: none; }
  .msg.mine .tool-btn { color: #D5BCDD; }
  .msg.mine .tool-btn:hover, .msg.mine .tool-btn[aria-expanded="true"] { background: rgba(255,255,255,.12); color: #fff; }
  .msg.mine.withdrawn .tool-btn { color: var(--text-3); }
  .reply-quote { min-width: 0; }
  .info-row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .chat-toast { bottom: 190px; }
  dialog.modal { padding: 16px; }
}

/* ---------- Attachment tiles and in-page viewer ---------- */
.attachment[data-viewable="true"] .name { cursor: zoom-in; }
.attachment.att-image .hex { background: #E6EEFA; color: #1F5AA0; }
.attachment.att-pdf .hex { background: #FCE4E7; color: var(--error); }
.attachment[data-viewable="true"]:hover { border-color: var(--brand-500); }
.msg.mine .attachment { background: rgba(255,255,255,.96); }

html.viewer-open { overflow: hidden; }
dialog.viewer { width: min(1100px, 96vw); height: min(92vh, 1000px); max-width: none; max-height: none; padding: 0; border: 0; border-radius: 20px; background: #16121A; color: #EDE6F0; box-shadow: 0 30px 80px rgba(0,0,0,.45); overflow: hidden; }
dialog.viewer[open] { display: flex; flex-direction: column; animation: step-in .16s ease-out; }
dialog.viewer::backdrop { background: rgba(16, 8, 20, .72); backdrop-filter: blur(3px); }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px 12px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.viewer-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.viewer-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.viewer-meta { display: flex; align-items: center; gap: 6px; }
.viewer-meta .chip.pap { border: 1px solid #6F6478; color: #EDE6F0; }
.viewer-bar .icon-btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #EDE6F0; }
.viewer-bar .icon-btn:hover { background: rgba(255,255,255,.14); border-color: var(--brand-500); color: #fff; }
.viewer-bar .icon-btn[aria-pressed="true"] { background: var(--brand-500); border-color: var(--brand-500); }
.viewer-bar .muted { color: #B9AEC1; }
.viewer-stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; padding: 16px; }
.viewer-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; cursor: zoom-in; background: #fff; }
.viewer-stage.zoomed { place-items: start; }
.viewer-stage.zoomed .viewer-image { max-width: none; max-height: none; cursor: zoom-out; }
.viewer-frame { width: 100%; height: 100%; border: 0; border-radius: 10px; background: #fff; }
.viewer-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: #CFC4D6; font-weight: 600; pointer-events: none; }
.viewer-loading[hidden] { display: none; }
.viewer-error { max-width: 460px; padding: 18px 20px; border-radius: 14px; background: rgba(255,255,255,.06); text-align: center; }
.viewer-foot { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px 12px; color: #B9AEC1; }
@media (max-width: 760px) {
  dialog.viewer { width: 100vw; height: 100dvh; border-radius: 0; }
  .viewer-bar { flex-wrap: wrap; }
  .viewer-bar #viewer-count { order: 5; }
}

/* Direct messages are a single conversation: no topics column */
.convo-body.direct { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
.topic-bar.direct-bar { padding-top: 8px; padding-bottom: 8px; }
.topic-bar.direct-bar .topic-bar-title .muted { display: inline-flex; align-items: center; gap: 6px; }
/* 1:1 chats: names and avatars on every bubble add nothing (WhatsApp style) */
.convo-body.direct .msg .who, .convo-body.direct .msg > .avatar { display: none; }
.convo-body.direct .msg { margin-top: 8px; }
.convo-body.direct .msg.continued { margin-top: 3px; }

/* Thumbnails in bubbles (watermarked, loaded lazily; opening still goes through the viewer) */
.attachment.has-thumb { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "thumb thumb" "body action"; gap: 8px 10px; padding: 6px 6px 8px 6px; max-width: 320px; }
.attachment.has-thumb > .hex { display: none; }
.attachment.has-thumb .att-thumb { grid-area: thumb; position: relative; display: block; border-radius: 10px; overflow: hidden; background: var(--canvas); border: 1px solid var(--border); cursor: zoom-in; }
.attachment.has-thumb .att-thumb img { display: block; width: 100%; height: auto; max-height: 260px; object-fit: cover; }
.attachment.att-pdf.has-thumb .att-thumb img { object-fit: cover; object-position: top; max-height: 200px; }
.attachment.has-thumb > .body { grid-area: body; padding-left: 4px; }
.attachment.has-thumb > .btn, .attachment.has-thumb > .pill { grid-area: action; align-self: center; }
.att-badge { position: absolute; left: 8px; bottom: 8px; padding: 2px 7px; border-radius: 6px; background: var(--error); color: #fff; font-size: 10px; font-weight: 800; letter-spacing: .04em; }
.att-thumb:hover { box-shadow: 0 0 0 2px var(--brand-500); }

/* ---------- Call panel (every page) ----------
   Web adaptation of the reference call screens: a dark rounded panel (or full screen) with a one-to-one
   "duo" layout and a group layout (participant strip, active speaker, chat overlaid), one control pill and
   a separate red hang-up. Minimises to a pill in the page's top strip. */
.call-panel {
  --call-bg: #1B0A1F; --call-line: rgba(255,255,255,.12); --call-soft: rgba(255,255,255,.08); --call-mute: #CFC4D6; --call-green: #3BD16F;
  position: fixed; right: 24px; bottom: 24px; z-index: 60; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; border-radius: 26px; color: #fff; overflow: hidden;
  background: radial-gradient(120% 70% at 50% 0%, #3A1644 0%, #1E0A22 55%, #130614 100%);
  box-shadow: 0 24px 60px rgba(20, 4, 24, .45); animation: step-in .16s ease-out;
}
.call-panel[hidden] { display: none; }
.call-panel.max { inset: 50px 16px 16px calc(var(--rail) + 16px); width: auto; max-height: none; } /* the RESTRICTED strip stays visible */
.call-panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px 16px; }
.call-head-avatar { border-color: rgba(255,255,255,.7); box-shadow: none; }
.call-panel-title { display: flex; flex-direction: column; min-width: 0; }
.call-panel-title b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-panel-title .small { color: var(--call-mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-head-meta { display: inline-flex; gap: 6px; color: var(--call-mute); font-variant-numeric: tabular-nums; white-space: nowrap; }
.call-head-timer:not(:empty)::before { content: "· "; }
.call-panel.layout-duo .call-head-meta { display: none; }
.call-kind { padding: 3px 9px; border-radius: var(--r-pill); background: var(--brand-500); font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.call-panel-head .icon-btn { background: var(--call-soft); border-color: transparent; color: #fff; }
.call-panel-head .icon-btn:hover { background: rgba(255,255,255,.18); color: #fff; }
.call-panel-banners { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 16px; }
.call-panel-banners:has(.on) { padding-bottom: 8px; }
.share-banner { display: none; align-items: center; gap: 8px; padding: 6px 14px; border-radius: var(--r-pill); background: var(--brand-500); font-weight: 700; font-size: 12px; }
.share-banner.on { display: inline-flex; }

.call-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.call-duo, .call-group { display: none; }
.call-panel.layout-duo .call-duo { display: flex; }
.call-panel.layout-group .call-group { display: flex; }

/* Avatars inside calls */
.call-avatar { position: relative; flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; font-weight: 800; color: var(--brand-900); font-size: 14px; }
.call-avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.call-avatar.lg { width: 76px; height: 76px; font-size: 24px; }
.call-avatar.xl { width: 72px; height: 72px; font-size: 22px; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }
.call-avatar.huge { width: clamp(96px, 22vmin, 168px); height: clamp(96px, 22vmin, 168px); font-size: clamp(30px, 6vmin, 52px); box-shadow: 0 0 0 6px rgba(255,255,255,.06); }
.call-panel:not(.max) .call-avatar.huge { width: 96px; height: 96px; font-size: 30px; }
.call-avatar.speaking { box-shadow: 0 0 0 3px var(--call-green), 0 0 0 9px rgba(59,209,111,.22); }
.call-avatar.pulse { animation: ring-pulse 1.8s ease-out infinite; }
.mute-badge { position: absolute; right: -3px; bottom: -3px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #2A1030; color: #fff; box-shadow: 0 0 0 2px #1E0A22; }
.mute-badge .icon { width: 13px; height: 13px; }

/* One-to-one: me » them, "In call with", name, timer */
.call-duo { flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 26px 16px 22px; text-align: center; }
.duo-avatars { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.duo-chev { font-size: 24px; letter-spacing: -2px; color: rgba(255,255,255,.55); animation: blink 1.6s infinite; }
.duo-label { font-size: 13px; font-weight: 600; color: var(--call-mute); }
.duo-label.live { color: var(--call-green); }
.duo-name { font-size: 24px; font-weight: 800; }
.duo-time { min-height: 20px; font-size: 15px; color: var(--call-mute); font-variant-numeric: tabular-nums; }
.call-panel.max .call-duo { gap: 10px; }
.call-panel.max .call-duo .call-avatar.xl { width: 104px; height: 104px; font-size: 32px; }
.call-panel.max .duo-name { font-size: 32px; }

/* Group: participant strip + active speaker */
.call-group { flex: 1; min-height: 0; flex-direction: column; gap: 10px; padding: 4px 12px 0; }
.call-strip { display: flex; gap: 12px; overflow-x: auto; padding: 6px 4px 4px; scrollbar-width: none; flex: none; }
.call-strip::-webkit-scrollbar { display: none; }
.strip-tile { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; padding: 0; border: 0; background: none; color: #fff; cursor: pointer; }
.strip-face { position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255,255,255,.14); transition: box-shadow .15s; }
.strip-face video { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.strip-face .call-avatar { width: 52px; height: 52px; }
.strip-tile.speaking .strip-face { box-shadow: 0 0 0 3px var(--call-green); }
.strip-tile.on-stage .strip-face { box-shadow: 0 0 0 3px var(--brand-500); }
.strip-tile.on-stage.speaking .strip-face { box-shadow: 0 0 0 3px var(--call-green); }
.strip-tile.pinned .strip-name::before { content: "\2022 "; color: var(--brand-500); }
.strip-name { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--call-mute); }
.call-speaker { position: relative; flex: 1; min-height: 240px; border-radius: 20px; overflow: hidden; background: radial-gradient(90% 90% at 50% 40%, #3A1742 0%, #210C26 100%); transition: box-shadow .15s; }
.call-speaker.speaking { box-shadow: inset 0 0 0 3px var(--call-green); }
.speaker-inner { position: absolute; inset: 0; display: grid; place-items: center; }
.speaker-inner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.speaker-inner video.contain { object-fit: contain; background: #0C040E; }
video.mirror { transform: scaleX(-1); }
.speaker-label { position: absolute; left: 12px; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; max-width: calc(100% - 24px); padding: 4px 12px; border-radius: var(--r-pill); background: rgba(0,0,0,.45); font-size: 12px; font-weight: 600; }
.speaker-share { color: var(--call-mute); font-weight: 500; }
.speaker-ringing { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; text-align: center; }
.ringing-avatars { display: flex; }
.ringing-avatars .call-avatar + .call-avatar { margin-left: -14px; }
.ringing-text { font-size: 18px; font-weight: 800; }
.ringing-sub { font-size: 13px; color: var(--call-mute); max-width: 320px; }
.call-panel.max .call-speaker { min-height: 0; }

/* Chat overlaid on the speaker (group) or under the names (duo) */
.call-chat { position: absolute; left: 22px; bottom: 10px; z-index: 2; display: flex; flex-direction: column; gap: 6px; width: min(360px, calc(100% - 44px)); max-height: 58%; padding: 10px; border-radius: 16px; background: linear-gradient(to top, rgba(12,3,14,.82), rgba(12,3,14,.35)); backdrop-filter: blur(2px); }
.call-chat[hidden] { display: none; }
.call-panel:not(.max).layout-group .call-chat { position: static; width: auto; max-height: 170px; margin: 10px 12px 0; background: rgba(255,255,255,.06); backdrop-filter: none; }
.call-panel:not(.max).layout-group:has(.call-chat:not([hidden])) .call-speaker { min-height: 170px; }
.call-panel.layout-duo .call-chat { position: static; width: auto; max-height: 220px; margin: 0 14px 6px; background: rgba(255,255,255,.06); }
.call-chat-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 0; scrollbar-width: thin; }
.call-bubble { display: flex; gap: 8px; align-items: flex-start; }
.call-bubble-text { display: flex; flex-direction: column; min-width: 0; font-size: 13px; line-height: 1.35; }
.call-bubble-text b { font-size: 12px; color: var(--call-mute); font-weight: 600; }
.call-bubble-text span { overflow-wrap: anywhere; }
.call-bubble-text .muted { color: var(--call-mute); font-style: italic; }
.call-chat-note { font-size: 12px; color: var(--call-mute); }
.call-chat-form { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 6px; border-radius: var(--r-pill); background: rgba(255,255,255,.1); }
.call-chat-form .chip { height: 20px; padding: 0 6px; font-size: 10px; }
.call-chat-input { flex: 1; min-width: 0; height: 32px; border: 0; background: transparent; color: #fff; outline: none; }
.call-chat-input::placeholder { color: rgba(255,255,255,.55); }
.call-chat-send { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--brand-500); color: #fff; cursor: pointer; }
.call-flash { position: absolute; top: 10px; left: 50%; translate: -50% 0; z-index: 3; max-width: calc(100% - 24px); padding: 6px 14px; border-radius: var(--r-pill); background: rgba(255,255,255,.92); color: var(--brand-900); font-size: 13px; font-weight: 700; text-align: center; box-shadow: 0 6px 18px rgba(0,0,0,.3); }

/* Controls: one pill (mic, speaker, chat, camera, screen, moderator) and a separate red hang-up */
.call-controls { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 12px 16px; }
.call-panel.max .call-controls, .call-panel.layout-duo .call-controls { flex-direction: column; gap: 16px; padding-bottom: 20px; }
.call-ctl-pill { display: flex; align-items: center; gap: 6px; padding: 6px; border-radius: var(--r-pill); background: var(--call-soft); border: 1px solid var(--call-line); }
.call-ctl { position: relative; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--call-line); background: transparent; color: #fff; cursor: pointer; list-style: none; transition: background .12s, color .12s; }
.call-ctl::-webkit-details-marker { display: none; }
.call-ctl:hover { background: rgba(255,255,255,.12); }
.call-ctl.off { background: #fff; color: var(--brand-900); }
.call-ctl.active { background: var(--brand-500); border-color: var(--brand-500); }
.call-ctl-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--call-green); box-shadow: 0 0 0 2px #1E0A22; }
.call-hang { display: grid; place-items: center; width: 56px; height: 56px; flex: none; border: 0; border-radius: 50%; background: #E5484D; color: #fff; cursor: pointer; box-shadow: 0 10px 24px rgba(229,72,77,.4); transition: transform .08s, background .12s; }
.call-hang:hover { background: #C8102E; }
.call-hang:active { transform: scale(.96); }
.call-hang .icon { width: 26px; height: 26px; }
.call-output { position: relative; }
.call-output-menu { position: absolute; bottom: 54px; left: 50%; translate: -50% 0; z-index: 5; display: flex; flex-direction: column; min-width: 220px; padding: 8px; border-radius: 14px; background: #fff; color: var(--text); box-shadow: var(--shadow-lg); }
.call-output-title { padding: 4px 8px 6px; font-size: 12px; color: var(--text-3); }
.call-output-item { padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; }
.call-output-item:hover { background: var(--brand-50); }
.call-output-item.current { font-weight: 700; color: var(--brand-700); }
.call-output-item.current::after { content: " \2713"; }
.call-mod .panel { bottom: 56px; right: -6px; width: 320px; color: var(--text); }
.call-audio { display: none; }

/* Minimised: a compact pill centred in the page's top strip, clear of the chat header and composer */
.call-pill { display: none; }
.call-panel.min { top: 3px; bottom: auto; right: auto; left: 50%; translate: -50% 0; width: auto; max-width: min(520px, calc(100vw - 32px)); border-radius: var(--r-pill); box-shadow: 0 6px 20px rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.14); }
.call-panel.min > :not(.call-pill) { display: none; }
.call-panel.min .call-pill { display: inline-flex; align-items: center; gap: 10px; padding: 5px 6px 5px 14px; border: 0; background: transparent; color: #fff; font-weight: 700; font-size: 13px; cursor: pointer; }
.call-panel.min .call-pill [data-panel="pill-text"] { min-width: 0; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; background: #3BD16F; box-shadow: 0 0 0 4px rgba(59, 209, 111, .25); animation: blink 1.6s infinite; }
.call-pill-time { font-variant-numeric: tabular-nums; color: #CFC4D6; }
.call-pill-return { padding: 4px 10px; border-radius: var(--r-pill); background: var(--brand-500); font-size: 12px; }
[data-start-call].in-call { background: #E8F6EE; border-color: #3BD16F; color: #17693C; }

/* ---------- Incoming call (reference: incoming-call screen) ---------- */
dialog.ring-dialog { width: min(380px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 0; border-radius: 30px; color: #fff; overflow: auto; background: radial-gradient(120% 80% at 50% 0%, #4A1C55 0%, #230B28 55%, #150717 100%); box-shadow: 0 30px 80px rgba(10, 2, 12, .55); }
dialog.ring-dialog[open] { animation: ring-in .22s ease-out; }
dialog.ring-dialog::backdrop { background: rgba(22, 6, 26, .5); backdrop-filter: blur(8px); }
.ring-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 26px 26px; text-align: center; }
.ring-avatar { position: relative; display: grid; place-items: center; width: 120px; height: 120px; margin-bottom: 18px; }
.ring-wave { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(180, 68, 204, .7); animation: ring-wave 2s ease-out infinite; }
.ring-wave.w2 { animation-delay: 1s; }
.ring-initials { position: relative; display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; font-size: 38px; font-weight: 800; color: var(--brand-900); box-shadow: 0 0 0 4px rgba(255,255,255,.2); }
.ring-name { font-size: 24px; font-weight: 800; }
.ring-kind { font-size: 15px; color: #E4D6EA; }
.ring-context { max-width: 300px; font-size: 13px; color: #B9A8C0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ring-note { font-size: 12px; color: #FFD9A8; }
.ring-actions { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 22px; }
.ring-btn { display: flex; align-items: center; height: 56px; padding: 6px; border-radius: var(--r-pill); border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.1); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; transition: background .12s, transform .08s; }
.ring-btn > span:last-child { flex: 1; padding-right: 44px; }
.ring-btn:hover { background: rgba(255,255,255,.16); }
.ring-btn:focus-visible { outline: 3px solid rgba(255,255,255,.75); outline-offset: 3px; }
.ring-btn:active { transform: scale(.99); }
.ring-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: #fff; color: var(--brand-700); }
.ring-btn.answer { background: #1F9D55; border-color: #1F9D55; box-shadow: 0 10px 24px rgba(31,157,85,.35); }
.ring-btn.answer:hover { background: #1A8A4A; }
.ring-btn.answer .ring-ic { color: #1F9D55; animation: ring-shake 1.2s ease-in-out infinite; }
.ring-btn.decline { background: rgba(229,72,77,.18); border-color: rgba(229,72,77,.5); }
.ring-btn.decline:hover { background: rgba(229,72,77,.3); }
.ring-btn.decline .ring-ic { color: #E5484D; }
@keyframes ring-wave { from { transform: scale(1); opacity: .9; } to { transform: scale(1.55); opacity: 0; } }
@keyframes ring-pulse { 0% { box-shadow: 0 0 0 0 rgba(180,68,204,.55); } 100% { box-shadow: 0 0 0 18px rgba(180,68,204,0); } }
@keyframes ring-in { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ring-shake { 0%, 60%, 100% { transform: rotate(0); } 10%, 30%, 50% { transform: rotate(-14deg); } 20%, 40% { transform: rotate(14deg); } }

/* ---------- Call notices: "call in progress", missed calls, reminders ---------- */
.call-notices { position: fixed; top: 44px; right: 16px; z-index: 70; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.call-notice { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 12px; border-radius: 18px; background: #1E0A22; color: #fff; box-shadow: 0 14px 34px rgba(20,4,24,.35); pointer-events: auto; animation: step-in .16s ease-out; }
.call-notice .avatar { border-color: rgba(255,255,255,.6); box-shadow: none; }
.call-notice .call-dot { margin: 0 4px; }
.call-notice-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.call-notice-text b { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-notice-text span { font-size: 12px; color: #CFC4D6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-notice-action { background: var(--brand-500); color: #fff; }
.call-notice.live .call-notice-action { background: #1F9D55; }
.call-notice.error { background: #8E0B21; }
.call-notice-close { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border: 0; border-radius: 50%; background: transparent; color: #CFC4D6; cursor: pointer; }
.call-notice-close:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- Meetings ---------- */
.wrap-head { align-items: flex-start; flex-wrap: wrap; }
.wrap-head p { max-width: 620px; margin-top: 4px; }
.meeting-sections { display: flex; flex-direction: column; gap: 22px; }
.section-h { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); margin-bottom: 8px; }
.meeting-list { overflow: hidden; }
.meeting-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; }
.meeting-row + .meeting-row { border-top: 1px solid var(--border); }
.meeting-row.is-ended { opacity: .7; }
.meeting-date { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 52px; height: 56px; flex: none; border-radius: 14px; background: var(--brand-50); color: var(--brand-900); border: 1px solid var(--brand-100); }
.meeting-row.is-live .meeting-date { background: #E8F6EE; border-color: #C4E8D3; color: #17693C; }
.meeting-month { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.meeting-day { font-size: 20px; font-weight: 800; line-height: 1; }
.meeting-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.meeting-title-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meeting-title { font-size: 15px; font-weight: 700; }
.meeting-title:hover { color: var(--brand-700); }
.meeting-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-2); }
.meeting-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.meeting-meta .icon { color: var(--text-3); }
.meeting-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-3); letter-spacing: .02em; }
.meeting-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.live-chip { background: #E8F6EE; color: #17693C; gap: 6px; }
.live-chip .call-dot { width: 7px; height: 7px; box-shadow: none; }
.organiser-chip { background: var(--brand-100); color: var(--brand-700); }
.btn-join { background: #1F9D55; color: #fff; }
.btn-join:hover { background: #1A8A4A; }
.btn-lg { height: 50px; padding: 0 28px; font-size: 16px; }
.btn-danger-solid.btn-sm { box-shadow: none; }

.meeting-dialog { width: min(560px, calc(100vw - 24px)); }
.meeting-dialog form, .meeting-dialog #meeting-created { gap: 14px; }
.field-group { display: flex; flex-direction: column; gap: 8px; }
.field-group[hidden] { display: none; }
.field-label { font-weight: 600; font-size: 13px; }
.seg { display: inline-flex; align-self: flex-start; padding: 4px; gap: 4px; border-radius: var(--r-pill); background: var(--brand-50); border: 1px solid var(--brand-100); }
.seg-item { position: relative; cursor: pointer; }
.seg-item input { position: absolute; opacity: 0; pointer-events: none; }
.seg-item span { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 16px; border-radius: var(--r-pill); font-weight: 600; font-size: 13px; color: var(--text-2); }
.seg-item:has(input:checked) span { background: #fff; color: var(--brand-900); box-shadow: 0 2px 8px rgba(61,10,68,.12); }
.seg-item:has(input:focus-visible) span { outline: 3px solid var(--brand-500); outline-offset: 1px; }
.people-picker { position: relative; display: flex; flex-direction: column; gap: 8px; }
.people-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.people-chips:empty { display: none; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 4px 0 4px; border-radius: var(--r-pill); background: var(--brand-50); border: 1px solid var(--brand-100); font-size: 13px; font-weight: 600; }
.avatar.xs { width: 24px; height: 24px; font-size: 10px; border-width: 1px; box-shadow: none; }
.people-results { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; margin-top: 4px; display: flex; flex-direction: column; max-height: 260px; overflow: auto; padding: 6px; border-radius: 14px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.people-result { display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer; }
.people-result:hover, .people-result:focus-visible { background: var(--brand-50); }
.people-result-text { display: flex; flex-direction: column; min-width: 0; }
.people-empty { padding: 8px; }
.form-error { min-height: 0; color: var(--error); font-size: 13px; font-weight: 600; }
.form-error:empty { display: none; }
.hex-sm { width: 34px; height: 34px; }
.hex-sm .icon { width: 16px; height: 16px; }
.link-box { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--brand-50); color: var(--brand-700); }
.link-input { flex: 1; min-width: 0; border: 0; background: transparent; font-weight: 600; color: var(--text); outline: none; }
.send-chat { display: flex; align-items: flex-end; gap: 8px; }
.send-chat .field { flex: 1; min-width: 0; }
.send-chat .btn { height: 42px; }

/* /meet/{code} lobby */
.lobby { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 20px; align-items: start; max-width: 1100px; margin: 0 auto; }
.lobby.in-call { opacity: .35; pointer-events: none; }
.lobby-preview { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px; border-radius: 26px; background: radial-gradient(120% 90% at 50% 0%, #3A1644 0%, #1E0A22 60%, #130614 100%); box-shadow: var(--shadow-lg); }
.preview-box { position: relative; width: 100%; aspect-ratio: 16 / 10; display: grid; place-items: center; border-radius: 18px; overflow: hidden; background: #26102B; color: #fff; }
.preview-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.preview-avatar { display: grid; place-items: center; width: 112px; height: 112px; border-radius: 50%; font-size: 36px; font-weight: 800; color: var(--brand-900); }
.preview-name { position: absolute; left: 12px; bottom: 12px; padding: 4px 12px; border-radius: var(--r-pill); background: rgba(0,0,0,.45); font-size: 12px; font-weight: 600; }
.preview-msg { position: absolute; top: 12px; left: 50%; translate: -50% 0; color: #E4D6EA; }
.preview-msg:empty { display: none; }
.preview-controls { display: flex; gap: 10px; padding: 6px; border-radius: var(--r-pill); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }
.preview-controls .call-ctl { color: #fff; }
.lobby-info { display: flex; flex-direction: column; gap: 14px; }
.lobby-kicker { font-size: 12px; font-weight: 700; color: var(--brand-700); text-transform: uppercase; letter-spacing: .05em; }
.lobby-kicker .meeting-code { text-transform: none; }
.lobby-info h1 { font-size: 26px; }
.lobby-facts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; color: var(--text-2); }
.lobby-facts li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lobby-facts .icon { color: var(--text-3); }
.lobby-live { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; padding: 6px 12px; border-radius: var(--r-pill); background: #E8F6EE; color: #17693C; font-weight: 700; font-size: 13px; }
.lobby-live[hidden] { display: none; }
.lobby-state { padding: 10px 14px; border-radius: 12px; background: var(--brand-50); color: var(--brand-900); font-weight: 600; }
.lobby.ended .lobby-state { background: #FDECEF; color: #8E0B21; }
.lobby-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.lobby-end { align-self: flex-start; }
.not-invited h1 { font-size: 22px; color: var(--text); }
.not-invited p { max-width: 420px; }
.row.center { justify-content: center; }
.center-text { text-align: center; }
.call-join h1 { font-size: 20px; color: var(--text); }

@media (max-width: 1080px) {
  .lobby { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .call-panel { right: 8px; left: 8px; bottom: 76px; width: auto; max-height: calc(100dvh - 90px); }
  .call-panel.max { inset: 0; border-radius: 0; max-height: none; z-index: 80; }
  .call-panel.min { top: auto; bottom: 150px; left: auto; right: 8px; translate: none; }
  .call-panel-head { padding: 12px 10px 6px 12px; gap: 8px; }
  .call-head-meta { display: none; }
  .call-ctl { width: 42px; height: 42px; }
  .call-ctl-pill { gap: 4px; padding: 5px; }
  .call-controls { gap: 10px; }
  .call-speaker { min-height: 200px; }
  .call-notices { top: 8px; right: 8px; left: 8px; width: auto; }
  .meeting-row { flex-wrap: wrap; }
  .meeting-actions { width: 100%; justify-content: flex-end; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .send-chat { flex-direction: column; align-items: stretch; }
  .lobby-info h1 { font-size: 22px; }
}
@media (max-width: 420px) {
  .call-panel:not(.max) .call-ctl[data-role="screen"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ring-wave, .ring-btn.answer .ring-ic, .call-avatar.pulse, .duo-chev { animation: none; }
}

/* Formatted message text (FR-018) */
.text .fmt-li { padding-left: 4px; }
.text .fmt-quote { border-left: 3px solid var(--brand-100); padding-left: 8px; color: var(--text-secondary, #6B6275); }
.text code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: rgba(61, 10, 68, 0.08); padding: 0 4px; border-radius: 4px; }

/* FR-033: protected files. The page doesn't print and preview text can't be selected. */
.print-refused { display: none; }
.protected .preview-image, .protected .preview-frame { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media print {
  .protected > :not(.print-refused) { display: none !important; }
  .protected .print-refused { display: block; }
}

/* DG-003: privacy notice and terms, shown as plain text (never rendered as HTML). */
.policy-text { white-space: pre-wrap; font-size: 0.95rem; line-height: 1.55; max-height: 28rem; overflow: auto; }

/* ---------- Edits, threads, archive and alert cards in the conversation ---------- */
.msg-meta .edited { font-style: italic; color: var(--text-3); cursor: help; }
.composer.editing .reply-strip { border-left-color: var(--warning); }
.thread-link { display: inline-flex; align-items: center; gap: 8px; margin: 4px 0 2px; padding: 4px 10px 4px 4px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); font-size: 12.5px; color: var(--brand-700); cursor: pointer; }
.thread-link:hover { border-color: var(--brand-500); background: var(--brand-50); }
.thread-link .thread-faces { display: inline-flex; }
.thread-link .thread-faces .avatar + .avatar { margin-left: -8px; }
.msg.mine .thread-link { align-self: flex-end; }
.thread-wrap { position: relative; }
.thread-panel { position: absolute; inset: 0 0 0 auto; z-index: 6; display: flex; flex-direction: column; width: min(420px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.thread-panel[hidden] { display: none; }
.thread-panel-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.thread-panel-head h3 { margin: 0; font-size: 15px; }
.thread-panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.thread-panel .msg-tools, .thread-panel .thread-link { display: none; }
.thread-sep { margin: 6px 0; padding-bottom: 4px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-3); }
.thread-composer { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: end; padding: 10px 14px 12px; border-top: 1px solid var(--border); background: var(--canvas); }
.thread-composer textarea { resize: none; min-height: 40px; max-height: 140px; }
.thread-composer .thread-marking, .thread-composer .composer-error { grid-column: 1 / -1; margin: 0; }
.archived-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; font-weight: 600; color: var(--text-2); cursor: pointer; text-align: left; }
.archived-toggle:hover, .archived-toggle.open { background: var(--brand-50); color: var(--brand-700); }
.archived-toggle[hidden] { display: none; }
.alert-card { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 8px; padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid var(--brand-500); border-radius: 10px; background: var(--brand-50); }
.alert-card-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--brand-700); }
.alert-card-head .chip { height: 18px; padding: 0 6px; font-size: 10px; color: #fff; }
.alert-card-title { font-size: 14.5px; }
.alert-card-open { align-self: flex-start; }
.alert-card-state { margin-left: auto; padding: 1px 8px; border-radius: var(--r-pill); background: var(--surface); color: var(--text-2); font-size: 11px; text-transform: none; letter-spacing: 0; }
.alert-card.is-withdrawn, .alert-card.is-superseded { border-left-color: var(--text-3); background: var(--canvas); }
.alert-card.is-withdrawn .alert-card-title { text-decoration: line-through; color: var(--text-2); }
.bubble .msg-link { color: var(--brand-700); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.msg.mine .bubble .msg-link { color: inherit; }

/* ---------- Administration → Users ---------- */
.mt-4 { margin-top: 4px; }
.page-head > div > p { margin-top: 4px; }
.invite-issued { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; border-color: #C4E8D3; background: #F3FBF6; }
.invite-issued-icon { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; background: #DDF1E4; color: #17693C; }
.invite-issued-body { flex: 1; min-width: 0; }
.invite-issued-body h2 { font-size: 16px; margin-bottom: 4px; color: #17693C; }
.invite-code { display: flex; align-items: center; gap: 10px; flex: none; padding: 8px 8px 8px 16px; border-radius: 14px; background: #fff; border: 1px dashed #9FD4B4; }
.invite-code .mono { font-size: 20px; font-weight: 700; letter-spacing: .08em; color: var(--brand-900); user-select: all; }

.user-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.user-stats .stat { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer; font: inherit; transition: border-color .12s, box-shadow .12s; }
.user-stats .stat:hover { border-color: var(--brand-500); }
.user-stats .stat-row { align-self: stretch; }
.user-stats .stat.active { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(180,68,204,.16); }

.users-card { overflow: hidden; }
.users-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.users-toolbar .filter-chips { padding: 0; }
.users-toolbar .filter-chips a span { margin-left: 4px; opacity: .7; }
.users-search { position: relative; flex: 1 1 260px; max-width: 380px; color: var(--text-3); }
.users-search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.users-search .input { padding-left: 38px; border-radius: var(--r-pill); }
.table-scroll { position: relative; overflow-x: auto; } /* positioned, so visually-hidden labels inside wide tables stay in the scroll box */
.users-table tr[hidden] { display: none; }
.users-table .user-id { min-width: 0; }
.users-table .user-id b { margin-right: 6px; }
.users-actions { text-align: right; width: 1%; white-space: nowrap; }
.role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip { background: var(--brand-50); color: var(--brand-700); border: 1px solid var(--brand-100); }
.you-chip { height: 18px; padding: 0 6px; font-size: 10px; background: var(--canvas); color: var(--text-2); }
.user-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.user-status-Active { background: #E3F4EA; color: #17693C; }
.user-status-Invited { background: #FFF4D6; color: #7A5200; }
.user-status-Suspended { background: #FCE4E7; color: var(--error); }
.user-status-Deactivated { background: var(--canvas); color: var(--text-3); }

.seg-wrap { flex-wrap: wrap; border-radius: 18px; }
.role-hint { padding: 8px 12px; border-radius: 10px; background: var(--brand-50); color: var(--brand-900); }
.role-hint[hidden], .guest-fields[hidden], .manage-action[hidden] { display: none; }

.manage-dialog { width: min(560px, calc(100vw - 24px)); overflow-y: auto; }
.manage-who { flex: 1; min-width: 0; }
.manage-who h2 { font-size: 17px; }
.manage-action { display: flex; flex-direction: column; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; }
.manage-text { display: flex; flex-direction: column; gap: 2px; }
.manage-go { display: flex; gap: 8px; align-items: center; }
.manage-go .input { min-height: 36px; padding: 6px 12px; border-radius: 10px; }
.manage-go select.input { flex: 0 0 170px; }
.manage-go .btn { flex: none; }
.manage-link { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; font-weight: 600; }
.manage-link span { flex: 1; }
.manage-link:hover { border-color: var(--brand-500); color: var(--brand-700); }
.danger-zone { border-color: #F2C4CC; background: #FFF8F9; }
.danger-zone b { color: var(--error); }

@media (max-width: 1080px) {
  .user-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .invite-issued { flex-wrap: wrap; }
  .invite-code { width: 100%; justify-content: space-between; }
}
@media (max-width: 760px) {
  .page-head:has(.actions) { flex-wrap: wrap; }
  .users-table thead { display: none; }
  .users-table tr { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .users-table td { padding: 0; border: 0; }
  .users-table td:first-child { grid-column: 1 / -1; }
  .users-actions { grid-column: 2; grid-row: 2 / span 2; align-self: center; }
  .manage-go { flex-wrap: wrap; }
  .manage-go select.input { flex: 1 1 100%; }
}

/* ================= Administration: shell and shared building blocks =================
   Page anatomy (every admin view):
     .page-head > div > h1 + p.page-sub     .page-head > .actions > buttons
     .stats > .stat (value, label, optional .hint)
     .section (a card) > .section-head (h2, p, .actions) then .section-body or a .table-scroll
     .toolbar > .search-field + .filter-chips      .badge.badge-{ok|warn|danger|info|muted|brand}
     dialog.modal for create / edit forms (admin.js opens them)
*/
.admin { display: grid; grid-template-columns: 228px minmax(0, 1fr); gap: 28px; align-items: start; }
.admin-main { min-width: 0; }
.admin-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 80px); overflow-y: auto; padding: 14px 10px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--border); scrollbar-width: thin; }
.admin-nav-title { padding: 2px 10px 0; font-size: 15px; font-weight: 800; color: var(--brand-900); }
.admin-nav-group { display: flex; flex-direction: column; gap: 2px; }
.admin-nav-heading { padding: 0 10px 4px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.admin-nav-item { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--text-2); }
.admin-nav-item .icon { color: var(--text-3); }
.admin-nav-item:hover { background: var(--brand-50); color: var(--brand-900); }
.admin-nav-item.active { background: var(--brand-900); color: #fff; }
.admin-nav-item.active .icon { color: #E7B6F2; }

.page-sub { margin-top: 4px; color: var(--text-3); max-width: 760px; }
.page-head .actions { flex-wrap: wrap; justify-content: flex-end; }

.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.section-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.section-head > div:first-child { flex: 1; min-width: 0; }
.section-head h2 { font-size: 16px; }
.section-head p { margin-top: 3px; color: var(--text-3); font-size: 13px; }
.section-head .actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.section-body { padding: 20px; }
.section-body.stack { gap: 16px; }
.section > .table-scroll:last-child .table tr:last-child td { border-bottom: 0; }
.section .empty { padding: 36px 24px; }
.section-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--canvas); }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .filter-chips { padding: 0; }
.search-field { position: relative; flex: 1 1 240px; max-width: 360px; color: var(--text-3); }
.search-field .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-field .input { padding-left: 38px; border-radius: var(--r-pill); min-height: 38px; }
.table tr[hidden] { display: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .row-actions > * + * { margin-left: 6px; }
.table .sub { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 6px; font-size: 11px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; background: var(--brand-100); color: var(--brand-700); }
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: #E3F4EA; color: #17693C; }
.badge-warn { background: #FFF4D6; color: #7A5200; }
.badge-danger { background: #FCE4E7; color: var(--error); }
.badge-info { background: #E6EEFA; color: #1F5AA0; }
.badge-muted { background: var(--canvas); color: var(--text-3); border: 1px solid var(--border); }
.badge-brand { background: var(--brand-900); color: #fff; }

.stat .hint { display: block; margin-top: 2px; font-size: 12px; color: var(--text-3); }
a.stat:hover, button.stat:hover { border-color: var(--brand-500); }
.stat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--brand-50); color: var(--brand-700); }
.stat.alert .stat-icon { background: #FCE4E7; color: var(--error); }

.tile-links { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tile-link { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.tile-link:hover { border-color: var(--brand-500); box-shadow: var(--shadow); }
.tile-link .stat-icon { flex: none; }
.tile-link b { display: block; }
.tile-link span.muted { display: block; font-size: 12.5px; margin-top: 2px; }

.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 14px; background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-900); font-size: 13.5px; margin-bottom: 20px; }
.callout .icon { flex: none; margin-top: 1px; color: var(--brand-700); }
.callout-warn { background: #FFF8E6; border-color: #F2DDA0; color: #7A5200; }
.callout-warn .icon { color: #B7791F; }
.callout-danger { background: #FFF5F6; border-color: #F5C6CF; color: #8E0B21; }
.callout-danger .icon { color: var(--error); }

.page-tabs { display: flex; gap: 4px; margin-bottom: 20px; padding: 4px; width: fit-content; max-width: 100%; overflow-x: auto; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); scrollbar-width: none; }
.page-tabs a, .page-tabs button { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 16px; border: 0; border-radius: var(--r-pill); background: transparent; font: inherit; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.page-tabs a:hover, .page-tabs button:hover { color: var(--brand-900); }
.page-tabs a.active, .page-tabs button.active { background: var(--brand-900); color: #fff; }
.page-tabs .count-badge { height: 18px; min-width: 18px; font-size: 10px; }
.page-tabs .active .count-badge { background: #fff; color: var(--brand-900); }

.item-list { display: flex; flex-direction: column; }
.item { display: flex; gap: 14px; align-items: flex-start; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.item-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 700; }
.item-meta { font-size: 12px; color: var(--text-3); }
.item-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }

.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-form .input { min-height: 36px; padding: 6px 12px; border-radius: 10px; flex: 1 1 200px; width: auto; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; }
.check-row input { width: 16px; height: 16px; accent-color: var(--brand-700); }
.toggle-list { display: flex; flex-direction: column; gap: 10px; }
.danger-text { color: var(--error); }

@media (max-width: 1280px) {
  .admin { grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 1080px) {
  .admin { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .admin-nav { position: static; flex-direction: row; align-items: center; gap: 4px; max-height: none; margin-bottom: 20px; padding: 6px; overflow-x: auto; border-radius: var(--r-pill); scrollbar-width: none; }
  .admin-nav-title, .admin-nav-heading { display: none; }
  .admin-nav-group { flex-direction: row; gap: 4px; }
  .admin-nav-group + .admin-nav-group { padding-left: 4px; border-left: 1px solid var(--border); }
  .admin-nav-item { flex: none; white-space: nowrap; border-radius: var(--r-pill); padding: 0 14px; }
  .admin-nav-item .icon { display: none; }
}
@media (max-width: 760px) {
  .section-head { flex-wrap: wrap; padding: 16px; }
  .section-body { padding: 16px; }
  .item { flex-wrap: wrap; padding: 14px 16px; }
  .item-side { align-items: flex-start; width: 100%; }
  .page-head { flex-wrap: wrap; }
  /* Count tiles: a compact two-up grid so the page content starts on the first screen */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 24px; }
  .stat .hint { display: none; }
  .stat-icon { width: 30px; height: 30px; border-radius: 10px; }
  .stat-icon .icon { width: 16px; height: 16px; }
}

/* ---------- Idle-timeout warning (session.js) ---------- */
dialog.session-dialog[open] { align-items: center; text-align: center; gap: 12px; padding: 28px 24px 20px; }
.session-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); }
.session-icon .icon { width: 26px; height: 26px; }
.session-dialog h2 { font-size: 19px; }
.session-dialog p { color: var(--text-2); max-width: 340px; }
.session-countdown { color: var(--brand-900); font-variant-numeric: tabular-nums; }
.session-error { color: var(--error); font-size: 13px; }
.session-dialog .modal-foot { width: 100%; padding-top: 6px; }

/* ---------- Messages: chat search (chat-search.js) ---------- */
.chat-search-results { padding-top: 4px; }
.chat-search-results[hidden], .chat-search-group[hidden], .chat-search-results .list-row[hidden] { display: none; }
.pane-body[hidden] { display: none; }
.archived-toggle.search-hidden { display: none; }
.chat-search-heading { margin: 10px 10px 4px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.chat-search-hex { width: 36px; height: 36px; font-size: 11px; }
.chat-search-archived { height: 18px; padding: 0 6px; font-size: 10px; background: var(--canvas); color: var(--text-3); margin-left: 6px; }
.chat-search-messages { display: flex; align-items: center; gap: 10px; margin: 10px 8px 4px; padding: 12px 10px; border-top: 1px solid var(--border); color: var(--brand-700); font-weight: 600; font-size: 13px; }
.chat-search-messages:hover { background: var(--brand-50); border-radius: 12px; }
.chat-search-messages span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Assist button and panel (every page) ---------- */
.assist-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 55; display: inline-flex; align-items: center; gap: 8px;
  height: 48px; padding: 0 18px 0 14px; border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-900)); color: #fff; font: inherit; font-weight: 700;
  box-shadow: var(--shadow-lg); transition: transform .15s, box-shadow .15s;
}
.assist-fab:hover { transform: translateY(-1px); }
.assist-fab .icon { width: 20px; height: 20px; }
.assist-fab.open { background: var(--brand-900); }
/* Out of the way of the message composer's send button, and hidden while a call is on screen. */
/* On a conversation it shrinks to a round icon above the composer (or the read-only note). */
body:has(.composer, .read-only-note) .assist-fab { bottom: 190px; width: 44px; height: 44px; padding: 0; justify-content: center; }
body:has(.composer, .read-only-note) .assist-fab span { display: none; }
/* Room at the end of every page so the last buttons can scroll clear of the Assist button. */
body:has(.assist-fab):not(:has(.composer, .read-only-note)) .content { padding-bottom: 96px; }
body:has(#call-panel:not([hidden])) .assist-fab,
body:has(#call-panel:not([hidden])) .assist-panel { display: none; }
.assist-panel {
  position: fixed; right: 24px; bottom: 84px; z-index: 56; display: flex; flex-direction: column;
  width: min(400px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 140px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow-lg);
  overflow: hidden; animation: step-in .16s ease-out;
}
.assist-panel[hidden] { display: none; }
body:has(.composer, .read-only-note) .assist-panel { bottom: 244px; height: min(540px, calc(100dvh - 300px)); }
.assist-panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.assist-panel-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); flex: none; }
.assist-panel-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.assist-panel-title h2 { margin: 0; font-size: 15px; }
.assist-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--canvas); }
.assist-welcome p { margin: 0 0 10px; color: var(--text-2); font-size: 13px; }
.assist-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.assist-panel .chip-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--brand-700); border-radius: var(--r-pill);
  padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
}
.assist-panel .chip-btn:hover:not(:disabled) { border-color: var(--brand-500); }
.assist-panel .chip-btn:disabled { opacity: .5; cursor: default; }
.assist-q { align-self: flex-end; max-width: 85%; padding: 9px 12px; border-radius: 16px 16px 4px 16px; background: var(--brand-700); color: #fff; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.assist-a { align-self: flex-start; max-width: 95%; padding: 10px 12px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.assist-thinking { color: var(--text-2); font-style: italic; }
.assist-error { color: var(--error); }
.assist-withheld { color: var(--text-2); font-style: italic; }
.assist-a-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.assist-label { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; color: var(--brand-700); }
.assist-a-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.assist-cite { display: inline-grid; place-items: center; min-width: 17px; height: 17px; margin: 0 1px; padding: 0 4px; border-radius: 9px; background: var(--brand-100); color: var(--brand-700); font-size: 10px; font-weight: 800; text-decoration: none; vertical-align: 1px; }
.assist-sources { margin: 8px 0 0; padding: 8px 0 0 18px; border-top: 1px solid var(--border); font-size: 12px; display: flex; flex-direction: column; gap: 4px; }
.assist-sources li { overflow-wrap: anywhere; }
.assist-sources .chip { margin-left: 6px; height: 18px; font-size: 10px; padding: 0 6px; vertical-align: 1px; }
.assist-report { margin-top: 8px; }
.assist-report .link-btn { border: 0; background: none; padding: 0; color: var(--text-2); font: inherit; font-size: 12px; text-decoration: underline; cursor: pointer; }
.assist-report-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.assist-report-choices[hidden] { display: none; }
.assist-off { margin: 0; padding: 10px 16px; background: #FFF6E5; color: #7A4B00; font-size: 13px; border-top: 1px solid var(--border); }
.assist-off[hidden] { display: none; }
.assist-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--border); background: var(--surface); }
.assist-form .input { flex: 1; resize: none; min-height: 40px; max-height: 140px; border-radius: 14px; font-size: 13px; }
.assist-send { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; background: var(--brand-900); color: #fff; cursor: pointer; }
.assist-send:disabled { opacity: .45; cursor: default; }
.assist-warning { margin: 0; padding: 4px 14px 10px; font-size: 11px; color: var(--text-3); background: var(--surface); }
@media (max-width: 760px) {
  .assist-fab { right: 16px; bottom: 82px; height: 44px; padding: 0 14px 0 12px; }
  .assist-fab span { display: none; }
  .assist-fab { width: 44px; padding: 0; justify-content: center; }
  body:has(.composer, .read-only-note) .assist-fab { bottom: 210px; }
  .assist-panel, body:has(.composer, .read-only-note) .assist-panel { right: 8px; left: 8px; bottom: 76px; width: auto; height: calc(100dvh - 150px); }
}

/* ---------- Assistant chats (sidebar like a chat app) ---------- */
.assistant-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start; }
.assistant-layout.no-chats { grid-template-columns: minmax(0, 1fr); }
.assistant-layout .assistant { width: 100%; }
.chat-list { position: sticky; top: 16px; max-height: calc(100dvh - 120px); overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.chat-list .new-chat { display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 8px; }
.chat-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-group { margin: 10px 8px 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.chat-link { display: block; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: 13px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-link:hover { background: var(--brand-50); }
.chat-link.active { background: var(--brand-100); color: var(--brand-900); font-weight: 600; }
.chat-list-empty { margin: 4px 8px; }
.assistant-title { flex: 1; min-width: 0; }
.assistant-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list-toggle { display: none; }
@media (max-width: 1000px) {
  .assistant-layout { grid-template-columns: minmax(0, 1fr); }
  .chat-list { display: none; position: static; max-height: 50dvh; }
  .chat-list.open { display: flex; }
  .chat-list-toggle { display: inline-flex; align-items: center; gap: 6px; }
}

/* A stream where this person can read and react but not send messages. */
.read-only-note { display: flex; align-items: center; gap: 8px; margin: 12px 18px 16px; padding: 12px 16px; border-radius: 14px; background: var(--brand-50); border: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.read-only-note .icon { color: var(--brand-700); flex: none; }

/* @mention suggestions above the composer */
.composer, .thread-composer { position: relative; }
.mention-list { position: absolute; left: 18px; bottom: calc(100% - 8px); z-index: 30; width: min(320px, calc(100% - 36px)); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); }
.mention-list[hidden] { display: none; }
.mention-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; cursor: pointer; }
.mention-item.active, .mention-item:hover { background: var(--brand-100); }
.mention-avatar { display: grid; place-items: center; width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--brand-50); color: var(--brand-700); font-size: 11px; font-weight: 800; }
.mention-text { display: flex; flex-direction: column; min-width: 0; }
.mention-text b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mention-text span { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Alerts from the SIEM, and indicators ---------- */
.studio-source { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 4px; padding: 12px 14px; border-radius: 12px; background: var(--brand-50); border: 1px solid var(--brand-100); font-size: 14px; color: var(--text); }
.studio-source .icon { flex: none; margin-top: 2px; color: var(--brand-700); }
.ioc-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ioc-list li { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ioc-list code { overflow-wrap: anywhere; font-size: 13px; }
.ioc-list .chip { flex: none; text-transform: none; }

/* ================= Administration: row action menu (admin.js [data-menu]) and the Sectors page ================= */
.stat.warn .value { color: var(--warning); }
.toolbar .filter-chips a span { margin-left: 4px; opacity: .7; }
.row-menu { display: inline-block; }
.row-menu > .btn { gap: 6px; }
.row-menu > .btn[aria-expanded="true"] { background: var(--brand-50); color: var(--brand-900); }
.row-menu-list { position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 184px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); text-align: left; }
.row-menu-list[hidden] { display: none; }
.row-menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; font-weight: 600; text-align: left; cursor: pointer; }
.row-menu-list button .icon { color: var(--text-3); }
.row-menu-list button:hover, .row-menu-list button:focus-visible { background: var(--brand-50); color: var(--brand-900); outline: none; }
.row-menu-list button:hover .icon, .row-menu-list button:focus-visible .icon { color: var(--brand-700); }
.row-menu-list button.danger, .row-menu-list button.danger .icon { color: var(--error); }
.row-menu-list button.danger:hover, .row-menu-list button.danger:focus-visible { background: #FDF3F5; }

.sector-stats { margin-bottom: 20px; }
.sector-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sector-code { flex: none; display: grid; place-items: center; min-width: 44px; height: 44px; padding: 0 8px; border-radius: var(--r-tile); background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-900); font-size: 12px; font-weight: 800; letter-spacing: .03em; }
.sector-name { display: flex; flex-direction: column; min-width: 0; }
.sector-name b { overflow-wrap: anywhere; }
.sector-name .sub { font-size: 12.5px; color: var(--text-3); }
.sector-regulator { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.sector-regulator .icon { flex: none; color: var(--brand-700); }
.sector-count { display: inline-grid; place-items: center; min-width: 32px; height: 26px; padding: 0 9px; border-radius: var(--r-pill); background: var(--canvas); font-weight: 700; }
.sector-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.sector-facts > div { padding: 10px 12px; border-radius: var(--r-tile); background: var(--canvas); }
.sector-facts dt { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.sector-facts dd { margin: 2px 0 0; font-weight: 700; }
.sector-usage { margin: 0; padding: 12px 14px 12px 32px; border-radius: var(--r-tile); background: var(--canvas); font-weight: 600; }
.sector-usage li + li { margin-top: 4px; }
@media (max-width: 760px) {
  .sector-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sector-stats .stat { padding: 14px; }
  .sector-stats .stat .value { font-size: 24px; }
}

/* ---------- Organisation SIEM connection ---------- */
.siem-scope { display: flex; align-items: center; gap: 8px; }
.siem-scope .input { min-height: 36px; padding: 6px 12px; border-radius: 10px; width: auto; max-width: 320px; }

.siem-status { display: flex; flex-direction: column; gap: 16px; margin-bottom: 20px; padding: 20px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); }
.siem-status-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.siem-status-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-50); color: var(--brand-700); }
.siem-status-icon.bad { background: #FDECEF; color: var(--error); }
.siem-status-icon.ok { background: #E8F6EE; color: var(--success); }
.siem-status-icon.warn { background: #FFF4D6; color: #7A5200; }
.siem-status-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.siem-status-title { display: flex; flex-wrap: wrap; gap: 6px; }
.siem-endpoint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.siem-status-actions { flex: none; }
.siem-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 0; }
.siem-metrics > div { padding: 12px 14px; border-radius: 14px; background: var(--canvas); }
.siem-metrics dt { font-size: 12px; font-weight: 600; color: var(--text-3); }
.siem-metrics dd { margin: 4px 0 0; font-size: 18px; font-weight: 700; color: var(--brand-900); }
.siem-metrics .bad dd { color: var(--error); }
.siem-last-error { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border-radius: 12px; background: #FDECEF; color: #8E0B21; font-size: 13px; }
.siem-last-error .mono { flex: 1; overflow-wrap: anywhere; }
.siem-last-error .icon { flex: none; margin-top: 2px; }

.siem-intro { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; padding: 22px; border-radius: 20px; background: var(--brand-50); border: 1px solid var(--brand-100); }
.siem-intro-icon { display: grid; place-items: center; flex: none; width: 48px; height: 48px; border-radius: 14px; background: var(--brand-900); color: #fff; }
.siem-intro h2 { margin: 0 0 8px; font-size: 18px; }
.siem-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--text-2); }
.siem-steps b { color: var(--text); }

.siem-form { display: flex; flex-direction: column; }
.siem-card { overflow: visible; }
.siem-card-head { padding: 18px 20px 0; }
.siem-card-head h2 { margin: 0; font-size: 16px; }
.siem-card-head p { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
.siem-card-body { display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 20px; }
.siem-card-body > .btn { align-self: flex-start; }
.siem-card-head:last-child { padding-bottom: 18px; }
.siem-narrow { max-width: 360px; }
.siem-options { gap: 10px; }
.siem-option { display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid var(--border); cursor: pointer; transition: border-color .15s, background .15s; }
.siem-option:hover { border-color: var(--brand-500); }
.siem-option:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); }
.siem-option input { width: 18px; height: 18px; accent-color: var(--brand-700); }
.siem-option > span:nth-of-type(2) { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--text-2); }
.siem-option b { font-size: 14px; color: var(--text); }
.siem-option-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--brand-100); color: var(--brand-700); }
.siem-option-warn:has(input:checked) { border-color: #F2DDA0; background: #FFFBEF; }
.siem-option-warn .siem-option-icon { background: #FFF4D6; color: #7A5200; }
.siem-dir { padding: 3px 10px; border-radius: var(--r-pill); background: var(--canvas); font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.siem-dir.in { background: #E6EEFA; color: #1F5AA0; }
.siem-savebar { position: sticky; bottom: 16px; z-index: 2; display: flex; align-items: flex-end; gap: 12px; padding: 14px 16px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.siem-savebar .field { flex: 1; }

.siem-secrets { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; }
.siem-secrets li { display: flex; align-items: center; gap: 8px; }
.siem-row-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.siem-row-form .field { flex: 1 1 220px; }
.siem-row-form > .input { flex: 1 1 200px; width: auto; min-height: 36px; }
.siem-row-form .check-row { flex: 1 1 100%; }
.siem-danger { border-color: #F5C6CF; }
.siem-danger .siem-card-head h2 { color: var(--error); }
.siem-failed-item { flex-direction: column; align-items: stretch; gap: 10px; }

@media (max-width: 760px) {
  .siem-scope { width: 100%; }
  .siem-scope .input { flex: 1; max-width: none; }
  .siem-status-main { flex-wrap: wrap; }
  .siem-status-actions { width: 100%; }
  .siem-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .siem-option { grid-template-columns: auto 1fr; }
  .siem-option-icon, .siem-dir { display: none; }
  .siem-savebar { position: static; flex-direction: column; align-items: stretch; box-shadow: none; }
}

/* ---------- NCCC overview of organisation SIEM connections ---------- */
.siem-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; font-size: 13.5px; font-weight: 600; color: var(--brand-700); text-decoration: none; }
.siem-back:hover { text-decoration: underline; }
.siem-overview-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.siem-overview-summary { margin-bottom: 20px; }
.siem-status-icon.none { background: var(--canvas); color: var(--text-3); }
.siem-status-icon.siem-row-icon { width: 36px; height: 36px; border-radius: 10px; }
.siem-overview-dirs { display: flex; flex-wrap: wrap; gap: 4px; }
.siem-overview-table td { vertical-align: middle; }
.siem-overview-table .nowrap { white-space: nowrap; }
.row-menu-list a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; color: var(--text); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.row-menu-list a .icon { color: var(--text-3); }
.row-menu-list a:hover, .row-menu-list a:focus-visible { background: var(--brand-50); color: var(--brand-900); outline: none; }
.row-menu-list a:hover .icon, .row-menu-list a:focus-visible .icon { color: var(--brand-700); }
.row-menu-list button:disabled { opacity: .5; cursor: not-allowed; }
@media (max-width: 760px) {
  .siem-overview-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Access reviews ---------- */
.ar-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.ar-summary-item { display: flex; align-items: baseline; gap: 6px; padding: 10px 16px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-size: 13px; color: var(--text-2); }
.ar-summary-value { font-size: 18px; font-weight: 800; color: var(--brand-900); }
.ar-summary-item.attention { border-color: #F5C6CF; background: #FDF3F5; }
.ar-summary-item.attention .ar-summary-value { color: var(--error); }
.ar-rules { margin-left: auto; font-size: 13px; }
.ar-rules summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--brand-700); font-weight: 600; list-style: none; }
.ar-rules summary::-webkit-details-marker { display: none; }
.ar-rules[open] { flex-basis: 100%; margin-left: 0; padding: 12px 16px; border-radius: 14px; background: var(--brand-50); }
.ar-rules ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; color: var(--text-2); }

.ar-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 24px; text-align: center; }
.ar-empty h2 { margin: 6px 0 0; font-size: 18px; }
.ar-empty p { max-width: 520px; margin: 0; color: var(--text-2); font-size: 14px; }

.ar-campaign-head { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.ar-campaign-title { flex: 1 1 320px; min-width: 0; }
.ar-campaign-title h2 { margin: 0 0 8px; font-size: 17px; }
.ar-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ar-progress { flex: 0 1 240px; display: flex; flex-direction: column; gap: 6px; }
.ar-progress-text { font-size: 13px; color: var(--text-2); }
.ar-progress-text b { color: var(--brand-900); }
.ar-progress-bar { width: 100%; height: 8px; border: 0; border-radius: 999px; overflow: hidden; background: var(--brand-50); appearance: none; -webkit-appearance: none; }
.ar-progress-bar::-webkit-progress-bar { background: var(--brand-50); border-radius: 999px; }
.ar-progress-bar::-webkit-progress-value { background: var(--brand-500); border-radius: 999px; }
.ar-progress-bar::-moz-progress-bar { background: var(--brand-500); border-radius: 999px; }

.ar-people { list-style: none; margin: 0; padding: 0; }
.ar-person { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(280px, 380px); align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.ar-person:last-child { border-bottom: 0; }
.ar-person.decided { background: var(--canvas); }
.ar-person-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ar-person-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.ar-person-access { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ar-sectors { font-size: 12.5px; color: var(--text-3); }
.ar-decide { display: flex; flex-direction: column; gap: 8px; }
.ar-decide-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-decide .input { min-height: 34px; padding: 6px 12px; border-radius: 10px; font-size: 13px; }
.ar-keep { border-color: #C4E8D3; color: #17693C; }
.ar-keep:hover { border-color: var(--success); color: #17693C; }
.ar-other { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); }
.ar-outcome { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ar-note { flex-basis: 100%; font-size: 13px; color: var(--text-2); font-style: italic; }

.ar-lower { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.ar-lower > .section { margin: 0; }
.ar-past { list-style: none; margin: 0; padding: 0; }
.ar-past > li { border-top: 1px solid var(--border); }
.ar-past summary { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 20px; cursor: pointer; list-style: none; }
.ar-past summary::-webkit-details-marker { display: none; }
.ar-past-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ar-past-counts { display: flex; gap: 6px; }
.ar-past-items { list-style: none; margin: 0; padding: 0 20px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ar-past-items li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

@media (max-width: 900px) {
  .ar-person { grid-template-columns: auto minmax(0, 1fr); }
  .ar-person-decision { grid-column: 1 / -1; }
  .ar-rules { margin-left: 0; }
}

/* ---------- Retention ---------- */
.ret-mode { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 20px; padding: 16px 18px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); }
.ret-mode > div { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; color: var(--text-2); }
.ret-mode b { font-size: 15px; color: var(--text); }
.ret-mode-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border-radius: 12px; background: #E8F6EE; color: var(--success); }
.ret-mode.off { border-color: #F2DDA0; background: #FFFBEF; }
.ret-mode.off .ret-mode-icon { background: #FFF4D6; color: #7A5200; }

.ret-waiting { border-color: #F2DDA0; }
.ret-review-list { list-style: none; margin: 0; padding: 0; }
.ret-review { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(320px, 460px); align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.ret-review-icon, .ret-card-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 11px; background: var(--brand-100); color: var(--brand-700); }
.ret-review-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ret-decide { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ret-decide .input { flex: 1 1 100%; min-height: 34px; padding: 6px 12px; border-radius: 10px; font-size: 13px; }

.ret-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; padding: 16px 20px 20px; }
.ret-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface); }
.ret-card-head { display: flex; align-items: center; gap: 10px; }
.ret-card-head h3 { flex: 1; margin: 0; font-size: 15px; }
.ret-period { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--brand-50); }
.ret-period-value { font-size: 22px; font-weight: 800; color: var(--brand-900); }
.ret-period.none { background: var(--canvas); }
.ret-period.none .ret-period-value { font-size: 16px; color: var(--text-2); }
.ret-statutory { display: flex; align-items: flex-start; gap: 6px; margin: 0; font-size: 13px; color: var(--text-2); }
.ret-statutory .icon { flex: none; margin-top: 2px; color: var(--brand-700); }
.ret-overrides { list-style: none; margin: 0; padding: 10px 0 0; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ret-overrides li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.ret-history { list-style: none; margin: 0; padding: 0; }
.ret-history li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 20px; border-top: 1px solid var(--border); font-size: 13.5px; }

@media (max-width: 900px) {
  .ret-review { grid-template-columns: auto minmax(0, 1fr); }
  .ret-decide { grid-column: 1 / -1; }
}

/* ---------- Alerts: table or grid ---------- */
.alerts-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.alerts-search { position: relative; display: flex; align-items: center; flex: 1 1 260px; max-width: 420px; }
.alerts-search .icon { position: absolute; left: 14px; color: var(--text-3); pointer-events: none; }
.alerts-search .input { padding-left: 38px; min-height: 40px; border-radius: var(--r-pill); }
.view-switch { display: inline-flex; padding: 4px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); }
.view-switch a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600; color: var(--text-2); }
.view-switch a:hover { color: var(--brand-900); }
.view-switch a.active { background: var(--brand-900); color: #fff; }

.alerts-table-wrap { overflow: hidden; }
.alerts-table td { vertical-align: middle; }
.alerts-table tbody tr { box-shadow: inset 4px 0 0 transparent; }
.alerts-table tbody tr.sev-row-S1 { box-shadow: inset 4px 0 0 #C8102E; }
.alerts-table tbody tr.sev-row-S2 { box-shadow: inset 4px 0 0 #E8590C; }
.alerts-table tbody tr.awaiting { background: #FFFBF3; }
.alerts-title-cell { min-width: 260px; }
.alerts-title-cell a { color: var(--text); }
.alerts-title-cell a:hover b { color: var(--brand-700); text-decoration: underline; }
.alerts-title-cell .sub { display: block; margin-top: 2px; max-width: 520px; }
.alerts-title-cell .badge { margin-top: 6px; }
.alerts-status { white-space: nowrap; }

.alerts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.alert-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px 18px 16px 22px; border-radius: 18px; background: var(--surface); border: 1px solid var(--border); overflow: hidden; transition: box-shadow .15s, transform .15s; }
.alert-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #6B7280; }
.alert-card.sev-edge-S1::before { background: #C8102E; }
.alert-card.sev-edge-S2::before { background: #E8590C; }
.alert-card.sev-edge-S3::before { background: #F2C200; }
.alert-card.sev-edge-S4::before { background: #2F7ED8; }
.alert-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.alert-card.awaiting { border-color: #F2DDA0; }
.alert-card-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.alert-card-title { margin: 0; font-size: 16px; line-height: 1.35; }
.alert-card-title a { color: var(--text); }
.alert-card-title a::after { content: ""; position: absolute; inset: 0; }
.alert-card-body { margin: 0; font-size: 13.5px; line-height: 1.5; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.alert-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.alert-card-foot form { position: relative; z-index: 1; }

@media (max-width: 760px) {
  .view-switch span { display: none; }
  .alerts-search { max-width: none; }
  /* The table stacks: one block per alert, nothing off-screen. */
  .alerts-table-wrap .table-scroll { overflow: visible; }
  .alerts-table thead { display: none; }
  .alerts-table, .alerts-table tbody { display: block; }
  .alerts-table tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .alerts-table td { display: block; padding: 0; border: 0; }
  .alerts-table td.alerts-title-cell { order: -1; flex: 1 1 100%; min-width: 0; }
  .alerts-table td[data-label="Published"]::before { content: "Published "; color: var(--text-3); }
  .alerts-table td[data-label="Valid until"]::before { content: "· until "; color: var(--text-3); }
  .alerts-table td.alerts-status { flex: 1 1 100%; }
}
