/* MunimenStack chat UI -- single-file vanilla styles.
   Palette + typography are sourced from the Stitch "Technical Precision"
   design system (see stitch_munimstack_chat_enhancement/technical_precision/
   DESIGN.md). Page chrome (top app bar, sidebar, sticky composer, dashboard
   cards, settings cards) is rendered with Tailwind via CDN; this file
   styles the dynamic content emitted at runtime by app.js / admin.js /
   reports.js (chat bubbles, KPI bars, admin tables, status pills, the
   inline settings dialog, etc.). */

/* Enforce the HTML `hidden` attribute over later author rules that set
   `display: flex` on the same element (e.g. `.dashboard`, `.btn`). Without
   this, gated panels like `#operator` and the auth-login/logout buttons
   leak through their `hidden` state on first render. */
[hidden] {
  display: none !important;
}

:root {
  /* Stitch "Technical Precision" tokens (subset; see DESIGN.md frontmatter). */
  --bg: #f9f9ff;           /* surface                     */
  --bg-2: #ffffff;         /* surface-container-lowest    */
  --bg-3: #f1f3ff;         /* surface-container-low       */
  --bg-4: #e9edff;         /* surface-container           */
  --bg-5: #e1e8fd;         /* surface-container-high      */
  --line: #c3c6d7;         /* outline-variant             */
  --line-strong: #737686;  /* outline                     */
  --fg: #141b2b;           /* on-surface                  */
  --fg-soft: #434655;      /* on-surface-variant          */
  --fg-dim: #737686;       /* outline                     */
  --fg-faint: #c3c6d7;     /* outline-variant             */
  --accent: #2563eb;       /* primary-container (action)  */
  --accent-hover: #004ac6; /* primary (deeper)            */
  --accent-soft: #eef0ff;  /* primary tint                */
  --accent-soft-line: #dbe1ff; /* primary-fixed           */
  --accent-fg: #ffffff;    /* on-primary                  */
  --danger: #ba1a1a;       /* error                       */
  --danger-soft: #ffdad6;  /* error-container             */
  --good: #006c49;         /* secondary                   */
  --good-soft: #6cf8bb;    /* secondary-container         */
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --ink: #141b2b;
  --ink-hover: #293040;    /* inverse-surface             */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --space: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.10);
  --font-sans:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono:
    "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

::selection {
  background: var(--accent);
  color: var(--accent-fg);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-3);
  color: var(--fg-soft);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ------------ Top app bar (Stitch "Technical Precision" chrome) ------------
   Used by reports.html / admin.html. The chat page (index.html) styles its
   own header inline with Tailwind classes since it also needs a flexible
   sidebar shell. Visually consistent with both. */
.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 50;
}

.has-app-bar {
  padding-top: 64px;
}

.app-bar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.app-bar-brand-icon {
  color: var(--accent);
  font-size: 24px;
}

.app-bar-brand-text {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.app-bar-brand-text .app-bar-brand-accent {
  color: var(--accent);
}

.app-bar-brand-sub {
  color: var(--fg-dim);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--line);
}

.app-bar-nav {
  display: none;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
}

@media (min-width: 768px) {
  .app-bar-nav {
    display: flex;
  }
}

.app-bar-link {
  text-decoration: none;
  color: var(--fg-soft);
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: background-color 120ms ease, color 120ms ease;
}

.app-bar-link:hover {
  background: var(--bg-3);
  color: var(--fg);
}

.app-bar-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ----- Phase 8b apex client picker -----
   Mounted into #client-picker-mount on apex pages (index/admin/reports)
   when the caller is a Platform Admin. Hidden by default in HTML; the
   JS flips `hidden` off after /api/me resolves. Tailwind is only loaded
   by index.html, so we style the select with a semantic class so it
   looks consistent on admin.html / reports.html too. */
.client-picker-mount {
  display: inline-flex;
  align-items: center;
}

.client-picker-mount[hidden] {
  display: none;
}

.client-picker-select {
  appearance: none;
  -webkit-appearance: none;
  background-color: var(--surface, #ffffff);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px 16px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  color: var(--fg, #0f172a);
  font: 500 13px/1 "Inter", system-ui, sans-serif;
  padding: 7px 30px 7px 12px;
  max-width: 240px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.client-picker-select:hover:not(:disabled) {
  border-color: var(--accent, #2563eb);
}

.client-picker-select:focus-visible {
  outline: none;
  border-color: var(--accent, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.client-picker-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--fg-faint);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.04);
}

.dot.ok {
  background: var(--good);
}

.dot.warn {
  background: var(--warn);
}

.dot.err {
  background: var(--danger);
}

.auth-user {
  color: var(--fg-dim);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------ Buttons ------------ */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    box-shadow 120ms ease;
}

.btn:hover {
  background: var(--bg);
  border-color: var(--line-strong);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-soft);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--bg-3);
  border-color: transparent;
  color: var(--accent);
}

