/* Mello Desk — near-black, minimal, dense. Dark is the default; light is an alternative token set. */

:root {
  --bg: #0a0a0b;
  --sidebar: #0e0e10;
  --surface: #121214;
  --surface-2: #18181b;
  --hover: #1e1e22;
  --border: #232326;
  --border-strong: #2f2f35;
  --text: #ededef;
  --text-2: #a1a1aa;
  --text-3: #6b6b74;
  --accent: #3fb59a;
  --on-accent: #04130f;
  --accent-soft: rgba(63, 181, 154, 0.12);
  --live: #4c8dff;
  --live-soft: rgba(76, 141, 255, 0.14);
  --success: #3fb950;
  --success-soft: rgba(63, 185, 80, 0.13);
  --warning: #e3b341;
  --warning-soft: rgba(227, 179, 65, 0.13);
  --on-warning: #1a1405;
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.13);
  --overlay: rgba(0, 0, 0, 0.6);
  --code-bg: #0d0d0f;

  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --r-card: 8px;
  --r-control: 6px;
  --r-pill: 999px;
  --rail: 56px;
  --side: 240px;
  --top: 48px;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #fafafa;
  --sidebar: #f4f4f5;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --hover: #ececee;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #8b8b94;
  --accent: #0e7c66;
  --on-accent: #ffffff;
  --accent-soft: rgba(14, 124, 102, 0.1);
  --live: #2563eb;
  --live-soft: rgba(37, 99, 235, 0.1);
  --success: #1a7f37;
  --success-soft: rgba(26, 127, 55, 0.1);
  --warning: #9a6700;
  --warning-soft: rgba(154, 103, 0, 0.1);
  --on-warning: #ffffff;
  --danger: #cf222e;
  --danger-soft: rgba(207, 34, 46, 0.1);
  --overlay: rgba(0, 0, 0, 0.3);
  --code-bg: #f6f6f7;
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #fafafa;
    --sidebar: #f4f4f5;
    --surface: #ffffff;
    --surface-2: #f4f4f5;
    --hover: #ececee;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --text: #18181b;
    --text-2: #52525b;
    --text-3: #8b8b94;
    --accent: #0e7c66;
    --on-accent: #ffffff;
    --accent-soft: rgba(14, 124, 102, 0.1);
    --live: #2563eb;
    --live-soft: rgba(37, 99, 235, 0.1);
    --success: #1a7f37;
    --success-soft: rgba(26, 127, 55, 0.1);
    --warning: #9a6700;
    --warning-soft: rgba(154, 103, 0, 0.1);
  --on-warning: #ffffff;
    --danger: #cf222e;
    --danger-soft: rgba(207, 34, 46, 0.1);
    --overlay: rgba(0, 0, 0, 0.3);
    --code-bg: #f6f6f7;
    color-scheme: light;
  }
}

