/* ============================================================================
 * components.css — buttons, cards, chips, search+filter, forms, modal/sheet,
 * chat, badges, avatars, charts, states. All token-driven; reused everywhere.
 * ========================================================================== */

/* ---- buttons ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: var(--pill); padding: 10px 18px;
  font-size: 14px; font-weight: var(--fw-semibold); cursor: pointer; white-space: nowrap;
  transition: transform var(--t-fast), background var(--t-fast), border-color var(--t-fast), opacity var(--t-fast);
  background: var(--cta); color: var(--on-cta); }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--glow); }
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.subtle { background: var(--primary-weak); color: var(--primary); }
.btn.danger { background: var(--danger-weak); color: var(--danger); }
.btn.sm { padding: 7px 13px; font-size: 13px; }
.btn.lg { padding: 13px 24px; font-size: 15px; }
.btn .ico { width: 18px; height: 18px; }
.iconbtn { width: 40px; height: 40px; border-radius: var(--pill); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); display: grid; place-items: center; cursor: pointer;
  transition: var(--t-fast); }
.iconbtn:hover { background: var(--surface-2); }
.iconbtn.accent { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.iconbtn.plain { background: transparent; border-color: transparent; color: var(--muted); }
.iconbtn.plain:hover { color: var(--text); background: var(--surface-2); }

/* ---- cards --------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px; box-shadow: var(--sh-sm); transition: box-shadow var(--t), transform var(--t-fast), border-color var(--t-fast); }
.card.pad-lg { padding: 24px; }
.card.clickable { cursor: pointer; }
.card.clickable:hover { box-shadow: var(--sh); transform: translateY(-2px); border-color: var(--border-2); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head .t { font-weight: var(--fw-semibold); font-size: 1rem; }
.card-title { font-size: 1.15rem; font-weight: var(--fw-bold); font-family: var(--font-display); }
.card-sub { color: var(--muted); font-size: 13px; }
/* hero / accent-filled cards (BrightPath-style) */
.card.hero { color: #fff; border: 0; }
.card.hero.blue { background: var(--c1); } .card.hero.accent { background: var(--accent); color: var(--on-accent); }
.card.hero.ink { background: var(--text); } .card.hero.cta { background: var(--cta); color: var(--on-cta); }
.card.hero .card-sub { color: rgba(255,255,255,.8); }

/* stat tile */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; }
.stat .v { font-size: 2rem; font-weight: var(--fw-bold); font-family: var(--font-display); letter-spacing: -.02em; }
.stat .k { color: var(--muted); font-size: 13px; margin-top: 2px; }
.stat .v.sm { font-size: 1.4rem; }

/* ---- chips, badges, segmented ------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--pill);
  background: var(--surface-2); color: var(--text-2); font-size: 12.5px; font-weight: var(--fw-medium); border: 1px solid transparent; }
.chip.solid { background: var(--primary); color: var(--on-primary); }
.chip.outline { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--pill);
  font-size: 11.5px; font-weight: var(--fw-semibold); background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.info { background: var(--primary-weak); color: var(--primary); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.seg { display: inline-flex; padding: 4px; background: var(--surface-2); border-radius: var(--pill); gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 7px 16px; border-radius: var(--pill);
  font-size: 13.5px; font-weight: var(--fw-semibold); cursor: pointer; transition: var(--t-fast); }
.seg button.active { background: var(--cta); color: var(--on-cta); }

/* filter pills (BrightPath category style) */
.pillfilters { display: flex; gap: 8px; flex-wrap: wrap; }
.pillfilter { border: 1px solid var(--border-2); background: transparent; color: var(--text-2);
  padding: 8px 16px; border-radius: var(--pill); font-size: 13px; font-weight: var(--fw-medium); cursor: pointer; transition: var(--t-fast); }
.pillfilter:hover { border-color: var(--primary); color: var(--primary); }
.pillfilter.active { background: var(--primary); color: var(--on-primary); border-color: transparent; }