.btn-icon {
  padding: 4px 10px;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
}

/* ------------ Chat area ------------ */
.chat-main {
  overflow-y: auto;
  padding: 32px 20px;
  background: var(--bg);
}

.empty-state {
  max-width: 580px;
  margin: 12vh auto 0;
  text-align: center;
}

.empty-state h1 {
  font-weight: 800;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
  color: var(--fg);
}

.empty-state p {
  color: var(--fg-dim);
  font-size: 15px;
  line-height: 1.6;
}

.empty-state-cta {
  margin-top: 28px;
}

.messages {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 780px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  padding: 16px 20px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg-5);
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: var(--shadow-sm);
  font-size: 16px;
  line-height: 1.5;
}

/* User bubble: solid primary-container with the top-right corner pinned to
   visually anchor the bubble against an avatar placed on its right edge. */
.msg-user {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  align-self: flex-end;
  max-width: 85%;
  border-top-right-radius: 4px;
  box-shadow: var(--shadow-soft);
}

/* AI bubble: surface-container-high with the top-left corner pinned to
   visually anchor the bubble against an avatar on its left edge. */
.msg-assistant {
  align-self: flex-start;
  max-width: 90%;
  border-top-left-radius: 4px;
  background: var(--bg-5);
}

.msg-meta {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--fg-dim);
  font-size: 12px;
  font-family: var(--font-mono);
}

.msg-meta .tag {
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--fg-soft);
}

.msg-meta .tag.redacted {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: rgba(217, 119, 6, 0.35);
}

/* Observation-mode counterpart of `.tag.redacted`. Same shape but a
   blue/info treatment to read as "we saw it but didn't substitute"
   rather than the amber "redacted" tag. */
.msg-meta .tag.detected {
  color: #1e3a8a; /* blue-900 */
  background: #dbeafe; /* blue-100 */
  border-color: rgba(37, 99, 235, 0.35);
}

.msg-error {
  border-color: rgba(185, 28, 28, 0.35);
  background: var(--danger-soft);
  color: var(--danger);
}

.msg-error .btn {
  margin-left: 8px;
  vertical-align: middle;
}

.msg-billing-note {
  display: block;
  margin-top: 6px;
  color: var(--fg-dim);
  font-size: 12px;
}

.cursor {
  display: inline-block;
  width: 6px;
  height: 14px;
  background: var(--fg);
  vertical-align: text-bottom;
  margin-left: 1px;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* ------------ Composer ------------ */
.composer {
  display: flex;
  gap: 10px;
  padding: 14px 20px 20px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  align-items: flex-end;
  position: sticky;
  bottom: 0;
}

.prompt {
  flex: 1;
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  resize: none;
  font: inherit;
  max-height: 200px;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.prompt:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.prompt[disabled] {
  opacity: 0.6;
  background: var(--bg-3);
}

.send-btn {
  padding: 10px 18px;
}

/* ------------ Settings dialog ------------ */
.settings-dialog {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0;
  min-width: 420px;
  max-width: 560px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.18);
}

.settings-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 20px 16px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin: -8px -4px 0;
  padding: 0 4px 12px;
}

.settings-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 10px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}

.settings-group legend {
  padding: 0 6px;
  color: var(--fg-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.settings-group label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--fg-soft);
}

.settings-group input,
.settings-group select {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color-scheme: light;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.settings-group input:focus,
.settings-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.hint {
  color: var(--fg-dim);
  font-size: 12px;
  margin: 0;
  line-height: 1.5;
}

.settings-footer {
  display: flex;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 4px;
}

.grow {
  flex: 1;
}

/* ------------ Reports / admin shared layout ------------ */
.reports-body {
  /* Dashboard is full-page scroll, not pinned composer at the bottom. */
  display: block;
}

.reports-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.auth-gate {
  max-width: 540px;
  margin: 12vh auto 0;
  text-align: center;
}

.auth-gate-inner h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--fg);
}

.auth-gate-inner p {
  color: var(--fg-dim);
  font-size: 15px;
  line-height: 1.6;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.dashboard-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--fg);
}

.dashboard-sub {
  color: var(--fg-dim);
  margin: 0;
  font-size: 13px;
}

