/* Avalon AI Studio — one stylesheet, light and dark, RTL and LTR.
   Logical properties (inline-start/end) everywhere, so Arabic mirrors itself. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #14181f;
  --muted: #5d6675;
  --faint: #8a93a3;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --info: #1d4ed8;
  --info-soft: #e8efff;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, sans-serif;
  --sidebar: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b23; --surface-2: #1c232d; --border: #2a3340;
    --text: #e6e9ee; --muted: #a3acba; --faint: #77808f;
    --accent: #2dd4bf; --accent-soft: #0f2e2b; --accent-text: #04201d;
    --danger: #f97066; --danger-soft: #3a1513; --warn: #fdb022; --warn-soft: #33260a;
    --ok: #47cd89; --ok-soft: #0b2a1b; --info: #84adff; --info-soft: #14213d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b23; --surface-2: #1c232d; --border: #2a3340;
  --text: #e6e9ee; --muted: #a3acba; --faint: #77808f;
  --accent: #2dd4bf; --accent-soft: #0f2e2b; --accent-text: #04201d;
  --danger: #f97066; --danger-soft: #3a1513; --warn: #fdb022; --warn-soft: #33260a;
  --ok: #47cd89; --ok-soft: #0b2a1b; --info: #84adff; --info-soft: #14213d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow-x: hidden; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14.5px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.hidden { display: none !important; }

/* ── Boot / spinner ──────────────────────────────────────────────── */
.boot { display: grid; place-items: center; height: 100vh; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Buttons & inputs ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer;
  font-weight: 500; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }
.icon-btn { border: 0; background: transparent; padding: 6px; border-radius: 8px; cursor: pointer;
  color: var(--muted); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--border);
  background: var(--surface); border-radius: var(--radius-sm); padding: 8px 11px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 90px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13.5px; }

/* ── Login ────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: linear-gradient(150deg, #0f766e 0%, #134e4a 55%, #0b2f2c 100%); color: #fff;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art h1 { font-size: 34px; margin-top: 18px; }
.login-art p { color: rgba(255,255,255,.82); max-width: 460px; font-size: 16px; }
.login-art .chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.login-art .chips span { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  padding: 5px 12px; border-radius: 99px; font-size: 13px; }
.login-form { display: grid; place-items: center; padding: 40px 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 22px; margin-bottom: 6px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  display: grid; place-items: center; color: var(--accent-text); }
.login-art .brand-mark { background: rgba(255,255,255,.16); color: #fff; }
.brand-mark svg { width: 20px; height: 20px; }
.brand-logo { width: 36px; height: 36px; object-fit: contain; flex: none; }
/* On the coloured login panel the logo sits on a white tile so its colours stay true. */
.login-art .brand-logo { background: #fff; border-radius: 10px; padding: 4px; width: 40px; height: 40px; }
.error-text { color: var(--danger); font-size: 13.5px; min-height: 20px; }

/* ── Shell ────────────────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; height: 100vh; }
.sidebar { background: var(--surface); border-inline-end: 1px solid var(--border); display: flex;
  flex-direction: column; padding: 16px 12px; gap: 4px; overflow-y: auto; }
.sidebar .brand { padding: 4px 8px 16px; }
.nav-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint);
  padding: 14px 10px 6px; font-weight: 600; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--muted); cursor: pointer; font-weight: 500; border: 0; background: none; width: 100%;
  text-align: start; }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.badge { margin-inline-start: auto; background: var(--danger); color: #fff; border-radius: 99px;
  font-size: 11.5px; padding: 0 7px; min-width: 20px; text-align: center; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; flex: none; }
.me .who { min-width: 0; }
.me .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; width: 100%; height: 100vh; overflow: hidden; }
.topbar { height: 58px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 22px;
  border-bottom: 1px solid var(--border); background: var(--surface); min-width: 0; }
.topbar h2 { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar > * { flex-shrink: 0; }
.topbar > h2 { flex-shrink: 1; }
.topbar .spacer { flex: 1; }
.topbar select.input { width: auto; padding: 6px 10px; }
.menu-btn { display: none; }
.page { flex: 1; overflow-y: auto; padding: 26px 28px 40px; }
.page-head { display: flex; align-items: end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

/* ── Home ─────────────────────────────────────────────────────────── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.agents { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.agent-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; display: flex; flex-direction: column; gap: 10px; text-align: start;
  transition: transform .12s, box-shadow .12s, border-color .12s; position: relative; overflow: hidden; }
.agent-card::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px; background: var(--c); }
.agent-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: transparent; }
.agent-icon { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); }
.agent-icon svg { width: 22px; height: 22px; }
.agent-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.agent-card .go { margin-top: auto; color: var(--c); font-weight: 600; font-size: 13px; }

/* ── Chat ─────────────────────────────────────────────────────────── */
.chat { display: grid; grid-template-columns: 260px 1fr; height: 100%; min-height: 0; }
.threads { border-inline-end: 1px solid var(--border); background: var(--surface); overflow-y: auto;
  padding: 12px; display: flex; flex-direction: column; gap: 3px; }
.thread { padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 0; background: none;
  text-align: start; width: 100%; color: var(--text); }
.thread:hover { background: var(--surface-2); }
.thread.active { background: var(--accent-soft); }
.thread .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13.5px; font-weight: 500; }
.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.conv-head { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border);
  background: var(--surface); }
