@font-face {
  font-family: "Vazirmatn";
  src: url("./fonts/Vazirmatn[wght].woff2") format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #19172f;
  --ink-soft: #57566d;
  --ink-faint: #7c7b91;
  --canvas: #f7f6fb;
  --surface: #ffffff;
  --surface-alt: #f0eff8;
  --surface-tint: #faf9fd;
  --line: #e2e0ed;
  --line-strong: #c9c5dd;
  --brand: #5b4fe9;
  --brand-strong: #4338ca;
  --brand-soft: #eceaff;
  --accent: #e86f51;
  --accent-soft: #fff0eb;
  --success: #137c69;
  --success-soft: #e3f5f1;
  --warning: #9d6105;
  --warning-soft: #fff2d8;
  --danger: #ae3932;
  --danger-soft: #fae6e3;
  --shadow: 0 18px 45px rgba(38, 31, 79, .1);
  --shadow-float: 0 18px 42px rgba(67, 56, 202, .25);
  --radius-xl: 18px;
  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font: "Vazirmatn", Tahoma, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .58; }
a { color: var(--brand-strong); }
:focus-visible { outline: 3px solid #9d94ff; outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

/* Shared controls */
.button {
  min-height: 46px; padding: 8px 18px; border: 1px solid transparent; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  font-weight: 750; transition: transform .16s ease, background .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--brand); box-shadow: 0 7px 18px color-mix(in srgb, var(--brand) 24%, transparent); }
