/* ARQVEA design system - v1
   Desktop-first enterprise control tower. Light and dark are both first class:
   every colour is a token, no component hard-codes a hex. */

:root {
  color-scheme: light;

  --gray-0: #ffffff;
  --gray-25: #fcfcfd;
  --gray-50: #f8f9fb;
  --gray-100: #f1f3f7;
  --gray-150: #e9ecf2;
  --gray-200: #dfe3ea;
  --gray-300: #c7cdd9;
  --gray-400: #9aa3b2;
  --gray-500: #6b7484;
  --gray-600: #4d5566;
  --gray-700: #363d4d;
  --gray-800: #232936;
  --gray-900: #141922;

  --bg: var(--gray-50);
  --bg-raised: var(--gray-0);
  --bg-sunken: var(--gray-100);
  --bg-hover: var(--gray-100);
  --bg-active: var(--gray-150);
  --surface-nav: #12151d;
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --text-subtle: var(--gray-400);
  --text-invert: #ffffff;

  --accent: #5b53d6;
  --accent-hover: #4b43c4;
  --accent-soft: #eeecfd;
  --accent-border: #cfcaf7;
  --accent-text: #4b43c4;

  --ok: #12805c;
  --ok-soft: #e3f5ee;
  --ok-border: #b7e4d3;
  --warn: #a35c07;
  --warn-soft: #fdf1de;
  --warn-border: #f3ddb4;
  --danger: #c0362c;
  --danger-soft: #fdeceb;
  --danger-border: #f6c9c5;
  --info: #1a6fb8;
  --info-soft: #e7f1fb;
  --info-border: #bcd9f3;

  --chart-1: #5b53d6;
  --chart-2: #0d9488;
  --chart-3: #d97706;
  --chart-4: #be185d;
  --chart-5: #2563eb;
  --chart-6: #65a30d;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 20, 30, .06), 0 1px 1px rgba(16, 20, 30, .04);
  --shadow: 0 4px 16px rgba(16, 20, 30, .08), 0 1px 3px rgba(16, 20, 30, .05);
  --shadow-lg: 0 24px 60px rgba(16, 20, 30, .18), 0 4px 12px rgba(16, 20, 30, .08);

  --sidebar-w: 244px;
  --topbar-h: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1017;
  --bg-raised: #151a23;
  --bg-sunken: #10141c;
  --bg-hover: #1c222d;
  --bg-active: #232a37;
  --surface-nav: #0a0d13;
  --border: #232a36;
  --border-strong: #323b4a;
  --text: #eef1f6;
  --text-muted: #98a2b3;
  --text-subtle: #6c778a;

  --accent: #8b83f5;
  --accent-hover: #9d96f7;
  --accent-soft: #1e1d3d;
  --accent-border: #37347a;
  --accent-text: #a9a3f8;

  --ok: #3ecf9a;
  --ok-soft: #10231d;
  --ok-border: #1c483a;
  --warn: #f0b357;
  --warn-soft: #241c0f;
  --warn-border: #4a381a;
  --danger: #f87d72;
  --danger-soft: #241413;
  --danger-border: #522724;
  --info: #6cb2f0;
  --info-soft: #101c28;
  --info-border: #1e3a52;

  --chart-1: #8b83f5;
  --chart-2: #2dd4bf;
  --chart-3: #fbbf24;
  --chart-4: #f472b6;
  --chart-5: #60a5fa;
  --chart-6: #a3e635;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 28px 70px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.018em; font-weight: 620; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================ app shell */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface-nav);
  color: #cdd3df;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; height: var(--topbar-h);
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, #6d64ea, #35c8b0);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
.brand-name { color: #fff; font-weight: 640; letter-spacing: .06em; font-size: 14px; }
.brand-env { font-size: 10px; color: #8891a5; letter-spacing: .08em; text-transform: uppercase; }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group { margin-top: 14px; }
.nav-group-label {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase;
  color: #6e7789; padding: 6px 10px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: #c2c9d6; cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-decoration: none; position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(124, 114, 240, .18); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.ico { display: inline-flex; align-items: center; justify-content: center; flex: none; line-height: 1; }
.nav-item .ico { width: 16px; height: 16px; opacity: .85; }
.nav-count {
  margin-left: auto; font-size: 11px; padding: 1px 6px; border-radius: 20px;
  background: rgba(255, 255, 255, .1); color: #dfe4ee; font-variant-numeric: tabular-nums;
}
.nav-count.alert { background: rgba(240, 90, 80, .22); color: #ffb4ad; }

.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .06); }
.org-switch {
  display: flex; align-items: center; gap: 9px; width: 100%;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .07);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer; text-align: left;
}
.org-switch:hover { background: rgba(255, 255, 255, .09); }
.org-avatar {
  width: 24px; height: 24px; border-radius: 6px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, #4a44b8, #2c8f86); color: #fff; font-size: 11px; font-weight: 700;
}
.org-meta { min-width: 0; }
.org-meta strong { display: block; color: #fff; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-meta span { font-size: 11px; color: #8b93a5; }

/* ================================================================ topbar */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; background: var(--bg-raised); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.crumbs strong { color: var(--text); font-weight: 600; }
.topbar-spacer { flex: 1; }
.cmd-trigger {
  display: flex; align-items: center; gap: 8px; min-width: 260px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 6px 10px; color: var(--text-subtle);
  cursor: pointer; font-size: 13px;
}
.cmd-trigger:hover { border-color: var(--border-strong); }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--bg-raised); color: var(--text-muted);
}
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-muted); position: relative;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-toggle { display: none; }
.dot-badge {
  position: absolute; top: 4px; right: 4px; min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: 10px; background: var(--danger); color: #fff; font-size: 9.5px;
  display: grid; place-items: center; font-weight: 700; border: 2px solid var(--bg-raised);
}
.avatar-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #2c8f86); color: #fff;
  font-size: 11.5px; font-weight: 700;
}

