/* Mello Desk — quiet operations console. Tokens on :root, swapped for dark at the root only. */
:root {
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --surface-2: #F0F0ED;
  --border: #E1E1DC;
  --border-strong: #C9C9C2;
  --text: #1B1C1E;
  --text-2: #5B5E63;
  --text-3: #8A8E94;
  --accent: #0E6B5A;
  --accent-soft: #D9F0EA;
  --on-accent: #FFFFFF;
  --warning: #9A5B00;
  --warning-soft: #FBEBD0;
  --danger: #B3261E;
  --danger-soft: #F9DEDC;
  --success: #2E7D32;
  --success-soft: #DFF2E0;
  --info: #2A5DB0;
  --info-soft: #DDE7F7;
  --focus: #0E6B5A;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --overlay: rgba(20,22,24,.36);

  /* Agent hues: same lightness in both themes so an agent reads the same everywhere. */
  --hue-teal: #2A9D8F;
  --hue-indigo: #5C6BC0;
  --hue-amber: #D08C1F;
  --hue-rose: #D0587E;
  --hue-violet: #8E63CE;
  --hue-cyan: #2595B8;
  --hue-lime: #6E9F2B;
  --hue-slate: #6B7785;

  --font-ui: Inter, "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-control: 6px;
  --r-card: 10px;
  --r-pill: 999px;
  --header-h: 56px;
  --gutter: 24px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121315;
    --surface: #1A1C1F;
    --surface-2: #232629;
    --border: #2E3236;
    --border-strong: #3D4248;
    --text: #ECECE8;
    --text-2: #A3A7AD;
    --text-3: #70757C;
    --accent: #3FB59A;
    --accent-soft: #15332D;
    --on-accent: #0B1A16;
    --warning: #E5A33B;
    --warning-soft: #3A2B10;
    --danger: #F28B82;
    --danger-soft: #3E1B19;
    --success: #81C995;
    --success-soft: #1C3320;
    --info: #8AB4F8;
    --info-soft: #1A2840;
    --focus: #3FB59A;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
    --overlay: rgba(0,0,0,.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #121315;
  --surface: #1A1C1F;
  --surface-2: #232629;
  --border: #2E3236;
  --border-strong: #3D4248;
  --text: #ECECE8;
  --text-2: #A3A7AD;
  --text-3: #70757C;
  --accent: #3FB59A;
  --accent-soft: #15332D;
  --on-accent: #0B1A16;
  --warning: #E5A33B;
  --warning-soft: #3A2B10;
  --danger: #F28B82;
  --danger-soft: #3E1B19;
  --success: #81C995;
  --success-soft: #1C3320;
  --info: #8AB4F8;
  --info-soft: #1A2840;
  --focus: #3FB59A;
  --shadow: 0 1px 2px rgba(0,0,0,.5);
  --overlay: rgba(0,0,0,.55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
:lang(ar) body, [lang="ar"] { line-height: 1.6; letter-spacing: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { margin: 0; }
h1 { font-size: 20px; line-height: 28px; font-weight: 600; }
h2 { font-size: 16px; line-height: 24px; font-weight: 600; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; }
p { margin: 0 0 8px; }
.num { font-variant-numeric: tabular-nums; font-weight: 500; }
.mono, code, pre, kbd { font-family: var(--font-mono); font-size: 13px; line-height: 20px; }
.ltr { direction: ltr; unicode-bidi: isolate; text-align: start; }
.bidi { unicode-bidi: isolate; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.meta { font-size: 12px; line-height: 16px; color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-block-start: 8px; } .mt-16 { margin-block-start: 16px; } .mt-24 { margin-block-start: 24px; }
.mb-8 { margin-block-end: 8px; } .mb-16 { margin-block-end: 16px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flip-rtl:dir(rtl), [dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ---------- header ---------- */
.header {
  position: sticky; inset-block-start: 0; z-index: 30;
  height: var(--header-h);
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding-inline: var(--gutter);
}
.header .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; color: var(--text); }
.header .brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.tabs { display: flex; gap: 2px; margin-inline: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding-inline: 12px;
  border-radius: var(--r-control); color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tab[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.header-right { display: flex; align-items: center; gap: 6px; }
.count-badge {
  min-width: 18px; height: 18px; padding-inline: 5px; border-radius: var(--r-pill);
  background: var(--warning); color: var(--surface); font-size: 11px; line-height: 18px; text-align: center; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-inline: 10px;
  border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  font-size: 12px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.pill:hover { border-color: var(--border-strong); color: var(--text); }
.pill.active { color: var(--accent); border-color: var(--accent); }
.org-switch select { min-width: 140px; }
.mobile-nav { display: none; }

/* ---------- layout ---------- */
.page { max-width: 1440px; margin-inline: auto; padding: 24px var(--gutter) 64px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-block-end: 16px; }
.page-head h1 { margin-inline-end: auto; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); padding: 16px; }
.panel + .panel { margin-block-start: 16px; }
.col > .panel + .panel, .grid-halves > .panel + .panel { margin-block-start: 0; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-halves > .full { grid-column: 1 / -1; }
@media (max-width: 960px) { .grid-halves { grid-template-columns: 1fr; } }
.panel h2 { margin-block-end: 12px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-block: 24px 12px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding-inline: 14px; border-radius: var(--r-control);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); border-color: var(--border-strong); }
.btn.danger.confirm { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn.sm { height: 32px; padding-inline: 10px; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 32px; }
@media (pointer: coarse) { .btn, .pill, .tab { min-height: 40px; } .btn.icon { width: 40px; } }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span, .label { font-size: 12px; line-height: 16px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input {
  height: 36px; padding-inline: 10px; border-radius: var(--r-control);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  width: 100%; min-width: 0;
}
textarea.input { height: auto; min-height: 96px; padding-block: 8px; resize: vertical; line-height: 20px; }
textarea.input.mono { min-height: 160px; }
.input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.input::placeholder { color: var(--text-3); }
.input.sm { height: 32px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--border-strong); border: 0; cursor: pointer; flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: inset-inline-start .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { inset-inline-start: 18px; }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-control); overflow: hidden; background: var(--surface); }
.segmented button { height: 32px; padding-inline: 10px; border: 0; background: transparent; cursor: pointer; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.segmented button + button { border-inline-start: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding-inline: 8px;
  border-radius: var(--r-pill); font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.s-backlog { background: var(--surface-2); color: var(--text-2); }
.badge.s-ready, .badge.info { background: var(--info-soft); color: var(--info); }
.badge.s-running, .badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.s-needs_approval, .badge.warning, .badge.s-pending { background: var(--warning-soft); color: var(--warning); }
.badge.s-done, .badge.success, .badge.s-succeeded, .badge.s-approved { background: var(--success-soft); color: var(--success); }
.badge.s-failed, .badge.s-blocked, .badge.danger, .badge.s-rejected, .badge.s-refused_budget, .badge.s-expired { background: var(--danger-soft); color: var(--danger); }
.badge.s-cancelled, .badge.s-queued, .badge.s-waiting_approval { background: var(--surface-2); color: var(--text-2); }
.badge.s-waiting_approval { background: var(--warning-soft); color: var(--warning); }
.model-badge {
  display: inline-flex; align-items: center; gap: 4px; max-width: 150px; height: 20px; padding-inline: 6px;
  border-radius: var(--r-control); background: var(--surface-2); color: var(--text-2);
  font-family: var(--font-mono); font-size: 11px; line-height: 16px; direction: ltr; unicode-bidi: isolate;
}
.model-badge .bad { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); flex: none; }

/* ---------- avatar / agent chip ---------- */
.avatar {
  width: 20px; height: 20px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  color: #fff; font-size: 10px; font-weight: 600; line-height: 1; text-transform: uppercase;
}
.avatar.lg { width: 32px; height: 32px; font-size: 13px; }
.hue-teal { background: var(--hue-teal); } .hue-indigo { background: var(--hue-indigo); } .hue-amber { background: var(--hue-amber); }
.hue-rose { background: var(--hue-rose); } .hue-violet { background: var(--hue-violet); } .hue-cyan { background: var(--hue-cyan); }
.hue-lime { background: var(--hue-lime); } .hue-slate { background: var(--hue-slate); }
.agent-chip { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.agent-chip.paused { opacity: .6; }
.agent-chip .pause-glyph { font-size: 10px; color: var(--text-2); }

/* ---------- board ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-block-end: 16px; }
.filters .input { width: auto; min-width: 140px; }
.filters .search { min-width: 200px; flex: 1 1 200px; max-width: 320px; }
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: 300px; gap: 12px;
  overflow-x: auto; padding-block-end: 12px; align-items: start; scroll-snap-type: x proximity;
}
.column {
  background: var(--surface-2); border-radius: var(--r-card); padding: 8px; min-height: 200px;
  display: flex; flex-direction: column; gap: 8px; scroll-snap-align: start;
}
.column.drop-ok { outline: 2px dashed var(--accent); outline-offset: -2px; }
.column-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 2px; font-weight: 600; }
.column-head .n { color: var(--text-3); font-weight: 500; font-variant-numeric: tabular-nums; }
.column-empty { color: var(--text-3); font-size: 12px; padding: 12px 4px; text-align: center; }
.status-switch { display: none; margin-block-end: 12px; overflow-x: auto; }
.offline .card { opacity: .8; }

.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
  box-shadow: var(--shadow); padding: 12px; padding-inline-start: 15px; cursor: pointer; display: block; color: var(--text);
  overflow: hidden;
}
.card:hover { border-color: var(--border-strong); text-decoration: none; }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.card.picked { border-color: var(--accent); outline: 2px solid var(--accent); }
.card.dragging { opacity: .5; }
.card::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--bar, var(--border-strong)); }
.card.st-backlog { --bar: var(--border-strong); }
.card.st-ready { --bar: var(--info); }
.card.st-running { --bar: var(--accent); }
.card.st-needs_approval { --bar: var(--warning); }
.card.st-done { --bar: var(--success); }
.card.st-failed, .card.st-blocked { --bar: var(--danger); }
.card-title { display: flex; gap: 8px; align-items: flex-start; }
.card-title .t { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; unicode-bidi: isolate; }
.card-meta { display: flex; align-items: center; gap: 8px; margin-block-start: 8px; font-size: 12px; line-height: 16px; color: var(--text-3); flex-wrap: wrap; }
.card-meta .cost { color: var(--text-2); }
.card-key { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.card-note { margin-block-start: 6px; font-size: 12px; line-height: 16px; color: var(--warning); }
.card-flags { display: inline-flex; gap: 4px; margin-inline-start: auto; align-items: center; }
.drag-handle { position: absolute; inset-block-start: 8px; inset-inline-end: 6px; color: var(--text-3); opacity: 0; cursor: grab; padding: 2px 4px; border-radius: 4px; font-size: 12px; letter-spacing: -2px; }
.card:hover .drag-handle, .card:focus-within .drag-handle, .card.picked .drag-handle { opacity: 1; }
@media (hover: none) { .drag-handle { opacity: .6; } }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); display: inline-block; animation: pulse 2s ease-in-out infinite; flex: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } * { transition: none !important; } }
.clock-warn { color: var(--warning); }

.skeleton { background: var(--surface-2); border-radius: var(--r-card); height: 72px; }
.column .skeleton { background: var(--surface); opacity: .7; }
.skeleton-line { background: var(--surface-2); border-radius: 4px; height: 14px; margin-block: 8px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: start; padding: 8px 12px; border-block-end: 1px solid var(--border); vertical-align: middle; height: 44px; }
.table th { font-size: 12px; font-weight: 500; color: var(--text-2); background: var(--surface-2); height: 36px; white-space: nowrap; }
.table tr:last-child td { border-block-end: 0; }
.table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--accent-soft); }
.table td.num, .table th.num { text-align: end; }

/* ---------- budget meter ---------- */
.meter { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.meter-bar { height: 6px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.meter.warn .meter-fill { background: var(--warning); }
.meter.over .meter-fill { background: var(--danger); }
.meter-label { font-size: 12px; line-height: 16px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- drawer / dialog ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(640px, 100vw); z-index: 51;
  background: var(--surface); border-inline-start: 1px solid var(--border); display: flex; flex-direction: column;
}
.drawer-head, .dialog-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-block-end: 1px solid var(--border); min-height: 56px; }
.drawer-body, .dialog-body { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.drawer-foot, .dialog-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-block-start: 1px solid var(--border); flex-wrap: wrap; }
.dialog {
  position: fixed; z-index: 51; inset-block-start: 50%; inset-inline-start: 50%; transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-card); display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
[dir="rtl"] .dialog { transform: translate(50%, -50%); }
.popover {
  position: absolute; inset-block-start: calc(100% + 6px); inset-inline-end: 0; z-index: 40; width: min(420px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: 0 8px 24px rgba(0,0,0,.16); padding: 8px;
}
.rel { position: relative; }

/* ---------- toasts & banners ---------- */
.toasts { position: fixed; inset-block-end: 16px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100vw - 32px)); }
[dir="rtl"] .toasts { transform: translateX(50%); }
.toast { display: flex; align-items: flex-start; gap: 12px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 10px 12px; box-shadow: 0 4px 16px rgba(0,0,0,.14); }
.toast.error { border-color: var(--danger); }
.toast.error .toast-text { color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast-text { flex: 1; }
.banner { padding: 8px var(--gutter); font-size: 13px; text-align: center; }
.banner.warning { background: var(--warning-soft); color: var(--warning); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.inline-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--r-control); padding: 8px 12px; font-size: 13px; }
.inline-warn { color: var(--warning); background: var(--warning-soft); border-radius: var(--r-control); padding: 8px 12px; font-size: 13px; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------- markdown ---------- */
.md { overflow-wrap: anywhere; unicode-bidi: plaintext; }
.md > :first-child { margin-block-start: 0; }
.md > :last-child { margin-block-end: 0; }
.md h1, .md h2, .md h3 { margin-block: 16px 8px; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3 { font-size: 14px; }
.md ul, .md ol { padding-inline-start: 20px; margin-block: 0 8px; }
.md code { background: var(--surface-2); padding: 1px 4px; border-radius: 4px; direction: ltr; unicode-bidi: isolate; }
.md pre { background: var(--surface-2); padding: 12px; border-radius: var(--r-control); overflow-x: auto; direction: ltr; text-align: left; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin-block: 8px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 4px 8px; text-align: start; }
.md blockquote { margin: 0 0 8px; padding-inline-start: 12px; border-inline-start: 3px solid var(--border-strong); color: var(--text-2); }
.md img { max-width: 100%; }

/* ---------- code blocks ---------- */
.codeblock {
  background: var(--surface-2); border-radius: var(--r-control); padding: 10px 12px; margin: 0;
  overflow-x: auto; white-space: pre; direction: ltr; text-align: left; unicode-bidi: isolate;
  font-family: var(--font-mono); font-size: 13px; line-height: 20px;
}
.codeblock.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.codeblock.clamped { max-height: 400px; overflow: hidden; position: relative; }
.tok-kw { color: var(--info); font-weight: 500; }
.tok-str { color: var(--success); }
.tok-num { color: var(--warning); }
.tok-com { color: var(--text-3); }
.diff-add { color: var(--success); display: block; background: var(--success-soft); }
.diff-del { color: var(--danger); display: block; background: var(--danger-soft); }
.diff-hunk { color: var(--info); display: block; }

/* ---------- run log ---------- */
.runlog { border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); max-height: calc(100vh - 260px); min-height: 320px; overflow-y: auto; }
.ev { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 10px 12px; border-block-end: 1px solid var(--border); }
.ev:last-child { border-block-end: 0; }
.ev-icon { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; font-size: 12px; background: var(--surface-2); color: var(--text-2); }
.ev.k-message .ev-icon { background: var(--accent-soft); color: var(--accent); }
.ev.k-tool_call .ev-icon { background: var(--info-soft); color: var(--info); }
.ev.k-tool_result .ev-icon { background: var(--surface-2); }
.ev.k-approval .ev-icon { background: var(--warning-soft); color: var(--warning); }
.ev.err .ev-icon { background: var(--danger-soft); color: var(--danger); }
.ev-head { display: flex; gap: 8px; align-items: center; font-size: 12px; line-height: 16px; color: var(--text-3); margin-block-end: 4px; flex-wrap: wrap; }
.ev-head strong { color: var(--text-2); font-weight: 500; }
.ev-body { min-width: 0; }
details > summary { cursor: pointer; color: var(--text-2); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; display: inline-block; width: 14px; transition: transform .1s; }
[dir="rtl"] details > summary::before { content: "◂"; }
details[open] > summary::before { transform: rotate(90deg); }
[dir="rtl"] details[open] > summary::before { transform: rotate(-90deg); }
.jump-live { position: sticky; inset-block-end: 8px; display: flex; justify-content: center; pointer-events: none; }
.jump-live .btn { pointer-events: auto; box-shadow: var(--shadow); }

/* ---------- approvals ---------- */
.approval { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--shadow); overflow: hidden; }
.approval::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--warning); }
.approval.selected { border-color: var(--warning); outline: 2px solid var(--warning); outline-offset: 0; }
.approval-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px 8px 19px; flex-wrap: wrap; }
.approval-body { padding: 0 16px 12px 19px; display: flex; flex-direction: column; gap: 8px; }
.approval-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 16px; border-block-start: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.approval + .approval { margin-block-start: 12px; }
.reasoning { color: var(--text-2); font-size: 13px; border-inline-start: 3px solid var(--border-strong); padding-inline-start: 10px; }
kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; font-size: 11px; }

/* ---------- spend charts ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(100px, 180px) 1fr 90px; gap: 12px; align-items: center; }
.bar-track { height: 10px; background: var(--surface-2); border-radius: var(--r-pill); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.chart-svg { width: 100%; height: 180px; display: block; direction: ltr; }
.chart-svg .axis { stroke: var(--border); }
.chart-svg .line { stroke: var(--accent); fill: none; stroke-width: 2; }
.chart-svg .area { fill: var(--accent-soft); }
.chart-svg text { fill: var(--text-3); font-size: 11px; font-family: var(--font-ui); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 20px; line-height: 28px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ---------- auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(400px, 100%); }
.auth-card .brand-mark { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; margin-block-end: 16px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- misc ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding-inline: 8px; border-radius: var(--r-pill); background: var(--surface-2); font-size: 12px; direction: ltr; unicode-bidi: isolate; }
.tag button { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0 2px; }
.grant { border: 1px solid var(--border); border-radius: var(--r-control); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.colour-pick { display: flex; gap: 6px; flex-wrap: wrap; }
.colour-pick button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.colour-pick button[aria-pressed="true"] { border-color: var(--text); box-shadow: inset 0 0 0 2px var(--surface); }
.hr { height: 1px; background: var(--border); border: 0; margin: 4px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding-block: 8px; border-block-end: 1px solid var(--border); }
.list-plain li:last-child { border-block-end: 0; }
.comment { padding: 10px 12px; border-radius: var(--r-control); background: var(--surface-2); }
.comment.agent { background: var(--accent-soft); }
.result-links { display: flex; flex-wrap: wrap; gap: 8px; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 1280px) { .grid-2 { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tabs .tab .lbl-long { display: none; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .header { gap: 6px; }
  .header .brand .brand-name { display: none; }
  .tabs { display: none; }
  .mobile-nav {
    display: flex; position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 30; background: var(--surface);
    border-block-start: 1px solid var(--border); padding-block-end: env(safe-area-inset-bottom); overflow: hidden;
  }
  .mobile-nav .tab { flex: 1 1 0; min-width: 0; padding-inline: 2px; white-space: nowrap; height: 52px; flex-direction: column; gap: 0; font-size: 11px; justify-content: center; border-radius: 0; }
  .page { padding-block-end: 96px; }
  .org-switch select { min-width: 0; max-width: 130px; }
  .hide-phone { display: none !important; }
  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: 1fr; overflow-x: visible; }
  .board .column { display: none; }
  .board .column.mobile-active { display: flex; }
  .status-switch { display: flex; }
  .bar-row { grid-template-columns: 90px 1fr 70px; }
  .drawer { width: 100vw; }
  .toasts { inset-block-end: 72px; }
}