.dashboard-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.month-picker {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
}

.month-picker input {
  background: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color-scheme: light;
}

.month-picker input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

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

.kpi {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  color: var(--fg-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--fg);
}

.card-hint {
  color: var(--fg-dim);
  font-size: 13px;
  margin: -6px 0 14px;
}

.card-hint-muted {
  font-style: italic;
  margin-top: 0;
}

.card-empty {
  color: var(--fg-dim);
  font-size: 13px;
  padding: 12px 0;
}

.admin-subhead {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-dim);
  margin: 18px 0 6px;
}

.admin-subhead:first-of-type {
  margin-top: 8px;
}

.admin-table-readonly {
  background: var(--bg-subtle, transparent);
  opacity: 0.92;
  margin-bottom: 8px;
}

.daily-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
  gap: 4px;
  align-items: end;
  /* Bars stretch to fill the column, labels live below. The fixed height
     keeps the chart legible across screen sizes. */
  height: 160px;
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.daily-col {
  position: relative;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1px;
}

.daily-bar {
  display: block;
  width: 5px;
  border-radius: 2px 2px 0 0;
  min-height: 1px;
}

.daily-bar-requests {
  background: var(--accent);
  opacity: 0.35;
}

.daily-bar-redactions {
  background: var(--warn);
}

.daily-label {
  position: absolute;
  bottom: -16px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  color: var(--fg-dim);
  font-family: var(--font-mono);
}

.daily-table,
.models-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.daily-table th,
.daily-table td,
.models-table th,
.models-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  color: var(--fg-soft);
}

.daily-table th.num,
.daily-table td.num,
.models-table th.num,
.models-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.daily-table thead th,
.models-table thead th {
  color: var(--fg-dim);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.archive-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.archive-link {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--fg);
  background: var(--bg-2);
  transition:
    border-color 120ms ease,
    background 120ms ease,
    color 120ms ease;
}

.archive-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.archive-title {
  font-weight: 600;
}

.archive-meta {
  color: var(--fg-dim);
  font-size: 12px;
  font-family: var(--font-mono);
}

.dashboard-error {
  background: var(--danger-soft);
  border: 1px solid rgba(185, 28, 28, 0.35);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 0;
  font-size: 13px;
}

/* ------------ Admin panels ------------ */
.admin-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: -8px;
}

.admin-tab {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--fg-dim);
  padding: 10px 16px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  border-radius: 0;
}

.admin-tab:hover {
  color: var(--fg);
}

.admin-tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-panel {
  /* Sits inside .card already; nothing extra needed but kept as a hook
     for future per-tab tweaks. */
}

.admin-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-panel-header h2 {
  margin: 0;
}

.admin-panel-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.org-info {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0;
  font-size: 14px;
}

.org-info dt {
  color: var(--fg-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 2px;
}

.org-info dd {
  margin: 0;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 8px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  color: var(--fg-soft);
}

.admin-table thead th {
  color: var(--fg-dim);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-actions {
  text-align: right;
  white-space: nowrap;
}

.admin-actions > * + * {
  margin-left: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(185, 28, 28, 0.35);
  background: var(--bg-2);
}

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

/* ------------ Pill / badge utility (matches website) ------------ */
.pill-label {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-line);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-hover);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.pill-ok {
  background: var(--accent-soft);
  border-color: var(--accent-soft-line);
  color: var(--accent-hover);
}

.pill-muted {
  background: var(--bg-2);
  border-color: var(--line);
  color: var(--fg-dim);
}

.pill-info {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.25);
  color: #1e40af;
}

.pill-warn {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.3);
  color: #92400e;
}

.pill-err {
  background: rgba(186, 26, 26, 0.08);
  border-color: rgba(186, 26, 26, 0.25);
  color: #93000a;
}

/* ------------ Presidio category overrides (Phase 11-4) ------------ */
.presidio-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.presidio-reason-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-1);
  color: var(--fg);
}

.presidio-reason-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.presidio-audit {
  font-size: 11px;
  color: var(--fg-dim);
}

.presidio-category-label {
  display: block;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.3;
}

.presidio-category-code {
  display: inline-block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--fg-dim);
  background: transparent;
  padding: 0;
}

/* ------------ Governance tab redesign ----------------------------------
   Polished card-based layout for the /admin → Governance tab. Matches
   the "Stitch UX Optimizer" reference (rounded container, header bar,
   spaced sections, 2-col grid for security posture, dashed empty
   state). All functional IDs remain unchanged so JS modules continue
   to work. */

.governance-container {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 0;
}