/* agent hues: same lightness in both themes */
.hue-teal { --hue: #3fb59a; }
.hue-indigo { --hue: #7c83f2; }
.hue-amber { --hue: #e3a33b; }
.hue-rose { --hue: #ee6b8a; }
.hue-violet { --hue: #a78bfa; }
.hue-cyan { --hue: #38bdd8; }
.hue-lime { --hue: #94c947; }
.hue-slate { --hue: #94a3b8; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 13.5px/20px var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 20px; line-height: 28px; }
h2 { font-size: 14px; line-height: 20px; }
h3 { font-size: 13px; line-height: 18px; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--text); }
button { font: inherit; color: inherit; }
img, svg { display: block; }
code, pre, kbd { font-family: var(--mono); }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- utilities ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sr-only:focus { position: fixed !important; top: 8px; left: 8px; width: auto; height: auto; clip: auto; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-control); z-index: 100; }
.row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.muted { color: var(--text-2); }
.meta { color: var(--text-3); font-size: 12px; line-height: 16px; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12px; }
.rel { position: relative; }
.full { width: 100%; }
.label { color: var(--text-3); font-size: 12px; font-weight: 500; }
.section-label { color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; }
.link { color: var(--accent); }
.link:hover { color: var(--accent); text-decoration: underline; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 4px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.kbd, kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 10.5px; color: var(--text-3); background: var(--surface-2); font-family: var(--mono); }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--rail) var(--side) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0;
}
.rail-mark { width: 32px; height: 32px; display: grid; place-items: center; margin-bottom: 6px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.org-tile {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
  font: 700 11px/1 var(--font); letter-spacing: 0.02em; border: 0; color: #0a0a0b; background: var(--hue, var(--accent));
  opacity: 0.55; transition: opacity 0.12s, box-shadow 0.12s;
}
.org-tile:hover { opacity: 0.85; }
.org-tile[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--sidebar), 0 0 0 3.5px var(--hue, var(--accent)); }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 10px 10px 12px;
}
.side-orgs { display: none; gap: 10px; padding: 4px 8px 12px; }
.side-head { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 6px 0 8px; margin-bottom: 8px; }
.side-head .org-name { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; }
.side-section { margin-top: 18px; }
.side-section > .section-label { display: block; padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; border-radius: var(--r-control);
  color: var(--text-2); font-weight: 500; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; min-width: 0;
}
.nav-item:hover { background: var(--hover); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.nav-item svg { flex: none; color: var(--text-3); }
.nav-item[aria-current="page"] svg, .nav-item:hover svg { color: var(--text-2); }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .agent-tile { margin-left: -2px; }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; padding-left: 8px; }
.side-foot .email { flex: 1; min-width: 0; color: var(--text-3); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; font-size: 13px; color: var(--text-3); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-3); opacity: 0.6; }
.crumbs .current { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumbs .top-title { color: var(--text); font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 6px; }
.btn.hamburger { display: none; }
.page { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 28px 64px; }
.page.wide { max-width: none; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { flex: 1; min-width: 0; }
.page-sub { color: var(--text-3); margin-top: 2px; }
.offline .card, .offline .live-row { opacity: 0.8; }
.side-scrim { display: none; }

.banner { padding: 8px 20px; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.banner.warning { background: var(--warning-soft); color: var(--warning); }
.banner.danger { background: var(--danger-soft); color: var(--danger); }
.banner.info { background: var(--accent-soft); color: var(--text); }
.banner.info .link-btn { color: var(--accent); font-weight: 600; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--r-control); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; user-select: none;
}
.btn:hover { background: var(--hover); color: var(--text); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border-strong)); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.confirm { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn.icon { width: 32px; padding: 0; }
.btn.sm.icon { width: 26px; }
.btn .kbd { margin-left: 2px; }
.btn.primary .kbd { background: transparent; border-color: color-mix(in srgb, var(--on-accent) 40%, transparent); color: var(--on-accent); }

.input {
  width: 100%; height: 32px; padding: 0 10px; border-radius: var(--r-control); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-size: 13px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-3); }
.input:disabled { opacity: 0.55; }
textarea.input { height: auto; padding: 8px 10px; line-height: 20px; resize: vertical; }
textarea.input.mono, .input.mono { font-family: var(--mono); font-size: 12.5px; }
select.input {
  appearance: none; padding-right: 28px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center;
}
.input.sm { height: 26px; font-size: 12px; padding: 0 8px; }
select.input.sm { padding-right: 24px; background-position: right 7px center; }
.input.num { font-variant-numeric: tabular-nums; }
input[type="file"].input { padding: 5px 8px; height: auto; }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:first-child { color: var(--text-2); font-size: 12px; font-weight: 500; }
.hint { color: var(--text-3); font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text-2); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }

.segmented { display: inline-flex; padding: 2px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button {
  height: 26px; padding: 0 10px; border: 0; border-radius: 5px; background: transparent; color: var(--text-3);
  font-weight: 500; font-size: 12.5px; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--hover); color: var(--text); }
.segmented button:disabled { opacity: 0.4; cursor: not-allowed; }

.switch { position: relative; width: 32px; height: 18px; border-radius: 99px; border: 0; background: var(--border-strong); cursor: pointer; flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(14px); }

.pill {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 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;
}
.pill:hover { background: var(--hover); color: var(--text); }
.pill.active { color: var(--text); border-color: var(--border-strong); }

/* ---------- badges, status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 20px; padding: 0 7px; border-radius: 5px;
  background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap; border: 1px solid var(--border);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.success, .badge.s-done, .badge.s-succeeded, .badge.s-approved { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge.warning, .badge.s-needs_approval, .badge.s-waiting_approval, .badge.s-pending { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.danger, .badge.s-failed, .badge.s-blocked, .badge.s-rejected, .badge.s-refused_budget { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.info, .badge.s-ready, .badge.s-queued { background: var(--live-soft); color: var(--live); border-color: transparent; }
.badge.accent, .badge.s-running { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge.s-running .dot { animation: pulse 1.6s ease-in-out infinite; }
.badge.s-backlog, .badge.s-cancelled, .badge.s-expired { color: var(--text-3); }
.count-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--warning); color: var(--on-warning); font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.live-badge { display: inline-flex; align-items: center; gap: 5px; color: var(--live); font-size: 11.5px; font-weight: 500; white-space: nowrap; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--live); flex: none; animation: pulse 1.6s ease-in-out infinite; }
.status-circle { flex: none; }
.status-circle.spin .ring { animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .badge.s-running .dot, .status-dot.live { animation: none !important; } }

/* agent identity */
.avatar {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; flex: none;
  background: color-mix(in srgb, var(--hue, #94a3b8) 18%, transparent); color: var(--hue, #94a3b8); font-size: 9.5px; font-weight: 700;
}
.avatar.lg { width: 28px; height: 28px; font-size: 11px; border-radius: 8px; }
.agent-tile {
  position: relative; display: inline-grid; place-items: center; flex: none; border-radius: 6px;
  background: color-mix(in srgb, var(--hue, #94a3b8) 15%, var(--surface-2)); color: var(--hue, #94a3b8);
  border: 1px solid color-mix(in srgb, var(--hue, #94a3b8) 22%, transparent);
}
.agent-tile .status-dot { position: absolute; right: -2px; bottom: -2px; width: 8px; height: 8px; border-radius: 50%; border: 2px solid var(--sidebar); box-sizing: content-box; }
.status-dot.live { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.status-dot.idle { background: var(--success); }
.status-dot.paused { background: var(--warning); }
.status-dot.errored { background: var(--danger); }
.agent-chip { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: var(--text); font-weight: 500; }
.agent-chip.paused { opacity: 0.6; }
.pause-glyph { color: var(--warning); display: inline-flex; }
.model-badge {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; height: 20px; padding: 0 6px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font: 11px/1 var(--mono);
}
.model-badge .bad { width: 6px; height: 6px; border-radius: 50%; background: var(--danger); flex: none; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 16px; min-width: 0; }
.panel > h2 { margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h2, .panel-head .section-label { flex: 1; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head .section-label { flex: 1; }
.list-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 14px; border-top: 1px solid var(--border); min-width: 0; }
.list-row:first-child { border-top: 0; }
a.list-row:hover, button.list-row:hover, .list-row.clickable:hover { background: var(--hover); }
button.list-row { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; font: inherit; }
.list-row .time { color: var(--text-3); font-size: 12px; white-space: nowrap; flex: none; margin-left: auto; font-variant-numeric: tabular-nums; }
.list-plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list-plain > li { min-width: 0; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px 16px; margin: 0; align-items: center; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.grid-halves { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:first-child td { border-top: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--hover); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.inline-error { padding: 8px 12px; border-radius: var(--r-control); background: var(--danger-soft); color: var(--danger); font-size: 12.5px; overflow-wrap: anywhere; }
.inline-warn { padding: 8px 12px; border-radius: var(--r-control); background: var(--warning-soft); color: var(--warning); font-size: 12.5px; }
.empty { padding: 48px 16px; text-align: center; color: var(--text-3); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.empty.compact { padding: 20px 14px; }
.skeleton-line, .skeleton { height: 12px; border-radius: 4px; background: var(--surface-2); margin: 10px 0; animation: pulse 1.6s ease-in-out infinite; }
.skeleton { height: 64px; border-radius: var(--r-card); margin: 0 0 8px; }

/* ---------- stat cards (dashboard) ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-card {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 16px 16px 14px; min-height: 120px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); min-width: 0;
}
a.stat-card:hover { border-color: var(--border-strong); }
.stat-card .big { font-size: 26px; line-height: 34px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 18px; }
.stat-card .name { color: var(--text-2); font-weight: 500; }
.stat-card .sub { color: var(--text-3); font-size: 12px; line-height: 17px; }
.stat-card .ico { position: absolute; top: 14px; right: 14px; width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); }
.stat-card .meter { margin-top: 8px; }

/* ---------- live runs ---------- */
.live-list { display: flex; flex-direction: column; gap: 8px; }
.live-row {
  display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(0, 2fr) auto; gap: 16px; align-items: center;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--live); border-radius: var(--r-card);
}
.live-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.live-who .who-text { min-width: 0; }
.live-who .who-name { font-weight: 500; }
.live-task { font-weight: 500; }
.live-mid { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.live-figs { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.live-figs b { color: var(--text-2); font-weight: 500; }
.live-event { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 12px; min-width: 0; font-family: var(--mono); }
.live-event svg { color: var(--text-3); flex: none; }
.live-side { display: flex; align-items: center; gap: 12px; }
.elapsed { font: 500 13px/1 var(--mono); color: var(--text); font-variant-numeric: tabular-nums; }
.progress { position: relative; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--live); border-radius: 4px; }
.progress.warn > i { background: var(--warning); }

/* system strip */
.sys-strip { display: flex; flex-wrap: wrap; gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.sys-cell { display: flex; flex-direction: column; gap: 6px; padding: 12px 16px; border-right: 1px solid var(--border); min-width: 150px; flex: 1 1 150px; }
.sys-cell:last-child { border-right: 0; }
.sys-cell .v { font-variant-numeric: tabular-nums; font-weight: 500; }
.slots { display: flex; gap: 5px; align-items: center; }
.slot { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border-strong); }
.slot.on { background: var(--live); border-color: var(--live); }
.health { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.health span { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-2); }
.health i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.health i.bad { background: var(--danger); }
.health i.off { background: var(--text-3); }

/* activity feed */
.activity-text { flex: 1; min-width: 0; color: var(--text-2); line-height: 19px; }
.activity-text strong { color: var(--text); font-weight: 600; }
.activity-text a strong:hover { text-decoration: underline; }
.actor-icon { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-3); font-size: 9.5px; font-weight: 600; flex: none; }

/* charts */
.chart-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.chart-cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 14px 16px 12px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chart-card .t { font-weight: 500; }
.chart-card .s { color: var(--text-3); font-size: 11.5px; }
.chart-card .total { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }
.mini-chart { width: 100%; height: 96px; margin-top: 12px; overflow: visible; }
.mini-chart .base { stroke: var(--border); }
.chart-axis { display: flex; justify-content: space-between; margin-top: 6px; color: var(--text-3); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-axis.even span { flex: 1; text-align: center; }
.chart-axis b { color: var(--text-2); font-weight: 500; }
.chart-legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; font-size: 11px; color: var(--text-3); }
.chart-legend i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.chart-svg { width: 100%; height: 180px; }
.chart-svg .axis { stroke: var(--border); }
.chart-svg .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-svg .area { fill: var(--accent-soft); stroke: none; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 140px) minmax(0, 1fr) 72px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 6px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* meters */
.meter { display: flex; flex-direction: column; gap: 5px; min-width: 120px; }
.meter-bar { height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 4px; }
.meter.warn .meter-fill { background: var(--warning); }
.meter.over .meter-fill { background: var(--danger); }
.meter-label { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }

/* ---------- board ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters .search { flex: 1 1 220px; max-width: 320px; }
.filters select.input { width: auto; min-width: 140px; }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: 280px; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { display: flex; flex-direction: column; gap: 6px; min-height: 140px; padding: 8px; border-radius: var(--r-card); background: var(--sidebar); border: 1px solid var(--border); }
.column.drop-ok { border-color: var(--accent); background: var(--accent-soft); }
.column-head { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 4px 4px; }
.column-head .col-name { font-weight: 500; flex: 1; }
.column-head .n { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.column-empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 24px 8px; }
.status-switch { display: none; margin-bottom: 12px; overflow-x: auto; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 7px;
  background: var(--surface); border: 1px solid var(--border); cursor: pointer; color: var(--text); min-width: 0;
}
.card:hover { border-color: var(--border-strong); background: color-mix(in srgb, var(--surface) 80%, var(--hover)); }
.card.picked { outline: 2px dashed var(--accent); outline-offset: 2px; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-key { font: 500 11px/1 var(--mono); color: var(--text-3); letter-spacing: 0.01em; white-space: nowrap; }
.card-title { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.card-title .t { font-weight: 500; line-height: 19px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-3); font-size: 11.5px; }
.card-meta .cost { font-variant-numeric: tabular-nums; }
.card-flags { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.card-note { font-size: 11.5px; color: var(--warning); font-family: var(--mono); }
.card-note.bad { color: var(--danger); }
.clock-warn { color: var(--warning); display: inline-flex; }
.drag-handle { position: absolute; top: 8px; right: 6px; color: var(--text-3); opacity: 0; }
.card:hover .drag-handle, .card:focus .drag-handle { opacity: 1; }

/* ---------- task page ---------- */
.task-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; align-items: start; min-height: calc(100vh - var(--top)); }
.task-main { padding: 24px 32px 64px; min-width: 0; max-width: 920px; }
.task-side { position: sticky; top: var(--top); border-left: 1px solid var(--border); min-height: calc(100vh - var(--top)); padding: 20px; background: var(--sidebar); }
.task-side h2 { margin-bottom: 16px; }
.task-title-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: var(--text-3); font-size: 12px; }
.task-title { font-size: 22px; line-height: 30px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 16px; }
.props { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px 12px; align-items: center; font-size: 13px; margin: 0; }
.props dt { color: var(--text-3); }
.props dd { margin: 0; min-width: 0; }
.props-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.tabs-line { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 28px 0 16px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs-line::-webkit-scrollbar { display: none; }
.tabs-line button { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 0; background: none; color: var(--text-3); font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs-line button:hover { color: var(--text); }
.tabs-line button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--text); }
.tabs-line .n { color: var(--text-3); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.live-box { border: 1px solid color-mix(in srgb, var(--live) 45%, var(--border)); border-radius: var(--r-card); background: var(--surface); margin-top: 20px; overflow: hidden; }
.live-box-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 500; }
.live-box-body { max-height: 220px; overflow-y: auto; padding: 8px 14px; font: 12px/18px var(--mono); color: var(--text-2); }
.live-box-body .ln { display: flex; gap: 8px; padding: 2px 0; min-width: 0; }
.live-box-body .ln .k { color: var(--text-3); flex: none; width: 88px; white-space: nowrap; }
.block { margin-top: 24px; }
.block > h3 { margin-bottom: 10px; color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.comment { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.comment.agent { border-left: 2px solid var(--accent); }
.result-links { display: flex; flex-wrap: wrap; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; display: flex; gap: 12px; padding: 0 0 16px 0; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::before { display: none; }

/* ---------- run log ---------- */
.runlog { position: relative; max-height: 68vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--code-bg); }
.ev { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; padding: 10px 14px 10px 10px; border-top: 1px solid var(--border); }
.ev:first-child { border-top: 0; }
.ev-icon { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-3); }
.ev.k-tool_call .ev-icon { color: var(--live); }
.ev.k-tool_result .ev-icon { color: var(--accent); }
.ev.k-approval .ev-icon { color: var(--warning); }
.ev.err .ev-icon { color: var(--danger); background: var(--danger-soft); }
.ev-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ev-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.ev-head strong { color: var(--text); font-family: var(--font); font-weight: 600; font-size: 12.5px; }
.jump-live { position: sticky; bottom: 12px; display: flex; justify-content: center; pointer-events: none; }
.jump-live .btn { pointer-events: auto; }

/* code + markdown */
.codeblock { margin: 0; padding: 12px 14px; border-radius: var(--r-control); background: var(--code-bg); border: 1px solid var(--border); overflow-x: auto; font: 12px/19px var(--mono); color: var(--text); white-space: pre; }
.codeblock.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.tok-kw { color: #c792ea; } .tok-str { color: #a5d6a7; } .tok-num { color: #f9c97c; } .tok-com { color: var(--text-3); }
.diff-add { color: var(--success); } .diff-del { color: var(--danger); } .diff-hunk { color: var(--live); }
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 12px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; font-size: 10px; transition: transform 0.12s; }
details[open] > summary::before { transform: rotate(90deg); }
details[open] > summary { margin-bottom: 8px; }
.md { overflow-wrap: anywhere; line-height: 21px; color: var(--text); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote, .md table { margin: 0 0 10px; }
.md h1, .md h2, .md h3 { margin: 16px 0 8px; font-size: 14px; }
.md ul, .md ol { padding-left: 20px; }
.md a { color: var(--accent); }
.md a:hover { text-decoration: underline; }
.md code { background: var(--surface-2); border: 1px solid var(--border); padding: 0 4px; border-radius: 4px; font-size: 12px; }
.md pre { background: var(--code-bg); border: 1px solid var(--border); padding: 12px; border-radius: var(--r-control); overflow-x: auto; }
.md pre code { background: none; border: 0; padding: 0; }
.md blockquote { border-left: 2px solid var(--border-strong); padding-left: 12px; color: var(--text-2); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 9px; font-size: 12.5px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }

/* ---------- agents ---------- */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.agent-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); cursor: pointer; min-width: 0; text-align: left; font: inherit; color: inherit; }
.agent-card:hover { border-color: var(--border-strong); }
.agent-card .head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.agent-card .name { font-weight: 600; font-size: 14px; }
.agent-card .foot { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; }
.agent-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 24px; }
.agent-hero .titles { flex: 1; min-width: 200px; }
.agent-hero h1 { font-size: 22px; }
.state-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; text-transform: lowercase; }
.state-pill.idle { background: var(--warning-soft); color: var(--warning); }
.state-pill.running { background: var(--live-soft); color: var(--live); }
.state-pill.paused { background: var(--surface-2); color: var(--text-3); }
.latest-run { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); }
.short-id { font: 12px var(--mono); color: var(--text-3); }
.icon-pick { display: grid; grid-template-columns: repeat(6, 36px); gap: 6px; }
.icon-pick button { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.icon-pick button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.colour-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.colour-pick button { width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--hue); cursor: pointer; padding: 0; }
.colour-pick button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--hue); }
.grant { border: 1px solid var(--border); border-radius: var(--r-control); padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px 0 8px; border-radius: 5px; background: var(--surface); border: 1px solid var(--border); font: 11.5px var(--mono); }
.tag button { border: 0; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; padding: 2px; }

/* ---------- org chart ---------- */
.org-canvas { position: relative; height: calc(100vh - var(--top) - 120px); min-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--sidebar); background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 20px 20px; }
.org-zoom { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; flex-direction: column; gap: 6px; }
.org-zoom .btn { width: 30px; height: 30px; padding: 0; background: var(--surface); }
.org-stage { padding: 48px 24px; min-width: max-content; }
.org-chart, .org-chart ul { display: flex; justify-content: center; margin: 0; padding: 0; list-style: none; }
.org-chart { gap: 32px; width: max-content; margin: 0 auto; }
.org-chart ul { position: relative; padding-top: 24px; }
.org-chart li { position: relative; display: flex; flex-direction: column; align-items: center; padding: 24px 10px 0; }
.org-chart > li { padding-top: 0; }
.org-chart ul > li::before, .org-chart ul > li::after { content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 24px; border-top: 1px solid var(--border-strong); }
.org-chart ul > li::after { right: auto; left: 50%; border-left: 1px solid var(--border-strong); }
.org-chart ul > li:only-child::before, .org-chart ul > li:only-child::after { display: none; }
.org-chart ul > li:only-child { padding-top: 0; }
.org-chart ul > li:first-child::before, .org-chart ul > li:last-child::after { border: 0; }
.org-chart ul > li:last-child::before { border-right: 1px solid var(--border-strong); }
.org-chart ul::before { content: ""; position: absolute; top: 0; left: 50%; height: 24px; border-left: 1px solid var(--border-strong); }
.org-node { display: flex; align-items: flex-start; gap: 12px; width: 196px; padding: 14px; text-align: left; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-card); font: inherit; cursor: pointer; }
.org-node:hover { border-color: var(--border-strong); background: var(--surface-2); }
.org-node .nm { font-weight: 600; }
.org-node .sub { color: var(--text-2); font-size: 11.5px; font-family: var(--mono); }
.org-node .prov { color: var(--text-3); font-size: 11px; }

/* ---------- approvals ---------- */
.approval { background: var(--surface); border: 1px solid var(--border); border-left: 2px solid var(--warning); border-radius: var(--r-card); cursor: pointer; }
.approval.selected { border-color: var(--border-strong); border-left-color: var(--warning); box-shadow: 0 0 0 1px var(--border-strong); }
.approval-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px 6px; }
.approval-body { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.approval-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }
.reasoning { color: var(--text-2); border-left: 2px solid var(--border-strong); padding-left: 10px; white-space: pre-wrap; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 50; }
.dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 51; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; display: flex; flex-direction: column;
}
.dialog-head, .drawer-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.dialog-body, .drawer-body { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.dialog-foot, .drawer-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 51; background: var(--surface); border-left: 1px solid var(--border-strong); display: flex; flex-direction: column; }
.popover { position: absolute; top: calc(100% + 6px); right: 0; z-index: 40; width: min(400px, calc(100vw - 24px)); padding: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }
.popover .list-row { padding: 8px; border-top: 0; border-radius: 6px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(520px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4); font-size: 13px; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 50%, var(--border-strong)); }
.toast.error .toast-text { color: var(--danger); }
.toast.warning .toast-text { color: var(--warning); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* command palette */
.palette { position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); z-index: 61; width: min(600px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.palette-input input { flex: 1; height: 48px; border: 0; outline: none; background: none; color: var(--text); font: inherit; font-size: 15px; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-group { padding: 8px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--text-2); cursor: pointer; text-align: left; font: inherit; min-width: 0; }
.palette-item[aria-selected="true"] { background: var(--hover); color: var(--text); }
.palette-item .hint-r { margin-left: auto; color: var(--text-3); font-size: 11.5px; }
.palette-scrim { z-index: 60; }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(380px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .stat-cards, .chart-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-row { grid-template-columns: minmax(0, 1fr) auto; }
  .live-row .live-mid { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .task-layout { grid-template-columns: minmax(0, 1fr); }
  .task-side { position: static; min-height: 0; border-left: 0; border-bottom: 1px solid var(--border); order: -1; }
  .task-main { padding: 20px; }
}
@media (max-width: 767px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; height: auto; width: min(300px, 86vw); z-index: 55; transform: translateX(-100%); transition: transform 0.18s ease; }
  .sidebar.open { transform: none; }
  .side-scrim.open { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 54; }
  .btn.hamburger { display: inline-flex; }
  .side-orgs { display: flex; }
  .topbar { padding: 0 10px; gap: 6px; }
  .page { padding: 16px 16px 48px; }
  .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stat-card { min-height: 104px; padding: 12px; }
  .stat-card .big { font-size: 22px; margin-top: 14px; }
  .chart-cards, .chart-cards.two, .grid-halves { grid-template-columns: minmax(0, 1fr); }
  .live-row { grid-template-columns: minmax(0, 1fr); }
  .live-side { justify-content: space-between; }
  .board { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: minmax(0, 1fr); overflow-x: visible; }
  .board .column { display: none; }
  .board .column.mobile-active { display: flex; }
  .status-switch { display: block; }
  .filters .search { max-width: none; }
  .filters select.input { flex: 1 1 140px; }
  .hide-phone { display: none !important; }
  .bar-row { grid-template-columns: 90px minmax(0, 1fr) 64px; }
  .drawer { width: 100vw; }
  .crumbs .hide-sm { display: none; }
  .sys-cell { border-right: 0; border-bottom: 1px solid var(--border); }
  .sys-cell:last-child { border-bottom: 0; }
  .org-canvas { height: calc(100vh - var(--top) - 96px); }
}
@media (pointer: coarse) { .btn, .nav-item { min-height: 40px; } .btn.icon { width: 40px; } }

/* ---- New task composer ---- */
.composer-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.55); display: flex; justify-content: center; align-items: flex-start; padding: 14vh 16px 16px; }
.composer-wrap { width: min(640px, 100%); }
.composer-org { display: flex; padding: 0 12px; }
.composer-org .chip-select {
  height: 30px; padding: 0 12px; border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0;
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 12.5px;
}
.composer-org .chip-select > svg:first-child { color: var(--accent); }
.composer { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; padding: 14px 14px 10px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45); }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border-strong)); }
.composer-input {
  display: block; width: 100%; min-height: 72px; max-height: 320px; resize: none; border: 0; outline: 0; background: transparent;
  color: var(--text); font: inherit; font-size: 14.5px; line-height: 22px; padding: 2px 4px;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 2px 0; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--border); font-size: 12px; color: var(--text-2); }