.conv-head .agent-icon { width: 36px; height: 36px; }
.messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(720px, 86%); display: flex; flex-direction: column; gap: 8px; }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: normal; word-wrap: break-word; }
.msg.user .bubble { background: var(--accent); color: var(--accent-text); border-end-end-radius: 4px; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--border); border-end-start-radius: 4px; }
.bubble p { margin: 0 0 6px; } .bubble p:last-child { margin: 0; }
.bubble ul { margin: 4px 0; padding-inline-start: 20px; }
.tools-used { font-size: 12px; color: var(--faint); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tools-used span { background: var(--surface-2); border-radius: 6px; padding: 1px 7px; }
.event { align-self: center; font-size: 13px; color: var(--muted); background: var(--surface-2);
  border-radius: 99px; padding: 5px 14px; max-width: 90%; text-align: center; }
.event.ok { background: var(--ok-soft); color: var(--ok); }
.event.bad { background: var(--danger-soft); color: var(--danger); }
.event.wait { background: var(--warn-soft); color: var(--warn); }
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { border-top: 1px solid var(--border); background: var(--surface); padding: 12px 22px 16px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.starter { border: 1px solid var(--border); background: var(--bg); border-radius: 99px; padding: 5px 12px;
  font-size: 13px; cursor: pointer; color: var(--muted); }
.starter:hover { border-color: var(--accent); color: var(--accent); }
.compose-row { display: flex; gap: 10px; align-items: flex-end; }
.compose-row textarea { flex: 1; min-height: 44px; max-height: 180px; resize: none; border-radius: 12px; padding: 11px 14px; }
.empty-chat { margin: auto; text-align: center; max-width: 460px; color: var(--muted); }
.empty-chat .agent-icon { margin: 0 auto 12px; width: 54px; height: 54px; }
.empty-chat .agent-icon svg { width: 28px; height: 28px; }

/* ── Draft cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; min-width: min(460px, 100%); }
.card-head { display: flex; align-items: flex-start; gap: 10px; padding: 13px 16px 10px; }
.card-head .title { font-weight: 600; }
.card-head .spacer { flex: 1; }
.status { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.status.proposed { background: var(--info-soft); color: var(--info); }
.status.awaiting_approval, .status.approved, .status.executing { background: var(--warn-soft); color: var(--warn); }
.status.done { background: var(--ok-soft); color: var(--ok); }
.status.failed, .status.rejected { background: var(--danger-soft); color: var(--danger); }
.status.cancelled, .status.expired, .status.superseded { background: var(--surface-2); color: var(--muted); }
.card-fields { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; padding: 0 16px 10px; font-size: 13.5px; }
.card-fields dt { color: var(--muted); } .card-fields dd { margin: 0; }
table.lines { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.lines th { text-align: start; font-weight: 500; color: var(--muted); font-size: 12.5px; background: var(--surface-2);
  padding: 7px 16px; }
table.lines td { padding: 7px 16px; border-top: 1px solid var(--border); }
table.lines td.r, table.lines th.r { text-align: end; }
.totals { padding: 10px 16px; border-top: 1px solid var(--border); display: grid; gap: 2px; justify-items: end; font-size: 13.5px; }
.totals .grand { font-size: 17px; font-weight: 700; }
.notice { margin: 0 16px 10px; padding: 8px 12px; border-radius: 8px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--info-soft); color: var(--info); }
.card-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; align-items: center; }
.records { display: flex; flex-direction: column; gap: 4px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 13.5px; }
.records a { display: inline-flex; gap: 6px; align-items: center; }
.records .kind { color: var(--muted); min-width: 92px; display: inline-block; }

/* ── Tables & panels ──────────────────────────────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.panel-pad { padding: 18px 20px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.grid th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 10px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
table.grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr.clickable { cursor: pointer; } table.grid tr.clickable:hover td { background: var(--surface-2); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 14px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.chip { display: inline-block; font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 1px 8px; margin: 1px; }
.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ── Dialog & toast ───────────────────────────────────────────────── */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface);
  color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10, 14, 20, .45); }
