/*
 * Styled to sit inside Dynamics 365 Finance and Operations: the default blue theme, Segoe UI, neutral
 * grays, square-ish controls, an action pane, list selection with an accent bar, and message bars.
 * The chat itself follows the look of the Copilot pane in F&O. Colors are Fluent neutral and theme tokens.
 * Directions use logical properties (inline-start/end) so Arabic flips correctly.
 */
:root {
  --theme: #0078d4;
  --theme-hover: #106ebe;
  --theme-pressed: #005a9e;
  --theme-lighter: #deecf9;
  --theme-lighterAlt: #eff6fc;

  --text: #201f1e;
  --text-secondary: #605e5c;
  --text-disabled: #a19f9d;
  --bg: #faf9f8;
  --surface: #ffffff;
  --hover: #f3f2f1;
  --pressed: #edebe9;
  --divider: #edebe9;
  --border: #e1dfdd;
  --input-border: #8a8886;

  --error: #a4262c;
  --error-bg: #fde7e9;
  --info-bg: #f3f2f1;
  --user-bubble: #ebf3fc;

  /* Chart series (Fluent data-viz order). */
  --chart-1: #0078d4;
  --chart-2: #e3008c;
  --chart-3: #2aa0a4;
  --chart-4: #ca5010;
  --chart-5: #8764b8;
  --chart-6: #498205;
  --chart-7: #c19c00;
  --chart-8: #69797e;

  --shadow-card: 0 0 2px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.14);
  --radius: 2px;
  --radius-card: 6px;

  font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; min-width: 280px; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 1px solid var(--text); outline-offset: 1px; }

.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; }
[dir="rtl"] .ico.flip svg { transform: scaleX(-1); }

/* ---- Action pane --------------------------------------------------------------------------- */
.actionpane {
  display: flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px;
  background: var(--surface); border-bottom: 1px solid var(--divider);
}
.ap-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px;
  background: none; border: none; border-radius: var(--radius); white-space: nowrap;
}
.ap-btn .ico { color: var(--theme); }
.ap-btn:hover { background: var(--hover); }
.ap-btn:active, .ap-btn[aria-expanded="true"] { background: var(--pressed); }
.ap-sep { width: 1px; height: 20px; margin: 0 6px; background: var(--border); }
.ap-spacer { flex: 1; }

.who { display: flex; align-items: center; gap: 8px; min-width: 0; padding-inline-end: 4px; color: var(--text-secondary); font-size: 14px; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px;
  border-radius: 50%; background: var(--theme); color: #fff; font-size: 13px; font-weight: 600;
}
.avatar:empty { display: none; }

/* ---- Form caption -------------------------------------------------------------------------- */
.caption { display: flex; align-items: baseline; gap: 8px; padding: 10px 20px 8px; flex-wrap: wrap; }
.caption-mark { color: var(--theme); align-self: center; display: inline-flex; }
.caption h1 { margin: 0; font-size: 22px; font-weight: 600; line-height: 28px; }
.caption-sub { color: var(--text-secondary); font-size: 14px; }
/* Which engine answers: grey for the Claude API, solid blue for Claude Code. */
.caption-engine { padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--hover); color: var(--text-secondary); border: 1px solid var(--border); }
.caption-engine.code { background: var(--theme); color: #ffffff; border-color: var(--theme); }
.caption-build { margin-inline-start: auto; color: var(--text-secondary); font-size: 13px; white-space: nowrap; }

/* ---- Workspace: conversations pane + messages ---------------------------------------------- */
.workspace { flex: 1; display: flex; min-height: 0; position: relative; }

.pane {
  width: 272px; flex: none; display: flex; flex-direction: column;
  background: var(--surface); border-inline-end: 1px solid var(--divider);
}
.pane-head, .pane-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 8px 8px 16px; }
[dir="rtl"] .pane-head, [dir="rtl"] .pane-foot { padding: 8px 16px 8px 8px; }
.pane-head { border-bottom: 1px solid var(--divider); }
.pane-foot { border-top: 1px solid var(--divider); }
.pane-title { font-weight: 600; }
.hint { color: var(--text-secondary); font-size: 14px; }

.list { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; flex: 1; }
.list .note { color: var(--text-secondary); padding: 12px 16px; font-size: 15px; }
.list .item { position: relative; display: flex; align-items: stretch; }
.list .item:hover { background: var(--hover); }
.list .item.current { background: var(--theme-lighter); }
.list .item.current::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--theme); }
.list .open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; padding: 7px 8px 7px 16px;
  background: none; border: none; text-align: start;
}
[dir="rtl"] .list .open { padding: 7px 16px 7px 8px; }
.list .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .when { color: var(--text-secondary); font-size: 14px; }
.list .delete { display: inline-flex; align-items: center; padding: 0 10px; background: none; border: none; color: var(--text-secondary); visibility: hidden; }
.list .item:hover .delete, .list .delete:focus-visible { visibility: visible; }
.list .delete:hover { color: var(--error); }

/* Narrow frames (an F&O workspace tile, a phone): the pane covers the messages. */
@media (max-width: 640px) {
  .pane { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 2; width: min(88%, 300px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); }
  .caption-sub { display: none; }
  .ap-btn > span:not(.ico) { display: none; }
  .ap-btn { padding: 0 8px; }
}

/* ---- Messages ------------------------------------------------------------------------------ */
.messages { flex: 1; overflow-y: auto; padding: 12px 20px 16px; display: flex; flex-direction: column; gap: 14px; }

