/* Copied from qhse-portal/web/css/theme.css (keep in step) */
/* Truckoman QHSE Portal - core theme from the Truckoman Group UI Framework v2.0 (Appendix A, as implemented in the AI Hub). */
:root {
  --surface-page: #FFFFFF;   /* QHSE: full white canvas */
  --surface-card: #FFFFFF;
  --surface-subtle: #F8F9FC;
  --surface-hover: #F1F3F8;
  --surface-selected: #EEF2FF;
  --border: #E6E9EF;
  --border-strong: #D3D9E2;
  --text-primary: #0E1729;
  --text-secondary: #4B5563;
  --text-tertiary: #6B7280;   /* slightly darker than spec #9CA3AF for 4.5:1 contrast on white */
  --text-placeholder: #9CA3AF;
  --text-inverse: #FFFFFF;
  --navy: #1B2E52;
  --navy-dark: #0E1729;
  --navy-mid: #2D4A8A;
  --navy-hover: #243D6B;
  --accent: #E63B2E;
  --accent-hover: #C42E22;
  --link: #185FA5;

  --ok-bg: #EAF3DE; --ok-fg: #3B6D11; --ok-bd: #C0DD97;
  --info-bg: #E6F1FB; --info-fg: #185FA5; --info-bd: #B5D4F4;
  --warn-bg: #FAEEDA; --warn-fg: #854F0B; --warn-bd: #FAC775;
  --danger-bg: #FCEBEB; --danger-fg: #A32D2D; --danger-bd: #F7C1C1;
  --neutral-bg: #F1EFE8; --neutral-fg: #5F5E5A; --neutral-bd: #D3D1C7;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", "Roboto Mono", ui-monospace, monospace;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --rail-w: 56px;
  --focus: 0 0 0 2px #2D4A8A;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-page);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { color: var(--text-primary); font-weight: 500; margin: 0; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
/* No underlines, not even on hover (UI-FRAMEWORK rule 22): links are known by colour and the hand pointer, the same as
   the buttons that look like links. */
a:hover { text-decoration: none; }
b, strong { font-weight: 500; color: var(--text-primary); }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); }
/* Text boxes show focus with their own border (.input / .textarea / .select :focus) or with the frame around them
   (:focus-within — re-login, people picker, recipients, composer, search). The generic ring drew a second box inside
   those frames (UI-FRAMEWORK rule 21). :where() keeps this at the same weight, so .input:focus still wins. */
:where(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]):not([type=color]), textarea, select):focus-visible { box-shadow: none; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.ico { flex-shrink: 0; display: block; }
.muted { color: var(--text-tertiary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; background: transparent; transition: background 100ms ease;
  text-decoration: none !important;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { border-color: var(--border-strong); color: var(--text-secondary); background: var(--surface-card); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-ghost { color: var(--link); padding: 0 6px; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); }
.btn-danger { color: var(--danger-fg); border-color: var(--danger-bd); background: var(--surface-card); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--radius-md);
  border: none; background: transparent; color: var(--text-tertiary); cursor: pointer; transition: background 100ms ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 10px; font-weight: 500;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap; line-height: 1.6;
}
.badge.dot::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-info { background: var(--info-bg); color: var(--info-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-danger { background: var(--danger-bg); color: var(--danger-fg); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.badge-cloud { background: var(--info-bg); color: var(--info-fg); }
.badge-local { background: #E7F5F1; color: #0F6B5B; }
.badge-admin { background: var(--navy); color: #fff; }
.chip { display: inline-flex; align-items: center; font-size: 10px; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--surface-hover); color: var(--text-secondary); }
.count { font-size: 10px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--navy); color: #fff; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field-label { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.field-hint { font-size: 11px; color: var(--text-tertiary); line-height: 1.5; }
.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 6px 10px; border-radius: var(--radius-md);
  border: 1px solid var(--border-strong); background: #fff; color: var(--text-primary); font-size: 13px;
}
.textarea { resize: vertical; line-height: 1.6; }
.input::placeholder, .textarea::placeholder { color: var(--text-placeholder); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); background: #fff; }
.input[disabled] { color: var(--text-tertiary); }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); cursor: pointer; padding: 4px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--navy); margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.code-area { font-family: var(--font-mono); font-size: 12px; min-height: 420px; }
.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: var(--text-secondary); }
.toggle input { position: absolute; opacity: 0; }
.toggle .track { width: 34px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 100ms ease; flex-shrink: 0; }
.toggle .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 100ms ease; }
.toggle input:checked + .track { background: var(--ok-fg); }
.toggle input:checked + .track::after { left: 16px; }
.toggle input:focus-visible + .track { box-shadow: var(--focus); }

/* ---------- Alerts, toasts, empty states ---------- */
.inline-alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-md); font-size: 13px; line-height: 1.5; margin: 8px 0; }
.inline-alert .ico { margin-top: 2px; }
.inline-alert-error { background: var(--danger-bg); color: var(--danger-fg); }
.inline-alert-warning { background: var(--warn-bg); color: var(--warn-fg); }
.inline-alert-info { background: var(--info-bg); color: var(--info-fg); }
.inline-alert-success { background: var(--ok-bg); color: var(--ok-fg); }

