/*
 * SAP Assistant: history sidebar on the left, one centred conversation, green theme.
 * Light by default, dark when the system asks for it. Status colours stay semantic:
 * red means missing authorization, amber means errors, never the brand green.
 */
:root {
  --bg: #fbfbf9;
  --sidebar: #f4f4f0;
  --surface: #ffffff;
  --surface-2: #f5f5f1;
  --hover: #eaeae4;
  --ink: #1f2420;
  --muted: #6b706a;
  --line: #e5e4dd;
  --accent: #1e7a4c;
  --accent-strong: #17633d;
  --accent-ink: #ffffff;
  --accent-soft: #e6f2ea;
  --user-bubble: #e9f2ec;
  --user-ink: #1f2420;
  --ok: #1a7f37;
  --ok-bg: #e3f3e7;
  --warn: #8a5d00;
  --warn-bg: #fff4d6;
  --warn-line: #e8c46b;
  --bad: #a40e26;
  --bad-bg: #fdecec;
  --bad-line: #f0a8b2;
  --partial: #a35200;
  --partial-bg: #fdefe2;
  --shadow: 0 1px 2px rgba(30, 30, 20, 0.04), 0 1px 6px rgba(30, 30, 20, 0.05);
  --shadow-lg: 0 1px 3px rgba(30, 30, 20, 0.05), 0 8px 28px rgba(30, 30, 20, 0.07);
  --radius: 14px;
  --sidebar-w: 268px;
  --chart-1: #1e7a4c;
  --chart-2: #4f9fd1;
  --chart-3: #d4932a;
  --chart-4: #8a6fd1;
  --chart-5: #c7577f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1c1b;
    --sidebar: #161716;
    --surface: #232523;
    --surface-2: #272927;
    --hover: #2e312e;
    --ink: #ecede9;
    --muted: #a2a69f;
    --line: #333633;
    --accent: #4cbb7f;
    --accent-strong: #63c990;
    --accent-ink: #0c1a11;
    --accent-soft: #1f3528;
    --user-bubble: #27382c;
    --user-ink: #ecede9;
    --ok: #4ac26b;
    --ok-bg: #143020;
    --warn: #e3b341;
    --warn-bg: #2e2510;
    --warn-line: #6b5520;
    --bad: #ff8a95;
    --bad-bg: #3a1418;
    --bad-line: #7a2a33;
    --partial: #f0a35e;
    --partial-bg: #33220f;
    --shadow: none;
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.35);
    --chart-1: #4cc485;
    --chart-2: #6fb8e6;
    --chart-3: #f0b44c;
    --chart-4: #a993e8;
    --chart-5: #e57a9f;
  }
}


* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 system-ui, "Segoe UI", -apple-system, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; }

/* ---------- Shared bits ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); display: inline-grid; place-items: center; flex: none; }
.brand-mark svg, .spark svg { width: 100%; height: 100%; fill: currentColor; }
.brand-mark.large { width: 34px; height: 34px; }
.env-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.4px; color: var(--muted); border: 1px solid var(--line);
  border-radius: 6px; padding: 0 5px; line-height: 17px; cursor: help;
}
.brand-name { font-weight: 650; font-size: 15.5px; white-space: nowrap; letter-spacing: 0.1px; }

.btn {
  border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; font-size: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.large { padding: 12px 22px; font-size: 15px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 0; cursor: pointer; display: grid; place-items: center; flex: none;
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn svg, .send-btn svg, .new-chat-icon svg, .history-item .delete svg {
  width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------- Sign-in ---------- */
.signin { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.signin-card {
  max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 36px 32px; box-shadow: var(--shadow-lg); text-align: center;
}
.signin-card .brand-mark { margin: 0 auto 14px; }
.signin-card h1 { margin: 0 0 8px; font-size: 24px; font-weight: 650; }
.signin-card p { color: var(--muted); margin: 0 0 22px; }
.signin-card .fine { font-size: 13px; margin: 16px 0 0; }
.signin-error { color: var(--bad); font-weight: 600; margin-top: 12px !important; }

/* ---------- App layout ---------- */
.app { display: flex; height: 100%; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--sidebar); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0; transition: margin-left 0.2s ease;
}
.app.collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 14px; }

.new-chat {
  margin: 4px 8px 12px; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 10px;
  border: 0; background: transparent; color: var(--ink); font-weight: 550; cursor: pointer; text-align: left;
}
.new-chat:hover { background: var(--hover); }
.new-chat:disabled { opacity: 0.5; cursor: not-allowed; }
.new-chat-icon {
  width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center;
}
.new-chat-icon svg { width: 15px; height: 15px; stroke-width: 2.4; }