.msg { display: flex; gap: 8px; max-width: min(760px, 92%); }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.msg .bot {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; margin-top: 2px;
  border-radius: 50%; background: var(--theme-lighterAlt); color: var(--theme); border: 1px solid var(--theme-lighter);
}
.bubble { min-width: 0; padding: 10px 14px; border-radius: var(--radius-card); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user-bubble); }
.msg.assistant .bubble { background: var(--surface); box-shadow: var(--shadow-card); }
.msg.user.failed .bubble { opacity: 0.6; }
.bubble .text { display: block; }
.chart { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.chart figcaption { font-weight: 600; margin-bottom: 8px; }
.chart-pie { width: 160px; height: 160px; }
.chart--pie { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; align-items: center; }
.chart--pie figcaption { grid-column: 1 / -1; }
.chart-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 15px; }
.chart-legend li, .chart-row { display: flex; align-items: center; gap: 8px; }
.chart-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.chart-label { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-value { color: var(--text-secondary); white-space: nowrap; margin-inline-start: auto; }
.chart-bars { display: grid; gap: 6px; font-size: 15px; }
.chart-row .chart-label { width: 35%; }
.chart-track { flex: 1; height: 12px; background: var(--hover); border-radius: 2px; overflow: hidden; }
.chart-bar { display: block; height: 100%; border-radius: 2px; }
/* Line chart: axes in the theme's secondary text, light grid. */
.chart-line { display: block; width: 100%; height: auto; max-height: 260px; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-secondary); font-size: 12px; }
.chart-legend--inline { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 6px; }
.chart-legend--inline li .chart-value { margin-inline-start: 4px; }
/* KPI tiles: cards in a grid, the value large, a sparkline at the bottom. */
.chart--kpi { padding: 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.kpi-tile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); white-space: normal; }
.kpi-label { color: var(--text-secondary); font-size: 13px; }
.kpi-value { font-size: 22px; font-weight: 600; line-height: 1.25; }
.kpi-note { font-size: 13px; color: var(--text-secondary); }
.kpi-note.kpi-good { color: #107c10; }
.kpi-note.kpi-bad { color: var(--error); }
.kpi-spark { width: 100%; height: 28px; margin-top: 4px; stroke: var(--theme); }
.kpi-spark.kpi-good { stroke: #107c10; }
.kpi-spark.kpi-bad { stroke: var(--error); }
/* Answer buttons under a question. */
.choices { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.choice { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--theme); border-radius: 16px;
  background: var(--surface); color: var(--theme-pressed); font: inherit; cursor: pointer; }
.choice:hover:not(:disabled) { background: var(--theme-lighterAlt); }
.choice:disabled, .choices.answered .choice, .choice-check:has(input:disabled) { cursor: default; opacity: 0.55; }
.choice.picked { opacity: 1; background: var(--theme-lighter); font-weight: 600; }
.choice-check input { margin: 0; }
.choice-send { margin-inline-start: 4px; }
.choice-more { border-style: dashed; }
.choice-filter { flex: 1 0 100%; padding: 6px 10px; border: 1px solid var(--input-border); border-radius: 4px; font: inherit; }
.choice[hidden] { display: none; }

/* Documents (payslips, statements, reports): drawn in the reply, printed alone for Download PDF. */
.bubble.has-doc { max-width: min(760px, 100%); }
.msg:has(.bubble.has-wide) { width: min(760px, 92%); }
.bubble.has-wide { flex: 1; }
.doc { margin: 10px 0; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); }
.doc-page { padding: 16px 18px; color: var(--text); }
.doc-header { border-bottom: 2px solid var(--theme); padding-bottom: 8px; margin-bottom: 12px; }
.doc-title { margin: 0; font-size: 20px; }
.doc-subtitle { color: var(--text-secondary); margin-top: 2px; }
.doc-details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.doc-details dt { color: var(--text-secondary); }
.doc-details dd { margin: 0; }
.doc-section { margin: 12px 0; }
.doc-section h4 { margin: 0 0 6px; font-size: 16px; color: var(--theme-pressed); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.doc-table th, .doc-table td { padding: 5px 8px; border-bottom: 1px solid var(--divider); text-align: start; vertical-align: top; }
.doc-table thead th { background: var(--hover); font-weight: 600; }
.doc-pairs th { font-weight: normal; }
.doc-num { text-align: end !important; white-space: nowrap; font-variant-numeric: tabular-nums; }
.doc-total th, .doc-total td { font-weight: 600; border-top: 2px solid var(--border); }
.doc-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.doc-summary-item { flex: 1 1 160px; padding: 10px 12px; background: var(--theme-lighterAlt); border: 1px solid var(--theme-lighter); border-radius: 4px; display: grid; gap: 2px; }
.doc-summary-label { color: var(--text-secondary); font-size: 14px; }
.doc-summary-item strong { font-size: 18px; }
.doc-notes { margin: 10px 0 0; padding-inline-start: 18px; color: var(--text-secondary); font-size: 14px; }
.doc-footer { margin-top: 14px; padding-top: 8px; border-top: 1px solid var(--divider); color: var(--text-secondary); font-size: 13px; }
.doc-actions { display: flex; gap: 8px; padding: 10px 18px; border-top: 1px solid var(--divider); }
.doc-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.print-host { display: none; }
@media print {
  @page { margin: 14mm; }
  body.printing { height: auto !important; overflow: visible !important; background: #fff; }
  body.printing > :not(.print-host) { display: none !important; }
  body.printing .print-host { display: block; }
  .print-host .doc-page { padding: 0; }
  .print-host .doc-summary-item { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-host .doc-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media (max-width: 480px) { .chart--pie { grid-template-columns: 1fr; justify-items: center; } }
.bubble .meta {
  display: block; margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--divider);
  font-size: 13px; color: var(--text-secondary); white-space: normal;
}

/* Files inside a message. */
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.files:last-child { margin-bottom: 0; }
.thumb { display: block; max-width: 240px; max-height: 170px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface); }
.file {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px; padding: 5px 10px 5px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px; font-size: 14px; white-space: nowrap;
}
.file .ico { color: var(--theme); }
.file .name { overflow: hidden; text-overflow: ellipsis; }

/* Typing indicator, as an assistant message. */
.typing .bubble { display: inline-flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: 15px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--theme); opacity: 0.3; animation: dot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 0.6; } }

/* Welcome state. */
.empty { margin: auto; max-width: 520px; padding: 24px 8px; text-align: center; }
.empty .mark {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; margin-bottom: 12px;
  border-radius: 50%; background: var(--theme-lighterAlt); color: var(--theme); border: 1px solid var(--theme-lighter);
}
.empty h2 { margin: 0 0 6px; font-size: 22px; font-weight: 600; }
.empty p { margin: 0 0 18px; color: var(--text-secondary); line-height: 1.5; }
.suggestions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.suggestion {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; text-align: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card);
}
.suggestion .ico { color: var(--theme); }
.suggestion:hover { background: var(--theme-lighterAlt); border-color: var(--theme-lighter); }
.suggestion:disabled { opacity: 0.5; }

/* ---- Message bars (sign-in, errors) -------------------------------------------------------- */
.msgbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 14px;
  font-size: 15px; line-height: 1.4; border-inline-start: 3px solid transparent;
}
.msgbar.info { background: var(--info-bg); border-color: var(--text-secondary); margin: 0 20px 8px; }
.msgbar.error { background: var(--error-bg); border-color: var(--error); color: var(--text); }
/* Questions asked in the page (F&O's frame allows no browser dialogs): text, then Delete / Cancel. */
.ask-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 12px; background: var(--error-bg); border-color: var(--error); }
.ask-bar .ask-text { flex: 1 1 200px; }
.ask-bar .ask-actions { display: inline-flex; gap: 8px; }
.btn.primary.danger-primary { background: var(--error); border-color: var(--error); }
.msgbar.error > .ico { color: var(--error); }
.msgbar-text { flex: 1; }
.msg.error { align-self: stretch; max-width: none; }
.msg.error .msgbar { flex: 1; }
.msg.note .msgbar { flex: 1; margin: 0; }