.button-primary:hover:not(:disabled) { background: var(--brand-strong); }
.button-secondary { color: var(--brand-strong); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover:not(:disabled) { background: var(--brand-soft); }
.button-danger { color: var(--danger); background: #fff; border-color: #ebbbb5; }
.button-quiet { min-width: 44px; min-height: 44px; padding: 8px; color: var(--ink-soft); background: transparent; border-color: transparent; font-size: .85rem; }
.button-quiet:hover:not(:disabled) { color: var(--brand-strong); background: var(--surface-alt); }

/* Shared brand primitives. Public landing composition lives in landing.css. */
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font-weight: 850; }
.brand-mark {
  display: grid; place-items: center; width: 39px; height: 39px; overflow: hidden; padding: 5px; border: 1px solid var(--line); border-radius: 11px;
  color: var(--ink); background: var(--surface); box-shadow: 0 7px 18px rgba(67, 56, 202, .14); font-weight: 900;
}
.brand-logo {
  display: block; width: 100%; height: 100%; background: var(--brand);
  -webkit-mask: url("./brand-logo.png?v=20260817-brand-color-v2") center / contain no-repeat;
  mask: url("./brand-logo.png?v=20260817-brand-color-v2") center / contain no-repeat;
}
.brand small { display: block; color: var(--ink-faint); font-size: .69rem; font-weight: 500; margin-top: -5px; }

/* Chat dialog */
.chat-launcher {
  position: fixed; z-index: 22; inset-inline-start: max(20px, env(safe-area-inset-right)); inset-block-end: max(20px, env(safe-area-inset-bottom)); width: 56px; height: 56px;
  padding: 0; border: 1px solid rgba(255,255,255,.24); border-radius: 50%; color: #fff; background: linear-gradient(145deg, #7569f4, var(--brand-strong));
  box-shadow: none; cursor: pointer;
  display: grid; place-items: center; transform-origin: center; transition: transform .18s ease, opacity .18s ease;
}
.chat-launcher[hidden] { display: none; }
.chat-launcher:hover { transform: translateY(-2px); box-shadow: none; }
.chat-launcher:active { transform: scale(.96); }
.chat-launcher .icon { width: 25px; height: 25px; }
.chat-panel {
  position: fixed; z-index: 21; inset-inline-start: max(20px, env(safe-area-inset-right)); inset-block-end: max(20px, env(safe-area-inset-bottom));
  width: min(388px, calc(100vw - 32px)); height: min(600px, calc(100dvh - 40px));
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid color-mix(in srgb, var(--line) 86%, var(--brand)); border-radius: 20px; background: var(--surface);
  box-shadow: 0 24px 64px rgba(32, 27, 68, .22), 0 6px 20px rgba(32, 27, 68, .1); opacity: 0; transform: translateY(12px) scale(.975); transform-origin: 100% 100%; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.chat-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }
.chat-topbar { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 74px; padding: 14px 12px; padding-top: max(14px, env(safe-area-inset-top)); color: #fff; background: linear-gradient(135deg, var(--brand-strong), #6559e8); }
.chat-agent { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.chat-agent-mark { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.46); border-radius: 50%; color: #fff; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.chat-agent-mark .icon { width: 22px; height: 22px; }
.chat-topbar .button-quiet .icon { width: 21px; height: 21px; }
.chat-agent strong { display: block; line-height: 1.35; font-size: 1.02rem; font-weight: 850; }
.chat-topbar .button-quiet { color: #fff; }
.chat-topbar .button-quiet:hover:not(:disabled) { color: #fff; background: radial-gradient(circle, rgba(255,255,255,.18) 0 16px, transparent 17px); }
.chat-content { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 13px 10px; overscroll-behavior: contain; scrollbar-color: #c6d8ce transparent; background: linear-gradient(180deg, #fcfbff 0%, #fff 48%); }
.chat-welcome { width: min(100%, 360px); margin: auto; padding: 8px 2px 4px; border: 0; border-radius: 0; background: transparent; color: var(--ink-soft); font-size: .89rem; line-height: 1.9; text-align: center; box-shadow: none; }
.welcome-mark { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 16px; border: 1px solid color-mix(in srgb, var(--brand) 15%, #e4e0f2); border-radius: 18px; color: var(--brand-strong); background: linear-gradient(145deg, #f7f5ff 0%, color-mix(in srgb, var(--brand) 17%, #fff) 100%); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 13%, transparent); }
.welcome-mark .icon { width: 24px; height: 24px; }
.chat-welcome-copy { margin: 0; color: var(--ink); font-size: 1.16rem; font-weight: 850; line-height: 1.8; white-space: pre-wrap; }
.welcome-note { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 13px; color: var(--ink-faint); font-size: .71rem; }
.welcome-note .icon { color: var(--brand); }
.message { width: 100%; margin-top: 16px; display: flex; flex-direction: column; align-items: flex-end; }
.message.user { align-items: flex-start; }
.message-bubble { max-width: 89%; padding: 11px 14px; border: 1px solid transparent; border-radius: 18px; overflow-wrap: anywhere; white-space: pre-wrap; font-size: .88rem; line-height: 1.85; text-align: start; }
.message.user .message-bubble { border-end-start-radius: 6px; color: #fff; background: linear-gradient(145deg, #7569f4, var(--brand-strong)); box-shadow: 0 8px 18px color-mix(in srgb, var(--brand) 19%, transparent); }
.message[data-delivery="failed"] .message-bubble { background: #9d4540; }
.message.assistant .message-bubble { width: fit-content; max-width: 96%; padding: 11px 14px; border: 1px solid #e7e5ee; border-radius: 12px; border-end-end-radius: 4px; color: var(--ink); background: #f4f3f7; white-space: normal; text-align: right; box-shadow: none; }
.message.operator .message-bubble { border-color: #d9d0f5; border-end-end-radius: 6px; color: #35245f; background: #f4f0ff; white-space: normal; }
.message.assistant .message-bubble p { margin: 0; }
.message.assistant .message-bubble p + p, .message.assistant .message-bubble p + ul, .message.assistant .message-bubble p + ol, .message.assistant .message-bubble ul + p, .message.assistant .message-bubble ol + p { margin-top: .7em; }
.message.assistant .message-bubble ul, .message.assistant .message-bubble ol { margin: .48em 0; padding-inline-start: 1.4em; }
.message.assistant .message-bubble li + li { margin-top: .25em; }
.message.assistant .message-bubble strong { color: var(--ink); font-weight: 850; }
.message.assistant .message-bubble .answer-detail { padding: .1em .75em .1em 0; border-inline-start: 3px solid color-mix(in srgb, var(--brand) 35%, var(--line)); }
.message.assistant .message-bubble code { padding: .08em .35em; border: 1px solid var(--line); border-radius: 5px; background: var(--canvas); font-family: Consolas, "Courier New", monospace; font-size: .88em; direction: ltr; unicode-bidi: isolate; }
.message-footer { width: min(89%, 100%); min-height: 28px; margin-top: 4px; padding-inline: 4px; }
.message-meta { width: 100%; min-height: 28px; display: flex; align-items: center; gap: 7px; color: var(--ink-faint); font-size: .66rem; }
.message-delivery { color: var(--ink-faint); font-size: .66rem; }
.message-delivery { color: var(--danger); font-weight: 700; }
.message-actions { display: inline-flex; align-items: center; gap: 0; margin-inline-start: auto; }
.message-action + .message-action { margin-inline-start: -6px; }
.message-action { position: relative; display: grid; min-width: 44px; min-height: 44px; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--ink-faint); background: transparent; font-size: .67rem; font-weight: 700; }
.message-action::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; transition: background .16s ease; }
.message-action-icon { isolation: isolate; }
.message-action-icon .icon { width: 17px; height: 17px; }
.message-action-icon .icon { position: relative; z-index: 1; }
.message-action:hover:not(:disabled), .message-action.is-success { color: var(--brand-strong); background: transparent; }
.message-action:hover:not(:disabled)::before, .message-action.is-success::before { background: var(--brand-soft); }
.chat-loading { display: flex; gap: 6px; align-items: center; margin: 9px 0 0; padding: 10px 13px; width: max-content; border: 1px solid var(--line); border-radius: 14px; color: var(--ink-faint); background: #fff; font-size: .75rem; }
.loading-dots span { display: inline-block; width: 5px; height: 5px; margin-inline: 1px; border-radius: 50%; background: var(--brand); animation: blink 1s infinite both; }
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,80%,100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }
.chat-error { margin: 11px 0 0; padding: 10px 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 1px solid #efc4bf; border-radius: 14px; color: #71332e; background: linear-gradient(135deg, #fff4f2, var(--danger-soft)); font-size: .78rem; line-height: 1.75; }
.chat-error > span { min-width: 0; }
.chat-error .button { margin-inline-start: 0; min-width: 78px; min-height: 44px; padding: 5px 10px; color: #71332e; background: #fff; border-color: #e8aaa4; border-radius: 10px; box-shadow: none; font-size: .7rem; line-height: 1.35; white-space: nowrap; }
.chat-error .button:hover:not(:disabled) { color: #fff; background: #a84b45; border-color: #a84b45; }
.chat-footer { flex: 0 0 auto; padding: 9px 10px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid #eceaf3; background: #fff; }
.chat-followups {
  display: flex;
  gap: 6px;
  margin: 0 0 7px;
  overflow-x: auto;
  padding: 1px 1px 3px;
  scrollbar-width: none;
}
.chat-followups::-webkit-scrollbar { display: none; }
.widget-followup-question {
  flex: 0 0 auto;
  min-height: 34px;
  max-width: 230px;
  padding: 5px 10px;
  overflow: hidden;
  color: var(--brand-strong);
  background: color-mix(in srgb, var(--brand) 5%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 19%, var(--line));
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 750;
  line-height: 1.55;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.widget-followup-question:hover:not(:disabled) { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 34%, var(--line)); }
.chat-form { flex: 0 0 auto; }
.chat-composer-shell { display: flex; align-items: flex-end; gap: 8px; position: relative; }
.chat-compose { min-width: 0; flex: 1; display: flex; align-items: center; gap: 4px; padding: 0 4px; border: 1px solid #e1deed; border-radius: 16px; background: #f7f6fa; box-shadow: inset 0 1px 0 rgba(255,255,255,.82); transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.chat-compose textarea { min-width: 0; flex: 1; min-height: 32px; max-height: 96px; padding: 5px 8px; resize: none; border: 0; outline: 0; color: var(--ink); background: transparent; direction: rtl; text-align: right; caret-color: var(--brand); font-size: .84rem; line-height: 1.55; }
.chat-emoji-trigger {
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 44px;
  place-items: center;
  padding: 0;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  border-radius: 50%;
}
.chat-emoji-trigger:hover:not(:disabled), .chat-emoji-trigger[aria-expanded="true"] { color: var(--brand-strong); background: radial-gradient(circle, var(--brand-soft) 0 16px, transparent 17px); }
.chat-emoji-trigger .icon { width: 18px; height: 18px; }
.chat-emoji-picker {
  position: absolute;
  z-index: 4;
  inset-inline-end: 4px;
  inset-block-end: calc(100% + 8px);
  display: grid;
  grid-template-columns: repeat(6, 34px);
  gap: 4px;
  width: max-content;
  padding: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: 0 12px 28px rgba(32, 27, 68, .16);
}
.chat-emoji-option {
  display: grid;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 18px;
}
.chat-emoji-option:hover { background: var(--brand-soft); }
.chat-send { position: relative; isolation: isolate; display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px; padding: 0; border: 0; border-radius: 50%; color: #fff; background: transparent; box-shadow: none; }
.chat-send::before { content: ""; position: absolute; inset: 2px; z-index: 0; border-radius: 50%; background: linear-gradient(145deg, #7569f4, var(--brand-strong)); box-shadow: 0 5px 13px color-mix(in srgb, var(--brand) 25%, transparent); }
.chat-send:disabled { color: #aaa7b8; background: transparent; box-shadow: none; opacity: 1; }
.chat-send:disabled::before { background: #e2e0e9; box-shadow: none; }
.chat-send:hover:not(:disabled) { background: transparent; }
.chat-send:hover:not(:disabled)::before { background: var(--brand-strong); }
.chat-send .icon { position: relative; z-index: 1; }
.chat-support { width: 100%; margin: 0; padding: 11px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-tint); }
.chat-support-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-support-summary strong, .chat-support-summary small { display: block; }
.chat-support-summary strong { color: var(--ink); font-size: .78rem; }
.chat-support-summary small { color: var(--ink-soft); font-size: .66rem; line-height: 1.6; }
.handoff-form { display: grid; gap: 7px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.handoff-form label { color: var(--ink-soft); font-size: .72rem; font-weight: 800; }
.handoff-form label span { color: var(--ink-faint); font-weight: 500; }
.handoff-form textarea { width: 100%; min-height: 68px; padding: 8px 10px; resize: vertical; border: 1px solid var(--line-strong); border-radius: 10px; color: var(--ink); background: #fff; line-height: 1.65; }
.handoff-form textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent); }
.handoff-form-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--ink-faint); font-size: .61rem; }
.handoff-form-actions { display: flex; gap: 7px; }
.handoff-form-actions .button { min-height: 38px; padding: 5px 11px; font-size: .7rem; }
.handoff-status { margin: 9px 0 0; padding: 8px 10px; border-radius: 9px; color: var(--success); background: var(--success-soft); font-size: .68rem; }
.handoff-status[data-kind="error"] { color: var(--danger); background: var(--danger-soft); }
.support-contacts { display: grid; gap: 4px; margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); font-size: .68rem; }
.support-contacts a { width: fit-content; overflow-wrap: anywhere; }
.chat-powered-by { display: flex; align-items: center; justify-content: center; gap: 5px; margin-top: 7px; color: #7b73d7; font-size: .67rem; line-height: 1.5; text-decoration: none; }
.chat-powered-by strong { color: #5b4fe9; font-weight: 800; }
.chat-powered-by:hover { color: #5b4fe9; text-decoration: underline; text-underline-offset: 3px; }

/* Admin */
.admin-shell { min-height: 100vh; min-height: 100dvh; background: var(--canvas); }
.admin-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px max(20px, calc((100% - 1180px) / 2)); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.admin-header-right { display: flex; align-items: center; gap: 16px; }
.admin-header-actions { display: flex; align-items: center; gap: 8px; }
.admin-title { display: grid; color: var(--ink); font-size: .83rem; font-weight: 800; line-height: 1.45; }
.admin-title small { color: var(--ink-faint); font-size: .68rem; font-weight: 550; }
.admin-main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 60px; }
.admin-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-sidebar { position: sticky; top: 20px; z-index: 3; display: grid; gap: 10px; }
.admin-nav { display: grid; gap: 5px; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: rgba(255,255,255,.96); box-shadow: 0 8px 25px rgba(25,58,47,.035); }
.admin-nav a { padding: 9px 12px; border-radius: 10px; color: var(--ink-soft); text-decoration: none; font-size: .79rem; font-weight: 750; white-space: nowrap; }
.admin-nav a:hover { color: var(--brand-strong); background: var(--surface-alt); }
.admin-nav a[aria-current="true"] { color: var(--brand-strong); background: var(--brand-soft); }
.admin-content { min-width: 0; display: grid; gap: 24px; }
.admin-section { scroll-margin-top: 20px; }
.admin-section-title { margin: 0 0 12px; font-size: 1.08rem; }
.admin-ingestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.dashboard-banner { margin: -8px 0 20px; }
.section-notice { margin: 0; padding: 10px 14px; border-bottom: 1px solid #edc8c3; color: #842e28; background: var(--danger-soft); font-size: .76rem; }
.admin-section[data-load-state="loading"] { opacity: .72; }
.admin-page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.admin-page-heading h1 { margin: 0; font-size: clamp(1.6rem, 3vw, 2.3rem); line-height: 1.4; letter-spacing: -.025em; }
.admin-page-heading p { margin: 4px 0 0; color: var(--ink-soft); font-size: .89rem; }
.status-badge { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border: 1px solid transparent; border-radius: 999px; color: var(--warning); background: var(--warning-soft); font-size: .73rem; font-weight: 800; white-space: nowrap; }
.status-badge[data-state="ok"] { color: var(--success); background: var(--success-soft); }
.status-badge[data-state="error"] { color: var(--danger); background: var(--danger-soft); }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 28px; }
.status-tile { min-height: 125px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); }
.status-tile-label { color: var(--ink-soft); font-size: .77rem; font-weight: 700; }
.status-tile-value { display: block; margin-top: 10px; color: var(--ink); font-size: 1.65rem; font-weight: 850; line-height: 1.25; letter-spacing: -.03em; overflow-wrap: anywhere; }
.status-tile-value.textual { font-size: 1rem; line-height: 1.6; letter-spacing: 0; }
.status-tile-help { margin: 3px 0 0; color: var(--ink-faint); font-size: .7rem; }
.admin-card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); overflow: hidden; box-shadow: 0 8px 25px rgba(25,58,47,.035); }
.admin-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; padding: 20px 21px 15px; border-bottom: 1px solid var(--line); }
.admin-card-heading h2 { margin: 0; font-size: 1rem; }
.admin-card-heading p { margin: 3px 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.7; }
.admin-card-body { padding: 18px 21px 21px; }
.settings-updated, .installation-quota { flex: 0 0 auto; padding-top: 2px; color: var(--ink-faint); font-size: .69rem; white-space: nowrap; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 15px; }
.settings-grid .field + .field, .installation-create-fields .field + .field, .installation-edit-grid .field + .field { margin-top: 0; }
.settings-field-wide { grid-column: 1 / -1; }
.workspace-settings-form { display: grid; gap: 16px; }
.settings-group { min-width: 0; margin: 0; padding: 0 0 18px; border: 0; border-bottom: 1px solid var(--line); }
.settings-group legend { width: 100%; margin-bottom: 14px; }
.settings-group legend strong, .settings-group legend span { display: block; }
.settings-group legend strong { color: var(--ink); font-size: .86rem; }
.settings-group legend span { margin-top: 2px; color: var(--ink-faint); font-size: .68rem; font-weight: 550; }
.settings-contact-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.textarea { min-height: 92px; resize: vertical; line-height: 1.75; }
.brand-color-control { min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 6px 9px; border: 1px solid #c4d5cc; border-radius: 11px; background: #fff; }
.brand-color-control:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,117,86,.12); }
.brand-color-control input[type="color"] { width: 52px; height: 31px; padding: 0; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.brand-color-control code { color: var(--ink-soft); font-family: Consolas, "Courier New", monospace; font-size: .8rem; }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 2px; padding-top: 16px; border-top: 1px solid var(--line); }
.form-feedback { flex: 1; margin: 0; color: var(--success); font-size: .75rem; }
.form-feedback[data-kind="error"] { color: var(--danger); }
.form-feedback[data-kind="warning"] { color: var(--warning); }
.form-feedback[data-kind="pending"] { color: var(--info); }
.crawl-feedback { padding: 10px 12px; border: 1px solid currentColor; border-radius: 10px; background: var(--surface-tint); line-height: 1.7; }
.crawl-feedback p { margin: 0; }
.crawl-diagnostics { display: grid; gap: 7px; margin: 8px 0 0; padding: 0 18px 0 0; }
.crawl-diagnostics li { padding-inline-start: 3px; }
.crawl-diagnostics code { display: block; max-width: 100%; overflow: hidden; color: var(--ink-faint); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.crawl-preview { padding: 0 21px 21px; border-top: 1px solid var(--line); }
.crawl-preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 18px 0 13px; }
.crawl-preview-heading h3 { margin: 0; font-size: .9rem; }
.crawl-preview-heading p { margin: 3px 0 0; color: var(--ink-soft); font-size: .72rem; }
.crawl-selection-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.crawl-selection-actions .button { min-height: 38px; padding: 5px 9px; }
.crawl-preview-fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.crawl-preview-pages { display: grid; gap: 8px; max-height: 420px; overflow-y: auto; }
.crawl-preview-page { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-tint); cursor: pointer; }
.crawl-preview-page:has(input:checked) { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); background: var(--brand-soft); }
.crawl-preview-page input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--brand); }
.crawl-preview-page-body { min-width: 0; display: grid; gap: 3px; }
.crawl-preview-page-body strong { overflow-wrap: anywhere; font-size: .78rem; }
.crawl-preview-page-body code { overflow: hidden; color: var(--brand-strong); font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.crawl-preview-snippet { display: -webkit-box; overflow: hidden; color: var(--ink-soft); font-size: .7rem; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.crawl-preview-page-body small { color: var(--ink-faint); font-size: .63rem; }
.crawl-index-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; }
.crawl-index-actions .form-feedback { margin: 0; }
.installation-heading-actions { display: flex; align-items: center; gap: 12px; }
.installation-heading-actions .button { min-height: 40px; padding: 6px 12px; font-size: .75rem; }
.installation-setup { padding: 18px 21px 20px; border-bottom: 1px solid var(--line); background: var(--surface-tint); }
.installation-stepper { display: flex; align-items: center; max-width: 530px; margin-bottom: 18px; }
.installation-step { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-faint); font-size: .71rem; font-weight: 750; white-space: nowrap; }
.installation-step b { display: grid; width: 26px; height: 26px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--ink-soft); background: var(--surface); font-size: .68rem; }
.installation-step.is-active { color: var(--brand-strong); }
.installation-step.is-active b { color: #fff; border-color: var(--brand); background: var(--brand); }
.installation-step-line { height: 1px; flex: 1; min-width: 26px; margin-inline: 10px; background: var(--line); }
.installation-create-form { padding: 0; border: 0; background: transparent; }
.installation-create-fields { display: grid; grid-template-columns: minmax(150px, .75fr) minmax(230px, 1.25fr); gap: 13px; align-items: end; }
.installation-create-fields .button { white-space: nowrap; }
.installation-review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.installation-review > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.installation-review span, .installation-review strong { display: block; }
.installation-review span { color: var(--ink-faint); font-size: .67rem; }
.installation-review strong { margin-top: 4px; overflow-wrap: anywhere; color: var(--ink); font-size: .82rem; }
.installation-review p { grid-column: 1 / -1; margin: 2px 0 0; color: var(--ink-soft); font-size: .7rem; }
.installation-wizard-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.installation-wizard-actions #installation-cancel { margin-inline-end: auto; }
.field-help { margin: 7px 0 0; color: var(--ink-faint); font-size: .69rem; }
.installations-list { display: grid; }
.installation-card { padding: 0; border-top: 1px solid var(--line); }
.installation-card:first-child { border-top: 0; }
.installation-details > summary { list-style: none; }
.installation-details > summary::-webkit-details-marker { display: none; }
.installation-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0; padding: 17px 21px; cursor: pointer; }
.installation-card-header:hover { background: var(--surface-alt); }
.installation-card-header h3 { margin: 0; font-size: .95rem; }
.installation-card-header small { display: block; max-width: 600px; margin-top: 3px; overflow: hidden; color: var(--ink-faint); font-size: .67rem; text-overflow: ellipsis; white-space: nowrap; }
.installation-card-summary-actions { display: flex; align-items: center; gap: 10px; }
.installation-manage-label { color: var(--brand-strong); font-size: .69rem; font-weight: 750; }
.installation-details[open] .installation-manage-label { color: var(--ink-faint); }
.installation-details-body { padding: 0 21px 22px; }
.installation-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; color: var(--success); background: var(--success-soft); font-size: .69rem; font-weight: 800; white-space: nowrap; }
.installation-status[data-state="disabled"] { color: var(--ink-soft); background: var(--surface-alt); }
.installation-edit-form { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-tint); }
.installation-edit-grid { display: grid; grid-template-columns: minmax(160px, 1fr) 150px; gap: 11px; }
.installation-edit-form .field label { display: grid; gap: 5px; }
.installation-origins-field { grid-column: 1 / -1; }
.installation-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.installation-edit-actions .button { min-height: 40px; padding-block: 6px; font-size: .75rem; }
.installation-delete { margin-inline-start: auto; }
.installation-outputs { display: grid; gap: 12px; margin-top: 16px; }
.installation-output { display: grid; gap: 5px; }
.installation-output-label { color: var(--ink-soft); font-size: .72rem; font-weight: 800; }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.copy-value { color: var(--ink-soft); background: var(--surface-tint); font-family: Consolas, "Courier New", monospace; font-size: .74rem; }
.copy-row textarea.copy-value { min-height: 88px; white-space: pre; }
.copy-button { min-width: 62px; min-height: 44px; padding-inline: 12px; font-size: .74rem; }
.installation-empty { min-height: 190px; }
.form-row { display: grid; grid-template-columns: 1fr 100px; gap: 10px; }
.field { display: grid; gap: 5px; }
.field + .field { margin-top: 12px; }
.field label { color: var(--ink-soft); font-size: .76rem; font-weight: 800; }
.input, .select { width: 100%; min-height: 44px; padding: 8px 11px; border: 1px solid #c4d5cc; border-radius: 11px; outline: 0; color: var(--ink); background: #fff; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11,117,86,.12); }
.input::placeholder { color: #87958f; }
.upload-dropzone { width: 100%; display: grid; place-items: center; min-height: 154px; padding: 20px; border: 1.5px dashed #9fc5b3; border-radius: 15px; color: var(--ink-soft); background: var(--surface-tint); text-align: center; transition: background .16s ease, border .16s ease; }
.upload-dropzone.is-dragover { border-color: var(--brand); background: var(--brand-soft); }
.upload-dropzone strong { display: block; margin-top: 6px; color: var(--ink); font-size: .86rem; }
.upload-dropzone p { margin: 3px 0 10px; font-size: .73rem; }
.upload-dropzone .button { min-height: 38px; padding: 5px 11px; font-size: .77rem; }
.file-queue { display: grid; gap: 7px; margin-top: 12px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; background: var(--surface-alt); color: var(--ink-soft); font-size: .73rem; }
.file-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item-state { color: var(--brand-strong); font-weight: 800; white-space: nowrap; }
.file-item.error .file-item-state { color: var(--danger); }
.documents-card { min-height: 440px; }
.documents-actions { display: flex; align-items: center; gap: 5px; }
.documents-list { max-height: 590px; overflow: auto; }
.document-row { display: grid; grid-template-columns: minmax(170px, 1fr) 80px 90px 120px; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--line); font-size: .76rem; }
.document-row:last-child { border-bottom: 0; }
.document-name { min-width: 0; }
.document-name strong, .document-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-name strong { font-size: .78rem; }
.document-name small { color: var(--ink-faint); font-size: .67rem; }
.document-type { color: var(--ink-soft); }
.document-count { font-weight: 800; }
.document-date { color: var(--ink-faint); direction: rtl; }
.empty-state { display: grid; place-items: center; min-height: 250px; padding: 25px; text-align: center; color: var(--ink-soft); }
.empty-state strong { display: block; color: var(--ink); }
.empty-state p { max-width: 300px; margin: 4px 0 0; font-size: .8rem; }
.loading-state { padding: 30px; color: var(--ink-soft); text-align: center; font-size: .81rem; }
.inline-banner { margin: 0 20px 14px; padding: 10px 12px; border: 1px solid transparent; border-radius: 10px; font-size: .76rem; }
.inline-banner[data-kind="error"] { color: #842e28; border-color: #edc8c3; background: var(--danger-soft); }
.inline-banner[data-kind="success"] { color: var(--success); border-color: #bde0cd; background: var(--success-soft); }
@media (max-width: 850px) {
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { top: 0; display: flex; gap: 8px; margin-inline: -10px; padding: 8px 10px; overflow-x: auto; background: rgba(245,247,244,.96); backdrop-filter: blur(10px); }
  .admin-nav { display: flex; width: max-content; min-width: max-content; align-items: center; }
  .admin-nav a { flex: 0 0 auto; }
  .admin-section { scroll-margin-top: 82px; }
  .admin-ingestion-grid { grid-template-columns: 1fr; }
}

@media (max-width: 610px) {
  body.chat-is-open { overflow: hidden; }
  .admin-main { width: min(100% - 28px, 1180px); }
  .chat-launcher { inset-inline-start: max(14px, env(safe-area-inset-right)); inset-block-end: max(14px, env(safe-area-inset-bottom)); width: 54px; height: 54px; border-radius: 50%; }
  .chat-panel { inset-inline: 0; inset-block-end: 0; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; transform: translateY(16px); }
  .chat-panel.is-open { transform: none; }
  .chat-messages { padding-inline: 13px; }
  .message-bubble, .message-footer { max-width: 92%; width: auto; }
  .message-footer { width: 92%; }
  .chat-footer { padding-inline: max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-left)); }
  .admin-header { min-height: 66px; padding-inline: 14px; flex-wrap: wrap; }
  .admin-header .admin-title { display: none; }
  .admin-header-actions .button { min-height: 40px; padding-inline: 11px; font-size: .75rem; }
  .admin-main { padding-top: 25px; }
  .admin-page-heading { display: block; }
  .admin-page-heading .status-badge { margin-top: 11px; }
  .status-grid { gap: 10px; }
  .metric-grid, .metric-grid.compact { grid-template-columns: 1fr; }
  .metrics-body { padding-inline: 15px; }
  .status-tile { min-height: 112px; padding: 14px; }
  .status-tile-value { font-size: 1.35rem; }
  .status-tile-value.textual { font-size: .88rem; }
  .admin-card-heading, .admin-card-body { padding-inline: 15px; }
  .settings-grid, .installation-create-fields, .installation-edit-grid { grid-template-columns: 1fr; }
  .installation-create-form, .installation-card { padding-inline: 15px; }
  .installation-origins-field { grid-column: auto; }
  .installation-edit-actions { justify-content: stretch; flex-direction: column; }
  .installation-edit-actions .button { width: 100%; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions .button { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .crawl-preview { padding-inline: 15px; }
  .crawl-preview-heading, .crawl-index-actions { align-items: stretch; flex-direction: column; }
  .crawl-selection-actions .button, .crawl-index-actions .button { flex: 1; }
  .document-row { grid-template-columns: minmax(120px, 1fr) 58px 65px; padding-inline: 15px; }
  .document-date { display: none; }
}

.operations-dashboard { margin-bottom: 18px; }
.metrics-body { padding: 18px 21px 21px; }
.metric-group + .metric-group { margin-top: 22px; padding-top: 19px; border-top: 1px solid var(--line); }
.metric-group h3 { margin: 0 0 11px; color: var(--ink-soft); font-size: .82rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.metric-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-grid .status-tile { min-height: 118px; }
.metrics-note { margin: 18px 0 0; padding: 10px 12px; border-radius: 10px; color: var(--ink-soft); background: var(--surface-alt); font-size: .72rem; }
.metrics-note code { direction: ltr; unicode-bidi: isolate; }
.compact-filter { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--ink-soft); }
.compact-filter .input { min-height: 40px; width: auto; }
.conversation-admin-list, .handoff-admin-list { max-height: 460px; overflow: auto; }
.admin-list-row { width: 100%; border: 0; border-top: 1px solid var(--line); background: transparent; color: inherit; padding: 15px 20px; display: flex; justify-content: space-between; gap: 14px; text-align: right; cursor: pointer; font: inherit; }
.admin-list-row:hover, .admin-list-row:focus-visible { background: var(--surface-alt); }
.admin-list-row > span:first-child { display: grid; gap: 4px; min-width: 0; }
.admin-list-row small { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list-stats { flex: none; color: var(--ink-soft); font-size: .78rem; }
.handoff-row { border-top: 1px solid var(--line); padding: 15px 20px; display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.handoff-row p { margin: 4px 0 0; color: var(--ink-soft); }
.handoff-actions { display: flex; gap: 7px; flex-wrap: wrap; }
.handoff-transcript-link { min-width: 156px; }
.admin-dialog { width: min(760px, calc(100vw - 24px)); max-height: min(760px, calc(100dvh - 24px)); border: 0; border-radius: 22px; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.admin-dialog::backdrop { background: rgb(10 25 20 / .5); backdrop-filter: blur(4px); }
.admin-dialog-header { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--line); padding: 16px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-dialog-header h2, .admin-dialog-header p { margin: 0; }
.admin-dialog-header p { color: var(--ink-soft); font-size: .8rem; }
.admin-transcript { padding: 18px; display: grid; gap: 11px; }
.admin-message { max-width: 84%; border-radius: 16px; padding: 12px 14px; background: var(--surface-alt); }
.admin-message.user { margin-inline-start: auto; background: var(--brand-soft); }
.admin-message p { margin: 5px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-message small { color: var(--ink-soft); }
.transcript-notice { margin: 0; border: 1px solid #edc8c3; border-radius: 11px; }
.document-delete { min-height: 38px; padding-inline: 11px; }
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .admin-list-row, .handoff-row { align-items: stretch; flex-direction: column; }
  .chat-support-summary { align-items: stretch; flex-direction: column; }
  .document-row { grid-template-columns: minmax(110px, 1fr) 52px 60px auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Admin operations dashboard */
:root {
  --control-surface: #ffffff;
  --header-surface: rgba(255, 255, 255, .92);
  --sidebar-surface: rgba(255, 255, 255, .96);
  --scrim: rgba(9, 25, 19, .54);
  --info: #1667a2;
  --info-soft: #e3f1fb;
  --neutral-soft: #edf1ef;
  --skeleton-base: #e7ede9;
  --skeleton-highlight: #f7faf8;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f6f4fb;
  --ink-soft: #c4c0cc;
  --ink-faint: #95909e;
  --canvas: #111016;
  --surface: #1a1921;
  --surface-alt: #201f28;
  --surface-tint: #15141a;
  --control-surface: #111016;
  --header-surface: rgba(26, 25, 33, .92);
  --sidebar-surface: rgba(26, 25, 33, .96);
  --line: #34323d;
  --line-strong: #494653;
  --brand: #8e85ff;
  --brand-strong: #aaa3ff;
  --brand-soft: #292642;
  --accent: #ff9a7f;
  --accent-soft: #4a2b25;
  --success: #65c99b;
  --success-soft: #17382c;
  --warning: #f1bd60;
  --warning-soft: #45351b;
  --danger: #f18b82;
  --danger-soft: #472523;
  --info: #7dbce8;
  --info-soft: #1c3445;
  --neutral-soft: #292733;
  --skeleton-base: #292733;
  --skeleton-highlight: #34323d;
  --scrim: rgba(2, 7, 5, .72);
  --shadow: 0 20px 58px rgba(0, 0, 0, .3);
  --shadow-float: 0 18px 45px rgba(0, 0, 0, .38);
}

.admin-icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.admin-shell { color: var(--ink); background-color: var(--canvas); }
.admin-shell { background-image: linear-gradient(to bottom, color-mix(in srgb, var(--brand-soft) 22%, transparent), transparent 240px); }
.admin-header {
  position: sticky; top: 0; z-index: 15; min-height: 0; display: block;
  padding: 10px 22px 0; border: 0; background: linear-gradient(to bottom, var(--canvas) 66%, transparent);
  box-shadow: none; backdrop-filter: none;
}
.admin-header-inner {
  width: min(1320px, 100%); min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  margin: 0 auto; padding: 8px 10px 8px 14px; border: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
  border-radius: 18px; background: var(--header-surface); box-shadow: 0 10px 28px rgba(38, 31, 79, .07); backdrop-filter: blur(16px);
}
html[data-theme="dark"] .admin-header-inner { box-shadow: 0 12px 32px rgba(0, 0, 0, .2); }
.admin-header .brand { color: var(--ink); }
.admin-header .brand-mark { width: 36px; height: 36px; border-radius: 10px; box-shadow: 0 5px 14px color-mix(in srgb, var(--brand) 24%, transparent); }
.admin-header-right { min-width: 0; gap: 14px; }
.admin-header-divider { width: 1px; height: 28px; background: var(--line); }
.admin-title { min-width: 0; gap: 0; font-size: .78rem; line-height: 1.45; }
.admin-title small { color: var(--ink-faint); font-size: .61rem; font-weight: 650; }
.admin-title span:last-child { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-header-actions { flex-wrap: wrap; justify-content: flex-end; }
.admin-header-actions .button { min-height: 38px; padding: 6px 10px; border-radius: 10px; font-size: .73rem; }
.admin-header-actions .theme-toggle { min-width: 38px; }
.admin-header-actions .compact-filter { gap: 7px; font-size: .66rem; }
.admin-header-actions .compact-filter .select { width: 145px; min-height: 38px; padding-block: 5px; font-size: .72rem; }
.admin-main { width: min(1320px, calc(100% - 44px)); padding-top: 24px; }
.admin-layout { grid-template-columns: 236px minmax(0, 1fr); gap: 24px; }
.admin-content { gap: 30px; }
.admin-sidebar { top: 86px; }
.admin-page-heading { align-items: center; margin-bottom: 20px; }
.admin-page-heading h1 { font-size: clamp(1.55rem, 2.6vw, 2rem); line-height: 1.35; }
.admin-page-heading p { margin-top: 3px; font-size: .81rem; }
.admin-page-heading > div > p:last-child { max-width: 700px; }

.theme-toggle {
  width: 38px; height: 38px; min-width: 38px; min-height: 38px; display: grid; place-items: center; padding: 0;
  border-color: var(--line); border-radius: 10px; color: var(--ink-soft); background: var(--surface-alt); white-space: nowrap;
}
.theme-toggle:hover:not(:disabled) { color: var(--brand-strong); background: var(--brand-soft); }
.theme-toggle span { grid-area: 1 / 1; font-family: Arial, sans-serif; font-size: 1rem; line-height: 1; }
.theme-toggle .theme-icon-moon { display: block; }
.theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }

.tenant-card { border-color: var(--line); background: var(--surface); box-shadow: none; }
.admin-nav { gap: 8px; padding: 8px; border-color: var(--line); background: var(--sidebar-surface); box-shadow: none; }
.admin-nav-group { display: grid; gap: 3px; }
.admin-nav-group + .admin-nav-group { padding-top: 8px; border-top: 1px solid var(--line); }
.admin-nav-label { margin: 0; padding: 3px 11px 5px; color: var(--ink-faint); font-size: .64rem; font-weight: 800; }
.admin-nav a {
  min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 9px 11px;
  border: 1px solid transparent; color: var(--ink-soft); font-size: .8rem;
}
.admin-nav a .icon { width: 18px; height: 18px; }
.admin-nav-badge { margin-inline-start: auto; min-width: 24px; padding: 3px 7px; border-radius: 999px; color: #fff; background: var(--danger); font-size: .62rem; font-weight: 850; line-height: 1.35; text-align: center; }
.admin-nav a:hover { color: var(--ink); background: var(--surface-alt); }
.admin-nav a[aria-current="page"], .admin-nav a[aria-current="true"] {
  color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 24%, var(--line)); background: var(--brand-soft);
  box-shadow: inset -3px 0 0 var(--brand);
}

.section-heading-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading-row .admin-section-title { margin: 0; }
.section-heading-row p { margin: 4px 0 0; color: var(--ink-soft); font-size: .8rem; }
.compact-filter { flex: 0 0 auto; }
.compact-filter .select { width: 112px; min-height: 40px; }

#overview-section > .section-heading-row {
  align-items: center; margin-bottom: 12px; padding: 13px 15px; border: 1px solid var(--line);
  border-radius: 16px; background: color-mix(in srgb, var(--surface) 90%, var(--brand-soft));
}
#overview-section .overview-eyebrow { display: block; margin-bottom: 1px; color: var(--brand-strong); font-size: .63rem; font-weight: 800; }
#overview-section .admin-section-title { font-size: 1rem; line-height: 1.5; }
#overview-section > .section-heading-row p { margin-top: 1px; font-size: .72rem; }
#overview-section > .section-heading-row .compact-filter { display: flex; align-items: center; gap: 8px; color: var(--ink-faint); font-size: .67rem; font-weight: 750; }
#overview-section > .section-heading-row .select { width: 104px; min-height: 36px; padding-block: 5px; border-color: var(--line); font-size: .71rem; }

.onboarding-dialog { width: min(780px, calc(100vw - 24px)); overflow: auto; }
.onboarding-dialog-shell { padding: 24px; background: linear-gradient(145deg, color-mix(in srgb, var(--brand-soft) 56%, var(--surface)) 0%, var(--surface) 42%); }
.onboarding-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.onboarding-heading h2 { margin: 2px 0 4px; font-size: 1.25rem; line-height: 1.55; }
.onboarding-heading p { margin: 0; color: var(--ink-soft); font-size: .78rem; }
.onboarding-close { flex: 0 0 auto; width: 40px; min-height: 40px; padding: 0; }
.onboarding-close .icon { width: 19px; height: 19px; }
.onboarding-eyebrow { color: var(--brand-strong); font-size: .62rem; font-weight: 850; }
.onboarding-progress { height: 7px; margin: 18px 0; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--line) 76%, transparent); }
.onboarding-progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--brand); transition: width .25s ease; }
.onboarding-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 0; padding: 0; list-style: none; }
.onboarding-steps li { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: start; gap: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: color-mix(in srgb, var(--surface) 94%, transparent); }
.onboarding-step-marker { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: var(--brand-strong); background: var(--brand-soft); font-size: .69rem; font-weight: 850; }
.onboarding-steps li strong { display: block; color: var(--ink); font-size: .76rem; line-height: 1.55; }
.onboarding-steps li small { display: block; min-height: 40px; margin-top: 3px; color: var(--ink-faint); font-size: .65rem; line-height: 1.65; }
.onboarding-steps li a.button { grid-column: 1 / -1; min-height: 36px; margin-top: 3px; padding: 6px 10px; font-size: .68rem; text-decoration: none; }
.onboarding-steps li[data-complete="true"] .onboarding-step-marker { color: var(--success); background: var(--success-soft); }
.onboarding-steps li[data-complete="true"] small { color: var(--success); }
.onboarding-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.onboarding-footer > span { color: var(--ink-soft); font-size: .7rem; font-weight: 800; }

.advanced-options { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-tint); }
.advanced-options summary { padding: 10px 12px; cursor: pointer; color: var(--ink-soft); font-size: .72rem; font-weight: 800; }
.advanced-options summary span { margin-inline-start: 4px; color: var(--ink-faint); font-size: .62rem; font-weight: 600; }
.advanced-options[open] summary { border-bottom: 1px solid var(--line); }
.advanced-options .form-row { padding: 12px; }
.advanced-options .field-help { display: block; margin-top: 5px; color: var(--ink-faint); font-size: .62rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi-card {
  --kpi-tone: var(--brand); position: relative; min-height: 126px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start;
  padding: 15px 16px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--kpi-tone) 4%, var(--surface)), var(--surface) 56%); box-shadow: none;
  transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.kpi-card:hover { border-color: color-mix(in srgb, var(--kpi-tone) 30%, var(--line)); transform: translateY(-1px); box-shadow: 0 8px 20px rgba(38, 31, 79, .055); }
.kpi-card[data-kpi="requests"] { --kpi-tone: var(--warning); }
.kpi-card[data-kpi="tokens"] { --kpi-tone: var(--info); }
.kpi-card[data-kpi="latency"] { --kpi-tone: var(--success); }
.kpi-card[data-kpi="failures"] { --kpi-tone: var(--danger); }
.kpi-card::after { content: ""; position: absolute; top: 16px; inset-inline-start: 0; width: 3px; height: 34px; border-radius: 0 999px 999px 0; background: var(--kpi-tone); opacity: .65; }
.kpi-icon { grid-column: 2; grid-row: 1 / span 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--kpi-tone); background: color-mix(in srgb, var(--kpi-tone) 11%, var(--surface)); }
.kpi-icon .icon { width: 17px; height: 17px; }
.kpi-label { grid-column: 1; color: var(--ink-soft); font-size: .72rem; font-weight: 780; }
.kpi-value { grid-column: 1; display: block; margin-top: 5px; font-size: clamp(1.4rem, 2.5vw, 1.72rem); line-height: 1.25; letter-spacing: -.03em; }
.kpi-card p { grid-column: 1 / -1; align-self: end; margin: 9px 0 0; color: var(--ink-faint); font-size: .68rem; line-height: 1.65; }
.kpi-card.is-loading .kpi-label, .kpi-card.is-loading .kpi-value, .kpi-card.is-loading p { color: transparent; border-radius: 6px; background: var(--skeleton-base); animation: skeleton-shimmer 1.25s ease-in-out infinite alternate; }
.kpi-card.is-loading .kpi-label { width: 70%; }
.kpi-card.is-loading .kpi-value { width: 55%; height: 34px; }
.kpi-card.is-loading p { width: 84%; }

.conversation-trend-card {
  margin-top: 14px; padding: 17px 18px 13px; border: 1px solid var(--line); border-radius: 17px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--brand-soft) 26%, var(--surface)), var(--surface) 58%);
}
.conversation-trend-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.conversation-trend-heading h3 { margin: 0; color: var(--ink); font-size: .98rem; line-height: 1.5; }
.conversation-trend-heading p { margin: 2px 0 0; color: var(--ink-soft); font-size: .7rem; line-height: 1.65; }
.conversation-trend-heading .overview-eyebrow { display: block; margin-bottom: 1px; color: var(--brand-strong); font-size: .62rem; font-weight: 800; }
.conversation-trend-total { min-width: 92px; display: grid; gap: 2px; align-content: center; padding: 7px 11px; border: 1px solid color-mix(in srgb, var(--brand) 18%, var(--line)); border-radius: 12px; background: color-mix(in srgb, var(--brand-soft) 48%, var(--surface)); text-align: center; }
.conversation-trend-total span { color: var(--ink-faint); font-size: .61rem; line-height: 1.4; }
.conversation-trend-total strong { color: var(--brand-strong); font-size: 1.12rem; line-height: 1.3; }
.conversation-chart {
  --chart-count: 14; height: 216px; display: grid; grid-template-columns: repeat(var(--chart-count), minmax(0, 1fr)); gap: clamp(4px, 1.1vw, 10px); align-items: stretch;
  padding: 12px 8px 0; overflow: hidden; border-bottom: 1px solid color-mix(in srgb, var(--line) 82%, var(--brand));
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 46px, color-mix(in srgb, var(--line) 60%, transparent) 47px);
}
.conversation-chart-column { min-width: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; align-items: end; gap: 7px; }
.conversation-chart-column[role="listitem"] { outline: 0; }
.conversation-chart-bar { width: min(27px, 100%); min-height: 2px; justify-self: center; align-self: end; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #8177ff, var(--brand-strong)); box-shadow: 0 6px 13px color-mix(in srgb, var(--brand) 18%, transparent); transition: height .25s ease, filter .16s ease; }
.conversation-chart-bar.is-empty { background: color-mix(in srgb, var(--line) 70%, transparent); box-shadow: none; }
.conversation-chart-column:hover .conversation-chart-bar:not(.is-empty) { filter: saturate(1.2) brightness(1.04); }
.conversation-chart-label { min-width: 0; overflow: hidden; color: var(--ink-faint); font-size: .59rem; line-height: 1.4; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.conversation-chart-empty { margin: 9px 0 0; color: var(--ink-faint); font-size: .68rem; text-align: center; }

.admin-card { border-color: var(--line); background: var(--surface); box-shadow: none; }
.admin-card-heading { align-items: center; border-color: var(--line); }
.admin-card-heading h2 { color: var(--ink); }
.metrics-note { border: 1px solid var(--line); background: var(--surface-alt); }

.input, .select, .brand-color-control { color: var(--ink); border-color: var(--line-strong); background: var(--control-surface); }
.input::placeholder, textarea::placeholder { color: var(--ink-faint); opacity: .9; }
.select { width: 100%; min-height: 44px; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 11px; outline: 0; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.button-secondary { color: var(--brand-strong); border-color: var(--line-strong); background: var(--surface); }
.button-secondary:hover:not(:disabled) { background: var(--brand-soft); }
.button-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); background: var(--surface); }
.button-quiet { color: var(--ink-soft); }
.button-quiet:hover:not(:disabled) { color: var(--ink); background: var(--surface-alt); }
.icon-button-with-label { width: auto; min-width: 44px; padding-inline: 10px; }

.status-badge, .semantic-status {
  display: inline-flex; align-items: center; gap: 5px; width: fit-content; min-height: 27px; padding: 3px 8px;
  border: 1px solid transparent; border-radius: 999px; font-size: .67rem; font-weight: 800; line-height: 1.4; white-space: nowrap;
}
.status-badge .icon, .semantic-status .icon { width: 13px; height: 13px; }
.status-badge[data-tone="success"], .semantic-status[data-tone="success"] { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); background: var(--success-soft); }
.status-badge[data-tone="warning"], .semantic-status[data-tone="warning"] { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); background: var(--warning-soft); }
.status-badge[data-tone="danger"], .semantic-status[data-tone="danger"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); background: var(--danger-soft); }
.status-badge[data-tone="info"], .semantic-status[data-tone="info"] { color: var(--info); border-color: color-mix(in srgb, var(--info) 28%, transparent); background: var(--info-soft); }
.status-badge[data-tone="neutral"], .semantic-status[data-tone="neutral"] { color: var(--ink-soft); border-color: var(--line); background: var(--neutral-soft); }

.list-filters { display: grid; grid-template-columns: minmax(230px, 1fr) repeat(2, minmax(145px, .44fr)) auto auto; gap: 9px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface-tint); }
.list-filters.support-filters { grid-template-columns: minmax(240px, 1fr) minmax(170px, .45fr) auto auto; }
.list-filters .button { min-height: 44px; padding-inline: 13px; }
.search-control { position: relative; min-width: 0; }
.search-control > .icon { position: absolute; z-index: 1; top: 50%; right: 12px; width: 18px; height: 18px; color: var(--ink-faint); transform: translateY(-50%); pointer-events: none; }
.search-control .input { padding-right: 39px; }
.list-summary { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 8px 20px; border-bottom: 1px solid var(--line); color: var(--ink-faint); background: var(--surface); font-size: .69rem; }
.list-summary span:first-child { color: var(--ink-soft); font-weight: 800; }
.list-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 13px 20px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .74rem; }
.list-pagination .button { min-height: 38px; padding: 5px 12px; font-size: .72rem; }