.governance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}

.governance-title {
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg);
  margin: 0 0 6px;
}

.governance-desc {
  font-size: 12px;
  color: var(--fg-dim);
  margin: 0;
  max-width: 60ch;
  line-height: 1.55;
}

.governance-body {
  padding: 24px 24px 0;
}

.governance-section {
  margin-bottom: 28px;
}

.governance-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg);
  margin: 0 0 6px;
}

.governance-section-desc {
  font-size: 11px;
  font-style: normal;
  color: var(--fg-dim);
  margin: 0 0 12px;
  line-height: 1.55;
}

/* 2-column grid for the security posture fieldset (matches ref) */
.failure-mode-fieldset-grid {
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 700px) {
  .failure-mode-fieldset-grid {
    grid-template-columns: 1fr;
  }
}

/* Checked radio highlights the parent label with accent border + tint */
.failure-mode-option:has(input:checked) {
  border-color: #93c5fd;
  background: rgba(37, 99, 235, 0.03);
  box-shadow: 0 0 0 1px rgba(191, 219, 254, 0.6);
}

/* Governance filters section */
.governance-filters-section {
  padding: 0 24px 24px;
}

.governance-table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.governance-table {
  margin-top: 0;
}

.governance-table thead th {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
  background: var(--bg-3);
  color: var(--fg-dim);
  font-weight: 700;
}

.governance-table tbody tr {
  transition: background 0.15s;
  border-bottom: 1px solid var(--line);
}

.governance-table tbody tr:last-child {
  border-bottom: none;
}

.governance-table tbody tr:hover {
  background: var(--bg-3);
}

.governance-table tbody td {
  font-size: 11px;
}

/* View-all button for governance filters (when more than N are shown) */
.governance-view-all-btn {
  display: block;
  width: 100%;
  padding: 10px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 12px;
  transition: background 0.15s;
}
.governance-view-all-btn:hover {
  background: rgba(37, 99, 235, 0.08);
}

/* Client-specific redaction rules section */
.governance-rules-section {
  padding: 24px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg-3);
}

/* Empty state for rules (dashed card with centered content) */
.governance-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  border: 2px dashed var(--line);
  border-radius: var(--radius-xl);
  background: rgba(37, 99, 235, 0.015);
  color: var(--fg-dim);
  font-size: 12px;
  text-align: center;
  gap: 14px;
}

.governance-empty-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: #dbeafe;
  border-radius: 50%;
  color: var(--accent);
}

.governance-empty-btn {
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-error {
  background: rgba(186, 26, 26, 0.06);
  border: 1px solid rgba(186, 26, 26, 0.25);
  color: #93000a;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin: 0 0 14px;
}

.card-success {
  background: rgba(0, 108, 73, 0.08);
  border: 1px solid rgba(0, 108, 73, 0.25);
  color: #00532f;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin: 0 0 14px;
}

.row-hint {
  color: var(--fg-dim);
  font-size: 12px;
}

/* ------------ Responsive ------------ */
@media (max-width: 600px) {
  .app-bar,
  .composer {
    padding-left: 14px;
    padding-right: 14px;
  }
  .chat-main {
    padding: 20px 14px;
  }
  .settings-dialog {
    min-width: min(92vw, 420px);
  }
  .reports-main {
    padding: 22px 14px 40px;
  }
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-actions {
    justify-content: space-between;
  }
  .empty-state h1 {
    font-size: 26px;
  }
  .app-bar-brand-sub {
    display: none;
  }
}

/* ------------ Phase 11 follow-up: failure-mode radios ------------
   Per-firm PresidioFailureMode override radios on /admin →
   Redaction Rules. Each radio + description is wrapped in a card-
   style label so the entire row is clickable and visually
   distinct from the per-category Presidio toggles immediately
   below. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.failure-mode-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 12px;
  display: grid;
  gap: 8px;
}
.failure-mode-option {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: var(--bg-2);
  transition: border-color 0.15s, background 0.15s;
}
.failure-mode-option:hover {
  border-color: var(--accent, var(--fg-dim));
}
.failure-mode-option-body {
  display: grid;
  gap: 2px;
}
.failure-mode-option-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
}
.failure-mode-option:has(input:checked) .failure-mode-option-title {
  color: #1e3a8a;
}
.failure-mode-option-desc {
  font-size: 10px;
  color: var(--fg-dim);
  line-height: 1.45;
  margin-top: 2px;
}

/* ------------ Compact radio card group (rehydration / telemetry) ----
   Used for binary Enabled/Disabled toggles that don't need the full
   failure-mode card treatment. Renders as inline radio items inside a
   single bordered card, matching the Stitch refinement reference. */
.radio-card-group {
  border: none;
  padding: 0;
  margin: 0 0 12px;
}
.radio-card-group .radio-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-2);
  margin-bottom: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.radio-card-group .radio-card:last-child {
  margin-bottom: 0;
}
.radio-card-group .radio-card:has(input:checked) {
  border-color: #93c5fd;
  background: rgba(37, 99, 235, 0.03);
  box-shadow: 0 0 0 1px rgba(191, 219, 254, 0.6);
}
.radio-card-group .radio-card input[type="radio"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.radio-card-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--fg);
  display: block;
}
.radio-card:has(input:checked) .radio-card-label {
  color: #1e3a8a;
}
.radio-card-desc {
  font-size: 10px;
  color: var(--fg-dim);
  display: block;
  line-height: 1.45;
  margin-top: 2px;
}