/* ---- universal search + filter bar -------------------------------------- */
.searchfilter { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.searchbox { flex: 1; min-width: 200px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--pill); padding: 6px 6px 6px 16px; }
.searchbox input { flex: 1; border: 0; background: transparent; color: var(--text); font-size: 14px; outline: none; padding: 6px 0; }
.searchbox .go { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; cursor: pointer; }
.filterselect { position: relative; }
.filterselect select { appearance: none; border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  padding: 9px 34px 9px 14px; border-radius: var(--pill); font-size: 13.5px; cursor: pointer; outline: none; }
.filterselect::after { content: ""; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: translateY(-65%) rotate(45deg); pointer-events: none; }

/* ---- forms --------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: var(--fw-medium); }
input, select, textarea { width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); padding: 11px 13px; outline: none;
  transition: var(--t-fast); }
textarea { resize: none; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { background: var(--surface); border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; } .row > * { flex: 1; min-width: 160px; }
.checkrow { display: flex; align-items: center; gap: 10px; }
.checkrow input { width: auto; accent-color: var(--primary); }

/* ---- avatars ------------------------------------------------------------- */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-weak); color: var(--primary);
  display: grid; place-items: center; font-size: 12px; font-weight: var(--fw-bold); border: 2px solid var(--surface); flex: none; }
.avatar-stack { display: flex; } .avatar-stack .avatar { margin-left: -10px; } .avatar-stack .avatar:first-child { margin-left: 0; }
.avatar.more { background: var(--surface-3); color: var(--text-2); }

/* project icon */
.proj-ico { width: 44px; height: 44px; border-radius: var(--r); display: grid; place-items: center;
  font-weight: var(--fw-bold); font-size: 1rem; background: var(--primary-weak); color: var(--primary); flex: none; }

/* ---- split panel (the ONE primitive for large sections) -----------------
 * Desktop: a right-docked, full-height side panel (list stays visible on the
 * left). Mobile: a full-screen push/pop. Used everywhere via App.nav.openDrill.
 * Small UI (filters, emoji, confirms) use popovers, NOT this. */
.modal-scrim { position: fixed; inset: 0; background: rgba(10,12,20,.42); z-index: 60; display: flex;
  justify-content: flex-end; align-items: stretch; opacity: 0; pointer-events: none; transition: opacity var(--t);
  backdrop-filter: blur(1px); }
.modal-scrim.show { opacity: 1; pointer-events: auto; }
.modal { width: min(640px, 94vw); height: 100vh; max-height: 100vh; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--sh-lg); overflow: hidden;
  transform: translateX(100%); transition: transform var(--t); }
.modal.wide { width: min(900px, 96vw); }
.modal-scrim.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--border); flex: none; }
.modal-head .ttl { font-weight: var(--fw-bold); font-size: 1.2rem; font-family: var(--font-display); flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-body { padding: 20px; overflow-y: auto; overflow-x: hidden; flex: 1; display: flex; flex-direction: column; }
.modal-body > * { flex: none; }                 /* normal stacking… */
.modal-body > .chat, .modal-body > [data-fill] { flex: 1; min-height: 0; }  /* …except a chat fills (input pins to bottom) */
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: center;
  background: var(--surface); flex: none; }
@media (max-width: 980px) { .modal, .modal.wide { width: 100vw; border-left: 0; } }

/* ---- in-pane drill (R2) -------------------------------------------------
 * Drills no longer overlay the whole screen — they push INSIDE the left
 * content column (.content-col), so the permanent chat on the right is never
 * covered. The frame reuses .modal-head / .modal-body / .modal-foot internals
 * (so existing section render code is unchanged); only the container differs. */
.drill-host { position: absolute; inset: 0; z-index: 15; display: none; }
.drill-host.show { display: block; }
/* every mounted frame animates in (smooth push); pop re-mounts the parent → it
 * animates in too, so navigation reads smooth both ways. */
.drill-frame { position: absolute; inset: 0; display: flex; flex-direction: column;
  background: var(--bg); overflow: hidden; animation: drill-in .26s cubic-bezier(.4, 0, .2, 1); }