/* ---- Buttons ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid var(--input-border); background: var(--surface); font-weight: 600; white-space: nowrap;
}
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--theme); border-color: var(--theme); color: #fff; }
.btn.primary:hover { background: var(--theme-hover); border-color: var(--theme-hover); }
.btn.primary:active { background: var(--theme-pressed); }
.btn.primary:disabled { background: var(--pressed); border-color: var(--pressed); color: var(--text-disabled); }
.btn.small { height: 26px; padding: 0 10px; font-size: 14px; }
.btn.stop { height: 30px; padding: 0 12px; }
.btn.stop:hover { border-color: var(--error); color: var(--error); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  background: none; border: none; border-radius: var(--radius); color: var(--text-secondary);
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--theme); }
.icon-btn:disabled { color: var(--text-disabled); }
.icon-btn.listening { color: #fff; background: var(--error); border-radius: 50%; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(164, 38, 44, 0.15); } }

.link-btn { background: none; border: none; color: var(--theme); padding: 4px 6px; border-radius: var(--radius); font-size: 15px; }
.link-btn:hover { background: var(--hover); text-decoration: underline; }
.link-btn.danger { color: var(--error); }

/* ---- Composer ------------------------------------------------------------------------------ */
.composer { padding: 0 20px 10px; }
.status { min-height: 20px; padding: 2px 2px 4px; color: var(--text-secondary); font-size: 14px; }
.status.error { color: var(--error); }

.compose-box {
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--border); border-bottom: 2px solid var(--input-border); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
}
.compose-box:focus-within { border-bottom-color: var(--theme); }
.compose-box textarea {
  width: 100%; min-height: 48px; max-height: 200px; resize: none; padding: 10px 14px 4px;
  border: none; outline: none; background: transparent; font: inherit; color: inherit; line-height: 1.5;
}
.compose-box textarea::placeholder { color: var(--text-secondary); }
.compose-box textarea:disabled { color: var(--text-disabled); }
.compose-tools { display: flex; align-items: center; gap: 2px; padding: 2px 6px 6px; }
/* Company picker: the compose bar's company, like the company lookup in the F&O navigation bar. */
.company { position: relative; }
.company-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px; margin-inline-start: 4px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
}
.company-btn:hover:not(:disabled) { background: var(--hover); }
.company-btn:disabled { color: var(--text-disabled); cursor: default; }
.company-code { font-weight: 600; }
.company-pop {
  position: absolute; bottom: calc(100% + 4px); inset-inline-start: 0; z-index: 20; width: 340px; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}
.company-pop[hidden] { display: none; }
.company-search {
  margin: 6px; padding: 5px 8px; border: 1px solid var(--theme); border-radius: var(--radius);
  font: inherit; font-size: 14px; background: var(--surface); color: var(--text);
}
.company-options { list-style: none; margin: 0; padding: 0 0 4px; max-height: 260px; overflow-y: auto; }
.company-option { display: flex; gap: 12px; padding: 6px 10px; cursor: pointer; font-size: 14px; }
.company-option:hover { background: var(--hover); }
.company-option.active { background: var(--theme-lighter); }
.company-option[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--theme); }
[dir="rtl"] .company-option[aria-selected="true"] { box-shadow: inset -3px 0 0 var(--theme); }
.company-id { flex: none; width: 56px; font-weight: 600; }
.company-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.company-empty { padding: 8px 10px; color: var(--text-secondary); font-size: 14px; }
.counter { margin-inline-start: 6px; color: var(--text-secondary); font-size: 13px; }
.compose-tools .btn.stop, .compose-tools .send-btn { margin-inline-start: auto; }
.send-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  background: none; border: none; border-radius: var(--radius); color: var(--theme);
}
.send-btn:hover:not(:disabled) { background: var(--theme-lighterAlt); }
.send-btn:disabled { color: var(--text-disabled); }
.disclaimer { padding-top: 6px; text-align: center; color: var(--text-secondary); font-size: 13px; }

/* Files waiting to be sent. */
.pending { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 240px; height: 32px; padding-inline: 8px 2px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px; font-size: 14px;
}
.chip img { width: 24px; height: 24px; object-fit: cover; border-radius: 2px; }
.chip > .ico { color: var(--theme); }
.chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip button { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; background: none; border: none; border-radius: var(--radius); color: var(--text-secondary); }
.chip button:hover { background: var(--hover); color: var(--error); }

body.dropping .compose-box { border: 1px dashed var(--theme); border-bottom: 2px dashed var(--theme); background: var(--theme-lighterAlt); }

/* ---- Confirmation card (F&O changes) ------------------------------------------------------- */
.confirm-card { min-width: min(420px, 100%); border-inline-start: 3px solid var(--theme); white-space: normal; }
.confirm-card.kind-delete { border-inline-start-color: var(--error); }
.confirm-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.confirm-head > svg { color: var(--theme); }
.kind-delete .confirm-head > svg { color: var(--error); }
.badge {
  margin-inline-start: auto; padding: 1px 8px; border-radius: 10px; font-size: 13px; font-weight: 600;
  background: var(--theme-lighter); color: var(--theme-pressed);
}
.kind-delete .badge { background: var(--error-bg); color: var(--error); }
.confirm-summary { white-space: pre-wrap; line-height: 1.5; margin-bottom: 8px; }
.confirm-card details { margin-bottom: 8px; font-size: 14px; }
.confirm-card details summary { cursor: pointer; color: var(--theme); width: fit-content; }
.confirm-card pre {
  margin: 6px 0 0; padding: 8px 10px; max-height: 220px; overflow: auto; direction: ltr; text-align: left;
  background: var(--bg); border: 1px solid var(--divider); border-radius: 4px;
  font-family: Consolas, "Cascadia Mono", monospace; font-size: 14px; white-space: pre;
}
.confirm-note { color: var(--text-secondary); font-size: 14px; margin-bottom: 10px; }
.confirm-actions { display: flex; gap: 8px; }
.btn.danger { background: var(--error); border-color: var(--error); color: #fff; }
.btn.danger:hover { background: #8e1f25; border-color: #8e1f25; }
.confirm-state { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.decided-yes .confirm-state { color: var(--theme); }

/* Changes that ran without a card ("Confirm all"). */
.changes { margin-top: 10px; padding: 8px 10px; background: var(--theme-lighterAlt); border: 1px solid var(--theme-lighter); border-radius: 4px; white-space: normal; }
.changes-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--theme-pressed); }
.changes ul { margin: 6px 0 0; padding-inline-start: 20px; font-size: 15px; }
.kind-form .badge { background: var(--hover); color: var(--text); }
.confirm-actions { flex-wrap: wrap; }

[hidden] { display: none !important; }

/* ---- Inbox and My jobs (phase 0.6) --------------------------------------------------------- */
.pane.side-end { width: 340px; border-inline-end: none; border-inline-start: 1px solid var(--divider); order: 2; transition: width .18s ease; }
/* Wider Inbox / My jobs: long reports and progress notes read like a page, not a column. */
.pane.side-end.wide { width: min(760px, 62vw); }
.pane.side-end .pane-head .pane-title { flex: 1; }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px;
  margin-inline-start: 4px; border-radius: 9px; background: var(--theme); color: #fff; font-size: 13px; font-weight: 600;
}
.count-badge[hidden] { display: none; }
@media (max-width: 640px) {
  .ap-btn > .count-badge { display: inline-flex; }
  .pane.side-end { inset-inline-start: auto; inset-inline-end: 0; width: min(92%, 340px); }
  .pane.side-end.wide { width: 100%; }
}
.list.feed { padding: 0; }
.feed .entry { display: flex; flex-direction: column; gap: 4px; padding: 10px 16px; border-bottom: 1px solid var(--divider); }
.feed .entry.unread { background: var(--theme-lighter); box-shadow: inset 3px 0 0 var(--theme); }
[dir="rtl"] .feed .entry.unread { box-shadow: inset -3px 0 0 var(--theme); }
.feed .entry.kind-notice .entry-head strong { color: var(--text); }
.feed .entry.pinned { border-bottom: 2px solid var(--theme); }
.entry-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.entry-head strong { font-weight: 600; overflow-wrap: anywhere; }
.entry-body { white-space: pre-wrap; line-height: 1.45; font-size: 15px; overflow-wrap: anywhere; }
.entry-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.entry .link-btn { align-self: flex-start; }
#inboxClear { margin-inline-start: auto; }
.status-paused .badge, .status-needssignin .badge { background: var(--warning-bg, var(--hover)); color: var(--text); }
.status-completed .badge, .status-cancelled .badge { background: var(--hover); color: var(--text-secondary); }
.job-card .confirm-head > svg { color: var(--theme); }
.job-rules-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.job-rules { margin: 0 0 8px; padding-inline-start: 20px; line-height: 1.5; }
#jobsBanner { margin: 0 20px 8px; }