.toast-host { position: fixed; top: 16px; right: 16px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 12px 12px 14px; background: var(--surface-card);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--info-fg); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(14, 23, 41, 0.12); animation: toast-in 150ms ease-out;
}
.toast.leaving { opacity: 0; transition: opacity 150ms ease; }
.toast-success { border-left-color: var(--ok-fg); } .toast-success .toast-icon { color: var(--ok-fg); }
.toast-error { border-left-color: var(--danger-fg); } .toast-error .toast-icon { color: var(--danger-fg); }
.toast-warning { border-left-color: var(--warn-fg); } .toast-warning .toast-icon { color: var(--warn-fg); }
.toast-info .toast-icon { color: var(--info-fg); }
.toast-icon { margin-top: 1px; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 500; color: var(--text-primary); }
.toast-msg { color: var(--text-secondary); line-height: 1.5; overflow-wrap: anywhere; }
.toast-close { border: none; background: none; color: var(--text-tertiary); cursor: pointer; padding: 2px; border-radius: 4px; }
.toast-close:hover { color: var(--text-primary); background: var(--surface-hover); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.empty { text-align: center; padding: 40px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-hover); color: var(--text-tertiary); display: grid; place-items: center; margin-bottom: 6px; }
.empty-title { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.empty-text { color: var(--text-tertiary); max-width: 420px; }
.empty .btn { margin-top: 10px; }

/* ---------- Modals ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); display: grid; place-items: center; z-index: 900; padding: 16px; animation: fade 150ms ease-out; }
.modal-overlay.leaving { opacity: 0; transition: opacity 120ms ease; }
.modal-card { background: #fff; border-radius: 16px; width: 100%; padding: 24px; max-height: calc(100dvh - 32px); overflow-y: auto; animation: pop 150ms ease-out; }
.modal-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.modal-head > div { flex: 1; }
.modal-head h3 { font-size: 16px; }
.modal-sub, .modal-text { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.modal-tone { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.modal-tone-danger { background: var(--danger-bg); color: var(--danger-fg); }
.modal-tone-info { background: var(--info-bg); color: var(--info-fg); }
.modal-tone-success { background: var(--ok-bg); color: var(--ok-fg); }
.modal-x { margin: -6px -6px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.97); } }

/* ---------- App shell ---------- */
.shell { display: flex; height: 100dvh; overflow: hidden; }
.rail {
  width: var(--rail-w); flex-shrink: 0; background: var(--navy-dark); display: flex; flex-direction: column;
  align-items: center; padding: 10px 0; gap: 4px; z-index: 50;
}
/* The logo is transparent: shown straight on the navy rail, no white tile. */
.rail-logo { width: 40px; height: 40px; border-radius: 10px; background: transparent; display: grid; place-items: center; margin-bottom: 10px; }
.rail-logo img { width: 36px; height: 36px; object-fit: contain; }
.rail-logo:hover { background: rgba(255, 255, 255, 0.06); }
.rail-item {
  position: relative; width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center;
  color: #fff; opacity: 0.55; transition: background 100ms ease, opacity 100ms ease; border: none; background: transparent; cursor: pointer;
}
.rail-item:hover { opacity: 0.85; background: rgba(255, 255, 255, 0.07); text-decoration: none; }
.rail-item.active { opacity: 1; background: rgba(255, 255, 255, 0.12); }
.rail-item.active::before { content: ''; position: absolute; left: -9px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
/* Main menu icons: smaller and bolder (chosen 14 Oct 2026; previously 20px, 1.5 stroke, 0.55 opacity). */
.rail-item > .ico { width: 17px; height: 17px; stroke-width: 2.2; }
.rail-item { opacity: 0.68; }
.rail-divider { width: 28px; height: 1px; background: rgba(255, 255, 255, 0.1); margin: 6px 0; }
.rail-label { font-size: 9px; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.4); text-transform: uppercase; margin: 2px 0; }
.rail-spacer { flex: 1; }
.rail-user { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-mid); color: #fff; font-size: 10px; font-weight: 500; display: grid; place-items: center; border: none; cursor: pointer; }
.rail-user:hover { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25); }
/* Tooltips for icon-only navigation */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--navy-dark); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 6px; white-space: nowrap;
  pointer-events: none; z-index: 60; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.popover {
  position: fixed; z-index: 800; background: #fff; border: 1px solid var(--border-strong); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(14, 23, 41, 0.16); padding: 6px; min-width: 230px; animation: pop 120ms ease-out;
}
.popover-head { padding: 10px 10px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.popover-head .name { color: var(--text-primary); font-weight: 500; }
.menu-item { text-decoration: none !important; display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; background: none; border-radius: 8px; cursor: pointer; color: var(--text-secondary); text-align: left; }
.menu-item:hover { background: var(--surface-hover); color: var(--text-primary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { flex: 1; overflow-y: auto; padding: 20px 24px 32px; }
.section-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.section-header h2 { font-size: 18px; }
.section-header .sub { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.section-header .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-tertiary); margin-bottom: 4px; }
.back-link:hover { color: var(--text-primary); text-decoration: none; }

.card { background: var(--surface-card); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-pad { padding: 16px 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; }
.card-head .sub { font-size: 11px; color: var(--text-tertiary); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: var(--surface-subtle); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-tertiary); text-align: left; padding: 9px 18px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-secondary); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 100ms ease; }
table.data tbody tr:hover { background: var(--surface-hover); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-title { color: var(--text-primary); font-weight: 500; }
.cell-sub { font-size: 11px; color: var(--text-tertiary); }

/* ---------- Agent avatar ---------- */
.agent-avatar { display: inline-grid; place-items: center; color: #fff; flex-shrink: 0; }

/* ---------- Home ---------- */
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.hero h1 { font-size: 22px; }
.hero p { margin: 4px 0 0; color: var(--text-secondary); }
.date-pill { font-size: 12px; color: var(--text-tertiary); border: 1px solid var(--border-strong); border-radius: 999px; padding: 4px 12px; background: #fff; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 24px; font-weight: 500; color: var(--text-primary); margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-note { font-size: 11px; color: var(--text-tertiary); }
.home-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.agent-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; display: flex; flex-direction: column; gap: 10px;
  cursor: pointer; transition: background 100ms ease, border-color 100ms ease; text-align: left; color: inherit;
}
.agent-card:hover { border-color: var(--border-strong); background: var(--surface-subtle); text-decoration: none; }
.agent-card-top { display: flex; align-items: center; gap: 12px; }
.agent-card-name { color: var(--text-primary); font-weight: 500; font-size: 14px; line-height: 1.3; }
.agent-card-desc { color: var(--text-secondary); line-height: 1.55; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.agent-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.agent-card-foot .open { color: var(--link); font-weight: 500; font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 100ms ease; color: inherit; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-hover); text-decoration: none; }
.list-row .t { color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .s { font-size: 11px; color: var(--text-tertiary); }
.list-row > div { min-width: 0; flex: 1; }

/* ---------- Chat ---------- */
.chat { display: flex; height: 100%; overflow: hidden; }
.chat-side { width: 280px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-side-head { padding: 14px 14px 10px; }
.side-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); font-weight: 500; padding: 10px 14px 6px; }
.side-agents { padding: 0 8px; max-height: 40%; overflow-y: auto; }
.side-agent { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 8px; border: none; background: none; cursor: pointer; text-align: left; color: var(--text-secondary); }
.side-agent:hover { background: var(--surface-hover); }
.side-agent.active { background: var(--surface-selected); color: var(--text-primary); }
.side-agent .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.side-history { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.convo { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: var(--text-secondary); }
.convo:hover { background: var(--surface-hover); }
.convo.active { background: var(--surface-selected); color: var(--text-primary); }
.convo .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo .d { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }
.convo .del { visibility: hidden; flex-shrink: 0; }
.convo:hover .del { visibility: visible; }
.side-empty { color: var(--text-tertiary); font-size: 12px; padding: 6px 8px; }

.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; background: var(--surface-page); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border); background: var(--surface-page); }
.chat-head h2 { font-size: 16px; }
.chat-head .meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text-tertiary); }
.chat-head .grow { flex: 1; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 24px; }
.chat-inner { max-width: 920px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.welcome { text-align: center; padding: 6vh 16px 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.welcome h3 { font-size: 20px; margin-top: 8px; }
.welcome p { margin: 0; max-width: 560px; color: var(--text-secondary); }
.drop-zone { margin-top: 16px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 22px 28px; color: var(--text-tertiary); background: #fff; display: flex; align-items: center; gap: 12px; }
.suggestions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }
.suggestion { border: 1px solid var(--border-strong); background: #fff; border-radius: 999px; padding: 6px 14px; cursor: pointer; color: var(--text-secondary); }
.suggestion:hover { background: var(--surface-hover); color: var(--text-primary); }

.msg { display: flex; gap: 12px; }
.msg-user { justify-content: flex-end; }
.msg-user .stack { align-items: flex-end; max-width: 75%; }
.msg .stack { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.msg-user .bubble { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; font-size: 13.5px; }
.msg-ai .bubble { background: #fff; border: 1px solid var(--border); border-radius: 4px 14px 14px 14px; padding: 16px 20px; overflow-x: auto; }
.msg-ai .who { font-size: 12px; color: var(--text-tertiary); display: flex; align-items: center; gap: 6px; }
.msg-ai .who b { color: var(--text-primary); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px 6px 8px; background: #fff; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text-primary); max-width: 100%; }
.file-chip:hover { text-decoration: none; background: var(--surface-subtle); }
.file-chip .fi { width: 26px; height: 26px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-selected); color: var(--navy-mid); }
.file-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.file-chip .sz { font-size: 11px; color: var(--text-tertiary); }
.msg-actions { display: flex; gap: 4px; align-items: center; color: var(--text-tertiary); font-size: 10px; }
.msg-actions .sep { margin: 0 4px; }
.working { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); }
.working .steps { display: flex; flex-direction: column; gap: 2px; }
.working .elapsed { font-size: 10px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-mid); animation: pulse 1.2s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.error-card { display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px; background: var(--danger-bg); border: 1px solid var(--danger-bd); color: var(--danger-fg); }
.error-card .t { font-weight: 500; }
.error-card .m { color: #7A2222; margin-top: 2px; line-height: 1.5; }
.error-card .a { display: flex; gap: 8px; margin-top: 10px; }

.composer-wrap { padding: 8px 24px 16px; }
.composer { max-width: 920px; margin: 0 auto; background: #fff; border: 1px solid var(--border-strong); border-radius: 14px; padding: 8px; transition: border-color 100ms ease; }
.composer:focus-within { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); }
.composer textarea { width: 100%; border: none; resize: none; outline: none; min-height: 44px; max-height: 220px; padding: 6px 8px; font-size: 13.5px; line-height: 1.6; background: transparent; color: var(--text-primary); }
.composer textarea::placeholder { color: var(--text-placeholder); }
.composer textarea:focus-visible { box-shadow: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.composer-bar .grow { flex: 1; }
.composer-note { max-width: 920px; margin: 6px auto 0; font-size: 11px; color: var(--text-tertiary); text-align: center; }
.drag-overlay { position: absolute; inset: 8px; border: 2px dashed var(--navy-mid); border-radius: 16px; background: rgba(238, 242, 255, 0.9); display: grid; place-items: center; z-index: 5; pointer-events: none; color: var(--navy); font-size: 15px; font-weight: 500; }

/* Markdown answers */
.md { line-height: 1.65; color: var(--text-secondary); font-size: 13.5px; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { color: var(--text-primary); margin: 1.3em 0 0.5em; line-height: 1.35; }
.md h1 { font-size: 17px; } .md h2 { font-size: 15.5px; } .md h3 { font-size: 14px; }
.md strong { color: var(--text-primary); }
.md table { border-collapse: collapse; margin: 12px 0; font-size: 12.5px; width: 100%; }
.md th { background: var(--surface-subtle); color: var(--text-tertiary); font-weight: 500; text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; }
.md th, .md td { border-bottom: 1px solid var(--border-strong); padding: 8px 10px; text-align: left; vertical-align: top; overflow-wrap: normal; }
.md code { font-family: var(--font-mono); background: var(--surface-hover); padding: 1px 5px; border-radius: 4px; font-size: 12px; color: var(--text-primary); }
.md pre { background: var(--surface-subtle); border: 1px solid var(--border); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--warn-bd); background: var(--warn-bg); color: var(--warn-fg); border-radius: 0 6px 6px 0; }
.md ul, .md ol { padding-left: 22px; }
.md hr { border: none; border-top: 1px solid var(--border-strong); margin: 16px 0; }

/* ---------- Admin: agent editor ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; overflow-y: hidden; }
.tab { padding: 9px 14px; border: none; background: none; cursor: pointer; color: var(--text-tertiary); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -0.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-primary); border-bottom-color: var(--accent); }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.preview-card { position: sticky; top: 0; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, 38px); gap: 6px; }
.icon-opt { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border-strong); background: #fff; color: var(--text-secondary); display: grid; place-items: center; cursor: pointer; }
.icon-opt:hover { background: var(--surface-hover); }
.icon-opt.on { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); color: var(--navy); background: var(--surface-selected); }
.color-row { display: flex; gap: 8px; flex-wrap: wrap; }
.color-opt { width: 28px; height: 28px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; }
.color-opt.on { box-shadow: 0 0 0 2px var(--navy-dark); }
.engine-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.engine-card { border: 1px solid var(--border-strong); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; background: #fff; text-align: left; }
.engine-card:hover { background: var(--surface-subtle); }
.engine-card.on { border-color: var(--navy); box-shadow: 0 0 0 1px var(--navy); background: var(--surface-selected); }
.engine-card .ei { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--info-bg); color: var(--info-fg); flex-shrink: 0; }
.engine-card.local .ei { background: #E7F5F1; color: #0F6B5B; }
.engine-card .et { color: var(--text-primary); font-weight: 500; }
.engine-card .ed { font-size: 12px; color: var(--text-tertiary); line-height: 1.5; margin-top: 2px; }
.dropzone { border: 1px dashed var(--border-strong); border-radius: 12px; padding: 24px; text-align: center; background: var(--surface-subtle); cursor: pointer; transition: background 100ms ease; }
.dropzone:hover, .dropzone.over { background: var(--surface-selected); border-color: var(--navy-mid); }
.dropzone .di { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: #fff; color: var(--navy-mid); margin: 0 auto 8px; border: 1px solid var(--border); }
.status-line { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 6px; }
.status-line.ok { color: var(--ok-fg); } .status-line.err { color: var(--danger-fg); } .status-line.busy { color: var(--text-tertiary); }
.danger-zone { border: 1px solid var(--danger-bd); border-radius: 12px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
.danger-zone .t { color: var(--text-primary); font-weight: 500; }
.sticky-actions { position: sticky; bottom: -32px; background: var(--surface-page); padding: 12px 0 0; margin-top: 16px; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--border); }

/* ---------- Usage ---------- */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; padding: 2px; background: #fff; }
.segmented button { border: none; background: none; padding: 4px 12px; border-radius: 6px; cursor: pointer; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.segmented button.on { background: var(--navy); color: #fff; }
.usage-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.chart-box { position: relative; padding: 12px 18px 16px; }
.chart-box svg { display: block; width: 100%; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--navy-dark); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.4; white-space: nowrap; transform: translate(-50%, -100%); margin-top: -8px; z-index: 5; }
.chart-tip .v { font-weight: 500; }
.bar-cell { display: flex; align-items: center; gap: 8px; min-width: 140px; }
.bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-hover); overflow: hidden; }
.bar-fill { height: 100%; background: var(--navy); border-radius: 0 4px 4px 0; }
.bar-val { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .home-grid, .usage-grid, .editor { grid-template-columns: minmax(0, 1fr); }
  .preview-card { position: static; }
}
@media (max-width: 768px) {
  .shell { flex-direction: column-reverse; }
  .rail { width: 100%; height: 56px; flex-direction: row; justify-content: space-around; padding: 0 8px; }
  .rail-logo, .rail-label, .rail-divider, .rail-spacer { display: none; }
  .rail-item.active::before { left: 9px; right: 9px; top: -9px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  [data-tip]:hover::after { display: none; }
  .page { padding: 16px; }
  .chat-side { position: fixed; inset: 0 auto 56px 0; width: 280px; z-index: 40; transform: translateX(-100%); transition: transform 150ms ease; box-shadow: 0 0 40px rgba(0,0,0,0.2); }
  .chat.side-open .chat-side { transform: none; }
  .chat-head, .chat-scroll, .composer-wrap { padding-left: 16px; padding-right: 16px; }
  .msg-user .stack { max-width: 90%; }
  .grid-2, .grid-3, .engine-cards { grid-template-columns: 1fr; }
  table.data th, table.data td { padding-left: 12px; padding-right: 12px; }
}
@media (min-width: 769px) { .only-mobile { display: none !important; } }