.history { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; }
.history-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 8px 8px 6px; }
.history-empty { font-size: 13px; color: var(--muted); margin: 4px 8px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.history-item { position: relative; }
.history-item .open {
  width: 100%; text-align: left; border: 0; background: transparent; color: var(--ink); cursor: pointer;
  padding: 7px 34px 7px 10px; border-radius: 9px; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.history-item .open:hover { background: var(--hover); }
.history-item.active .open { background: var(--accent-soft); color: var(--ink); font-weight: 550; }
.history-item .delete {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border-radius: 7px;
  border: 0; background: transparent; color: var(--muted); cursor: pointer; display: none; place-items: center;
}
.history-item .delete svg { width: 16px; height: 16px; }
.history-item:hover .delete, .history-item .delete:focus-visible { display: grid; }
.history-item .delete:hover { color: var(--bad); background: var(--surface); }

.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; }
.account { display: flex; align-items: center; gap: 10px; padding: 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none;
}
.account-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.account-user { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-system { font: inherit; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.account-system:hover { color: var(--accent); text-decoration: underline; }
.history-fine { margin: 6px 4px 0; font-size: 11.5px; color: var(--muted); }

.scrim { display: none; }

/* ---------- Main column ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; min-height: 54px; }
.app:not(.collapsed) #expand { visibility: hidden; }
.chat-title { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 24px; }
.messages { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

/* Empty chat: greeting and composer sit together in the middle. */
.main.empty .thread { flex: 0 0 auto; margin-top: auto; overflow: visible; padding-bottom: 8px; }
.main.empty .composer-wrap { margin-bottom: auto; }
.main.empty { padding-bottom: 12vh; }
.main:not(.empty) .welcome, .main:not(.empty) .examples { display: none; }
.welcome { text-align: center; max-width: 780px; margin: 0 auto; padding: 0 8px; }
.welcome h2 {
  margin: 0 0 22px; font-size: 30px; font-weight: 600; letter-spacing: -0.3px;
  display: inline-flex; align-items: center; gap: 12px; color: var(--ink);
}
.welcome .spark { width: 30px; height: 30px; color: var(--accent); display: inline-grid; flex: none; }
.examples { max-width: 780px; margin: 14px auto 0; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.example {
  font-size: 13.5px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 7px 14px; cursor: pointer;
}
.example:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Messages ---------- */
.msg { display: flex; flex-direction: column; gap: 12px; }
.msg.user { align-items: flex-end; }
.bubble {
  max-width: 80%; padding: 10px 16px; border-radius: 18px; background: var(--user-bubble); color: var(--user-ink);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.user-images { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-images img { width: 96px; height: 96px; object-fit: cover; border-radius: 12px; border: 1px solid var(--line); }
.image-chip { font-size: 12.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 999px; padding: 3px 10px; }

.msg.assistant { align-items: stretch; }
.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 12px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose h1, .prose h2, .prose h3 { font-size: 16px; margin: 16px 0 6px; }
.prose strong { font-weight: 650; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.prose pre { background: var(--surface-2); padding: 10px 12px; border-radius: 10px; overflow-x: auto; }
.prose pre code { background: none; padding: 0; }
.prose a { color: var(--accent); }
.prose table, .data-table {
  border-collapse: collapse; width: 100%; font-size: 14px; margin: 4px 0 12px; display: block; overflow-x: auto;
}
.prose th, .prose td, .data-table th, .data-table td {
  border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; white-space: nowrap;
}
.prose th, .data-table th { background: var(--surface-2); font-weight: 600; font-size: 12.5px; color: var(--muted); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover td { background: var(--surface-2); }

.step {
  align-self: flex-start; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
}
.step.running::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--accent); border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}
.step.finished::before { content: "✓"; color: var(--accent); font-weight: 700; }
@keyframes spin { to { transform: rotate(360deg); } }

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* ---------- SAP result card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line);
}
.card-title { font-weight: 650; }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.batch-counts { margin: 0; font-size: 13.5px; color: var(--muted); }
.card .auth-box ul, .card .error-box ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
details.how summary { cursor: pointer; font-size: 12.5px; color: var(--muted); }
details.how pre { margin: 8px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-foot { padding: 8px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); background: var(--surface-2); }
.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge.Complete { color: var(--ok); background: var(--ok-bg); }
.badge.Partial { color: var(--partial); background: var(--partial-bg); }
.badge.Denied { color: var(--bad); background: var(--bad-bg); }
.badge.Error { color: var(--warn); background: var(--warn-bg); }

/* The red box: missing authorization, always drawn from the tool status, never by the AI. */
.auth-box {
  border: 1px solid var(--bad-line); background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px;
}
.auth-box h4, .error-box h4 { margin: 0 0 6px; font-size: 14px; display: flex; gap: 6px; align-items: center; }
.auth-box ul { margin: 0; padding-left: 20px; }
.auth-box .obj { font-family: ui-monospace, Consolas, monospace; font-size: 12px; opacity: 0.9; }
.auth-box .ask { margin: 8px 0 0; font-size: 13px; }
.error-box {
  border: 1px solid var(--warn-line); background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px;
}
.error-box p { margin: 0; }
.notes { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 18px; }
.kv div { min-width: 0; }
.kv dt { font-size: 12px; color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.table-title { font-size: 13px; font-weight: 650; color: var(--muted); margin: 0 0 4px; }
.yes { color: var(--ok); font-weight: 600; }
.no { color: var(--muted); }

.chart-card .card-body { height: 320px; }
.file-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; }
.file-icon {
  width: 40px; height: 40px; border-radius: 10px; background: #1d6f42; color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex: none;
}
.file-card .file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-card .file-meta { font-size: 12px; color: var(--muted); }
.file-card .btn { margin-left: auto; }

.inline-note { font-size: 13px; color: var(--muted); }
.inline-warn { font-size: 13px; color: var(--warn); }

/* ---------- Composer ---------- */
.composer-wrap { padding: 4px 20px 16px; }
.composer {
  max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg); padding: 10px 10px 8px 14px;
}
.composer:focus-within { border-color: var(--accent); }
.composer textarea {
  width: 100%; display: block; resize: none; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit;
  max-height: 220px; padding: 4px 2px 6px; min-height: 28px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; gap: 6px; }
.composer-hint { flex: 1; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 0; cursor: pointer; display: grid; place-items: center; flex: none;
  background: var(--accent); color: var(--accent-ink);
}
.send-btn:hover { background: var(--accent-strong); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn svg { stroke-width: 2.4; }
.composer.locked textarea { cursor: not-allowed; }
.composer.locked textarea::placeholder { color: var(--muted); }
.connect-btn { padding: 6px 14px; font-size: 13.5px; border-radius: 10px; white-space: nowrap; }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; background: transparent; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 0 8px; }
.thumb { position: relative; }
.thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); display: block; }
.thumb button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 13px; line-height: 1;
}
.drop-overlay {
  position: fixed; inset: 0; background: rgba(30, 122, 76, 0.12); border: 3px dashed var(--accent); display: grid; place-items: center;
  font-size: 18px; font-weight: 600; color: var(--accent); z-index: 20; pointer-events: none;
}