.conversation-admin-list { max-height: 620px; }
.admin-list-row { min-height: 94px; align-items: center; border-color: var(--line); background: var(--surface); }
.admin-list-row:first-child { border-top: 0; }
.admin-list-row:hover, .admin-list-row:focus-visible { background: var(--surface-alt); }
.admin-list-body { display: grid; gap: 5px; min-width: 0; }
.admin-list-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.admin-list-title-row strong { font-size: .82rem; }
.admin-list-time { color: var(--ink-faint); font-size: .65rem; }
.admin-list-stats { display: grid; gap: 3px; text-align: left; }
.admin-list-stats strong { color: var(--ink); font-size: .76rem; }
.admin-list-stats small { color: var(--ink-faint); font-size: .68rem; }

.empty-state { min-height: 240px; color: var(--ink-soft); }
.empty-state-content { display: grid; justify-items: center; }
.empty-state-icon { width: 35px; height: 35px; margin-bottom: 12px; color: var(--brand); }
.empty-state .button { margin-top: 15px; min-height: 40px; padding: 6px 13px; font-size: .73rem; }
.skeleton-row { min-height: 94px; display: grid; align-content: center; gap: 10px; padding: 17px 20px; border-top: 1px solid var(--line); }
.skeleton-row:first-child { border-top: 0; }
.skeleton-line, .skeleton-block { display: block; border-radius: 7px; background: var(--skeleton-base); animation: skeleton-shimmer 1.25s ease-in-out infinite alternate; }
.skeleton-line { width: 82%; height: 11px; }
.skeleton-title { width: 44%; height: 15px; }
.skeleton-short { width: 29%; }
.skeleton-block { width: 100%; height: 125px; }
@keyframes skeleton-shimmer { to { background: var(--skeleton-highlight); } }

