/* =========================================================================
   SHC AI Governance Gateway — theme aligned with sidneyhealth.org (Increment 6)
   Fonts are self-hosted (static/fonts, SIL OFL 1.1) — no external font calls.
   ========================================================================= */
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/nunito-sans-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito Sans"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/nunito-sans-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/nunito-700.woff2") format("woff2"); }

:root {
  /* SHC brand tokens (from sidneyhealth.org computed styles) */
  --shc-navy: #003057;
  --shc-blue: #005395;
  --shc-teal: #00B1B0;
  --shc-teal-dark: #008f8e;
  --shc-navy-dark: #001f3a;
  --shc-text: #666666;
  --shc-text-muted: #A7A7A7;
  --shc-panel: #F2F2F2;
  --shc-white: #FFFFFF;
  --shc-line: #dcdcdc;
  --font-body: "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-head: "Nunito", "Nunito Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;        /* default: inputs, buttons, bubbles, alerts, panels */
  --radius-sm: 6px;      /* small controls, chips, code, inline images */
  --radius-lg: 16px;     /* large surfaces: cards / primary panels */

  /* legacy aliases used throughout the stylesheet */
  --navy: var(--shc-navy);
  --accent: var(--shc-blue);
  --bg: var(--shc-panel);
  --card: var(--shc-white);
  --ink: #3f3f3f;
  --muted: var(--shc-text);
  --line: var(--shc-line);
  --warn-bg: #fff7e6; --warn-bd: #e8b34b;
  --err-bg: #fbeceb; --err-bd: #d9817a;
  --info-bg: #e6f0f8; --info-bd: #8fb3d6;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background: var(--shc-white);
  color: var(--shc-text);
  min-height: 100vh;
  display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--shc-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; color: var(--shc-blue); letter-spacing: .2px; }
h1 { font-size: 28px; line-height: 1.2; margin: 0; }
:focus-visible { outline: 2px solid var(--shc-blue); outline-offset: 2px; }