@keyframes drill-in { from { transform: translateX(26px); opacity: 0; } to { transform: none; opacity: 1; } }
.drill-frame.leaving { animation: drill-out .2s cubic-bezier(.4, 0, .2, 1) forwards; }
@keyframes drill-out { from { transform: none; opacity: 1; } to { transform: translateX(26px); opacity: 0; } }
/* the drill head sits flush under the appbar like a section band (opaque) */
.drill-frame > .modal-head { padding: 14px 24px; background: var(--bg); }
.drill-frame > .modal-body { padding: 20px 24px 24px; }
@media (max-width: 980px) { .drill-frame > .modal-head, .drill-frame > .modal-body { padding-left: 16px; padding-right: 16px; } }
/* Back — the ONE nav affordance for drills: a bold, theme-coloured icon button,
 * upper-left, no label. (Replaces the unintuitive X; back-only, one level/click.) */
.iconbtn.back-nav { width: 40px; height: 40px; background: var(--surface-2); border-color: transparent;
  color: var(--primary); }
.iconbtn.back-nav:hover { background: var(--primary-weak); color: var(--primary); }
.iconbtn.back-nav .ico { width: 23px; height: 23px; stroke-width: 2.4; }
/* a subtle callout pointing the user to the right-side assistant (feature drills
 * whose conversation lives in the ONE chat, e.g. the daily-rule form). */
.ai-route-note { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface);
  color: var(--text-2); font-size: 13.5px; line-height: 1.5; box-shadow: var(--sh-sm); }
.ai-route-note .ico { color: var(--primary); flex: none; margin-top: 1px; }

/* clean focus: keyboard ring only, no click-artifact ring on buttons */
button:focus { outline: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: var(--r-xs); }

/* ---- AI panel (persistent universal assistant; a rounded card) ----------- */
.ai-panel-head { padding: 15px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex: none; }
.ai-panel-head .ico { color: var(--primary); }
.ai-panel-head .t { font-weight: var(--fw-bold); font-family: var(--font-display); flex: 1; font-size: 1.02rem; }
/* the context chip in the head — themed, bold (persistent indicator of the active task) */
.ai-ctx .ctx-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  padding: 5px 12px; border-radius: var(--pill); background: var(--primary-weak); color: var(--primary);
  font-size: 12.5px; font-weight: var(--fw-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- chat / agent builder (fills the card; input pinned bottom) ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; height: 100%; min-height: 0; padding: 16px 18px 18px; }
.chat-log { display: flex; flex-direction: column; gap: 16px; padding: 2px; overflow-y: auto; flex: 1; min-height: 0; }
/* a bold, themed banner announcing an "edit/create with AI" context (attention) */
.chat-banner { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border-radius: var(--r);
  background: var(--primary-weak); color: var(--primary); font-weight: var(--fw-semibold); font-size: 14px;
  line-height: 1.45; box-shadow: var(--sh-sm); }
.chat-banner .ico { width: 20px; height: 20px; flex: none; }
.bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.bubble-row.user { flex-direction: row-reverse; }
.bubble { max-width: 82%; padding: 11px 15px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.agent { background: var(--surface-2); color: var(--text); border-top-left-radius: var(--r-xs); }
.bubble.user { background: var(--primary); color: var(--on-primary); border-top-right-radius: var(--r-xs); }
.bubble.sys { background: var(--accent-weak); color: var(--on-accent); font-size: 13px; align-self: center; text-align: center; max-width: 90%; }
/* AI assistant reply — boxed like the app's widgets (consistent), markdown inside */
.bubble-row.plain { display: block; }
.msg-agent { font-size: 14.5px; line-height: 1.62; color: var(--text); word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; }
.msg-agent > :first-child { margin-top: 0; } .msg-agent > :last-child { margin-bottom: 0; }
/* composer — a single rounded box wrapping the textarea + send button */
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 7px 7px 7px 14px;
  border: 1px solid var(--border-2); border-radius: var(--r-lg); background: var(--surface); }
.chat-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px var(--ring); }
.chat-input textarea { min-height: 30px; max-height: 160px; border: 0; background: transparent;
  padding: 6px 0; border-radius: 0; }
.chat-input textarea:focus { background: transparent; border: 0; box-shadow: none; }
.chat-input .btn { flex: none; width: 40px; height: 40px; padding: 0; border-radius: var(--pill); }
.working-card { background: var(--surface-2); border-radius: var(--r-lg); padding: 12px 14px; }
.step { display: flex; align-items: center; gap: 9px; padding: 5px 0; font-size: 13px; color: var(--text-2); }
.step .ico { width: 16px; height: 16px; color: var(--muted); }
.step.active { color: var(--text); } .step.active .ico { color: var(--primary); }
.step .x { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.step .cnt { color: var(--muted); font-size: 12px; }
.step.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 9px; font-weight: var(--fw-semibold); color: var(--text); }
.step.total .t-x { color: var(--text); }