.support-list-summary { min-height: 38px; }
.support-inbox-layout { display: grid; grid-template-columns: minmax(280px, 33%) minmax(0, 1fr); min-height: 560px; }
.support-queue { min-width: 0; border-left: 1px solid var(--line); }
.handoff-admin-list { max-height: 720px; overflow-y: auto; }
.support-ticket {
  width: 100%; min-height: 102px; display: grid; gap: 6px; padding: 13px 16px; border: 0; border-top: 1px solid var(--line);
  color: var(--ink); background: var(--surface); text-align: right; font: inherit; cursor: pointer;
}
.support-ticket:first-child { border-top: 0; }
.support-ticket:hover { background: var(--surface-alt); }
.support-ticket[aria-pressed="true"] { position: relative; background: var(--brand-soft); box-shadow: inset -3px 0 0 var(--brand); }
.support-ticket-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.support-ticket-meta { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.support-ticket-top strong { overflow: hidden; font-size: .79rem; text-overflow: ellipsis; white-space: nowrap; }
.support-ticket-reason { display: -webkit-box; overflow: hidden; color: var(--ink-soft); font-size: .74rem; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
.support-ticket-meta time { color: var(--ink-faint); font-size: .65rem; }
.support-detail { min-width: 0; min-height: 560px; background: var(--surface-tint); }
.support-detail-empty { min-height: 560px; display: grid; place-items: center; align-content: center; padding: 30px; color: var(--ink-soft); text-align: center; }
.support-detail-empty .icon { width: 42px; height: 42px; margin-bottom: 14px; color: var(--brand); }
.support-detail-empty strong { color: var(--ink); }
.support-detail-empty p { max-width: 330px; margin: 5px 0 0; font-size: .76rem; }
.support-detail-loading { display: grid; gap: 14px; padding: 24px; }
.support-detail-content { min-width: 0; }
.support-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.support-detail-eyebrow { color: var(--brand-strong); font-size: .67rem; font-weight: 850; }
.support-detail-header h3 { margin: 2px 0 0; font-size: 1.03rem; }
.support-detail-header p { margin: 3px 0 0; color: var(--ink-soft); font-size: .72rem; }
.support-detail-badges { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
.support-readonly-notice, .support-unsupported-notice { margin: 13px 20px 0; }
.inline-banner[data-kind="warning"] { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); background: var(--warning-soft); }
.support-controls { padding: 15px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.support-controls fieldset { margin: 0; padding: 0; border: 0; }
.support-controls legend { margin-bottom: 9px; color: var(--ink-soft); font-size: .72rem; font-weight: 850; }
.support-control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.support-control-grid label { color: var(--ink-soft); font-size: .69rem; font-weight: 760; }
.support-control-grid .select { margin-top: 4px; }
.support-control-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 11px; }
.support-control-actions .button { min-height: 39px; padding: 5px 11px; font-size: .71rem; }
.support-detail-section { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.support-detail-section h4 { margin: 0 0 9px; font-size: .8rem; }
.support-reason { margin: 0; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; color: var(--ink-soft); background: var(--surface); font-size: .76rem; white-space: pre-wrap; }
.support-subheading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.support-subheading h4 { margin: 0; }
.support-subheading span { color: var(--ink-faint); font-size: .66rem; }
.support-conversation-preview { display: grid; gap: 8px; max-height: 340px; overflow-y: auto; }
.support-preview-message { max-width: 88%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px 13px 13px 4px; background: var(--surface); }
.support-preview-message.user { margin-inline-start: auto; border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); border-radius: 13px 13px 4px 13px; background: var(--brand-soft); }
.support-preview-message.operator { border-color: color-mix(in srgb, var(--info) 30%, var(--line)); background: var(--info-soft); }
.support-preview-message small { color: var(--ink-faint); font-size: .62rem; }
.support-preview-message p { margin: 3px 0 0; color: var(--ink); font-size: .74rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.support-muted { margin: 0; padding: 13px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--ink-faint); font-size: .72rem; text-align: center; }
.support-composers { display: block; padding: 15px 18px 18px; background: var(--surface); }
.support-composer { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-tint); }
.support-composer label { color: var(--ink); font-size: .73rem; font-weight: 850; }
.support-composer label span { color: var(--ink-faint); font-size: .63rem; font-weight: 600; }
.support-composer textarea { margin-top: 7px; }
.support-composer > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.support-composer small { color: var(--ink-faint); font-size: .61rem; }
.support-composer .button { min-height: 38px; padding: 5px 10px; font-size: .7rem; white-space: nowrap; }

.documents-list { max-height: 640px; }
.document-row { grid-template-columns: minmax(170px, 1fr) 74px 80px 98px 118px auto; border-color: var(--line); }
.document-type { display: inline-flex; align-items: center; gap: 5px; }
.document-type .icon { width: 15px; height: 15px; }
.document-delete { min-width: 52px; }
.upload-dropzone { color: var(--ink-soft); border-color: color-mix(in srgb, var(--brand) 50%, var(--line)); background: var(--surface-tint); }
.upload-dropzone .icon { width: 27px; height: 27px; color: var(--brand); }
.file-item { background: var(--surface-alt); }

.settings-updated, .installation-quota { color: var(--ink-faint); }
.field-optional { color: var(--ink-faint); font-weight: 550; }
.installation-setup { border-color: var(--line); background: var(--surface-tint); }
.installation-create-form { background: transparent; }
.installation-card, .installation-edit-form { border-color: var(--line); }
.installation-edit-form, .copy-value { background: var(--surface-tint); }
.copy-value { color: var(--ink-soft); }

.admin-dialog { color: var(--ink); background: var(--surface); }
.admin-dialog::backdrop { background: var(--scrim); }
.admin-dialog-header { background: var(--surface); border-color: var(--line); }
.admin-message { background: var(--surface-alt); }
.admin-message.user { background: var(--brand-soft); }
.section-notice { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--line)); background: var(--danger-soft); }
.inline-banner[data-kind="error"] { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--line)); background: var(--danger-soft); }
.inline-banner[data-kind="success"] { color: var(--success); border-color: color-mix(in srgb, var(--success) 34%, var(--line)); background: var(--success-soft); }

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-filters.support-filters { grid-template-columns: minmax(230px, 1fr) minmax(155px, .5fr) auto auto; }
  .support-inbox-layout { grid-template-columns: minmax(275px, 36%) minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .admin-header { position: relative; padding-inline: 15px; }
  .admin-header-inner { width: 100%; }
  .admin-main { width: min(100% - 30px, 1320px); }
  .admin-layout { grid-template-columns: 1fr; gap: 18px; }
  .admin-sidebar { position: sticky; top: 0; z-index: 12; display: block; margin-inline: -15px; padding: 8px 15px; overflow-x: auto; background: var(--header-surface); backdrop-filter: blur(12px); scrollbar-width: thin; }
  .tenant-card { display: none; }
  .admin-nav { width: max-content; min-width: max-content; display: flex; gap: 5px; padding: 6px; }
  .admin-nav-group { display: flex; gap: 4px; }
  .admin-nav-group + .admin-nav-group { padding-top: 0; padding-inline-start: 8px; border-top: 0; border-inline-start: 1px solid var(--line); }
  .admin-nav-label { display: none; }
  .admin-nav a { flex: 0 0 auto; min-height: 42px; }
  .admin-nav-badge { margin-inline-start: 2px; }
  .admin-nav a[aria-current="page"], .admin-nav a[aria-current="true"] { box-shadow: inset 0 -3px 0 var(--brand); }
  .admin-section { scroll-margin-top: 74px; }
  .support-inbox-layout { grid-template-columns: 1fr; }
  .support-queue { border-left: 0; border-bottom: 1px solid var(--line); }
  .handoff-admin-list { max-height: 430px; }
  .support-detail, .support-detail-empty { min-height: 520px; }
  .document-row { grid-template-columns: minmax(150px, 1fr) 70px 76px 94px auto; }
  .document-date { display: none; }
}