/* ---------- Connect to SAP (signed in with Microsoft, SAP not yet) ---------- */
.sap-connect {
  max-width: 780px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 16px; box-shadow: var(--shadow);
}
.sap-connect p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.sap-connect .btn { margin-left: auto; white-space: nowrap; }

/* ---------- Preferences dialog ---------- */
.settings {
  width: min(520px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
.settings::backdrop { background: rgba(10, 20, 14, 0.4); }
.settings form { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 8px; }
.settings h2 { margin: 0; font-size: 18px; }
.settings-intro { margin: 0 0 8px; color: var(--muted); font-size: 13.5px; }
.settings label { font-size: 13px; font-weight: 600; margin-top: 6px; }
.settings textarea, .settings input {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.settings textarea { resize: vertical; min-height: 96px; }
.settings textarea:focus, .settings input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.settings-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-row div { display: flex; flex-direction: column; gap: 6px; }
.settings-error { margin: 4px 0 0; color: var(--bad); font-size: 13px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* ---------- Waiting for the SAP sign-in window ---------- */
.sap-wait { width: min(400px, calc(100vw - 32px)); }
.sap-wait-body { padding: 24px 22px 18px; display: flex; flex-direction: column; gap: 8px; }
.sap-wait-mark { width: 40px; height: 40px; border-radius: 11px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 19px; }
.sap-wait h2 { margin: 6px 0 0; font-size: 18px; }
.sap-wait .settings-intro { margin: 0; }
.sap-wait-host { margin: 0; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.sap-wait-host strong { font-weight: 600; color: inherit; }

/* ---------- Narrow screens: the sidebar slides over the chat ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; box-shadow: var(--shadow-lg); }
  .app.collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w) - 12px); }
  .app:not(.collapsed) .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.3); z-index: 25; }
  .app:not(.collapsed) #expand { visibility: visible; }
  .thread { padding: 8px 16px 20px; }
  .composer-wrap { padding: 4px 16px 12px; }
  .bubble { max-width: 90%; }
  .welcome h2 { font-size: 27px; }
  .main.empty { padding-bottom: 6vh; }
  .chart-card .card-body { height: 260px; }
  .composer-hint { display: none; }
  .sap-connect { flex-direction: column; align-items: stretch; }
  .sap-connect .btn { margin-left: 0; justify-content: center; }
}

/* Working steps of an analysis (ID lists, built-up inputs): one line, open on request. */
details.working-step { padding: 0; }
details.working-step > summary.working-step-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none; }
details.working-step > summary.working-step-head::-webkit-details-marker { display: none; }
details.working-step > summary .card-title { font-weight: 500; color: var(--muted); }
details.working-step[open] > summary .inline-note { visibility: hidden; }
.working-step-body { border-top: 1px solid var(--line); }
button.more-rows { margin: 6px 0 2px; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; }
button.more-rows:hover { text-decoration: underline; }

/* File preview (PDF as itself; Excel/Word as the server's HTML view, sandboxed) */
.file-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.file-card .file-actions .btn { margin-left: 0; }
.file-preview { width: min(1000px, calc(100vw - 32px)); height: min(88vh, 1100px); padding: 0; display: none; flex-direction: column; }
.file-preview[open] { display: flex; }
.file-preview-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.file-preview-title { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-note { margin: 0; padding: 6px 14px; font-size: 12.5px; color: var(--muted); }
.file-preview-frame { flex: 1; min-height: 0; background: #fff; }
.file-preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }

/* ---------------- Feedback (thumbs under an answer, occasional question) ---------------- */
.feedback { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: -4px; }
.fb-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; opacity: 0.55; transition: opacity 0.15s, background 0.15s, color 0.15s; }
.msg.assistant:hover .fb-btn, .fb-btn:focus-visible, .fb-btn.on { opacity: 1; }
.fb-btn:hover { background: var(--hover); color: var(--ink); }
.fb-btn svg { width: 16px; height: 16px; fill: currentColor; }
.fb-btn.on { color: var(--accent); background: var(--accent-soft); }
.fb-note { font-size: 12.5px; color: var(--muted); margin-left: 4px; }
.fb-panel { flex-basis: 100%; margin-top: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); max-width: 560px; }
.fb-q { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.fb-chip { border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; cursor: pointer; }
.fb-chip:hover { background: var(--hover); }
.fb-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.fb-text { width: 100%; resize: vertical; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 13px; background: var(--bg); color: var(--ink); }
.fb-text:focus { outline: none; border-color: var(--accent); }
.fb-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.fb-send { border: 0; background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 5px 14px; font-weight: 600; cursor: pointer; }
.fb-skip { border: 0; background: transparent; color: var(--muted); padding: 5px 8px; cursor: pointer; }
.fb-skip:hover { color: var(--ink); }
.survey { margin: 4px 0 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--accent-soft); max-width: 620px; }
.survey-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.survey-q { font-weight: 600; font-size: 14px; }
.survey-close { border: 0; background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.survey-close:hover { color: var(--ink); }
.survey-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.survey-n { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); cursor: pointer; }
.survey-n b { font-size: 16px; }
.survey-n span { font-size: 11px; color: var(--muted); min-height: 14px; text-align: center; }
.survey-n:hover { border-color: var(--accent); }
.survey-n.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.survey-n.on span { color: var(--accent-ink); }
.survey-more { margin-top: 10px; }
.survey-thanks { font-weight: 600; color: var(--accent); }

/* The chat's own SAP sign-in form (CHAT_SAP_LOGIN=form) */
.sap-form { text-align: left; }
.sap-form .sap-wait-mark, .sap-form h2 { align-self: center; }
.sap-form-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.sap-form-field input {
  font: inherit; font-weight: 400; font-size: 15px; padding: 10px 12px; min-height: 44px; box-sizing: border-box;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.sap-form-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.sap-form-error { margin: 0; font-size: 13px; color: #b42318; }