/* =============================================================== content */
.content { padding: 20px 24px 48px; max-width: 1560px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ============================================================== controls */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-raised); color: var(--text); font-size: 13px; font-weight: 550;
  cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { height: 27px; padding: 0 9px; font-size: 12.5px; }
.btn-icon { padding: 0; width: 32px; justify-content: center; }

.input, .select, .textarea {
  width: 100%; height: 32px; padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-raised); color: var(--text);
  font-size: 13px; outline: none;
}
.textarea { height: auto; padding: 8px 10px; min-height: 76px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-subtle); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 560; margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 15px; height: 15px; accent-color: var(--accent); }

.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .search { position: relative; min-width: 240px; flex: 1; max-width: 380px; }
.toolbar .search .input { padding-left: 30px; }
.toolbar .search svg { position: absolute; left: 9px; top: 8px; color: var(--text-subtle); }

/* ================================================================ cards */
.card {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }
.card-body.tight { padding: 12px; }
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: 2fr 1fr; }
.grid-1-2 { grid-template-columns: 1fr 2fr; }

/* ============================================================ stat tiles */
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-label {
  font-size: 11.5px; color: var(--text-muted); font-weight: 560;
  letter-spacing: .02em; display: flex; align-items: center; gap: 6px;
}
.stat-value { font-size: 25px; font-weight: 640; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.delta { font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--text-muted); }

/* =============================================================== badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px;
  border-radius: 5px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; letter-spacing: .01em;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-border); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent-border); }
.badge-neutral { background: var(--bg-sunken); color: var(--text-muted); border-color: var(--border); }
.pill { border-radius: 20px; padding: 0 9px; }

/* =============================================================== tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); font-weight: 600; padding: 9px 14px;
  border-bottom: 1px solid var(--border); background: var(--bg-sunken);
  position: sticky; top: 0; white-space: nowrap;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th .arrow { opacity: .5; font-size: 9px; margin-left: 3px; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-primary { font-weight: 570; }
.cell-sub { color: var(--text-muted); font-size: 12px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.pagination {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted);
}
.pagination .spacer { flex: 1; }

/* ========================================================= empty/loading */
.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty .icon {
  width: 42px; height: 42px; border-radius: 12px; margin: 0 auto 12px;
  background: var(--bg-sunken); display: grid; place-items: center; color: var(--text-subtle);
}
.empty h3 { color: var(--text); margin-bottom: 5px; }
.empty p { max-width: 380px; margin: 0 auto 14px; font-size: 13px; }

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--bg-hover) 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.skeleton-row { height: 13px; margin: 11px 14px; }