/* ---- My instructions ----------------------------------------------------------------------- */
.instructions-body { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; min-height: 0; }
.instructions-body .hint { margin: 0; line-height: 1.45; }
.instructions-example { font-style: italic; }
.instructions-body textarea {
  flex: 1; min-height: 160px; resize: none; padding: 8px 10px; font: inherit; font-size: 15px; line-height: 1.5; color: inherit;
  background: var(--surface); border: 1px solid var(--border); border-bottom: 2px solid var(--input-border); border-radius: var(--radius-card);
  outline: none;
}
.instructions-body textarea:focus { border-bottom-color: var(--theme); }
.instructions .pane-foot .hint { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* My approval policies: under the instructions; each policy with its status and Pause / Resume / Delete. */
.policies { flex: none; max-height: 40%; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.policies[hidden] { display: none; }
.policies-title { margin: 0; font-size: 15px; font-weight: 600; }
.policies-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.policy-item { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
.policy-item.paused { opacity: 0.7; }
.policy-text { line-height: 1.45; white-space: pre-wrap; }
.policy-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 6px; font-size: 13px; color: var(--text-secondary); }
.policy-meta .policy-buttons { margin-inline-start: auto; display: flex; gap: 6px; }
.policy-card .policy-quote { margin: 4px 0 8px; padding: 6px 10px; border-inline-start: 3px solid var(--theme); background: var(--info-bg); white-space: pre-wrap; line-height: 1.45; }
.policy-card .confirm-head > svg { color: var(--theme); }

.takeover { flex: none; padding: 4px 10px; border: 1px solid var(--text-secondary); border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.takeover:hover { background: var(--info-bg); }

/* Dashboard: replaces the chat while open; two tabs of widget cards in a grid. */
.dashboard { flex: 1; overflow-y: auto; padding: 12px 20px 20px; display: flex; flex-direction: column; gap: 12px; }
.dashboard[hidden] { display: none; }
body.dash-mode #messages, body.dash-mode .composer { display: none; }
.dash-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.dash-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.dash-tab {
  padding: 8px 14px; border: none; background: none; font: inherit; color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.dash-tab:hover { color: var(--text); background: var(--hover); }
.dash-tab[aria-selected="true"] { color: var(--theme); border-bottom-color: var(--theme); font-weight: 600; }
.dash-tools { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.dash-tools .btn { display: inline-flex; align-items: center; gap: 6px; }
.dash-tools .company-pop { bottom: auto; top: calc(100% + 4px); }
.dash-empty { color: var(--text-secondary); }
.widget-add { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); box-shadow: var(--shadow-card); display: flex; flex-direction: column; gap: 8px; }
.widget-add[hidden] { display: none; }
.widget-add-title { margin: 0; font-size: 16px; }
.widget-suggestions { display: flex; flex-wrap: wrap; gap: 6px; }
.widget-suggestions .chip { cursor: pointer; font: inherit; font-size: 14px; max-width: none; padding-inline: 10px; color: var(--text); }
.widget-suggestions .chip:hover { background: var(--hover); border-color: var(--theme); }
.widget-own { display: flex; gap: 8px; align-items: flex-end; }
.widget-own-input { flex: 1; min-height: 44px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); font: inherit; resize: vertical; background: var(--surface); color: var(--text); }
/* Widgets on a four-column board: each spans 1-4 columns (default 2) and may have its own height; narrower frames
   fold to two columns, then one. */
.widget-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: start; grid-auto-flow: row dense; }
.widget { position: relative; grid-column: span 2; }
.widget.w-1 { grid-column: span 1; }
.widget.w-2 { grid-column: span 2; }
.widget.w-3 { grid-column: span 3; }
.widget.w-4 { grid-column: span 4; }
.widget.sized .widget-body { flex: 1; overflow: auto; min-height: 0; }
.widget.resizing { outline: 2px dashed var(--theme); outline-offset: 2px; user-select: none; }
.widget-resize {
  position: absolute; bottom: 2px; inset-inline-end: 2px; width: 16px; height: 16px; cursor: nwse-resize; border-radius: 3px;
  background:
    linear-gradient(135deg, transparent 0 55%, var(--text-disabled) 55% 62%, transparent 62% 72%, var(--text-disabled) 72% 79%, transparent 79%);
  opacity: .55; transition: opacity .12s;
}
[dir="rtl"] .widget-resize { cursor: nesw-resize; transform: scaleX(-1); }
.widget:hover .widget-resize, .widget-resize:focus-visible { opacity: 1; }
.widget-resize:focus-visible { outline: 2px solid var(--theme); }
@media (max-width: 1100px) {
  .widget-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .widget.w-1, .widget.w-2 { grid-column: span 1; }
  .widget.w-3, .widget.w-4 { grid-column: span 2; }
}
@media (max-width: 760px) {
  .widget-board { grid-template-columns: minmax(0, 1fr); }
  .widget.w-1, .widget.w-2, .widget.w-3, .widget.w-4 { grid-column: span 1; }
}
.widget { background: var(--surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); display: flex; flex-direction: column; min-width: 0; }
.widget-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 8px 6px 14px; border-bottom: 1px solid var(--divider, var(--border)); }
.widget-head .widget-title { flex: 1 1 140px; }
[dir="rtl"] .widget-head { padding: 8px 14px 6px 8px; }
.widget-title { margin: 0; font-size: 15px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.widget-when { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.widget-every { font: inherit; font-size: 12px; color: var(--text-secondary); background: transparent; border: 1px solid var(--border); border-radius: 2px; padding: 1px 2px; max-width: 120px; }
.widget-actions { display: flex; gap: 0; }
.widget-actions .icon-btn { width: 28px; height: 28px; }
.flip-up svg { transform: rotate(180deg); }
.widget-body { padding: 8px 14px 12px; min-height: 60px; }
.widget-body .chart, .widget-body .doc { margin: 8px 0 0; }
.widget-text { margin: 0 0 4px; line-height: 1.5; }
.widget-error { margin: 0 0 6px; color: var(--error); }

/* Claude Code engine: the reply as it is written, plain text until the finished answer replaces it. */
.typing.streaming .bubble { align-items: flex-start; color: var(--text); }
.typing.streaming .bubble > span:last-child { white-space: pre-wrap; }


/* ---- Admin page (admin.html) ---------------------------------------------------------------
   A console of its own: a branded top bar, an overview row, environments as cards, grouped forms, chips for people.
   Scoped to body.admin so the chat page is untouched. */
body.admin {
  overflow: auto;
  background:
    radial-gradient(1200px 400px at 0% -10%, #e3efff 0%, transparent 60%),
    radial-gradient(900px 380px at 100% -20%, #efe8ff 0%, transparent 55%),
    #f5f7fb;
  --radius-admin: 14px;
  --shadow-admin: 0 1px 2px rgba(16, 32, 64, .06), 0 8px 24px rgba(16, 32, 64, .06);
}
.admin-top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px; padding: 10px 24px;
  background: rgba(255, 255, 255, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(16, 32, 64, .08);
}
.admin-brand { display: flex; align-items: center; gap: 10px; }
.admin-logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #0f6cbd, #6b4fd8); box-shadow: 0 4px 12px rgba(15, 108, 189, .3);
}
.admin-brand-name { font-weight: 700; font-size: 15px; line-height: 1.1; }
.admin-brand-sub { font-size: 12px; color: var(--text-secondary); }
.admin-user { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: #fff; border: 1px solid var(--border); font-size: 13px; }
.admin-avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--theme); color: #fff; font-size: 11px; font-weight: 700; }
.admin-avatar:empty { display: none; }

.admin-main { max-width: 1160px; margin: 0 auto; padding: 24px 24px 56px; display: flex; flex-direction: column; gap: 18px; }

/* Overview figures. */
.admin-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.admin-stats[hidden] { display: none; }
.admin-stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: #fff; border-radius: var(--radius-admin); box-shadow: var(--shadow-admin); }
.admin-stat-icon, .admin-head-icon {
  width: 36px; height: 36px; flex: none; border-radius: 10px; display: grid; place-items: center;
  background: #e8f1fc; color: var(--theme);
}
.admin-stat-icon.ok { background: #e3f5e1; color: #107c10; }
.admin-stat-icon.warm, .admin-head-icon.warm { background: #fdf3e2; color: #b4690e; }
.admin-stat-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.admin-stat-label { font-size: 12.5px; color: var(--text-secondary); }

/* Cards. */
.admin-card {
  background: #fff; border: 1px solid rgba(16, 32, 64, .06); border-radius: var(--radius-admin); box-shadow: var(--shadow-admin);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 14px;
}
.admin-card[hidden] { display: none; }
.admin-card-head { display: flex; align-items: center; gap: 12px; }
.admin-card-head h2 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; }
.admin-head-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.admin-head-text h2 { flex: none; }
.admin-card .hint { margin: 0; font-size: 13px; }
.admin-count { font-size: 12px; font-weight: 600; color: var(--text-secondary); background: var(--hover); padding: 2px 10px; border-radius: 999px; }
.admin-count:empty { display: none; }
.admin-collapse > summary { cursor: pointer; list-style: none; border-radius: 10px; }
.admin-collapse > summary::-webkit-details-marker { display: none; }
.admin-collapse > summary::after { content: "\25BE"; color: var(--text-secondary); font-size: 13px; transition: transform .15s; transform: rotate(-90deg); }
.admin-collapse[open] > summary::after { transform: none; }
.admin-collapse > * + * { margin-top: 12px; }

/* Buttons and fields on the admin page. */
body.admin .btn { border-radius: 8px; min-height: 32px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; transition: background .12s, border-color .12s, box-shadow .12s; }
body.admin .btn.primary { box-shadow: 0 1px 2px rgba(15, 108, 189, .25); }
body.admin .btn.danger { color: var(--error); border-color: #f1bbbc; }
body.admin .btn.danger:hover { background: var(--error-bg); }
body.admin .link-btn { font-size: 13px; }
.admin-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px 16px; }
.admin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text); }
.admin-optional { font-weight: 400; color: var(--text-secondary); font-size: 12px; }
.admin-form input[type=text], .admin-form input[type=url], .admin-form input[type=password], .admin-form input[type=number],
.admin-users-bar input[type=search], .admin-textarea {
  font: inherit; font-size: 14px; font-weight: 400; color: var(--text); background: #fbfcfe;
  border: 1px solid #d5dbe5; border-radius: 8px; padding: 8px 10px; min-height: 36px; box-sizing: border-box;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.admin-form input:focus, .admin-users-bar input:focus, .admin-textarea:focus { outline: none; border-color: var(--theme); background: #fff; box-shadow: 0 0 0 3px rgba(0, 120, 212, .15); }
.admin-form input:disabled { color: var(--text-disabled); background: var(--hover); }
.admin-textarea { width: 100%; resize: vertical; }
.admin-group { border: 1px solid #e6eaf1; border-radius: 12px; padding: 12px 16px 14px; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.admin-group legend { padding: 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-secondary); }
.admin-switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; user-select: none; }
.admin-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.admin-switch-track { width: 36px; height: 20px; border-radius: 10px; background: #c8ced8; position: relative; transition: background .15s; flex: none; }
.admin-switch-track::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.admin-switch input:checked + .admin-switch-track { background: var(--theme); }
.admin-switch input:checked + .admin-switch-track::after { transform: translateX(16px); }
[dir="rtl"] .admin-switch input:checked + .admin-switch-track::after { transform: translateX(-16px); }
.admin-switch input:focus-visible + .admin-switch-track { box-shadow: 0 0 0 3px rgba(0, 120, 212, .25); }
.admin-check { display: flex !important; flex-direction: row !important; align-items: center; gap: 6px; color: var(--text); font-weight: 400 !important; }
.admin-errors { margin: 0; padding: 10px 14px 10px 30px; color: var(--error); background: var(--error-bg); border-radius: 10px; font-size: 13px; }
.admin-errors[hidden] { display: none; }
.admin-checklist { font-size: 13.5px; background: #f7f9fc; border: 1px solid #e6eaf1; border-radius: 12px; padding: 10px 14px; }
.admin-checklist > summary { cursor: pointer; font-weight: 600; color: var(--theme); }
.admin-checklist code, .admin-card code { background: #eef2f8; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; }
.admin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Environments as cards. */
.env-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.env-card {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 12px; background: #fff;
  border: 1px solid #e6eaf1; position: relative; overflow: hidden; transition: box-shadow .15s, transform .15s, border-color .15s;
}
.env-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: linear-gradient(180deg, #0f6cbd, #6b4fd8); }
.env-card.off::before { background: #c8ced8; }
.env-card:hover { box-shadow: 0 10px 28px rgba(16, 32, 64, .10); transform: translateY(-1px); border-color: #d5dbe5; }
.env-card-head { display: flex; align-items: center; gap: 10px; }
.env-card-head h3 { margin: 0; font-size: 16px; font-weight: 650; flex: 1; overflow-wrap: anywhere; }
.env-card-host, .env-card-meta span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); font-size: 13px; overflow-wrap: anywhere; }
.env-card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.env-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.env-card-actions .btn { padding: 0 10px; font-size: 13px; min-height: 30px; }
.env-card-more { display: flex; gap: 14px; padding-top: 8px; border-top: 1px dashed #e6eaf1; }
.env-card-actions .hint { align-self: center; color: #107c10; font-weight: 600; }
.pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; letter-spacing: .02em; white-space: nowrap; }
.pill-ok { background: #e3f5e1; color: #107c10; }
.pill-warn { background: #fff4ce; color: #8a5d00; }
.pill-off { background: #eef0f3; color: var(--text-secondary); }
.admin-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 28px; color: var(--text-secondary); border: 2px dashed #e1e6ee; border-radius: 12px; }
.admin-empty[hidden] { display: none; }
.admin-empty p { margin: 0; }

/* People as chips. */
.admin-users { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; max-height: 420px; overflow-y: auto; font-size: 13.5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: #f1f4f9; border: 1px solid #e3e8f0; }
.chip .admin-check { gap: 8px; }
.chip:has(input:checked) { background: #e8f1fc; border-color: #b9d4f2; }
.chip-owner { background: #eef3ff; border-color: #cddbfa; color: #1f4fbf; }
.chip-wild { background: #fdf3e2; border-color: #f2dcb4; font-family: ui-monospace, Consolas, monospace; }
.admin-users-bar { padding: 8px 10px; background: #f7f9fc; border-radius: 10px; }
.admin-users-bar input[type=search] { min-width: 220px; }
.admin-owners { margin-bottom: 2px; }
.admin-manage { display: flex; flex-direction: column; gap: 8px; }
.admin-manage[hidden] { display: none; }

/* Usage this month: a bar per person against the budget; a row stopped by a limit stands out. */
.usage-table td { vertical-align: middle; }
.usage-name { font-weight: 600; }
.usage-bar { width: 180px; max-width: 100%; height: 8px; border-radius: 4px; background: #e8ecf2; overflow: hidden; margin-bottom: 4px; }
.usage-bar > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #0f6cbd, #4ea3ff); }
.usage-bar > span.high { background: linear-gradient(90deg, #b4690e, #e0a238); }
.usage-bar > span.full { background: linear-gradient(90deg, #a4262c, #d13438); }
.admin-table tr.usage-blocked td { background: #fff5f5; }
.usage-badge { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--error); color: #fff; font-size: 11.5px; font-weight: 700; margin-inline-end: 4px; }
#limitBudget { max-width: 220px; }

/* Tables (usage). */
.admin-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.admin-table th { text-align: start; padding: 8px 10px; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-secondary); background: #f7f9fc; border-bottom: 1px solid #e6eaf1; }
.admin-table th:first-child { border-start-start-radius: 8px; }
.admin-table th:last-child { border-start-end-radius: 8px; }
.admin-table td { text-align: start; padding: 10px; border-bottom: 1px solid #eef1f6; vertical-align: middle; }
.admin-table tbody tr:hover td { background: #fafbfd; }
.admin-table td.admin-row-actions { text-align: end; white-space: nowrap; }
.admin-row-actions > * + * { margin-inline-start: 6px; }

@media (max-width: 640px) {
  .admin-top { padding: 10px 14px; }
  .admin-main { padding: 16px 12px 40px; }
  .admin-user .who-name { display: none; }
  .env-grid { grid-template-columns: 1fr; }
}

/* No chat without an environment link: the notice and the way to the admin page. */
.landing { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; max-width: 640px; margin: 48px auto; padding: 0 20px; }
.landing .msgbar { margin: 0; }
.landing-admin { font-size: 14px; color: var(--theme); }


/* ---- The dictation window the chat opens inside F&O (dictate.html) -------------------------------------------
   A small window of its own: a breathing microphone orb, rings that ripple while it listens, a live level meter
   driven by the microphone, and the words appearing as they are heard. data-state on the card drives it all:
   starting, listening, paused (an error or silence), done. */
body.dictate {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(120% 80% at 0% 0%, #d9ecff 0%, transparent 55%),
    radial-gradient(100% 70% at 100% 100%, #efe3ff 0%, transparent 55%),
    #f6f8fc;
  overflow: hidden;
}
.dictate-card {
  --level: 0;
  --accent: #0f6cbd;
  --accent-2: #6b4fd8;
  box-sizing: border-box;
  width: min(440px, calc(100vw - 24px));
  padding: 16px 18px 18px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 20px 50px rgba(15, 50, 110, 0.16), 0 2px 6px rgba(15, 50, 110, 0.08);
  backdrop-filter: blur(14px);
  animation: dictate-in 0.35s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes dictate-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.dictate-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dictate-brand { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: var(--accent); }
.dictate-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef4fb; color: var(--text-secondary);
  transition: background .25s, color .25s;
}
.dictate-dot { width: 8px; height: 8px; border-radius: 50%; background: #a19f9d; transition: background .25s; }
.dictate-card[data-state="listening"] .dictate-chip { background: #fde7e9; color: #a4262c; }
.dictate-card[data-state="listening"] .dictate-dot { background: #d13438; animation: dictate-blink 1.1s ease-in-out infinite; }
.dictate-card[data-state="done"] .dictate-chip { background: #dff6dd; color: #107c10; }
.dictate-card[data-state="done"] .dictate-dot { background: #107c10; }
@keyframes dictate-blink { 50% { opacity: .25; } }

/* The orb and its rings. */
.dictate-stage { position: relative; height: 150px; display: grid; place-items: center; }
.dictate-orb {
  position: relative; z-index: 1;
  width: 92px; height: 92px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 25%, #4ea3ff 0%, var(--accent) 45%, var(--accent-2) 100%);
  box-shadow: 0 10px 28px rgba(15, 108, 189, .38), inset 0 -6px 14px rgba(0, 0, 0, .18), inset 0 6px 12px rgba(255, 255, 255, .25);
  transform: scale(calc(1 + var(--level) * .18));
  transition: transform .08s linear, box-shadow .25s, filter .25s;
}
.dictate-orb:hover { filter: brightness(1.06); }
.dictate-orb:focus-visible { outline: 3px solid #fff; box-shadow: 0 0 0 6px var(--accent); }
.dictate-card[data-state="paused"] .dictate-orb,
.dictate-card[data-state="starting"] .dictate-orb { filter: saturate(.55); }
.dictate-card[data-state="done"] .dictate-orb { background: radial-gradient(circle at 30% 25%, #6ccb5f 0%, #107c10 70%); }
.dictate-ring {
  position: absolute; width: 92px; height: 92px; border-radius: 50%;
  border: 2px solid rgba(15, 108, 189, .35);
  opacity: 0;
}
.dictate-card[data-state="listening"] .dictate-ring { animation: dictate-ripple 2.4s cubic-bezier(.2, .6, .3, 1) infinite; }
.dictate-card[data-state="listening"] .dictate-ring.r2 { animation-delay: .8s; border-color: rgba(107, 79, 216, .3); }
.dictate-card[data-state="listening"] .dictate-ring.r3 { animation-delay: 1.6s; }
@keyframes dictate-ripple { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.75); opacity: 0; } }

/* The level meter: bars from the microphone's live volume; a gentle idle wave when that isn't available. */
.dictate-wave { height: 34px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.dictate-wave > span {
  width: 4px; height: 100%; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  transform: scaleY(.12); transform-origin: center;
  transition: transform .09s linear, opacity .25s;
  opacity: .35;
}
.dictate-card[data-state="listening"] .dictate-wave > span { opacity: 1; }
.dictate-card[data-state="listening"] .dictate-wave.idle > span { animation: dictate-idle 1.2s ease-in-out infinite; animation-delay: calc(var(--i) * -0.07s); }
@keyframes dictate-idle { 0%, 100% { transform: scaleY(.15); } 50% { transform: scaleY(.55); } }

/* The words. */
.dictate-text {
  margin: 0; min-height: 52px; max-height: 120px; overflow-y: auto;
  padding: 10px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, .9); border: 1px solid #e3e8f0;
  font-size: 16px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere;
}
.dictate-text:empty::before { content: attr(data-placeholder); color: var(--text-disabled); font-style: italic; }
.dictate-status { margin: 0; min-height: 18px; font-size: 13px; color: var(--text-secondary); text-align: center; }
.dictate-status.error { color: var(--error); }

.dictate-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dictate-actions .btn { border-radius: 8px; min-width: 88px; }
.dictate-ghost { background: transparent; }
.dictate-actions .btn.dictate-done,
.dictate-actions .btn.dictate-done:hover { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.dictate-actions .btn.dictate-done:hover { filter: brightness(1.08); }

@media (prefers-reduced-motion: reduce) {
  .dictate-card, .dictate-ring, .dictate-dot, .dictate-wave > span { animation: none !important; }
}
@media (prefers-color-scheme: dark) {
  body.dictate {
    color: #f3f2f1;
    background:
      radial-gradient(120% 80% at 0% 0%, #10345c 0%, transparent 55%),
      radial-gradient(100% 70% at 100% 100%, #2e1f5c 0%, transparent 55%),
      #11141a;
  }
  .dictate-card { background: rgba(32, 36, 44, .78); border-color: rgba(255, 255, 255, .08); box-shadow: 0 20px 50px rgba(0, 0, 0, .5); }
  .dictate-chip { background: #252a33; color: #c8c6c4; }
  .dictate-brand { color: #6cb4ff; }
  .dictate-text { background: rgba(20, 23, 29, .85); border-color: #333a46; color: #f3f2f1; }
  .dictate-status { color: #c8c6c4; }
  .dictate-ghost { color: #f3f2f1; border-color: #4a5160; }
}

/* ---- Chat polish ----------------------------------------------------------------------------
   Still F&O: Segoe UI, the theme blue, Fluent depth. Softer cards, a branded assistant mark, structured answers,
   a welcome screen with suggestion cards, and a floating compose box. Later rules win over the base ones above. */
.messages { padding: 16px 20px 20px; gap: 18px; scroll-behavior: smooth; }
.msg { max-width: min(820px, 94%); gap: 10px; animation: msg-in .22s ease-out both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg .bot {
  width: 30px; height: 30px; border: none; color: #fff;
  background: linear-gradient(135deg, #0f6cbd 0%, #3a7fe0 55%, #6b4fd8 100%);
  box-shadow: 0 2px 6px rgba(15, 108, 189, .3);
}
.bubble { padding: 12px 16px; border-radius: 12px; line-height: 1.55; }
.msg.assistant .bubble { border: 1px solid #e8ebf0; box-shadow: 0 1px 2px rgba(16, 32, 64, .05), 0 4px 14px rgba(16, 32, 64, .05); }
.msg.user .bubble { background: #e5f0fb; border: 1px solid #d3e5f8; border-end-end-radius: 4px; }
.msg.assistant .bubble { border-start-start-radius: 4px; }

/* Structured answers (richtext.ts). */
.bubble .rt { white-space: normal; }
.rt > * { margin: 0; }
.rt > * + * { margin-top: 8px; }
.rt p { white-space: pre-wrap; }
.rt ul, .rt ol { padding-inline-start: 22px; }
.rt li { margin: 3px 0; padding-inline-start: 2px; }
.rt ul li::marker { color: var(--theme); }
.rt ol li::marker { color: var(--theme); font-weight: 600; }
.rt-heading { font-weight: 650; color: var(--theme-pressed); font-size: 14.5px; margin-top: 12px !important; }
.rt-pairs {
  display: grid; grid-template-columns: max-content 1fr; gap: 0; border: 1px solid #e8ebf0; border-radius: 8px; overflow: hidden;
}
.rt-pairs dt, .rt-pairs dd { margin: 0; padding: 6px 12px; border-bottom: 1px solid #eef1f5; }
.rt-pairs dt { color: var(--text-secondary); background: #f7f9fc; font-size: 14px; }
.rt-pairs dd { font-variant-numeric: tabular-nums; }
.rt-pairs dt:nth-last-of-type(1), .rt-pairs dd:last-of-type { border-bottom: none; }
.rt-sep { color: var(--theme); font-weight: 700; }
.rt strong { font-weight: 650; }

/* What the answer looked up: a quiet chip under it. */
.bubble .meta {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 3px 10px;
  border: none; border-radius: 999px; background: #f2f5f9; font-size: 12.5px;
}
.bubble .meta::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #3fb950; }

/* Typing: a shimmer on the label. */
.typing .bubble span:last-child:not(.dots) {
  background: linear-gradient(90deg, var(--text-secondary) 0%, var(--theme) 50%, var(--text-secondary) 100%);
  background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 2s linear infinite;
}
.typing.streaming .bubble span:last-child { background: none; color: var(--text); animation: none; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Welcome: a larger mark and suggestion cards. */
.empty { max-width: 640px; }
.empty .mark {
  width: 56px; height: 56px; border: none; color: #fff; margin-bottom: 14px;
  background: linear-gradient(135deg, #0f6cbd 0%, #3a7fe0 55%, #6b4fd8 100%);
  box-shadow: 0 8px 22px rgba(15, 108, 189, .28);
}
.empty h2 { font-size: 24px; letter-spacing: -.01em; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.suggestion {
  padding: 14px 16px; border-radius: 12px; border: 1px solid #e3e8ef; box-shadow: 0 1px 2px rgba(16, 32, 64, .04);
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; font-size: 14.5px;
}
.suggestion > svg { flex: none; box-sizing: content-box; padding: 7px; border-radius: 8px; background: #e8f1fc; color: var(--theme); }
.suggestion:hover:not(:disabled) { background: #fff; border-color: #b9d4f2; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(15, 108, 189, .12); }

/* Compose: a floating card with a focus ring and a round send button. */
.composer { padding: 0 20px 12px; }
.compose-box {
  border: 1px solid #d9dfe8; border-bottom-width: 1px; border-radius: 14px;
  box-shadow: 0 2px 4px rgba(16, 32, 64, .04), 0 8px 24px rgba(16, 32, 64, .06);
  transition: border-color .15s, box-shadow .15s;
}
.compose-box:focus-within { border-color: var(--theme); box-shadow: 0 0 0 3px rgba(0, 120, 212, .14), 0 8px 24px rgba(16, 32, 64, .06); }
.compose-box textarea { padding: 12px 16px 4px; font-size: 15px; }
.send-btn {
  width: 34px !important; height: 34px !important; border-radius: 50% !important; display: inline-grid !important; place-items: center;
  background: var(--theme) !important; color: #fff !important; border: none !important; transition: transform .12s, background .12s, opacity .12s;
}
.send-btn:hover:not(:disabled) { background: var(--theme-hover) !important; transform: scale(1.05); }
.send-btn:disabled { background: var(--pressed) !important; color: var(--text-disabled) !important; }

/* Cards in the conversation (confirmations, jobs, policies, widgets): the same softer depth. */
.confirm-card { border-radius: 12px; }

@media (prefers-reduced-motion: reduce) {
  .msg, .typing .bubble span:last-child { animation: none !important; }
  .suggestion:hover:not(:disabled), .send-btn:hover:not(:disabled) { transform: none; }
}

/* ---- Top bar polish --------------------------------------------------------------------------
   The action pane as soft tabs in F&O blue: rounded, a clear open state with an underline, New chat as the main
   action, a badge for unread items, the signed-in person as a chip, Sign out as a quiet icon. Then the caption row
   and the sign-in banner. */
.actionpane {
  min-height: 50px; padding: 0 12px; gap: 4px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid #e6eaf0; box-shadow: 0 1px 3px rgba(16, 32, 64, .04);
  position: relative; z-index: 3;
}
.ap-btn {
  height: 34px; padding: 0 12px; gap: 7px; border-radius: 8px; font-size: 14px; color: var(--text);
  position: relative; transition: background .12s, color .12s;
}
.ap-btn .ico { color: #4b6b8f; transition: color .12s; }
.ap-btn:hover { background: #eef3f9; }
.ap-btn:hover .ico { color: var(--theme); }
.ap-btn:active { background: #e3ecf6; }
.ap-btn[aria-expanded="true"] { background: #e5f0fb; color: var(--theme-pressed); font-weight: 600; }
.ap-btn[aria-expanded="true"] .ico { color: var(--theme); }
.ap-btn[aria-expanded="true"]::after {
  content: ""; position: absolute; inset-inline: 12px; bottom: -8px; height: 3px; border-radius: 3px 3px 0 0; background: var(--theme);
}
.ap-btn:focus-visible { outline: 2px solid var(--theme); outline-offset: 1px; }
/* New chat: the main action, outlined in the theme. */
#newChat { border: 1px solid #b9d4f2; background: #f5f9fe; color: var(--theme-pressed); font-weight: 600; }
#newChat .ico { color: var(--theme); }
#newChat:hover { background: #e5f0fb; border-color: var(--theme); }
.ap-sep { height: 22px; margin: 0 8px; background: #e1e6ee; }
/* Language: a small chip. */
#lang { border: 1px solid #e1e6ee; height: 30px; padding: 0 10px; border-radius: 999px; font-size: 13.5px; }
/* Unread: a badge that reads at a glance. */
.count-badge {
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11.5px; font-weight: 700;
  background: linear-gradient(135deg, #d13438, #e8590c); box-shadow: 0 0 0 2px #fff;
}
/* The signed-in person: a chip with an avatar. */
.who {
  gap: 8px; padding: 3px 12px 3px 3px; border-radius: 999px; background: #f4f7fb; border: 1px solid #e3e8ef;
  color: var(--text); font-size: 13.5px; font-weight: 500; max-width: 260px;
}
.who:has(.avatar:empty) { padding: 5px 12px; color: var(--text-secondary); font-weight: 400; }
.avatar {
  width: 28px; height: 28px; font-size: 12px; font-weight: 700; letter-spacing: .02em;
  background: linear-gradient(135deg, #0f6cbd 0%, #3a7fe0 55%, #6b4fd8 100%); box-shadow: 0 1px 3px rgba(15, 108, 189, .35);
}
/* Sign out: an icon with its name as tooltip. */
.ap-signout { width: 34px; padding: 0; justify-content: center; margin-inline-start: 2px; }
.ap-signout .label { display: none; }
.ap-signout .ico { color: #6b7a8c; }
.ap-signout:hover { background: #fdeceb; }
.ap-signout:hover .ico { color: var(--error); }

/* Caption: the title with a gradient mark, pill badges and a quiet version chip. */
.caption { padding: 14px 24px 8px; gap: 10px; align-items: center; }
.caption-mark {
  width: 30px; height: 30px; border-radius: 9px; display: inline-grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #0f6cbd 0%, #3a7fe0 55%, #6b4fd8 100%); box-shadow: 0 3px 10px rgba(15, 108, 189, .28);
}
.caption h1 { font-size: 21px; font-weight: 650; letter-spacing: -.01em; }
.caption-engine { border: none; background: #eef3ff; color: #3b5bdb; padding: 2px 10px; }
.caption-sub { font-size: 13.5px; }
.caption-build { background: #f2f5f9; padding: 2px 10px; border-radius: 999px; font-size: 12px; }

/* Sign-in: a banner card with a clear call to action. */
.msgbar.signin-banner {
  margin: 4px 24px 12px; padding: 12px 14px; gap: 14px; border: 1px solid #cfe1f6; border-inline-start: 1px solid #cfe1f6;
  border-radius: 12px; background: linear-gradient(90deg, #eef5fd 0%, #f6f3fe 100%);
  box-shadow: 0 2px 10px rgba(15, 108, 189, .08);
}
.signin-mark {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, #0f6cbd 0%, #3a7fe0 55%, #6b4fd8 100%);
}
.signin-banner .msgbar-text { display: flex; flex-direction: column; gap: 2px; }
.signin-banner .msgbar-text strong { font-weight: 650; }
.signin-sub { font-size: 13px; color: var(--text-secondary); }
.signin-banner .btn.primary { height: 36px; padding: 0 20px; border-radius: 8px; box-shadow: 0 2px 6px rgba(15, 108, 189, .3); }

/* A narrower frame (an F&O workspace column): icons only, New chat keeps its name; nothing scrolls sideways. */
@media (max-width: 1000px) {
  .ap-btn:not(#newChat) > span:not(.ico):not(.count-badge) { display: none; }
  .ap-btn:not(#newChat) { padding: 0 9px; }
  .ap-btn:not(#newChat) > .count-badge { position: absolute; top: 1px; inset-inline-end: 0; margin: 0; }
  .who { max-width: 200px; }
}
.actionpane { overflow: hidden; }
@media (max-width: 640px) {
  .actionpane { padding: 0 6px; gap: 2px; }
  .ap-btn { padding: 0 9px; }
  .ap-btn[aria-expanded="true"]::after { inset-inline: 6px; }
  #newChat { border: none; background: none; }
  .who { padding: 3px; }
  .who .who-name { display: none; }
  .caption { padding: 10px 14px 6px; }
  .msgbar.signin-banner { margin: 4px 12px 10px; flex-wrap: wrap; }
}