/* ---- Header: navy utility bar + white main band ---- */
.site-header { background: var(--shc-white); border-bottom: 1px solid var(--shc-line); }
.utility-bar { background: var(--shc-navy); color: #fff; font-size: 12.5px; }
.utility-inner, .band-inner { max-width: 1440px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; }
.utility-inner { min-height: 34px; gap: 18px; }
.utility-org { color: rgba(255,255,255,.75); letter-spacing: .3px; }
.utility-nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.utility-nav a { color: #fff; }
.utility-nav a:hover { color: var(--shc-teal); text-decoration: none; }
.utility-nav form { margin: 0; }
.nav-user { color: rgba(255,255,255,.85); padding-right: 18px; border-right: 1px solid rgba(255,255,255,.25); }
.util-btn { background: none; border: 0; padding: 0; margin: 0; color: #fff; font: inherit; cursor: pointer; }
.util-btn:hover { color: var(--shc-teal); }
.main-band { background: var(--shc-white); }
.band-inner { min-height: 84px; gap: 20px; }
.site-logo { display: flex; align-items: center; }
.site-logo img { height: 60px; width: auto; display: block; }
.site-title { font-family: var(--font-head); font-weight: 700; color: var(--shc-blue); font-size: 21px;
  padding-left: 20px; border-left: 1px solid var(--shc-line); line-height: 1.2; }
.site-nav { margin-left: auto; display: flex; align-items: stretch; align-self: stretch; gap: 4px; }
.site-nav a { display: flex; align-items: center; padding: 0 16px; color: var(--shc-text); font-weight: 700;
  font-size: 13.5px; text-transform: uppercase; letter-spacing: 1.2px; border-bottom: 3px solid transparent; }
.site-nav a:hover { color: var(--shc-blue); text-decoration: none; border-bottom-color: var(--shc-teal); }
.site-nav a.on { color: var(--shc-blue); border-bottom-color: var(--shc-blue); }
/* Transparency / acceptable-use notice band across the top of every authenticated page */
.transparency-bar { background: var(--info-bg); border-top: 1px solid var(--info-bd); border-bottom: 1px solid var(--info-bd); color: var(--shc-navy); }
.transparency-inner { max-width: 1440px; margin: 0 auto; padding: 7px 24px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; line-height: 1.35; }
.transparency-bar .tb-ico { font-size: 14px; color: var(--shc-blue); flex: 0 0 auto; }
.transparency-bar .tb-text { font-weight: 600; }
/* Same notice on the login card (header is suppressed there) */
.login-notice { display: flex; align-items: flex-start; gap: 8px; background: var(--info-bg);
  border: 1px solid var(--info-bd); border-radius: var(--radius); color: var(--shc-navy);
  padding: 10px 14px; font-size: 12.5px; line-height: 1.4; font-weight: 600; margin: 16px 0 4px; }
.login-notice .tb-ico { font-size: 14px; color: var(--shc-blue); flex: 0 0 auto; line-height: 1.4; }
@media (max-width: 720px) {
  .utility-org, .nav-user { display: none; }
  .site-title { font-size: 17px; }
  .band-inner { min-height: 70px; }
  .site-logo img { height: 48px; }
}
@media (max-width: 520px) { .site-title { display: none; } }

/* ---- Page frame ---- */
.wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px;
  background: var(--shc-panel); }
.card { background: var(--card); width: 100%; max-width: 480px; border: 1px solid var(--shc-line);
  border-top: 4px solid var(--shc-blue); border-radius: var(--radius-lg); padding: 30px 34px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.landing-card { max-width: 720px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brand-mark { background: var(--navy); color: #fff; font-weight: 700; width: 46px; height: 46px;
  display: flex; align-items: center; justify-content: center; font-size: 16px; }
.sub { margin: 4px 0 0; color: var(--shc-text); font-size: 13.5px; }
.lead { color: var(--shc-text); font-size: 16px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase; color: var(--shc-teal);
  margin-bottom: 8px; }
.muted { color: var(--shc-text-muted); }
.small { font-size: 12px; }
.foot { text-align: center; color: rgba(255,255,255,.8); font-size: 12px; padding: 16px; background: var(--shc-navy); }
.nonphi { color: #ffd0cb; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; }
code { font-size: 12px; background: var(--shc-panel); padding: 1px 5px; border-radius: var(--radius); }

/* ---- Forms ---- */
.form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
label { font-size: 13px; color: var(--shc-text); margin-top: 8px; font-weight: 700; }
input, select, textarea { font-family: var(--font-body); color: #333; }
input { padding: 10px 12px; border: 1px solid #c8c8c8; border-radius: var(--radius); font-size: 15px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--shc-blue);
  box-shadow: 0 0 0 3px rgba(0,83,149,.18); }

/* ---- Buttons (square, uppercase) ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  border-radius: var(--radius); cursor: pointer; font-family: var(--font-body); font-size: 13.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; padding: 12px 22px; margin-top: 16px; text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--shc-teal); border-color: var(--shc-teal); color: #fff; }
.btn-primary:hover { background: var(--shc-teal-dark); border-color: var(--shc-teal-dark); }
.btn-secondary { background: var(--shc-navy); border-color: var(--shc-navy); color: #fff; }
.btn-secondary:hover { background: var(--shc-navy-dark); }
.btn-ghost { background: #fff; color: var(--shc-blue); border-color: var(--shc-blue); margin-top: 0; }
.btn-ghost:hover { background: var(--shc-blue); color: #fff; }
.btn-sm { font-size: 11.5px; padding: 6px 12px; margin-top: 0; letter-spacing: .8px; }
.btn-danger { color: #b0281b; border-color: #b0281b; }
.btn-danger:hover { background: #b0281b; color: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-ms { width: 100%; }
.ms-logo { width: 16px; height: 16px; background:
  conic-gradient(#f25022 0 25%, #7fba00 0 50%, #ffb900 0 75%, #00a4ef 0); }

/* ---- Alerts / notices ---- */
.alert { border-radius: var(--radius); padding: 10px 14px; font-size: 13.5px; margin: 12px 0;
  border: 0; border-left: 4px solid; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-bd); color: #6f4e00; }
.alert-error { background: var(--err-bg); border-color: #b0281b; color: #8c1f14; }
.alert-info { background: var(--info-bg); border-color: var(--shc-blue); color: var(--shc-navy); }
.alert-ok { background: #e6f6f6; border-color: var(--shc-teal); color: #00605f; }

/* ---- Login ---- */
.login-card { max-width: 460px; padding: 38px 40px; }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { font-size: 30px; }
.login-logo { display: block; width: 220px; max-width: 72%; height: auto; margin: 4px auto 18px; }
@media (max-width: 520px) { .login-logo { width: 170px; } }

/* ---- Landing ---- */
.topbar { display: flex; justify-content: space-between; align-items: flex-start; }
.userbox { margin: 20px 0 10px; padding: 12px 16px; background: var(--shc-panel); border-left: 4px solid var(--shc-teal);
  font-size: 14px; }
.email { font-weight: 700; margin: 0 8px; color: #333; }
.role-pill, .badge { font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px; padding: 3px 8px;
  border-radius: var(--radius); font-weight: 700; }
.role-admin { background: var(--shc-navy); color: #fff; }
.role-user { background: var(--shc-panel); color: var(--shc-text); border: 1px solid var(--shc-line); }
.empty-state { margin-top: 18px; padding: 34px 20px; text-align: center; border: 1px dashed #c8c8c8;
  background: var(--shc-panel); }
.empty-state h2 { font-size: 20px; margin: 0 0 8px; }
.empty-state p { color: var(--shc-text); font-size: 14px; max-width: 420px; margin: 0 auto; }
.section-h { font-size: 19px; margin: 26px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--shc-line); }
.cap-list { display: grid; gap: 12px; }
.cap-card { display: block; padding: 16px 18px; border: 1px solid var(--shc-line); border-left: 4px solid var(--shc-teal);
  color: var(--shc-text); background: #fff; transition: border-color .15s, background-color .15s; }
.cap-card:hover { text-decoration: none; border-color: var(--shc-blue); border-left-color: var(--shc-blue); background: #f8fbfd; }
.cap-name { font-family: var(--font-head); font-weight: 700; color: var(--shc-blue); font-size: 18px; }
.cap-card:hover .cap-name::after { content: " →"; color: var(--shc-teal); }
.cap-desc { font-size: 14px; color: var(--shc-text); margin-top: 3px; }

/* ---- Chat ---- */
.chat-card { max-width: 860px; display: flex; flex-direction: column; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.nonphi-banner { margin: 6px 0 14px; }
.messages { border: 1px solid var(--shc-line); background: #fafafa; padding: 16px; min-height: 280px;
  display: flex; flex-direction: column; gap: 12px; }  /* flows with the page; the window scrolls, not this box */
.empty-chat { text-align: center; margin: auto; }
.msg { max-width: min(85%, 820px); padding: 10px 14px; border: 1px solid var(--shc-line); border-radius: var(--radius); }
.msg-user { align-self: flex-end; background: var(--info-bg); border-color: #c4d8ea; border-right: 3px solid var(--shc-blue); }
.msg-assistant { align-self: flex-start; background: #fff; border-left: 3px solid var(--shc-teal); }
.msg-error { align-self: flex-start; background: var(--err-bg); border-color: var(--err-bd); }
.msg-role { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--shc-blue); margin-bottom: 4px; }
.msg-assistant .msg-role { color: var(--shc-teal-dark); }
.msg-body { white-space: pre-wrap; word-wrap: break-word; font-size: 14.5px; line-height: 1.55; color: #3a3a3a; }
.msg-meta { font-size: 11px; color: var(--shc-text-muted); margin-top: 6px; }
.phi-warn { margin-top: 8px; padding: 6px 8px; font-size: 12px; font-weight: 700; background: var(--warn-bg);
  border-left: 3px solid var(--warn-bd); color: #6f4e00; }
/* Composer pinned to the bottom of the viewport while the page scrolls. Negative side/bottom
   margins cancel .card padding so it spans the card edge-to-edge and sits flush at its foot;
   it stays in normal flow, so the last message is never hidden behind it. */
.composer { position: sticky; bottom: 0; z-index: 20; background: var(--card);
  margin: 14px -34px -30px; padding: 4px 34px 16px; border-top: 1px solid var(--shc-line);
  box-shadow: 0 -6px 14px -8px rgba(0,0,0,.18); }
.chat-form { display: flex; gap: 10px; margin-top: 12px; align-items: stretch; }
.chat-form textarea { max-height: 40vh; }
.chat-form textarea { flex: 1; padding: 10px 12px; border: 1px solid #c8c8c8; border-radius: var(--radius);
  font-size: 14.5px; resize: vertical; }
.chat-form .btn { margin-top: 0; }

/* ---- Web search grounding ---- */
.web-toggle { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; color: #444; cursor: pointer; font-weight: 400; }
.web-toggle input { width: 16px; height: 16px; padding: 0; accent-color: var(--shc-teal); }
.sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--shc-line); font-size: 13px; }
.sources-h { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--shc-text); margin-bottom: 4px; }
.sources ol { margin: 0; padding-left: 20px; }
.sources a { color: var(--shc-blue); word-break: break-word; }
.web-note { margin-top: 8px; padding: 6px 8px; font-size: 12px; background: var(--info-bg);
  border-left: 3px solid var(--shc-blue); color: var(--shc-navy); }

/* ---- Increment 7: streaming + image mode ---- */
.msg.streaming .msg-body::after { content: "▍"; color: var(--shc-teal); animation: shc-blink 1s steps(2) infinite; }
@keyframes shc-blink { 50% { opacity: 0; } }
.mode-toggle { display: flex; gap: 0; margin-top: 12px; border: 1px solid var(--shc-teal); width: max-content; max-width: 100%; flex-wrap: wrap; }
.mode-toggle label { display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 13.5px; font-weight: 700;
  color: var(--shc-teal-dark); cursor: pointer; border-radius: var(--radius-sm); margin: 0; }
.mode-toggle label + label { border-left: 1px solid var(--shc-teal); }
.mode-toggle input { width: 14px; height: 14px; padding: 0; margin: 0; accent-color: var(--shc-teal); }
.mode-toggle label:has(input:checked) { background: var(--shc-teal); color: #fff; }
.mode-toggle label:has(input:checked) .muted { color: #e6fafa; }
.msg-image { margin-top: 2px; }
.msg-image img { display: block; max-width: min(100%, 512px); height: auto; border: 1px solid var(--shc-line); border-radius: var(--radius-sm); background: #f4f4f4; }
.img-tag { display: inline-block; padding: 1px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  background: var(--shc-teal); color: #fff; vertical-align: 1px; }
.img-thumb { display: block; max-width: 320px; height: auto; margin-top: 6px; border: 1px solid var(--shc-line); }

/* ---- Increment 9: attach-to-message file upload ---- */
.attach-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attach-bar input[type=file] { display: none; }
.attach-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13.5px; font-weight: 700;
  border: 1px solid var(--shc-blue); color: var(--shc-blue); background: #fff; border-radius: var(--radius-sm); cursor: pointer; margin: 0; }
.attach-btn:hover { background: var(--shc-blue); color: #fff; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; font-size: 12px; background: var(--info-bg);
  border-left: 3px solid var(--shc-blue); color: var(--shc-navy); border-radius: var(--radius-sm); max-width: 100%; word-break: break-all; }
.attach-chip.phi { border-left-color: var(--warn-bd); background: var(--warn-bg); color: #6f4e00; }
.attach-chip button { border: 0; background: none; color: var(--shc-navy); font-weight: 700; cursor: pointer; padding: 0 2px; margin: 0; font-size: 14px; line-height: 1; }
.attach-err { margin-top: 6px; padding: 6px 8px; font-size: 12px; font-weight: 700; background: #fdecea; border-left: 3px solid #b3261e; color: #7a1a14; }
.file-tag { display: inline-block; padding: 1px 6px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  background: var(--shc-blue); color: #fff; vertical-align: 1px; }

/* ---- Conversation sidebar ---- */
.wrap-chat { align-items: stretch; justify-content: center; padding: 24px 20px; }
.chat-layout { display: flex; gap: 20px; width: 100%; max-width: 1440px; align-items: flex-start; }
.chat-layout .chat-card { flex: 1; min-width: 0; max-width: none; }
.conv-sidebar { width: 280px; flex-shrink: 0; background: var(--shc-white); border: 1px solid var(--shc-line);
  border-top: 4px solid var(--shc-navy); padding: 14px 0 10px; position: sticky; top: 16px;
  max-height: calc(100vh - 160px); display: flex; flex-direction: column; }
.conv-sidebar form { margin: 0; }
.conv-sidebar > form { padding: 0 12px; }
.conv-new { width: 100%; margin-top: 0; }
.conv-h { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px; color: var(--shc-text);
  margin: 16px 14px 6px; }
.conv-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.conv-item { position: relative; display: flex; align-items: flex-start; border-left: 4px solid transparent; }
.conv-item:hover { background: var(--shc-panel); }
.conv-item.on { background: #e6f0f8; border-left-color: var(--shc-blue); }
.conv-link { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px 8px 8px 10px; color: #444; }
.conv-link:hover { text-decoration: none; }
.conv-link:focus-visible, .conv-menu summary:focus-visible { outline: 2px solid var(--shc-blue); outline-offset: -2px; }
.conv-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item.on .conv-title { font-weight: 700; color: var(--shc-blue); }
.conv-ts { font-size: 11px; color: var(--shc-text-muted); margin-top: 1px; }
.conv-item.on .conv-ts { color: var(--shc-teal-dark); }
.conv-menu summary { list-style: none; cursor: pointer; padding: 8px 10px; color: var(--shc-text-muted); font-weight: 700; user-select: none; }
.conv-menu summary::-webkit-details-marker { display: none; }
.conv-menu summary:hover, .conv-menu[open] summary { color: var(--shc-blue); background: #dde8f2; }
.conv-menu-body { position: absolute; right: 4px; top: 38px; z-index: 5; background: #fff; border: 1px solid var(--shc-line);
  border-top: 3px solid var(--shc-teal); box-shadow: 0 6px 18px rgba(0,48,87,.15); padding: 10px; width: 250px;
  display: flex; flex-direction: column; gap: 8px; }
.conv-rename { display: flex; gap: 6px; }
.conv-rename input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 13px; }
.conv-menu-body .btn { margin-top: 0; }
.conv-empty { padding: 8px 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 820px) {
  .chat-layout { flex-direction: column; align-items: stretch; }
  .conv-sidebar { width: 100%; position: static; max-height: 260px; }
}
@media (max-width: 600px) {
  .chat-card { padding: 20px 16px; }
  .composer { margin: 12px -16px -20px; padding: 4px 16px 12px; }
}

/* ---- Admin ---- */
.wrap-wide { align-items: flex-start; }
.admin-card { max-width: 1380px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  margin-bottom: 10px; border-bottom: 1px solid var(--shc-line); }
.admin-head h1 { padding-bottom: 10px; }
.admin-tabs { display: flex; gap: 0; flex-wrap: wrap; }
.admin-tabs a { padding: 10px 14px; color: var(--shc-text); font-size: 12.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.admin-tabs a:hover { color: var(--shc-blue); text-decoration: none; border-bottom-color: var(--shc-teal); }
.admin-tabs a.on { color: var(--shc-blue); border-bottom-color: var(--shc-blue); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.inline-form input, .inline-form select, select { padding: 7px 10px; border: 1px solid #c8c8c8; border-radius: var(--radius);
  font-size: 14px; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 6px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #fff;
  background: var(--shc-navy); padding: 9px 8px; font-weight: 700; }
.tbl td { border-bottom: 1px solid var(--shc-line); padding: 8px; vertical-align: top; word-break: break-word; color: #444; }
.tbl tr:nth-child(even) td { background: #fafafa; }
.tbl tr:hover td { background: #eef4f9; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tbl .actions form, .cell-form { margin: 0; }
.cell-form { margin-top: 6px; }
.nowrap { white-space: nowrap; }
.badge-active { background: #e6f6f6; color: #00605f; }
.badge-disabled { background: var(--err-bg); color: #8c1f14; }
.badge-implicit { background: var(--info-bg); color: var(--shc-navy); }
.badge-none { background: var(--shc-panel); color: var(--shc-text); }
/* ---- Audit log (Increment 13): roomy, scannable, never-cramped table ---- */
.tbl-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-top: 6px;
  border: 1px solid var(--shc-line); }
.tbl-scroll .tbl { margin-top: 0; }
.tbl-audit { min-width: 1080px; table-layout: fixed; font-size: 13.5px; }
.tbl-audit col.c-id { width: 64px; }
.tbl-audit col.c-ts { width: 108px; }
.tbl-audit col.c-user { width: 250px; }
.tbl-audit col.c-event { width: 170px; }
.tbl-audit col.c-detail { width: auto; }
.tbl-audit col.c-ip { width: 190px; }
.tbl-audit th { padding: 11px 12px; white-space: nowrap; }
.tbl-audit td { padding: 11px 12px; line-height: 1.45; border-bottom: 1px solid #e3e6ea; }
.tbl-audit tbody tr:nth-child(even) td { background: #f7f9fb; }
.tbl-audit tbody tr:hover td { background: #eef4f9; }
.tbl-audit .num { text-align: right; }
.tbl-audit .a-id { color: var(--shc-text-muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.tbl-audit .a-ts { font-variant-numeric: tabular-nums; word-break: normal; }
.tbl-audit .a-date { display: block; color: #333; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.tbl-audit .a-time { display: block; color: var(--shc-text-muted); font-size: 12px; white-space: nowrap; }
.tbl-audit .a-user span[title] { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; }
.tbl-audit .a-event code { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  vertical-align: top; background: #e8f1f8; color: var(--shc-navy); border-left: 3px solid var(--shc-teal);
  padding: 2px 7px; font-size: 12px; }
.tbl-audit .a-ip { word-break: normal; overflow-wrap: normal; }
.tbl-audit .ip { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px; color: #333; font-variant-numeric: tabular-nums;
  /* No break opportunities inside an address: IPv4 always one line; IPv6 / proxied lists wrap only at the
     <wbr> the template inserts after ':' and ', ' (never mid-group). */
  white-space: normal; word-break: keep-all; overflow-wrap: normal; }
.tbl-audit .a-detail { word-break: normal; overflow-wrap: anywhere; }
/* ---- Usage "Recent messages" (Increment 20): fixed columns, no mid-word breaks, 2-line preview ---- */
.tbl-recent { min-width: 980px; table-layout: fixed; font-size: 13.5px; }
.tbl-recent col.c-ts { width: 104px; }
.tbl-recent col.c-user { width: 236px; }
.tbl-recent col.c-role { width: 96px; }
.tbl-recent col.c-preview { width: auto; }
.tbl-recent col.c-tok { width: 78px; }
.tbl-recent col.c-phi { width: 78px; }
.tbl-recent col.c-view { width: 60px; }
.tbl-recent th { padding: 10px 12px; white-space: nowrap; }
.tbl-recent td { padding: 10px 12px; line-height: 1.45; vertical-align: top; word-break: normal; border-bottom: 1px solid #e3e6ea; }
.tbl-recent tbody tr:nth-child(even) td { background: #f7f9fb; }
.tbl-recent tbody tr:hover td { background: #eef4f9; }
.tbl-recent .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-recent .a-date { display: block; color: #333; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.tbl-recent .a-time { display: block; color: var(--shc-text-muted); font-size: 12px; white-space: nowrap; }
.tbl-recent .r-user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #333; }
.tbl-recent .r-preview { overflow-wrap: anywhere; color: #3a3a3a; }
.tbl-recent .preview-clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.tbl-recent .r-tok { color: #555; white-space: nowrap; }
.tbl-recent .r-view { white-space: nowrap; text-align: right; }
.tbl-recent .r-view a { font-weight: 700; }
.role-chip { display: inline-block; padding: 1px 7px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; white-space: nowrap; border-left: 3px solid var(--shc-teal); background: #e8f1f8; color: var(--shc-navy); }
.role-chip.role-user { border-left-color: var(--shc-blue); background: var(--shc-panel); color: #444; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); column-gap: 10px; row-gap: 3px; margin: 0; font-size: 12.5px; }
.kv dt { color: var(--shc-text-muted); font-weight: 700; white-space: nowrap; }
.kv dd { margin: 0; color: #3a3a3a; min-width: 0; }
.kv-more summary { cursor: pointer; list-style: none; }
.kv-more summary::-webkit-details-marker { display: none; }
.kv-more-lbl { color: var(--shc-blue); font-weight: 700; white-space: nowrap; }
.kv-more-lbl::after { content: "show all (" attr(data-n) " chars)"; }
.kv-more[open] .kv-prev { display: none; }
.kv-more[open] .kv-more-lbl::after { content: "hide"; }
.kv-full { white-space: pre-wrap; max-height: 260px; overflow: auto; padding: 6px 8px; background: #f6f8fa;
  border-left: 3px solid var(--shc-teal); font-size: 12px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 10px 0 4px; }
.stat { border: 1px solid var(--shc-line); border-top: 3px solid var(--shc-teal); padding: 12px 14px; background: #fff; }
.stat-n { font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--shc-blue); }
.stat-warn { color: #b0281b; }
.stat-l { font-size: 11px; color: var(--shc-text); text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.messages-tall { max-height: none; }

/* ---- Increment 11: collaborative image creation ---------------------------- */
.cap-banner { display: flex; align-items: flex-start; gap: 10px; margin: 10px 0 0; padding: 8px 12px;
  border: 1px solid var(--shc-teal); border-left: 4px solid var(--shc-teal); background: #effafa;
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--shc-navy); }
.cap-banner-tag { flex: none; background: var(--shc-teal); color: #fff; font-weight: 700; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 1px; padding: 2px 7px; margin-top: 1px; }
.cap-banner-text { flex: 1; line-height: 1.45; }
.cap-banner-x { flex: none; background: none; border: 0; color: var(--shc-blue); font-size: 18px; line-height: 1;
  cursor: pointer; padding: 0 2px; border-radius: var(--radius-sm); }
.cap-banner.compact { padding: 4px 10px; }
.cap-banner.compact .cap-banner-text, .cap-banner.compact .cap-banner-x { display: none; }
.cap-banner.compact .cap-banner-tag::after { content: " · " attr(data-model); }
.img-model-sub { color: var(--shc-teal); font-weight: 700; }
/* Increment 21: composer action row is horizontal — primary button expands, Attach/Search collapse
   to compact icon affordances, Options stays compact at the end. */
.form-actions { display: flex; flex-direction: row; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.form-actions .btn { margin-top: 0; }
.form-actions > .btn-primary { flex: 1 1 140px; }
.form-actions .opts { flex: 0 0 auto; }
.form-actions .opts-btn { flex: 0 0 auto; }
/* Icon affordances (📎 attach, 🌐 web-search toggle) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 42px; margin: 0;
  padding: 0 10px; font-size: 18px; line-height: 1; color: var(--shc-navy); background: #fff;
  border: 1px solid var(--shc-line); border-radius: var(--radius-sm); cursor: pointer; }
.icon-btn:hover { border-color: var(--shc-blue); color: var(--shc-blue); }
.icon-toggle { display: inline-flex; margin: 0; flex: 0 0 auto; cursor: pointer; }
.icon-toggle input:checked + .icon-btn { background: var(--shc-teal); border-color: var(--shc-teal); color: #fff; }
.icon-btn:focus-within, .icon-toggle input:focus-visible + .icon-btn { outline: 2px solid var(--shc-blue); outline-offset: 2px; }
.btn-image { background: #fff; color: var(--shc-blue); border: 2px solid var(--shc-teal); border-radius: var(--radius-sm); white-space: nowrap; }
.btn-image:hover:not(:disabled) { background: var(--shc-teal); color: #fff; }
.btn-image:disabled { opacity: .6; cursor: default; }
.img-size-field { display: flex; align-items: center; gap: 8px; }
.img-size-field > span { flex: 0 0 auto; }
.img-size-select { flex: 1; padding: 6px 8px; border: 1px solid var(--shc-teal); border-radius: var(--radius-sm); background: #fff; color: #222; font-family: var(--font-body); font-size: 13.5px; cursor: pointer; }
.ctx-toggle { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13.5px; color: #444; font-weight: 400; cursor: pointer; }
.ctx-toggle input { width: 15px; height: 15px; padding: 0; accent-color: var(--shc-teal); }
.msg-actions { margin-top: 6px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--shc-blue); font-family: var(--font-body);
  font-size: 12.5px; font-weight: 700; cursor: pointer; border-radius: var(--radius-sm); }
.link-btn:hover { color: var(--shc-teal); text-decoration: underline; }
.prompt-used { margin-top: 6px; font-size: 12.5px; color: #444; }
.prompt-used summary { cursor: pointer; color: var(--shc-blue); font-weight: 700; }
.prompt-used-body { margin-top: 4px; padding: 6px 8px; border-left: 3px solid var(--shc-teal); background: #f6f8fa; white-space: pre-wrap; }
.models-tbl code.model-name { font-weight: 700; color: var(--shc-navy); }

/* ---- Increment 16: ChatGPT-like polish ---- */
/* Onboarding empty state */
.welcome { text-align: center; max-width: 560px; padding: 18px 8px; }
.welcome-h { margin: 0 0 6px; font-size: 24px; }
.welcome-sub { margin: 0 0 6px; color: var(--shc-text); font-size: 14.5px; }
.welcome-phi { display: inline-block; margin: 4px 0 16px; padding: 4px 10px; font-size: 12.5px; color: #6f4e00;
  background: var(--warn-bg); border-left: 3px solid var(--warn-bd); }
.starters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; text-align: left; }
.starter { padding: 10px 12px; border: 1px solid var(--shc-line); border-left: 3px solid var(--shc-teal); background: #fff;
  color: #3a3a3a; font-family: var(--font-body); font-size: 13.5px; cursor: pointer; border-radius: var(--radius-sm); line-height: 1.35; }
.starter:hover, .starter:focus-visible { border-color: var(--shc-blue); border-left-color: var(--shc-blue); background: #f8fbfd; }
@media (max-width: 520px) { .starters { grid-template-columns: 1fr; } }

/* Rendered (sanitized) Markdown in assistant replies */
.msg-body.md { white-space: normal; }
.msg-body.md > :first-child { margin-top: 0; }
.msg-body.md > :last-child { margin-bottom: 0; }
.msg-body.md p { margin: 0 0 .7em; }
.msg-body.md h1, .msg-body.md h2, .msg-body.md h3, .msg-body.md h4, .msg-body.md h5, .msg-body.md h6 {
  font-family: var(--font-body); color: var(--shc-navy); margin: 1em 0 .4em; line-height: 1.3; letter-spacing: 0; }
.msg-body.md h1 { font-size: 1.3em; } .msg-body.md h2 { font-size: 1.2em; } .msg-body.md h3 { font-size: 1.08em; }
.msg-body.md h4, .msg-body.md h5, .msg-body.md h6 { font-size: 1em; }
.msg-body.md ul, .msg-body.md ol { margin: 0 0 .7em; padding-left: 1.5em; }
.msg-body.md li { margin: .2em 0; }
.msg-body.md li > p { margin: 0 0 .3em; }
.msg-body.md blockquote { margin: 0 0 .7em; padding: 4px 12px; border-left: 3px solid var(--shc-line); color: #555; }
.msg-body.md code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em;
  background: #f1f3f5; padding: 1px 5px; }
.msg-body.md pre { margin: 0 0 .7em; padding: 10px 12px; background: #f6f8fa; border: 1px solid var(--shc-line);
  overflow-x: auto; white-space: pre; }
.msg-body.md pre code { background: none; padding: 0; font-size: 13px; }
.msg-body.md table { border-collapse: collapse; margin: 0 0 .7em; font-size: 13.5px; display: block; overflow-x: auto; max-width: 100%; }
.msg-body.md th, .msg-body.md td { border: 1px solid var(--shc-line); padding: 5px 9px; text-align: left; vertical-align: top; }
.msg-body.md th { background: var(--shc-panel); color: var(--shc-navy); }
.msg-body.md hr { border: 0; border-top: 1px solid var(--shc-line); margin: 1em 0; }
.msg-body.md a { color: var(--shc-blue); text-decoration: underline; word-break: break-word; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 14px; }

/* Stop button while a reply is generating */
.btn.btn-stop { background: #fff; color: var(--shc-navy); border-color: var(--shc-navy); }
.btn.btn-stop:hover { background: var(--shc-navy); color: #fff; }

/* Options expander (advanced selectors) */
.opts { position: relative; display: flex; }
.opts-btn { flex: 1; margin-top: 0; background: #fff; color: var(--shc-text); border: 1px solid var(--shc-line);
  font-size: 12.5px; white-space: nowrap; }
.opts-btn:hover, .opts-btn[aria-expanded="true"] { color: var(--shc-blue); border-color: var(--shc-blue); }
.opts-panel { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 30; width: 300px; max-width: 80vw;
  display: flex; flex-direction: column; gap: 10px; padding: 12px; background: #fff; border: 1px solid var(--shc-line);
  border-top: 3px solid var(--shc-teal); box-shadow: 0 6px 18px rgba(0,0,0,.14); }
.opts-panel[hidden] { display: none; }
.opts-panel .img-size-field { margin: 0; justify-content: space-between; }
.opts-panel .img-size-field > span { min-width: 88px; }
.opts-panel .img-size-field > select { flex: 1 1 auto; min-width: 0; width: 100%; max-width: 190px; }

/* ---- Increment 17: Copy as a prominent upper-right button on assistant replies ---- */
.msg-assistant { position: relative; }
.msg-assistant.has-copy { min-width: 210px; }
.msg-assistant.has-copy .msg-role { padding-right: 88px; min-height: 24px; display: flex; align-items: center; margin-bottom: 4px; }
.copy-btn { position: absolute; top: 7px; right: 8px; z-index: 2; display: inline-flex; align-items: center; gap: 5px;
  margin: 0; padding: 3px 10px 3px 8px; font-family: var(--font-body); font-size: 12px; font-weight: 700; line-height: 1.4;
  color: var(--shc-navy); background: #fff; border: 1px solid var(--shc-teal); border-radius: 999px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); transition: background-color .12s, color .12s, border-color .12s; }
.copy-btn:hover { background: var(--shc-teal); border-color: var(--shc-teal); color: #fff; }
.copy-btn:focus-visible { outline: 2px solid var(--shc-blue); outline-offset: 2px; }
.copy-btn .copy-ico { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
.copy-btn.copied { background: var(--shc-teal-dark); border-color: var(--shc-teal-dark); color: #fff; }
.copy-btn.copy-err { background: var(--err-bg); border-color: #b0281b; color: #8c1f14; }
@media (max-width: 520px) {
  .copy-btn { top: 6px; right: 6px; padding: 3px 8px 3px 7px; }
  .msg-assistant.has-copy { min-width: 180px; }
}


/* ---- Increment 18: floating scroll-to-top / scroll-to-bottom (window scrolls; JS sets right/bottom
   so the pair hugs the message area's right edge just above the sticky composer). ---- */
.scroll-nav { position: fixed; right: 16px; bottom: 120px; z-index: 25; display: flex; flex-direction: column; gap: 6px; }
.scroll-nav--page { bottom: 24px; }  /* admin activity pages have no sticky composer to clear */
.scroll-nav[hidden], .scroll-btn[hidden] { display: none; }
.scroll-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; margin: 0; padding: 0;
  color: var(--shc-navy); background: #fff; border: 1px solid var(--shc-teal); border-radius: 999px; cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.14); transition: background-color .12s, color .12s, border-color .12s; }
.scroll-btn:hover { background: var(--shc-teal); border-color: var(--shc-teal); color: #fff; }
.scroll-btn:focus-visible { outline: 2px solid var(--shc-blue); outline-offset: 2px; }
.scroll-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 520px) {
  .scroll-btn { width: 40px; height: 40px; }  /* comfortable touch target */
}
@media print { .scroll-nav { display: none !important; } }


/* ---- Increment 21: Images studio + gallery ---- */
.studio-layout { width: 100%; max-width: 1440px; margin: 0 auto; }
.studio-card { max-width: 1180px; margin: 0 auto; }
.studio-card .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.studio-card .topbar form { margin: 0; }
.gallery { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--shc-line); }
.gallery-h { font-size: 18px; margin: 0 0 2px; color: var(--shc-navy); }
.gallery-sub { margin: 0 0 12px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.gallery-item { margin: 0; border: 1px solid var(--shc-line); background: #fff; display: flex; flex-direction: column; }
.gallery-img { display: block; background: #f4f4f4; }
.gallery-img img { display: block; width: 100%; height: 200px; object-fit: contain; }
.gallery-cap { padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.gallery-prompt { color: #3a3a3a; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; }
.gallery-by { color: var(--shc-teal-dark); }
.gallery-actions { display: flex; align-items: center; gap: 14px; margin-top: 2px; }
.gallery-actions .link-btn { font-size: 12.5px; }
.gallery-del { margin: 0; }
.link-btn.btn-danger { color: #b0281b; }
.link-btn.btn-danger:hover { color: #8c1f14; }
.gallery-empty { margin-top: 8px; }

/* Narrow screens: both composers (Chat + Images studio) stack — the prompt gets the full width on
   top and the action row becomes a single strip beneath it (Send expands, icons/Options stay compact).
   Previously the side-by-side row let the wrapping action group claim nearly all the width,
   squeezing the textarea to ~25px. 16px text also stops iOS Safari zooming on focus. */
@media (max-width: 600px) {
  .chat-form { flex-direction: column; gap: 8px; margin-top: 10px; }
  .chat-form textarea { width: 100%; min-height: 76px; max-height: 35vh; font-size: 16px; resize: none; }
  .form-actions { flex-wrap: nowrap; gap: 6px; }
  .form-actions > .btn-primary { flex: 1 1 auto; min-width: 0; padding: 10px 12px; }
  .form-actions .icon-btn { width: 44px; padding: 0; }
  .form-actions .opts-btn { padding: 10px 12px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .gallery-img img { height: 150px; }
}

/* ---- Increment 22: compact capability grants matrix ---- */
.tbl-scroll { overflow-x: auto; }
.tbl-caps { table-layout: auto; }
.tbl-caps th, .tbl-caps td { padding: 7px 8px; }
.tbl-caps thead th.cap-col { font-size: 11.5px; line-height: 1.25; white-space: normal;
  vertical-align: bottom; text-align: center; min-width: 76px; max-width: 110px; }
.tbl-caps td.cap-cell { text-align: center; vertical-align: middle; }
.tbl-caps td.cap-cell form { margin: 0; display: inline; }
.tbl-caps .cap-user { min-width: 200px; }
/* single compact toggle per cell; colour + glyph carry the state, attribution is in the tooltip */
.capx { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 26px;
  font-size: 14px; font-weight: 700; line-height: 1; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--shc-line); background: #fff; color: var(--shc-text-muted); padding: 0; margin: 0; }
.capx.on { background: var(--shc-teal); border-color: var(--shc-teal); color: #fff; }
.capx.on:hover { background: var(--shc-teal-dark); border-color: var(--shc-teal-dark); }
.capx.off:hover { border-color: var(--shc-teal); color: var(--shc-teal-dark); background: #f3fbfb; }
.capx.imp { cursor: default; border-style: dashed; background: var(--shc-panel); color: var(--shc-text-muted); }
.capx:focus-visible { outline: 2px solid var(--shc-blue); outline-offset: 1px; }
.cap-legend { width: 22px; height: 18px; font-size: 11px; vertical-align: middle; cursor: default; }

/* ===== Increment 24: admin Usage/Audit filter bar, clickable stats, CSV export ===== */
.filter-bar { border: 1px solid var(--shc-line); background: var(--shc-panel); padding: 10px 12px 6px; margin: 10px 0 12px; }
.fb-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.fb-presets { margin-bottom: 8px; }
.fb-pill { display: inline-block; padding: 5px 11px; border: 1px solid var(--shc-line); background: #fff; color: var(--shc-blue);
  font-size: 12.5px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.fb-pill:hover { border-color: var(--shc-blue); text-decoration: none; }
.fb-pill.on { background: var(--shc-blue); border-color: var(--shc-blue); color: #fff; }
.fb-pill:focus-visible, .stat-link:focus-visible, .fs-chip:focus-visible, .export-btn:focus-visible
  { outline: 3px solid var(--shc-teal); outline-offset: 2px; }
.fb-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .6px; color: var(--shc-text); }
.fb-field input, .fb-field select { margin: 0; padding: 6px 8px; font-size: 13.5px; height: 34px; min-width: 0;
  border: 1px solid var(--shc-line); background: #fff; font-family: var(--font-body); text-transform: none; letter-spacing: 0; }
.fb-field input[type=date] { width: 150px; }
.fb-user input { width: 220px; }
.fb-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.fb-actions .btn { height: 34px; }
.export-btn { background: #fff; color: var(--shc-navy); border-color: var(--shc-navy); }
.export-btn:hover { background: var(--shc-navy); color: #fff; }
.filter-window { margin: 8px 0 2px; color: var(--ink); }

/* Clickable stat boxes vs. plain KPI totals */
a.stat-link { display: block; color: inherit; text-decoration: none; cursor: pointer; position: relative;
  transition: border-color .15s, box-shadow .15s, background-color .15s; }
a.stat-link::after { content: "▸"; position: absolute; top: 8px; right: 10px; color: var(--shc-teal); font-size: 13px; }
a.stat-link:hover { border-color: var(--shc-teal); box-shadow: 0 2px 8px rgba(0, 48, 87, .12); text-decoration: none; }
a.stat-link.on { background: #e6f7f7; border-color: var(--shc-teal-dark); border-top-color: var(--shc-teal-dark);
  box-shadow: inset 0 0 0 1px var(--shc-teal-dark); }
a.stat-link.on::after { content: "✓"; color: var(--shc-teal-dark); }
.stat-kpi { background: var(--shc-panel); border-top: 3px solid var(--shc-text-muted); cursor: default; }
.stat-kpi .stat-n { color: var(--shc-navy); }
.stats-hint { margin: 4px 0 0; }
.filter-chip { display: inline-flex; flex-wrap: wrap; gap: 10px; align-items: center; background: #e6f7f7;
  border: 1px solid var(--shc-teal); padding: 6px 10px; margin: 0 0 8px; font-size: 13px; }
.filter-chip a { font-weight: 700; }
.filter-summary { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; font-size: 12.5px; }
.fs-total { margin-right: 6px; }
.fs-chip { border: 1px solid var(--shc-line); background: #fff; padding: 2px 8px; color: var(--ink); text-decoration: none; }
.fs-chip:hover { border-color: var(--shc-blue); text-decoration: none; }
.fs-chip.on { border-color: var(--shc-blue); background: var(--info-bg); }

@media (max-width: 600px) {
  .filter-bar { padding: 8px; }
  .fb-presets { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .fb-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .fb-fields > * { min-width: 0; }
  .fb-field input, .fb-field input[type=date], .fb-user input, .fb-field select { width: 100%; max-width: 100%; }
  .fb-user, .fb-actions, .fb-field:has(select) { grid-column: 1 / -1; }
  .fb-actions { margin-left: 0; display: grid; grid-template-columns: 1fr 1fr; }
  .fb-actions .export-btn { grid-column: 1 / -1; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-n { font-size: 22px; }
}
/* Contain absolutely-positioned .sr-only cells inside scrolling tables: without this the
   "Open" header label escaped the scroller and widened the mobile Usage page to ~990px. */
.tbl-scroll { position: relative; }

/* Increment 25: estimated cost + admin Rates page */
.cost-note { margin: 2px 0 14px; }
.rate-unset { color: #b0281b; font-size: 12.5px; white-space: nowrap; }
.rates-intro { max-width: 900px; margin-bottom: 12px; }
.rates-refresh { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 6px 0 4px; }
.tbl-rates .rate-in { width: 92px; text-align: right; padding: 4px 6px; font: inherit; font-size: 13px; }
.tbl-rates .note-in { width: 160px; padding: 4px 6px; font: inherit; font-size: 13px; }
.tbl-rates td { vertical-align: middle; }



/* ---- Saved memories (increment 26) ------------------------------------- */
.memory-card { max-width: 820px; }
.memory-intro { max-width: 760px; margin-bottom: 16px; }
.memory-add textarea,
.memory-edit-form textarea {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 14px;
  padding: 8px 10px; border: 1px solid var(--shc-line); border-radius: var(--radius);
  background: var(--shc-white); color: var(--shc-text); resize: vertical;
}
.memory-add { margin-bottom: 20px; }
.memory-add .section-h { display: block; margin-bottom: 6px; }
.memory-add .form-actions,
.memory-edit-form .form-actions {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px;
}
.memory-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.memory-item {
  border: 1px solid var(--shc-line); border-radius: var(--radius);
  padding: 12px 14px; background: var(--shc-white);
}
.memory-item.mem-off { opacity: 0.6; }
.memory-item-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.memory-content { white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; color: var(--shc-text); }
/* Admin memory table: fixed layout so the Memory column absorbs the slack (no dead gap) and
   clamps long text to 2 lines; full content shows on hover (title attr). Mirrors .tbl-recent. */
.tbl-memory { min-width: 900px; table-layout: fixed; }
.tbl-memory col.c-user { width: 240px; }
.tbl-memory col.c-mem { width: auto; }
.tbl-memory col.c-status { width: 96px; }
.tbl-memory col.c-source { width: 78px; }
.tbl-memory col.c-added { width: 100px; }
.tbl-memory col.c-edited { width: 100px; }
.tbl-memory .mem-text { cursor: help; overflow-wrap: anywhere; }
.tbl-memory .mem-text .preview-clamp { display: -webkit-box; -webkit-box-orient: vertical;
  -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.memory-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; }
.memory-actions form { margin: 0; }
.memory-edit { flex: 0 0 auto; }
.memory-edit > summary { list-style: none; cursor: pointer; display: inline-block; }
.memory-edit > summary::-webkit-details-marker { display: none; }
.memory-edit[open] { flex: 1 1 100%; }
.memory-edit-form { margin-top: 8px; }


/* ---- Memory split (increment 27) --------------------------------------- */
.memory-tips { margin: 0 0 16px; }
.memory-split-box { margin-top: 8px; }
.memory-split-box textarea { width: 100%; box-sizing: border-box; }
.split-proposed .split-item { display: block; }
.split-proposed .split-item textarea { width: 100%; box-sizing: border-box; }
.split-proposed .split-item .form-actions { justify-content: flex-end; }
.memory-split-confirm { justify-content: flex-end; gap: 10px; margin-top: 12px; }
.memory-split-llm { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--shc-line); }
.memory-split-llm form { margin: 0; }


/* ---- Increment 28: automatic memory candidates (review) + global on/off ---- */
/* Pending-count badge on the Memory nav link. */
.nav-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px;
  height: 18px; padding: 0 5px; margin-left: 2px; border-radius: 9px; background: var(--shc-blue);
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }

/* Global memory on/off selector near the top of the Memory page. */
.memory-settings { margin: 4px 0 20px; padding: 14px 16px; background: var(--shc-panel);
  border-left: 4px solid var(--shc-teal); border-radius: var(--radius); }
.memory-settings.is-off { border-left-color: var(--warn-bd); }
.memory-settings-form { margin: 0; }
.memory-settings-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.memory-settings-row .section-h { display: block; margin: 0 0 2px; }
.memory-settings .muted.small { margin: 0; }

/* Toggle switch. */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider { position: absolute; cursor: pointer; inset: 0; background: #bcbcbc;
  border-radius: 26px; transition: background .15s ease; }
.switch-slider::before { content: ""; position: absolute; height: 20px; width: 20px; left: 3px;
  bottom: 3px; background: #fff; border-radius: 50%; transition: transform .15s ease; }
.switch input:checked + .switch-slider { background: var(--shc-teal); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }
.switch input:focus-visible + .switch-slider { outline: 2px solid var(--shc-blue); outline-offset: 2px; }

/* Pending-review section: visually distinct from saved memories. */
.pending-review { margin: 0 0 22px; padding: 16px; border: 1px solid var(--shc-teal);
  border-radius: var(--radius); background: #f4fbfb; }
.pending-review .section-h { margin-top: 0; }
.pending-item { border-left: 3px solid var(--shc-teal); }
.pending-item .pending-approve { margin: 8px 0 6px; }
.pending-item .pending-approve textarea { width: 100%; box-sizing: border-box; }
.pending-item .pending-approve .form-actions { justify-content: flex-end; }
.pending-item .pending-dismiss { margin: 0; }
.badge-pending { background: #e6f6f6; color: #00605f; }

/* Subtle inline notice under an assistant reply when a candidate was proposed this turn. */
.memory-notice { margin-top: 8px; padding: 6px 8px; font-size: 12px; background: #f4fbfb;
  border-left: 3px solid var(--shc-teal); color: var(--shc-text); border-radius: 3px; }
.memory-notice a { font-weight: 700; }