.dialog-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.dialog-head .spacer { flex: 1; }
.dialog-body { padding: 18px 20px; max-height: 70vh; overflow-y: auto; }
.dialog-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
#toasts { position: fixed; inset-block-end: 18px; inset-inline-start: 50%; transform: translateX(-50%);
  display: grid; gap: 8px; z-index: 50; }
[dir="rtl"] #toasts { transform: translateX(50%); }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: rise .2s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.code-box { font-family: ui-monospace, Consolas, monospace; font-size: 22px; letter-spacing: .18em; background: var(--surface-2);
  border-radius: 10px; padding: 12px 16px; text-align: center; direction: ltr; }

/* ── Small screens ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { padding: 28px 20px; }
  .login-art .chips { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 270px; z-index: 30;
    transform: translateX(-105%); transition: transform .18s; box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar h2 { font-size: 15px; }
  .topbar select.input { max-width: 120px; }
  .topbar .btn .label { display: none; }
  .conv-head .faint { display: none; }
  .page { padding: 18px 16px 32px; }
  .chat { grid-template-columns: 1fr; }
  .threads { display: none; }
  .messages { padding: 14px 12px; }
  .composer { padding: 10px 12px 12px; }
  .msg { max-width: 94%; }
  .card { min-width: 0; }
  .two { grid-template-columns: 1fr; }
  table.grid { display: block; overflow-x: auto; }
}

/* ── Home: ask box, home assistant ───────────────────────────────── */
.ask-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow); border-top: 3px solid var(--c); }
.ask-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ask-box .starters { margin: 12px 0 0; }
.agent-card.home { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset, var(--shadow); }
.home-badge { position: absolute; inset-block-start: 12px; inset-inline-end: 12px; font-size: 11.5px; font-weight: 600;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); padding: 2px 8px; border-radius: 99px; }
.home-tag { margin-inline-start: auto; color: var(--warn); font-size: 12px; }

/* ── Odoo links under a reply ────────────────────────────────────── */
.doc-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.doc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  font-size: 12.5px; font-weight: 500; text-decoration: none; }
.doc-chip:hover { text-decoration: none; filter: brightness(.97); }
.doc-chip svg { width: 14px; height: 14px; }
.doc-chip .k { color: var(--muted); font-weight: 400; }
.doc-link { font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.event.handoff { background: var(--info-soft); color: var(--info); }
.event.handoff a { font-weight: 600; margin-inline-start: 6px; }

/* ── Charts under a reply, and on the performance page ─────────────── */
.chart { margin: 8px 0 0; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); max-width: 620px; }
.chart figcaption { font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.bar-track { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar-value { min-width: 56px; text-align: end; }
.line-chart { direction: ltr; }
.line-chart svg { width: 100%; height: 160px; display: block; }
.line-chart .axis { direction: ltr; display: flex; justify-content: space-between; font-size: 11.5px; color: var(--faint); }
.line-chart .legend { display: flex; gap: 14px; font-size: 12px; margin-top: 4px; color: var(--muted); }
.line-chart .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; }

/* ── How I got this answer ──────────────────────────────────────────── */
.trace { font-size: 12.5px; margin-bottom: 4px; color: var(--muted); }
.trace summary { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; list-style: none; }
.trace summary::-webkit-details-marker { display: none; }
.trace summary svg { width: 14px; height: 14px; color: var(--accent); }
.trace ol { margin: 6px 0 4px; padding-inline-start: 22px; display: grid; gap: 3px; }
.trace li.bad b { color: var(--danger); }
.trace-query { margin-top: 3px; }
.trace-query summary { font-size: 11.5px; color: var(--accent); }
.trace-query pre { margin: 4px 0; padding: 8px 10px; background: var(--panel-2, rgba(127,127,127,.08)); border-radius: 6px;
  font-size: 11.5px; white-space: pre-wrap; word-break: break-word; text-align: left; max-height: 220px; overflow: auto; }

/* ── Feedback ───────────────────────────────────────────────────────── */
.fb-row { display: flex; align-items: center; gap: 2px; margin-top: 2px; opacity: .55; transition: opacity .15s; flex-wrap: wrap; }
.msg:hover .fb-row, .fb-row:focus-within, .fb-row:has(.on) { opacity: 1; }
.fb { border: 0; background: none; padding: 4px; border-radius: 6px; cursor: pointer; color: var(--faint); display: inline-grid; }
.fb svg { width: 15px; height: 15px; }
.fb:hover { background: var(--surface-2); color: var(--text); }
.fb.on { color: var(--accent); }
.fb-note { display: flex; gap: 6px; flex: 1 1 260px; }
.fb-note .input { padding: 5px 9px; font-size: 13px; }
.fb-comment { font-size: 13px; color: var(--text); }

/* ── Proactive alerts ───────────────────────────────────────────────── */
.msg.alert .bubble { border-inline-start: 3px solid var(--warn); }
.alert-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--warn); margin-bottom: 3px; }
.alert-tag svg { width: 13px; height: 13px; }
.bell-wrap { position: relative; }
.icon-btn.bell { position: relative; }
.icon-btn.bell .badge { position: absolute; top: -2px; inset-inline-end: -4px; margin: 0; font-size: 10.5px; padding: 0 5px; }
.bell-panel { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); width: min(360px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 30; max-height: 70vh; overflow-y: auto; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.bell-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; }
.bell-item:hover { background: var(--surface-2); text-decoration: none; }
.bell-item.unread { border-inline-start: 3px solid var(--accent); }
.bell-item .row { display: flex; justify-content: space-between; gap: 8px; }
.bell-panel .empty { padding: 18px 14px; }