.error-state {
  border: 1px solid var(--danger-border); background: var(--danger-soft);
  border-radius: var(--radius); padding: 14px 16px; color: var(--danger);
  display: flex; gap: 10px; align-items: flex-start;
}
.error-state .btn { color: var(--text); }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================ drawer */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 13, 20, .45); z-index: 90;
  backdrop-filter: blur(2px); animation: fade .14s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 94vw); z-index: 91;
  background: var(--bg-raised); border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide-in .18s cubic-bezier(.32, .72, .35, 1);
}
@keyframes slide-in { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.drawer-head h2 { font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; background: var(--bg-sunken);
}

.modal {
  position: fixed; z-index: 91; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(560px, 94vw); max-height: 88vh; overflow: hidden;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .16s ease;
}
@keyframes pop { from { transform: translate(-50%, -46%) scale(.97); opacity: 0; } }
.modal .drawer-body { padding: 18px; }

/* ================================================== definition/meta list */
.meta-list { display: grid; grid-template-columns: 150px 1fr; gap: 9px 14px; font-size: 13px; }
.meta-list dt { color: var(--text-muted); }
.meta-list dd { margin: 0; word-break: break-word; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--text-muted); }

pre.payload {
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; overflow: auto; max-height: 320px; font-family: var(--mono);
  font-size: 12px; line-height: 1.5; margin: 0;
}

/* ============================================================== timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 1px; background: var(--border);
}
.tl-dot { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; z-index: 1; }
.tl-dot.done { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.tl-dot.failed { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.tl-dot.pending, .tl-dot.skipped { background: var(--bg-sunken); color: var(--text-muted); border: 1px solid var(--border); }
.tl-body strong { font-size: 13px; }
.tl-body p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-muted); }

/* =============================================================== charts */
.chart { width: 100%; display: block; overflow: visible; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }
.spark { display: block; }
.health-ring { display: grid; place-items: center; position: relative; }
.health-ring .val { position: absolute; text-align: center; }
.health-ring .val strong { font-size: 27px; font-weight: 650; display: block; line-height: 1.1; }
.health-ring .val span { font-size: 11.5px; color: var(--text-muted); }

.bar-track { height: 6px; border-radius: 4px; background: var(--bg-active); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--accent); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }

/* ============================================================== command */
.cmd-palette {
  position: fixed; top: 12vh; left: 50%; transform: translateX(-50%); z-index: 95;
  width: min(620px, 94vw); background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
}
.cmd-input {
  width: 100%; height: 48px; border: none; border-bottom: 1px solid var(--border);
  padding: 0 16px; font-size: 15px; background: transparent; outline: none;
}
.cmd-results { max-height: 56vh; overflow-y: auto; padding: 6px; }
.cmd-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13.5px;
}
.cmd-item.active { background: var(--accent-soft); color: var(--accent-text); }
.cmd-item .type { margin-left: auto; font-size: 11px; color: var(--text-subtle); }
.cmd-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-subtle); padding: 9px 11px 4px; font-weight: 650; }

/* =============================================================== toasts */
.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 99; display: flex;
  flex-direction: column; gap: 9px; }
.toast {
  min-width: 280px; max-width: 400px; background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 11px 13px;
  font-size: 13px; animation: toast-in .18s ease;
}
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast strong { display: block; margin-bottom: 2px; }

/* ============================================================ dropdowns */
.menu {
  position: absolute; z-index: 92; min-width: 190px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 5px; animation: pop-sm .12s ease;
}
@keyframes pop-sm { from { transform: translateY(-4px); opacity: 0; } }
.menu-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px; white-space: nowrap;
}
.menu-item:hover { background: var(--bg-hover); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 0; }
.menu-label { padding: 6px 9px 3px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-subtle); font-weight: 650; }