@media (max-width: 760px) {
  .onboarding-dialog-shell { padding: 18px; }
  .onboarding-heading h2 { font-size: 1.08rem; }
  .onboarding-steps { grid-template-columns: 1fr; }
  .onboarding-steps li small { min-height: 0; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conversation-trend-card { padding: 15px 14px 11px; }
  .conversation-trend-heading { gap: 10px; }
  .conversation-trend-total { min-width: 78px; padding-inline: 8px; }
  .conversation-chart { height: 196px; gap: 5px; padding-inline: 4px; }
  .list-filters, .list-filters.support-filters { grid-template-columns: 1fr 1fr; }
  .list-filters .search-control { grid-column: 1 / -1; }
  .list-summary { align-items: flex-start; flex-direction: column; gap: 2px; }
  .admin-list-row { align-items: flex-start; flex-direction: row; }
  .admin-list-stats { text-align: left; }
  .support-detail-header { flex-direction: column; }
  .support-detail-badges { justify-content: flex-start; }
  .support-control-grid { grid-template-columns: 1fr; }
  .document-row { grid-template-columns: minmax(130px, 1fr) 66px auto; }
  .document-count, .document-date { display: none; }
}

@media (max-width: 610px) {
  .onboarding-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 17px; }
  .onboarding-dialog-shell { padding: 16px; }
  .onboarding-footer { align-items: stretch; flex-direction: column; }
  .onboarding-footer .button { width: 100%; }
  .admin-header { padding: 8px 10px 0; }
  .admin-header-inner { min-height: 56px; gap: 10px; padding: 7px 8px 7px 10px; border-radius: 15px; }
  .admin-header-right { gap: 9px; }
  .admin-header-right .brand > span:last-child, .admin-header-divider, .admin-title, .admin-header-actions .button span { display: none; }
  .admin-header-actions .theme-toggle .theme-icon-moon { display: block; }
  .admin-header-actions .theme-toggle .theme-icon-sun { display: none; }
  html[data-theme="dark"] .admin-header-actions .theme-toggle .theme-icon-moon { display: none; }
  html[data-theme="dark"] .admin-header-actions .theme-toggle .theme-icon-sun { display: block; }
  .admin-header-actions { gap: 4px; flex-wrap: nowrap; }
  .admin-header-actions .button { width: 36px; min-width: 36px; min-height: 36px; padding: 7px; }
  .admin-header-actions .compact-filter { display: flex; gap: 0; font-size: 0; }
  .admin-header-actions .compact-filter .select { flex: 0 0 auto; width: 88px; min-height: 36px; padding-block: 4px; font-size: .66rem; }
  .admin-page-heading { margin-bottom: 18px; }
  .admin-page-heading .status-badge { margin-top: 12px; }
  .section-heading-row { align-items: stretch; flex-direction: column; }
  #overview-section > .section-heading-row { align-items: stretch; padding: 12px; }
  .compact-filter { justify-content: space-between; }
  .compact-filter .select { flex: 1; width: auto; }
  .kpi-grid { gap: 9px; }
  .kpi-card { min-height: 124px; padding: 13px; }
  .kpi-card::after { top: 14px; height: 30px; }
  .kpi-icon { width: 33px; height: 33px; }
  .settings-contact-grid, .installation-review { grid-template-columns: 1fr; }
  .installation-review p { grid-column: auto; }
  .installation-page-heading { align-items: stretch; flex-direction: column; }
  .installation-heading-actions { justify-content: space-between; }
  .installation-heading-actions .button span { display: inline; }
  .installation-setup, .installation-details-body { padding-inline: 14px; }
  .installation-card { padding-inline: 0; }
  .installation-card-header { align-items: flex-start; padding-inline: 14px; }
  .installation-card-summary-actions { align-items: flex-end; flex-direction: column; gap: 5px; }
  .installation-manage-label { display: none; }
  .installation-wizard-actions { flex-wrap: wrap; }
  .installation-wizard-actions .button { flex: 1; }
  .installation-wizard-actions #installation-cancel { flex: 0 0 100%; order: 2; }
  .list-filters, .list-filters.support-filters { padding-inline: 14px; }
  .list-filters .button { width: 100%; }
  .admin-list-row { padding-inline: 14px; }
  .support-ticket { padding-inline: 14px; }
  .support-detail-header, .support-controls, .support-detail-section, .support-composers { padding-inline: 14px; }
  .support-control-actions { align-items: stretch; flex-direction: column; }
  .support-control-actions .button { width: 100%; }
  .support-preview-message { max-width: 94%; }
  .document-row { padding-inline: 14px; }
}