/* ------------ Phase 11-3d: degraded-mode banner ------------
   Surfaced above the chat composer when the proxy emits the
   X-Munimen-Redaction-Degraded: true response header (tier B
   fail-open path: Presidio analyzer unreachable, engine fell back
   to the 12-category regex baseline). Yellow / amber treatment
   from the existing --warn / --warn-soft tokens to read as
   "warning, not error" — the request still went through, PII
   scrubbing is just incomplete. */
.banner-warn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  color: #78350f; /* amber-900, readable on --warn-soft */
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 11px;
  line-height: 1.5;
  margin-top: 10px;
}

/* Observation-mode banner, sibling of `.banner-warn`. Blue/info
   treatment because Observe is a deliberate posture choice rather
   than a degraded state — we want to inform, not warn. */
.banner-info {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #dbeafe; /* blue-100 */
  border: 1px solid #2563eb; /* blue-600 */
  color: #1e3a8a; /* blue-900, readable on blue-100 */
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
}
.banner-info-icon {
  flex: 0 0 auto;
  font-size: 20px;
  color: #2563eb;
  line-height: 1.2;
  margin-top: 1px;
}
.banner-info-body {
  flex: 1 1 auto;
  line-height: 1.45;
}
.banner-info-body strong {
  font-weight: 600;
  margin-right: 4px;
}
.banner-info[hidden] {
  display: none;
}
.banner-warn[hidden] {
  display: none;
}
.banner-warn-icon {
  color: var(--warn);
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1.2;
  margin-top: 1px;
}
.banner-warn-body {
  flex: 1;
}
.banner-warn-body strong {
  font-weight: 600;
  margin-right: 4px;
}

/* ------------ Document Summarization workflow ------------ */
.workflow-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.workflow-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workflow-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.workflow-field-optional {
  color: var(--fg-dim);
  font-weight: 400;
  font-size: 12px;
}

.workflow-field-hint {
  color: var(--fg-dim);
  font-size: 12px;
  font-weight: 400;
  font-family: var(--font-mono);
}

.workflow-field select,
.workflow-field textarea {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.workflow-field textarea {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
  resize: vertical;
  min-height: 220px;
}

.workflow-field select:focus-visible,
.workflow-field textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.workflow-field-file {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0;
  background: var(--bg-elev, transparent);
}

.workflow-field-file input[type="file"] {
  font: inherit;
  color: var(--fg);
}

.workflow-file-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
  padding: 6px 0;
}

.workflow-field-disabled textarea {
  opacity: 0.55;
  cursor: not-allowed;
}

.workflow-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workflow-status {
  color: var(--fg-dim);
  font-size: 12px;
}

.workflow-result {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.workflow-summary p {
  margin: 0 0 12px;
  line-height: 1.55;
  font-size: 14px;
  color: var(--fg);
}

.workflow-summary p:last-child {
  margin-bottom: 0;
}

.workflow-list {
  list-style: disc;
  padding-left: 20px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.workflow-list li {
  font-size: 14px;
  line-height: 1.45;
  color: var(--fg);
}

.workflow-audit {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 13px;
}

.workflow-audit dt {
  color: var(--fg-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
  align-self: center;
}

.workflow-audit dd {
  margin: 0;
  font-family: var(--font-mono);
  color: var(--fg);
  word-break: break-all;
}

.workflow-degraded {
  border-color: rgba(217, 119, 6, 0.35);
  background: var(--warn-soft, rgba(217, 119, 6, 0.08));
}

.workflow-degraded h2 {
  color: var(--warn, #b45309);
  display: flex;
  align-items: center;
  gap: 8px;
}