/* ── Admin: studio, knowledge, alerts, testing ──────────────────────── */
dialog.wide { width: min(900px, calc(100vw - 32px)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0 14px; }
.tool-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tool-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.tool-group .nav-title { padding: 0 0 4px; }
.tool-group .check { font-size: 13px; }
.ai-draft { background: var(--accent-soft); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; }
.ai-draft .field { margin-bottom: 8px; }
.low-rated { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: grid; gap: 4px; font-size: 13.5px; }
.watcher h3 { margin: 0; }
.case { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; }
.case.bad { border-inline-start: 3px solid var(--danger); }
.case.ok { border-inline-start: 3px solid var(--ok); }
.case summary { cursor: pointer; }
.case .fails { color: var(--danger); font-size: 13px; margin: 8px 0; }
.case .turn { border-top: 1px dashed var(--border); padding: 8px 0; font-size: 13.5px; display: grid; gap: 3px; }
.spinner.inline { display: inline-block; width: 14px; height: 14px; border-width: 2px; vertical-align: middle; }
@media (max-width: 720px) {
  .grid2 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: minmax(70px, 38%) 1fr auto; }
}
.spacer { flex: 1; }
.page-head > .btn { margin-inline-start: auto; }

/* ── Widgets under a reply ───────────────────────────────────────────── */
.widgets { display: grid; gap: 10px; margin-top: 8px; width: min(720px, 100%); }
.widget { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; animation: w-in .25s ease both; }
@keyframes w-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.widget figcaption { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.widget figcaption > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-tools { margin-inline-start: auto; display: flex; gap: 2px; opacity: .5; transition: opacity .15s; }
.widget:hover .w-tools { opacity: 1; }
.w-btn { border: 0; background: none; cursor: pointer; color: var(--muted); border-radius: 6px; padding: 2px 7px; font-size: 13px; }
.w-btn:hover { background: var(--surface-2); color: var(--text); }
.w-expanded { padding: 4px; }
.w-expanded .bars, .w-expanded .donut-wrap { font-size: 14px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.kpi { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 11px; border-inline-start: 3px solid var(--accent); }
.kpi.t-ok { border-color: var(--ok); } .kpi.t-warn { border-color: var(--warn); } .kpi.t-bad { border-color: var(--danger); }
.kpi.t-info { border-color: var(--info); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.kpi.t-bad .kpi-value { color: var(--danger); }
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 2px; }
.kpi-delta.up { color: var(--ok); } .kpi-delta.down { color: var(--danger); }

/* Bars with a second series */
.bar-track { position: relative; }
.bar-fill2 { position: absolute; inset-block: 2px; inset-inline-start: 0; border-radius: 99px; opacity: .85; }
.widget .legend { display: flex; gap: 14px; font-size: 12px; margin-top: 8px; color: var(--muted); }
.widget .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 5px; vertical-align: -1px; }

/* Donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut svg { width: 140px; height: 140px; display: block; }
.donut circle { transition: stroke-width .15s; cursor: default; }
.donut circle:hover { stroke-width: 22; }
.donut-total { font-size: 15px; font-weight: 700; fill: var(--text); font-family: var(--font); }
.donut-unit { font-size: 9px; fill: var(--faint); font-family: var(--font); }
.donut-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; flex: 1; min-width: 180px; font-size: 13px; }
.donut-legend li { display: grid; grid-template-columns: 12px 1fr auto 42px; gap: 8px; align-items: center; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.dl-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Table */
.w-scroll { overflow-x: auto; margin: 0 -4px; }
.w-table { font-size: 13px; min-width: 100%; }
.w-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.w-table th:hover { color: var(--text); }
.w-table td.n, .w-table th.n { text-align: end; }
.w-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.chip-s { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.chip-s.ok { background: var(--ok-soft); color: var(--ok); } .chip-s.warn { background: var(--warn-soft); color: var(--warn); }
.chip-s.bad { background: var(--danger-soft); color: var(--danger); } .chip-s.info { background: var(--info-soft); color: var(--info); }
.chip-s.muted { background: var(--surface-2); color: var(--muted); }
td .chip-s:empty { display: none; }

/* Record card */
.rec-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-head .avatar { width: 40px; height: 40px; font-size: 17px; }
.rec-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-top: 12px; }
.rec-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.rec-stat b { font-size: 16px; }
.rec-stat.t-bad b { color: var(--danger); }
.rec-fields { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 12px 0 0; font-size: 13px; }
.rec-fields dt { color: var(--muted); } .rec-fields dd { margin: 0; }

/* Steps */
.steps-w { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 0; }
.steps-w li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; position: relative; color: var(--faint); text-align: center; }
.steps-w li::before { content: ""; position: absolute; top: 11px; inset-inline-start: -50%; width: 100%; height: 3px; background: var(--border); z-index: 0; }
.steps-w li:first-child::before { display: none; }
.steps-w li.done::before, .steps-w li.current::before { background: var(--ok); }
.dot-s { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); border: 2px solid var(--border); display: grid; place-items: center;
  font-size: 12px; font-weight: 700; color: #fff; z-index: 1; }