.file-chip button { display: grid; place-items: center; width: 18px; height: 18px; border: 0; border-radius: 4px; background: transparent; color: var(--text-3); cursor: pointer; }
.file-chip button:hover { background: var(--hover); color: var(--text); }
.composer-error { padding: 8px 4px 0; color: var(--danger); font-size: 12.5px; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.composer-plus { position: relative; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--hover); color: var(--text); }
.composer-menu {
  position: absolute; left: 0; bottom: 36px; min-width: 250px; padding: 4px; z-index: 2;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}
.composer-menu button { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.composer-menu button:hover { background: var(--hover); }
.composer-menu button[aria-checked="true"] svg { color: var(--accent); }
.composer-tag { font-size: 11.5px; color: var(--text-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.composer-right { display: flex; align-items: center; gap: 4px; min-width: 0; }
.composer-dot { color: var(--text-3); padding: 0 2px; }
.chip-select { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-radius: 8px; color: var(--text-2); font-size: 13px; white-space: nowrap; cursor: pointer; min-width: 0; }
.chip-select:hover { background: var(--hover); color: var(--text); }
.chip-select:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-select .strong { color: var(--text); font-weight: 600; }
.chip-select.model span { overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.chip-select.model.chosen span { color: var(--text); }
/* The real <select> sits invisibly over the chip: native keyboard and mobile pickers, custom look. */
.chip-native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.send-btn { display: grid; place-items: center; width: 32px; height: 32px; margin-left: 6px; border-radius: 50%; border: 0; background: var(--text); color: var(--bg); cursor: pointer; flex: none; }
.send-btn:hover:not(:disabled) { background: var(--accent); color: var(--on-accent); }
.send-btn:disabled { background: var(--hover); color: var(--text-3); cursor: default; }
.composer-hint { margin: 10px 14px 0; font-size: 12px; color: var(--text-3); }
@media (max-width: 640px) {
  .composer-backdrop { padding-top: 8vh; }
  .composer-bar { flex-wrap: wrap; }
  .composer-right { width: 100%; justify-content: flex-end; }
  .chip-select.model span { max-width: 140px; }
}