/* ================================================================= tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 8px 12px; font-size: 13px; font-weight: 550; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ================================================================= auth */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  background: var(--surface-nav); color: #e6eaf2; padding: 44px 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  background-image: radial-gradient(900px 420px at 10% -10%, rgba(109, 100, 234, .35), transparent 60%),
                    radial-gradient(700px 380px at 90% 110%, rgba(45, 212, 191, .22), transparent 60%);
}
.auth-side h1 { font-size: 30px; color: #fff; max-width: 15ch; line-height: 1.2; }
.auth-side p { color: #a8b0c2; max-width: 46ch; }
.auth-points { display: grid; gap: 14px; margin-top: 26px; }
.auth-point { display: flex; gap: 11px; align-items: flex-start; }
.auth-point .tick {
  width: 20px; height: 20px; border-radius: 6px; background: rgba(124, 114, 240, .22);
  color: #b7b1fb; display: grid; place-items: center; flex: none; font-size: 11px;
}
.auth-point strong { color: #fff; display: block; font-size: 13.5px; }
.auth-point span { color: #98a1b4; font-size: 12.5px; }
.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 22px; margin-bottom: 6px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 22px; font-size: 13.5px; }
.auth-alt { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-muted); }
.demo-hint {
  margin-top: 18px; padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--accent-soft); border: 1px solid var(--accent-border);
  font-size: 12.5px; color: var(--accent-text);
}

/* ================================================================== ask */
.ask-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; height: calc(100vh - var(--topbar-h) - 40px); }
/* Grid items default to min-width: auto, not 0 -- their own content's
   intrinsic width can force them wider than their track and spill into
   the next column instead of respecting the fixed 250px. A long,
   space-less conversation title (a raw error message like a comma-
   separated id list) is exactly the kind of content that triggers this:
   the ellipsis truncation on .lead never gets a chance to apply because
   the sidebar itself overflowed past its column first. Both sides of
   the grid need an explicit min-width: 0 to actually respect their track. */