@media (forced-colors: active) {
  .kpi-card::after, .tenant-card::before { border: 2px solid currentColor; }
  .semantic-status, .status-badge, .admin-nav a[aria-current="page"], .support-ticket[aria-pressed="true"] { border: 2px solid currentColor; }
}

/* Local/demo widget v2 additions. Kept scoped to the customer chat panel. */
:root {
  --widget-visual-viewport-height: 100dvh;
  --widget-visual-viewport-offset-top: 0px;
}

.chat-panel .widget-starter-questions { display: grid; gap: 11px; margin-top: 22px; }
.chat-panel .widget-starter-question {
  width: 100%; min-height: 52px; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 11px 16px; border: 1px solid color-mix(in srgb, var(--brand) 18%, #ddd9eb); border-radius: 16px;
  color: var(--brand-strong); background: linear-gradient(135deg, #fff 0%, color-mix(in srgb, var(--brand-soft) 48%, #fff) 100%); box-shadow: 0 5px 16px color-mix(in srgb, var(--brand) 8%, transparent); font-size: .82rem; font-weight: 750; line-height: 1.7; text-align: right; transition: transform .16s ease, color .16s ease, border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.chat-panel .widget-starter-question:hover:not(:disabled) { transform: translateY(-2px); color: color-mix(in srgb, var(--brand-strong) 86%, #211a5b); background: linear-gradient(135deg, #fff 0%, color-mix(in srgb, var(--brand-soft) 82%, #fff) 100%); border-color: color-mix(in srgb, var(--brand) 38%, #d4cfea); box-shadow: 0 10px 24px color-mix(in srgb, var(--brand) 14%, transparent); }
.chat-panel .widget-starter-question:active:not(:disabled) { transform: translateY(0) scale(.995); }

.chat-panel .widget-stream-card {
  position: relative; display: block; align-self: flex-end;
  width: fit-content; max-width: 92%; margin-top: 12px; padding-bottom: 8px;
  margin-inline-start: auto;
  color: var(--ink); background: transparent; border: 0;
}
.chat-panel .widget-stream-bubble {
  position: relative; display: flex; align-items: center; gap: 9px;
  width: fit-content; max-width: 100%; min-height: 66px; min-width: 0;
  padding: 15px 18px; border: 0;
  border-radius: 28px; border-end-start-radius: 26px;
  color: var(--ink-soft); background: color-mix(in srgb, var(--surface-alt) 90%, var(--line));
  box-shadow: none; text-align: right;
}
.chat-panel .widget-stream-bubble::before,
.chat-panel .widget-stream-bubble::after {
  content: ""; position: absolute; z-index: 0; display: block; border-radius: 50%;
  background: color-mix(in srgb, var(--surface-alt) 90%, var(--line)); pointer-events: none;
}
.chat-panel .widget-stream-bubble::before {
  inset-inline-end: -2px; inset-block-end: -10px; width: 18px; height: 18px;
}
.chat-panel .widget-stream-bubble::after {
  inset-inline-end: -13px; inset-block-end: -20px; width: 9px; height: 9px;
}
.chat-panel .widget-stream-bubble strong { position: relative; z-index: 1; display: block; min-width: 0; color: var(--ink-soft); font-size: .9rem; font-weight: 550; line-height: 1.55; }
.chat-panel .widget-stream-bubble p { display: none; }
.chat-panel .widget-stream-dots { position: relative; z-index: 1; display: flex; flex: 0 0 auto; gap: 3px; order: 2; align-self: flex-end; margin-block-end: 2px; }
.chat-panel .widget-stream-dots i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); animation: widget-stream-pulse .9s infinite ease-in-out;
}
.chat-panel .widget-stream-dots i:nth-child(2) { animation-delay: .12s; }
.chat-panel .widget-stream-dots i:nth-child(3) { animation-delay: .24s; }
@keyframes widget-stream-pulse {
  0%, 60%, 100% { opacity: .42; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.chat-panel .widget-stop {
  position: relative; isolation: isolate; display: grid; place-items: center; width: 44px; height: 44px; min-width: 44px; min-height: 44px; flex: 0 0 44px; padding: 0; border: 0; border-radius: 50%;
  color: #fff; background: transparent; box-shadow: none;
}
.chat-panel .widget-stop::before { content: ""; position: absolute; inset: 2px; z-index: 0; border-radius: 50%; background: var(--danger); box-shadow: 0 4px 11px rgba(174, 57, 50, .2); }
.chat-panel .widget-stop span { position: relative; z-index: 1; width: 13px; height: 13px; border-radius: 3px; background: currentColor; }
.chat-panel .chat-compose textarea { min-height: 32px; max-height: 96px; padding-block: 5px; }
.chat-panel .chat-footer { overflow: visible; }
.chat-panel .chat-error .button,
.chat-panel .handoff-form-actions .button,
.chat-panel .message-action { min-height: 44px; }

.chat-panel .message[data-stream-draft="true"] { opacity: .88; }
.chat-panel .message.operator { align-items: flex-end; }
.chat-panel .message.operator .message-bubble {
  border: 1px solid #d9d0f5; border-radius: 18px; border-end-end-radius: 6px; color: #35245f; background: #f4f0ff; white-space: normal;
  box-shadow: 0 5px 16px rgba(53, 36, 95, .05);
}
.chat-panel .message.operator .message-bubble p { margin: 0; }
.chat-panel .message.operator .message-bubble p + p,
.chat-panel .message.operator .message-bubble p + ul,
.chat-panel .message.operator .message-bubble p + ol { margin-top: .7em; }
.chat-panel .message.operator .message-bubble ul,
.chat-panel .message.operator .message-bubble ol { margin: .48em 0; padding-inline-start: 1.4em; }
.chat-panel .message.assistant .message-bubble blockquote,
.chat-panel .message.operator .message-bubble blockquote {
  margin: .55em 0; padding-inline-start: .75em; border-inline-start: 3px solid #9dd0b8; color: var(--ink-soft);
}
.chat-panel .widget-message-label { margin-bottom: 4px; padding-inline: 4px; color: #6941c6; font-size: .67rem; font-weight: 750; }
.chat-panel .widget-terminal-state { color: var(--ink-faint); font-size: .66rem; }

.chat-panel .chat-support-summary {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px;
}
.chat-panel .widget-handoff-icon {
  display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; color: var(--brand); background: var(--surface);
}
.chat-panel .widget-handoff-icon .icon { width: 19px; height: 19px; }
.chat-panel .widget-handoff-badge {
  padding: 4px 8px; border-radius: 999px; color: var(--warning); background: var(--warning-soft); font-size: .61rem; font-weight: 800; white-space: nowrap;
}
.chat-panel .widget-handoff-badge[data-kind="resolved"] { color: var(--success); background: var(--success-soft); }
.chat-panel .widget-handoff-badge[data-kind="cancelled"] { color: var(--ink-soft); background: var(--surface-alt); }
.chat-panel .handoff-status[data-kind="pending"] { color: var(--warning); background: var(--warning-soft); }
.chat-panel .handoff-form textarea { max-height: 110px; resize: none; }

@media (max-width: 610px) {
  .chat-panel {
    top: var(--widget-visual-viewport-offset-top); bottom: auto;
    height: min(100dvh, var(--widget-visual-viewport-height));
    padding-right: env(safe-area-inset-right); padding-left: env(safe-area-inset-left);
  }
  .chat-panel .chat-topbar { padding-inline: max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-left)); }
  .chat-panel .chat-messages { padding-inline: max(13px, env(safe-area-inset-right)) max(13px, env(safe-area-inset-left)); }
  .chat-panel .chat-footer { padding-inline: max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-left)); }
  .chat-panel .chat-support { width: 100%; }
}
