/* Bella Trade Dashboard - design tokens + components. RTL-first (logical properties), light / dark, responsive. */
:root {
  --brand: #0f6b5c; --brand-ink: #ffffff; --brand-soft: #e3f2ef;
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f8fafb; --line: #e2e7ec; --fg: #17202b; --muted: #5d6877;
  --in-bubble: #ffffff; --ai-bubble: #eef2ff; --ai-ink: #3730a3; --staff-bubble: #dff3ec; --staff-ink: #0b5547;
  --waiting: #b45309; --waiting-bg: #fff4e5; --taken: #1d4ed8; --taken-bg: #e8efff; --resolved: #047857; --resolved-bg: #e6f6ef;
  --danger: #b42318; --danger-bg: #fde8e7; --warn-bg: #fff7db; --warn: #7a5a00; --focus: #2563eb;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #3fb59f; --brand-ink: #062a24; --brand-soft: #123a33;
  --bg: #0e1319; --surface: #151c24; --surface-2: #1a232d; --line: #263241; --fg: #e6ecf2; --muted: #9aa7b6;
  --in-bubble: #1c2631; --ai-bubble: #222a4a; --ai-ink: #c7d0ff; --staff-bubble: #123d34; --staff-ink: #bff0e2;
  --waiting: #f5b454; --waiting-bg: #3a2a10; --taken: #8fb0ff; --taken-bg: #1c2847; --resolved: #6fd6ad; --resolved-bg: #143327;
  --danger: #ff8a80; --danger-bg: #3d1a18; --warn-bg: #3a3214; --warn: #f4d58d; --focus: #8fb0ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 8px; top: -40px; background: var(--surface); padding: 6px 10px; border-radius: 6px; z-index: 50; }
.skip:focus { top: 8px; }

/* ---- buttons, inputs, chips, badges ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.05); background: var(--brand); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.input, textarea.input, select.input { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
textarea.input { resize: none; min-height: 44px; max-height: 160px; line-height: 1.45; }
label.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.WAITING { color: var(--waiting); background: var(--waiting-bg); }
.badge.TAKEN { color: var(--taken); background: var(--taken-bg); }
.badge.RESOLVED { color: var(--resolved); background: var(--resolved-bg); }
.badge.NONE, .badge.muted { color: var(--muted); background: var(--surface-2); }
.badge.ai-OFF { color: var(--danger); background: var(--danger-bg); }
.badge.ai-ON { color: var(--resolved); background: var(--resolved-bg); }
.notice { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.notice.error { background: var(--danger-bg); color: var(--danger); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.info { background: var(--brand-soft); color: var(--fg); }
.muted { color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* ---- auth ---- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; display: grid; gap: 16px; }
.auth-card h1 { margin: 0; font-size: 22px; }
.brandmark { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--brand); }
.brandmark img { width: 34px; height: 34px; }
.code-input { letter-spacing: .4em; text-align: center; font-size: 22px; direction: ltr; }
.secret { font-family: ui-monospace, Consolas, monospace; direction: ltr; word-break: break-all; background: var(--surface-2); padding: 8px; border-radius: 6px; user-select: all; }

/* ---- app shell ---- */
.shell { display: grid; grid-template-columns: 72px 1fr; height: 100%; }
.rail { background: var(--surface); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; }
.rail .brandmark { margin-bottom: 10px; }
.rail a, .rail button { width: 56px; min-height: 52px; display: grid; place-items: center; gap: 2px; border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  text-decoration: none; font-size: 11px; cursor: pointer; padding: 6px 2px; }
.rail a[aria-current="page"], .rail a:hover, .rail button:hover { background: var(--brand-soft); color: var(--fg); }
.rail .icon { font-size: 20px; line-height: 1; }
.rail .spacer { flex: 1; }
.main { min-width: 0; height: 100%; overflow: hidden; display: flex; flex-direction: column; }
.topbanner { padding: 6px 12px; text-align: center; font-size: 13px; }

/* ---- inbox (list | chat | profile) ---- */
.inbox { display: grid; grid-template-columns: minmax(290px, 360px) 1fr; height: 100%; min-height: 0; }
.inbox.with-profile { grid-template-columns: minmax(290px, 360px) 1fr minmax(280px, 340px); }
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); border-inline-end: 1px solid var(--line); }
.pane-head { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.pane-head h2 { margin: 0; font-size: 18px; }
.list { overflow-y: auto; flex: 1; margin: 0; padding: 0; list-style: none; }
.conv { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.conv:hover, .conv:focus-visible { background: var(--surface-2); }
.conv[aria-selected="true"] { background: var(--brand-soft); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 16px; }
.conv .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .preview { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .meta { display: grid; justify-items: end; gap: 4px; font-size: 12px; color: var(--muted); }
.conv .no { color: var(--muted); font-weight: 500; font-size: 12px; margin-inline-start: 4px; }
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); }
.conv.unread .name { color: var(--fg); }
.conv.unread .preview { color: var(--fg); font-weight: 600; }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); display: grid; gap: 8px; justify-items: center; }