/* ---- live run timeline (code-driven progress: startup → Думаю → tools) ------
 * Inline, NO bubble/box. Light step lines; the active one carries a quiet pulse;
 * completed lines fade. Seconds stay (subtle, tabular, right-aligned). When done,
 * it collapses to a one-line "Готово · N шаг. · 36s" you can click to expand. */
.run-row .avatar { align-self: flex-start; }
.run { flex: 1 1 auto; min-width: 0; padding: 3px 0 2px; }
.run-steps { display: flex; flex-direction: column; gap: 1px; }
.run-steps.collapsed { display: none; }
.run-step, .run-summary { display: flex; align-items: center; gap: 9px; font-size: 13px; line-height: 1.55; color: var(--text-2); padding: 1.5px 0; }
.run-step .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .2s ease; }
.run-step .sec, .run-summary .sec { margin-left: auto; padding-left: 12px; font-size: 11px; color: var(--muted); opacity: .75; font-variant-numeric: tabular-nums; letter-spacing: .2px; }
.run-step .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border-2); flex: none; transition: background .2s ease; }
.run-step.active { color: var(--text); }
.run-step.active .lbl { font-weight: var(--fw-medium); }
.run-step.active .dot { background: var(--primary); animation: run-pulse 1.15s ease-in-out infinite; }
.run-step.done { color: var(--muted); opacity: .68; }
.run-summary { cursor: pointer; color: var(--text-2); font-weight: var(--fw-medium); user-select: none; }
.run-summary:hover { color: var(--text); }
.run-summary .dot.ok { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
@keyframes run-pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.65); opacity: .4; } }

.spin { animation: spin 1s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.typing span { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--muted); margin: 0 1px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

/* ---- empty / loading / skeleton ----------------------------------------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ico { width: 40px; height: 40px; margin: 0 auto 12px; color: var(--border-2); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r-sm); }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---- toast --------------------------------------------------------------- */
#toaster { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: var(--pill); font-size: 13.5px; box-shadow: var(--sh-lg);
  animation: toastin .25s var(--ease); max-width: 90vw; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px); } }

/* ---- progress bar -------------------------------------------------------- */
.bar { height: 8px; border-radius: var(--pill); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--cta); border-radius: var(--pill); }

/* ============================================================================
 * Per-theme CARD TREATMENTS — cards are ONE component; each theme restyles them
 * via tokens. The accent colour comes from the theme's own chart palette
 * (--c1..), so it stays coherent and no colour is hard-coded. `.accent.a0..a3`
 * cycle the palette; BrightPath fills solid (its signature), other themes use a
 * coloured top bar + tinted icon tile.
 * ========================================================================== */
.card.accent.a0 { --ac: var(--c1); }
.card.accent.a1 { --ac: var(--c2); }
.card.accent.a2 { --ac: var(--c4); }
.card.accent.a3 { --ac: var(--c3); }
.card.accent { border-top: 3px solid var(--ac); }
.card.accent .proj-ico { background: color-mix(in srgb, var(--ac) 20%, transparent); color: var(--ac); }