.steps-w li.done { color: var(--text); } .steps-w li.done .dot-s { background: var(--ok); border-color: var(--ok); }
.steps-w li.current { color: var(--warn); font-weight: 600; } .steps-w li.current .dot-s { border-color: var(--warn); background: var(--warn-soft); }

/* Progress per line */
.prog { display: grid; gap: 10px; }
.prog-label { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.prog-row { display: grid; grid-template-columns: 70px 1fr 80px; gap: 8px; align-items: center; font-size: 12px; margin-top: 3px; }
.prog-row .num { text-align: end; }

/* Rings */
.rings { display: flex; flex-wrap: wrap; gap: 18px; }
.ring { display: grid; justify-items: center; gap: 2px; min-width: 96px; }
.ring svg { width: 84px; height: 84px; }
.ring-num { font-size: 17px; font-weight: 700; fill: var(--text); font-family: var(--font); }
.ring-label { font-size: 13px; font-weight: 600; text-align: center; }

@media (max-width: 720px) {
  .widgets { width: 100%; }
  .donut svg { width: 116px; height: 116px; }
  .steps-w li { font-size: 11px; }
  .prog-row { grid-template-columns: 56px 1fr 64px; }
}
.msg.assistant:has(.widgets) { width: min(760px, 94%); max-width: min(760px, 94%); }

.w-table td.num, .w-table td.n, .w-table .chip-s { white-space: nowrap; }

/* A downloadable file under a reply (the Excel model) */
.w-file { padding: 0; }
.file-btn { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.file-btn:hover { background: var(--surface-2); text-decoration: none; border-radius: var(--radius); }
.file-ico { background: #107c41; color: #fff; font-weight: 700; font-size: 11px; border-radius: 6px; padding: 8px 6px; }

.w-message .msg-text { white-space: pre-wrap; font-family: inherit; font-size: 13.5px; line-height: 1.6; margin: 0;
  padding: 10px 12px; background: var(--panel-2, rgba(127,127,127,.08)); border-radius: 8px; }

/* Admin → Connect Odoo */
.warn-text { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: 8px; }
.bad-text { color: var(--danger); }