.chat { background: var(--bg); min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.chat-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-head .who { min-width: 0; flex: 1; }
.chat-head .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.back { display: none; }
.messages { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 6px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); padding: 2px 10px; border-radius: 999px; margin: 8px 0; }
.msg { max-width: min(76%, 640px); padding: 8px 12px 6px; border-radius: 12px; box-shadow: var(--shadow); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.in { align-self: flex-start; background: var(--in-bubble); border-start-start-radius: 4px; }
.msg.ai { align-self: flex-end; background: var(--ai-bubble); color: var(--ai-ink); border-start-end-radius: 4px; }
.msg.staff { align-self: flex-end; background: var(--staff-bubble); color: var(--staff-ink); border-start-end-radius: 4px; }
.msg .from { font-size: 12px; font-weight: 700; margin-bottom: 2px; }
.msg .foot { display: flex; gap: 8px; justify-content: flex-end; font-size: 11px; opacity: .8; margin-top: 2px; }
.delivery.FAILED, .delivery.SUPPRESSED { color: var(--danger); font-weight: 700; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer-row .input { flex: 1; }
.profile { overflow-y: auto; padding: 14px; display: grid; gap: 14px; align-content: start; }
.profile h3 { margin: 0; font-size: 15px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.note { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px; }
.note .muted { font-size: 12px; }

/* ---- pages (overview, staff) ---- */
.page { flex: 1; min-height: 0; overflow-y: auto; padding: 20px; display: block; }
.page > * { margin: 0; }
.page > * + * { margin-top: 18px; }   /* block flow: a grid in a fixed-height pane let tables (overflow hidden) collapse under the headings */
.page h1 { margin: 0; font-size: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card .num { font-size: 28px; font-weight: 800; }
.card .lbl { color: var(--muted); font-size: 13px; }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: start; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table-wrap { overflow-x: auto; max-width: 100%; border-radius: var(--radius); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: end; }
.toast-zone { position: fixed; inset-inline: 0; bottom: 16px; display: grid; justify-items: center; gap: 8px; z-index: 40; pointer-events: none; }
.toast { pointer-events: auto; background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 92vw; }
.toast.error { background: var(--danger); color: #fff; }

/* ---- responsive: tablet (profile becomes a drawer), phone (one pane at a time, bottom nav) ---- */
@media (max-width: 1100px) {
  .inbox.with-profile { grid-template-columns: minmax(270px, 330px) 1fr; }
  .inbox.with-profile .profile-pane { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(360px, 92vw); z-index: 30; box-shadow: var(--shadow); border-inline-start: 1px solid var(--line); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 4px; border-inline-end: 0; border-top: 1px solid var(--line); }
  .rail .brandmark, .rail .spacer { display: none; }
  .rail a, .rail button { width: auto; flex: 1; min-height: 50px; }
  .inbox, .inbox.with-profile { grid-template-columns: 1fr; }
  .inbox .chat, .inbox .profile-pane { display: none; }
  .inbox.show-chat .list-pane { display: none; }
  .inbox.show-chat .chat { display: flex; }
  .inbox.show-profile .list-pane, .inbox.show-profile .chat { display: none; }
  .inbox.show-profile .profile-pane { display: flex; position: static; width: auto; }
  .back { display: inline-flex; }
  .msg { max-width: 88%; }
  .page { padding: 14px; }
}
.stack { display: grid; gap: 12px; }
#app { height: 100%; }
.shell { height: 100%; height: 100dvh; }
.conv-body { min-width: 0; }
.chat-head .who { min-width: 160px; }

/* ===================== UX upgrade (2026-10-14): navigation, tables, filters, notifications, attention, charts ===================== */
:root { --accent-soft: #eef6f4; --overdue: #b42318; }
:root[data-theme="dark"] { --accent-soft: #10302b; --overdue: #ff8a80; }
h1, h2, h3 { line-height: 1.25; letter-spacing: 0; }
.page h2 { font-size: 17px; font-weight: 700; margin: 0; }
.card .num, .table td.num, .count, .count-badge, .chart-value { font-variant-numeric: tabular-nums; }
.small { font-size: 12.5px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head h2 { margin: 0; }
kbd { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 1px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700; margin-inline-start: 6px; }
.overdue { color: var(--overdue); font-weight: 600; }

/* rail: role-based sections; secondary items move into "More" on phones; bell with unread count */
.rail .more-btn { display: none; }
.rail .bell { position: relative; }
.count-badge { position: absolute; top: 4px; inset-inline-end: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.count-badge[hidden] { display: none; }
.rail .lbl { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* dialogs used as sheets (notifications, shortcuts, open customer, More) */
dialog.sheet { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 0; width: min(520px, 94vw); max-height: 86vh; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
dialog.sheet.small { width: min(360px, 94vw); }
dialog.sheet::backdrop { background: rgba(10, 16, 24, .45); }
.sheet-body { padding: 16px; display: grid; gap: 12px; overflow-y: auto; max-height: 86vh; }
.more-list { display: grid; gap: 4px; }
.more-list a, .more-list button { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 10px; border: 0; background: transparent; color: var(--fg); text-decoration: none; font: inherit; cursor: pointer; text-align: start; }
.more-list a:hover, .more-list button:hover, .more-list a[aria-current="page"] { background: var(--brand-soft); }
/* the More sheet lives inside the rail element: undo the compact rail item styles there */
.rail .more-list a, .rail .more-list button { width: auto; flex: none; display: flex; place-items: initial; align-items: center; font-size: 15px; color: var(--fg); min-height: 48px; padding: 0 12px; }

/* notifications */
.notif-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 56vh; overflow-y: auto; }
.notif-item { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; color: var(--fg); text-decoration: none; }
.notif-item:hover, .notif-item:focus-visible { background: var(--surface-2); }
.notif-item.unread { background: var(--accent-soft); }
.notif-item.unread .notif-text { font-weight: 600; }
.notif-item .pri { color: var(--muted); font-size: 12px; }
.notif-item.high .pri { color: var(--danger); }

/* toolbars, filters, pager */
.toolbar { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.toolbar-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-row > .input { flex: 1 1 220px; width: auto; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 10px; align-items: end; }
label.field.compact { font-size: 12.5px; font-weight: 600; color: var(--muted); gap: 4px; }
label.field.compact .input { min-height: 36px; padding: 6px 10px; color: var(--fg); font-weight: 400; font-size: 14px; }
label.field.inline { display: inline-flex; align-items: center; gap: 6px; }
label.field.inline .input { width: auto; }
label.check { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; cursor: pointer; }
.filter-panel { display: grid; gap: 8px; padding-top: 4px; }
.filter-panel[hidden] { display: none; }
.table-meta { color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.more-row { padding: 10px; display: grid; justify-items: center; }

/* tables: sortable headers, drill-down rows, numbers aligned to the end */
.table th[aria-sort] { padding: 0; }
.table th .sort { width: 100%; display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; cursor: pointer; text-align: start; }
.table th.num .sort { justify-content: flex-end; }
.table th .sort:hover, .table th .sort.active { color: var(--fg); }
.sort-ind { font-size: 10px; opacity: .7; }
.table td.num, .table th.num { text-align: end; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td, .table tr.clickable:focus-visible td { background: var(--surface-2); }
.table .empty-cell { text-align: center; color: var(--muted); padding: 24px; }
.table.compact th, .table.compact td { padding: 6px 10px; font-size: 13px; }
.cell-main { display: inline-flex; gap: 2px 6px; flex-wrap: wrap; align-items: baseline; }

/* dashboard: attention center, KPI cards, charts */
.attention { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 12px; box-shadow: var(--shadow); }
.att-group h3 { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.att-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.att-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; border-inline-start-width: 4px; }
.att-item.p1 { border-inline-start-color: var(--danger); }
.att-item.p2 { border-inline-start-color: var(--waiting); }
.att-item.p3 { border-inline-start-color: var(--taken); }
.att-main { min-width: 0; display: grid; gap: 4px; }
.att-main .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.rules summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.rules ol { margin: 6px 0 0; padding-inline-start: 20px; font-size: 13px; color: var(--muted); }
a.card.kpi { color: var(--fg); text-decoration: none; display: block; }
a.card.kpi:hover, a.card.kpi:focus-visible { border-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.chart { margin: 0; display: grid; gap: 8px; }
.chart figcaption { font-weight: 600; font-size: 14px; }
.chart-box { overflow-x: auto; }
.chart-svg { width: 100%; height: auto; min-width: 280px; display: block; }
.chart-svg .bar { fill: var(--brand); }
.chart-svg .bar.waiting { fill: var(--waiting); }
.chart-svg .bar.taken { fill: var(--taken); }
.chart-svg .bar.resolved { fill: var(--resolved); }
.chart-svg .bar.none { fill: var(--muted); }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .chart-label, .chart-svg .chart-value { fill: var(--muted); font-size: 11px; }
.chart details summary { cursor: pointer; color: var(--muted); font-size: 13px; }

/* phones: bottom bar with primary sections + bell + More; tables become cards; sheets fill the width */
@media (max-width: 760px) {
  .rail .secondary { display: none; }
  .rail .more-btn { display: grid; }
  .rail a, .rail button { min-height: 54px; font-size: 10.5px; }
  .rail .lbl { max-width: 72px; }
  .count-badge { top: 2px; inset-inline-end: 18%; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.responsive { border: 0; background: transparent; }
  table.responsive tr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; padding: 6px 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 6px 12px; text-align: end; }
  table.responsive td::before { content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 12.5px; text-align: start; }
  table.responsive td[data-label=""]::before { content: none; }
  .toolbar { padding: 10px; }
  .filter-grid { grid-template-columns: 1fr 1fr; }
  dialog.sheet, dialog.sheet.small { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
  .att-item { flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .pager .btn { min-height: 44px; flex: 1; }
}
:root[data-theme="dark"] :focus-visible { outline-color: #9ec1ff; }

/* ===================== Security & Access (2026-10-14) ===================== */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.tab { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 12px; border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer; min-height: 44px; }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--brand); }
.tab:hover { color: var(--fg); }
[role="tabpanel"] { display: grid; gap: 14px; padding-top: 14px; }
[role="tabpanel"] > h2 { margin: 6px 0 0; }
button.card.kpi { text-align: start; font: inherit; color: var(--fg); cursor: pointer; }
button.card.kpi:hover, button.card.kpi:focus-visible { border-color: var(--brand); }
.btn.danger-solid { background: var(--danger); color: #fff; border-color: transparent; }
:root[data-theme="dark"] .btn.danger-solid { color: #2b0b09; }   /* the dark theme's danger is a light red: dark text keeps AA contrast */
.kv.card { padding: 14px; }
.auth-card .code-input { letter-spacing: .15em; font-size: 18px; }

/* ---- v2 access: sign-in links, compact selects in tables, padded cards, link-styled buttons ---- */
.auth-links { margin-top: 14px; text-align: center; font-size: .92rem; color: var(--muted); }
.auth-links a, .linklike { color: var(--taken); text-decoration: underline; text-underline-offset: 2px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.input.sm { padding: 4px 8px; min-height: 32px; width: auto; max-width: 14rem; font-size: .9rem; }
.card.pad { padding: 16px; max-width: 32rem; }

/* Knowledge (K5): the fact text editor */
textarea.input.kb-value { min-height: 120px; max-height: 360px; resize: vertical; }
.kb-pre { white-space: pre-wrap; }

/* Knowledge: four-step approval guide (draft -> review -> approved -> published) */
.kb-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; }
.kb-step { width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: start; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; cursor: pointer; }
.kb-step:hover { background: var(--surface-2); }
.kb-step.on { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.kb-step-no { flex: none; width: 24px; height: 24px; border-radius: 999px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 800; font-size: 13px; }
.kb-step-body { display: grid; gap: 2px; }