/* BrightPath — solid vivid hero cards (blue / coral / ink / lime) */
:root[data-theme="brightpath"] .card.accent { background: var(--ac); color: #fff; border: 0; box-shadow: var(--sh); }
:root[data-theme="brightpath"] .card.accent .card-sub,
:root[data-theme="brightpath"] .card.accent .dim,
:root[data-theme="brightpath"] .card.accent .muted,
:root[data-theme="brightpath"] .card.accent .stat .k { color: rgba(255,255,255,.82) !important; }
:root[data-theme="brightpath"] .card.accent .proj-ico { background: rgba(255,255,255,.22); color: #fff; }
:root[data-theme="brightpath"] .card.accent .chip { background: rgba(255,255,255,.2); color: #fff; }
:root[data-theme="brightpath"] .card.accent .bar { background: rgba(255,255,255,.25); }
:root[data-theme="brightpath"] .card.accent.a3 { color: #151313; }       /* lime → dark text */
:root[data-theme="brightpath"] .card.accent.a3 .card-sub,
:root[data-theme="brightpath"] .card.accent.a3 .stat .k { color: rgba(21,19,19,.7) !important; }
:root[data-theme="brightpath"] .card.accent.a3 .proj-ico { background: rgba(21,19,19,.14); color: #151313; }

/* Capture — soft dark capsule cards, mint accent bar */
:root[data-theme="capture"] .card { background: var(--surface); border-color: transparent; box-shadow: var(--sh-sm); }
:root[data-theme="capture"] .card.accent .proj-ico { background: color-mix(in srgb, var(--ac) 26%, var(--surface)); }

/* Space Grotesk — crisp dark cards, vivid accent bar + chips */
:root[data-theme="spacegrotesk"] .card.accent { border-top-width: 3px; }
:root[data-theme="spacegrotesk"] .card { border-color: var(--border-2); }

/* Care — clean white cards, coloured icon tile + thin accent (default look) */

/* ---- rule view (labeled fields; shared App.ruleView) --------------------- */
.rf-row { display: flex; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.rf-row:last-child { border-bottom: 0; }
.rf-k { color: var(--muted); min-width: 130px; flex: none; font-weight: var(--fw-medium); }
.rf-v { color: var(--text); word-break: break-word; }

/* ---- blocking loader (long ops: provider switch / gateway restart) ------- */
.busy-scrim { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(10,12,20,.55); backdrop-filter: blur(2px); opacity: 0; transition: opacity var(--t); }
.busy-scrim.show { opacity: 1; }
.busy-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 28px 32px; max-width: 340px; text-align: center; box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; align-items: center; gap: 14px; }
.busy-card .ico { width: 30px; height: 30px; color: var(--primary); }
.busy-msg { color: var(--text); font-size: 14.5px; line-height: 1.5; }

/* ---- popover (small UI: filters, emoji) ---------------------------------- */
.popover { position: absolute; z-index: 70; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--sh-lg); padding: 14px; min-width: 240px; }
.popover-scrim { position: fixed; inset: 0; z-index: 69; }

/* ---- rendered markdown (reports, KB) ------------------------------------- */
.md { line-height: 1.65; font-size: 14.5px; color: var(--text); overflow-wrap: anywhere; }
.md pre { white-space: pre-wrap; word-break: break-word; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); margin: 18px 0 8px; line-height: 1.25; }
.md h1 { font-size: 1.5rem; } .md h2 { font-size: 1.25rem; } .md h3 { font-size: 1.08rem; } .md h4 { font-size: .98rem; }
.md p { margin: 8px 0; } .md ul, .md ol { margin: 8px 0; padding-left: 22px; } .md li { margin: 3px 0; }
.md a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.md strong { font-weight: var(--fw-bold); } .md em { font-style: italic; }
.md code { background: var(--surface-2); border-radius: var(--r-xs); padding: 1px 6px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .9em; }
.md pre { background: var(--surface-2); border-radius: var(--r-sm); padding: 14px; overflow-x: auto; margin: 10px 0; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--primary); margin: 10px 0; padding: 4px 14px; color: var(--text-2); background: var(--surface-2); border-radius: 0 var(--r-xs) var(--r-xs) 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md .wiki { color: var(--primary); background: var(--primary-weak); border-radius: var(--r-xs); padding: 0 6px; font-weight: var(--fw-medium); }
.md h1:first-child, .md h2:first-child, .md p:first-child { margin-top: 0; }
/* graceful table fallback (assistant is told not to emit tables; if one slips
 * through we render a real table, never raw |pipe| rows) */
.md table.md-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.md table.md-table th, .md table.md-table td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; vertical-align: top; }
.md table.md-table th { background: var(--surface-2); font-weight: var(--fw-semibold); }
.md table.md-table tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.msg-agent table.md-table { font-size: 13px; }

/* ---- login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 32px; box-shadow: var(--sh-lg); }
.login-card .logo { width: 52px; height: 52px; border-radius: var(--r); background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: var(--fw-bold); font-size: 1.3rem; margin-bottom: 18px; box-shadow: var(--glow); }