.ask-sidebar { min-width: 0; overflow: hidden; }
.ask-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.ask-thread { flex: 1; overflow-y: auto; padding: 6px 4px 12px; scroll-behavior: smooth; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg {
  display: flex; gap: 11px; margin-bottom: 20px;
  animation: msg-in .32s cubic-bezier(.16,1,.3,1) both;
}
.msg-avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #fff; box-shadow: 0 2px 6px rgba(16,20,30,.12);
}
.msg.user .msg-avatar { background: linear-gradient(135deg, #4d5566, #2f3543); }
.msg.assistant .msg-avatar {
  background: linear-gradient(135deg, #6d64ea, #35c8b0);
}
.msg-body { min-width: 0; flex: 1; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.msg.user .msg-body { background: var(--bg-sunken); }
.msg-body .who { font-size: 12px; font-weight: 650; margin-bottom: 5px; }
.msg-content { font-size: 13.6px; line-height: 1.62; }
.msg-content p { margin: 0 0 9px; }
.msg-content ul { margin: 0 0 9px; padding-left: 18px; }
.msg-content li { margin-bottom: 3px; }
.msg-content code {
  background: var(--bg-sunken); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border);
}
.msg-content .table-wrap { margin: 0 0 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.msg-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.msg-table th, .msg-table td {
  padding: 7px 11px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.msg-table thead th { background: var(--bg-sunken); font-weight: 650; color: var(--text-muted); }
.msg-table tbody tr:last-child th, .msg-table tbody tr:last-child td { border-bottom: none; }
.msg-image-preview { max-width: 220px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  margin-bottom: 8px; display: block; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-subtle);
  animation: typing-bounce 1.1s ease-in-out infinite;
}
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
.tool-trace {
  margin-top: 9px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-sunken); font-size: 12px; overflow: hidden;
}
.tool-trace summary { padding: 7px 11px; cursor: pointer; color: var(--text-muted); }
.tool-trace .rows { padding: 4px 11px 9px; display: grid; gap: 5px; }
.tool-row { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 11.5px; }
.tool-row .ok { color: var(--ok); }
.tool-row .err { color: var(--danger); }
.action-card {
  margin-top: 11px; border: 1px solid var(--accent-border); background: var(--accent-soft);
  border-radius: var(--radius); padding: 13px 15px;
}
.action-card h4 { font-size: 13px; margin-bottom: 3px; color: var(--accent-text); }
.action-card .acts { display: flex; gap: 8px; margin-top: 11px; }
.ask-composer {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-raised);
  padding: 10px; box-shadow: var(--shadow-sm); transition: border-color .15s ease, box-shadow .15s ease;
}
.ask-composer:focus-within { border-color: var(--accent-border); box-shadow: 0 0 0 3px var(--accent-soft); }
.ask-composer textarea {
  width: 100%; border: none; outline: none; resize: none; background: transparent;
  font-size: 14px; min-height: 48px; line-height: 1.55;
}
.ask-composer .row { display: flex; align-items: center; gap: 8px; }
.icon-toggle {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--text-muted);
  cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-toggle:hover { background: var(--bg-sunken); color: var(--text); }
.icon-toggle.active { background: var(--danger-soft, #fdeceb); color: var(--danger); border-color: var(--danger-border, #f6c9c5); }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192, 54, 44, .35); } 50% { box-shadow: 0 0 0 6px rgba(192, 54, 44, 0); } }
.icon-toggle.active.mic-live { animation: mic-pulse 1.4s ease-out infinite; }
.attach-preview {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border);
  background: var(--bg-sunken); border-radius: var(--radius-sm); padding: 5px 8px 5px 5px;
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 8px;
  animation: msg-in .2s ease both;
}
.attach-preview img { width: 32px; height: 32px; object-fit: cover; border-radius: 5px; }
.attach-preview button {
  border: none; background: none; cursor: pointer; color: var(--text-subtle); display: grid; place-items: center;
  padding: 2px; border-radius: 4px;
}
.attach-preview button:hover { background: var(--bg-active); color: var(--text); }
.suggest-chip {
  border: 1px solid var(--border); background: var(--bg-raised); border-radius: 20px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer; color: var(--text-muted);
}
.suggest-chip:hover { border-color: var(--accent-border); color: var(--accent-text); background: var(--accent-soft); }

/* =========================================================== mapping ui */
.map-grid { display: grid; grid-template-columns: 1fr 44px 1fr; gap: 10px; align-items: center; }
.map-field {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px;
  background: var(--bg-raised); font-size: 12.8px;
}
.map-field .type { color: var(--text-subtle); font-size: 11px; font-family: var(--mono); }
.map-arrow { text-align: center; color: var(--text-subtle); }
.confidence { height: 4px; border-radius: 3px; background: var(--bg-active); overflow: hidden; margin-top: 5px; }
.confidence i { display: block; height: 100%; background: var(--ok); }
.confidence.mid i { background: var(--warn); }
.confidence.low i { background: var(--danger); }

/* =============================================================== matrix */
.matrix { display: grid; gap: 8px; }
.matrix-row {
  display: grid; grid-template-columns: 1fr auto 1fr 120px; gap: 12px; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 13px;
  background: var(--bg-raised);
}
.node { display: flex; align-items: center; gap: 8px; min-width: 0; }
.node .glyph {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--bg-sunken); border: 1px solid var(--border); font-size: 10px;
  font-weight: 700; color: var(--text-muted); flex: none;
}
.flow-line { color: var(--text-subtle); font-size: 11px; text-align: center; }

.mini-list { display: grid; gap: 9px; }
.mini-item {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  background: var(--bg-raised); min-width: 0; overflow: hidden;
}
.mini-item:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.mini-item .lead { font-weight: 560; font-size: 13px; }
.mini-item .meta { font-size: 12px; color: var(--text-muted); }

.sev-strip { width: 3px; border-radius: 3px; align-self: stretch; flex: none; }
.sev-critical { background: var(--danger); }
.sev-high { background: var(--warn); }
.sev-medium { background: var(--info); }
.sev-low { background: var(--text-subtle); }

/* =========================================================== responsive */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1, .grid-1-2, .grid-3 { grid-template-columns: 1fr; }
  .ask-layout { grid-template-columns: 1fr; }
  .ask-sidebar { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .nav-toggle { display: grid; }
  .sidebar { position: fixed; z-index: 80; transform: translateX(-100%); transition: transform .18s;
    width: var(--sidebar-w); }
  .sidebar.open { transform: none; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .content { padding: 16px; }
  .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .cmd-trigger { min-width: 0; }
  .cmd-trigger span.label, .kbd { display: none; }
}
