:root {
  --bg: #060b12;
  --bg-2: #0a111b;
  --panel: rgba(15, 24, 36, 0.86);
  --panel-solid: #0f1824;
  --panel-2: #0b131e;
  --panel-3: #111e2e;
  --line: #1e2d40;
  --line-soft: rgba(30, 45, 64, 0.7);
  --text: #dce7f3;
  --text-dim: #9fb0c3;
  --muted: #6f849a;
  --accent: #37e0a8;
  --accent-2: #22c7ff;
  --accent-dim: #175d49;
  --blue: #4aa8ff;
  --crit: #ff4d6d;
  --high: #ff914d;
  --med: #ffd166;
  --low: #58c7ff;
  --info: #8b9bb0;
  --ok: #37e0a8;
  --warn: #ffcf5c;
  --danger: #ff5d78;
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  --sidebar: 246px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 600px at 8% -10%, rgba(24, 72, 96, 0.32), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(31, 32, 92, 0.28), transparent 55%),
    radial-gradient(800px 800px at 55% 120%, rgba(12, 74, 60, 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-only { display: none !important; }

/* ---------- Auth ---------- */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(800px 500px at 30% 10%, rgba(20, 100, 80, 0.25), transparent 60%),
    radial-gradient(700px 500px at 80% 90%, rgba(30, 60, 140, 0.22), transparent 60%),
    #05090f;
}
.auth-glow {
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(55, 224, 168, 0.14), transparent 65%);
  filter: blur(20px);
  pointer-events: none;
}
.auth-card {
  position: relative;
  width: min(440px, 100%);
  margin: auto;
  padding: 34px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(17, 28, 42, 0.96), rgba(9, 16, 25, 0.97));
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
}
.auth-brand { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.auth-brand h1 { font-size: 24px; letter-spacing: -0.02em; }
.auth-brand p { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; margin-top: 4px; }
.logo-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: var(--accent);
  background: radial-gradient(circle at 50% 30%, rgba(55, 224, 168, 0.2), rgba(10, 20, 30, 0.9));
  border: 1px solid rgba(55, 224, 168, 0.3);
  box-shadow: 0 0 30px rgba(55, 224, 168, 0.18);
  flex: 0 0 auto;
}
.logo-mark.small { width: 40px; height: 40px; border-radius: 12px; }
.auth-step { display: grid; gap: 14px; }
.auth-foot { margin-top: 22px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.auth-note { font-size: 12px; color: var(--text-dim); line-height: 1.55; }
.auth-note strong { color: var(--accent); }
.secret-box {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--line);
  background: var(--panel-2);
  color: var(--accent);
}
.qr-wrap {
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 14px;
  background: #fff;
  width: 220px;
  margin: 0 auto;
}
.qr-wrap img { width: 200px; height: 200px; display: block; }
.qr-wrap.qr-large { width: min(320px, 100%); }
.qr-wrap.qr-large img { width: 100%; height: auto; }
.qr-fallback { padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.qr-fallback .copy-row code { font-size: 11px; }
.qr-fallback .hint { line-height: 1.5; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 14px 14px;
  background: linear-gradient(180deg, rgba(8, 14, 22, 0.98), rgba(6, 11, 18, 0.98));
  border-right: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 16px; }
.sb-title { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.sb-title span { color: var(--accent); }
.nav { display: flex; flex-direction: column; gap: 3px; overflow: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  font-weight: 550;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex: 0 0 auto; opacity: 0.86; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(55, 224, 168, 0.16), rgba(55, 224, 168, 0.03));
  border-color: rgba(55, 224, 168, 0.28);
  color: #eafff7;
}
.nav-item.active svg { color: var(--accent); opacity: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 9px 6px; }
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #04140e;
  background: linear-gradient(135deg, var(--accent), #5cf0c8);
  flex: 0 0 auto;
  text-transform: uppercase;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-meta strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.9px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar); display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(6, 11, 18, 0.82);
  backdrop-filter: blur(14px);
}
.page-title { min-width: 0; flex: 1; }
.eyebrow { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin-bottom: 1px; }
.page-title h2 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--mono);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 3px rgba(110, 130, 150, 0.12); }
.chip.on { color: var(--ok); border-color: var(--accent-dim); }
.chip.on i { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.chip.off { color: var(--danger); border-color: #4a2230; }
.chip.off i { background: var(--danger); }
.model-chip { color: var(--accent-2); border-color: #233f5a; }
.view { flex: 1; padding: 22px; max-width: 1680px; width: 100%; margin: 0 auto; outline: none; }

/* ---------- Generic ---------- */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.overview { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.2px; color: #b7c6d8; }
.section-head .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.card {
  background: linear-gradient(180deg, rgba(17, 27, 41, 0.92), rgba(10, 17, 27, 0.94));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  min-width: 0;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}
.card.flush { padding: 0; overflow: hidden; }
.card.tight { padding: 14px; }
.card.glow { border-color: rgba(55, 224, 168, 0.24); box-shadow: 0 0 0 1px rgba(55, 224, 168, 0.06), 0 20px 60px rgba(0, 0, 0, 0.3); }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.row.tight { gap: 6px; }
.spacer { flex: 1; }

/* ---------- Stats ---------- */
.stat {
  position: relative;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 32, 47, 0.92), rgba(10, 17, 27, 0.94));
  overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(55, 224, 168, 0.14), transparent 70%); }
.stat .label { font-size: 10px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); }
.stat .value { font-family: var(--mono); font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 6px; }
.stat .value.sm { font-size: 20px; }
.stat .foot { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.stat.crit .value { color: var(--crit); }
.stat.high .value { color: var(--high); }
.stat.med .value { color: var(--med); }
.stat.ok .value { color: var(--ok); }
.stat.blue .value { color: var(--accent-2); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
  transition: filter 0.15s ease, border-color 0.15s ease, background 0.15s ease, transform 0.07s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); border-color: #2c425a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-primary { background: linear-gradient(180deg, #33dda3, #1f9c72); border-color: #1f9c72; color: #03140d; }
.btn-blue { background: linear-gradient(180deg, #3f9dff, #1f73d6); border-color: #1f73d6; color: #041429; }
.btn-danger { background: linear-gradient(180deg, #ff5d78, #cf3550); border-color: #cf3550; color: #190409; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; }
.btn-xs { padding: 3px 8px; font-size: 10.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: #2c425a; }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 12px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 600; }
.field .hint { font-size: 11px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-size: 13px;
}
input::placeholder, textarea::placeholder { color: #53677c; }
input:focus, select:focus, textarea:focus { border-color: var(--accent-dim); box-shadow: 0 0 0 3px rgba(55, 224, 168, 0.1); }
textarea { resize: vertical; min-height: 80px; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
select { font-family: inherit; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 12px;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1.45;
}
.check input { margin-top: 2px; flex: 0 0 auto; }
.check strong { color: var(--text); }
.search-input { min-width: 220px; }
.form-error { color: var(--danger); font-size: 12px; min-height: 16px; }
.form-ok { color: var(--ok); font-size: 12px; }
.inline-note {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #4d3a1c;
  border-left: 3px solid var(--warn);
  background: rgba(255, 207, 92, 0.07);
  color: #ffe6b0;
  font-size: 11.5px;
  line-height: 1.5;
}
.inline-note.danger { border-color: #4a2230; border-left-color: var(--danger); background: rgba(255, 93, 120, 0.07); color: #ffd0d8; }
.inline-note.info { border-color: #233f5a; border-left-color: var(--accent-2); background: rgba(74, 168, 255, 0.06); color: #cfe9ff; }
.inline-note strong { color: inherit; }

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.sev-critical, .badge.critical { color: var(--crit); border-color: #5a2634; background: rgba(255, 77, 109, 0.08); }
.sev-high, .badge.high { color: var(--high); border-color: #5a3a1d; background: rgba(255, 145, 77, 0.08); }
.sev-medium, .badge.medium { color: var(--med); border-color: #5a4a1d; background: rgba(255, 209, 102, 0.08); }
.sev-low, .badge.low { color: var(--low); border-color: #234a6b; background: rgba(88, 199, 255, 0.08); }
.sev-info, .badge.info { color: var(--info); border-color: var(--line); }
.badge.ok, .status-completed, .status-idle { color: var(--ok); border-color: var(--accent-dim); background: rgba(55, 224, 168, 0.07); }
.badge.running, .status-running { color: var(--accent-2); border-color: #234a6b; background: rgba(74, 168, 255, 0.08); }
.badge.error, .status-error, .status-failed { color: var(--crit); border-color: #5a2634; background: rgba(255, 77, 109, 0.08); }
.badge.warn, .status-paused, .status-stalled { color: var(--warn); border-color: #5a4a1d; background: rgba(255, 207, 92, 0.07); }
.badge.neutral { color: var(--muted); }
.badge.sandbox { color: #c9a7ff; border-color: #40305f; background: rgba(154, 110, 255, 0.08); }
.badge.source { color: var(--accent-2); border-color: #233f5a; }
.sev-bars { display: grid; gap: 9px; }
.sev-bar-row { display: grid; grid-template-columns: 74px 1fr 34px; align-items: center; gap: 9px; font-size: 11px; color: var(--text-dim); }
.sev-bar { height: 7px; border-radius: 99px; background: #0a121c; border: 1px solid var(--line); overflow: hidden; }
.sev-bar i { display: block; height: 100%; width: 0%; border-radius: 99px; transition: width 0.5s ease; }
.sev-bar i.critical { background: linear-gradient(90deg, #ff4d6d, #ff8aa1); }
.sev-bar i.high { background: linear-gradient(90deg, #ff914d, #ffc08a); }
.sev-bar i.medium { background: linear-gradient(90deg, #ffd166, #ffe9a8); }
.sev-bar i.low { background: linear-gradient(90deg, #58c7ff, #a8e4ff); }
.sev-bar i.info { background: linear-gradient(90deg, #8b9bb0, #c5d0dd); }

/* ---------- Tables / lists ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: 9px 11px;
  background: #0b1420;
  color: var(--muted);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.table .cell-actions { text-align: right; white-space: nowrap; }
.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: rgba(10, 17, 27, 0.4);
}
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 12px;
}
.list-item .meta { color: var(--muted); font-size: 10.5px; font-family: var(--mono); margin-top: 3px; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item.clickable { cursor: pointer; }
.list-item.clickable:hover { border-color: var(--accent-dim); }
.list-item.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(55, 224, 168, 0.12); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 12px; }
.kv dt { color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.7px; }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }
.scope-list { display: flex; flex-wrap: wrap; gap: 5px; }
.scope-chip { font-family: var(--mono); font-size: 10px; padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--text-dim); background: var(--panel-2); }
.scope-chip.include { color: var(--ok); border-color: var(--accent-dim); }
.scope-chip.exclude { color: var(--danger); border-color: #4a2230; }

/* ---------- Overview ---------- */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid rgba(55, 224, 168, 0.2);
  background:
    radial-gradient(700px 240px at 10% 0%, rgba(55, 224, 168, 0.16), transparent 65%),
    linear-gradient(180deg, rgba(18, 32, 47, 0.95), rgba(9, 16, 25, 0.95));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.hero h2 { font-size: 24px; letter-spacing: -0.03em; }
.hero p { color: var(--text-dim); font-size: 12.5px; margin-top: 4px; max-width: 720px; }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pulse { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--ok); }
.pulse i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 rgba(55, 224, 168, 0.5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(55, 224, 168, 0.45); } 70% { box-shadow: 0 0 0 9px rgba(55, 224, 168, 0); } 100% { box-shadow: 0 0 0 0 rgba(55, 224, 168, 0); } }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; gap: 14px; align-items: start; height: calc(100vh - 118px); min-height: 560px; }
.chat-panel { display: flex; flex-direction: column; min-height: 0; height: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); overflow: hidden; }
.chat-panel-head { padding: 13px 15px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: rgba(10, 17, 27, 0.6); }
.chat-panel-head h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.1px; color: #b7c6d8; }
.chat-sessions { overflow: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.session-item { padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12px; }
.session-item:hover { border-color: var(--accent-dim); }
.session-item.active { border-color: var(--accent); background: rgba(55, 224, 168, 0.06); }
.session-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .meta { display: flex; justify-content: space-between; gap: 6px; margin-top: 4px; color: var(--muted); font-size: 10px; font-family: var(--mono); }
.chat-main { display: flex; flex-direction: column; min-height: 0; height: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: linear-gradient(180deg, rgba(15, 24, 36, 0.9), rgba(8, 14, 22, 0.95)); overflow: hidden; }
.chat-header { padding: 11px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: rgba(10, 17, 27, 0.55); }
.chat-header .chat-title { font-weight: 700; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.chat-header .chat-sub { font-size: 10.5px; color: var(--muted); font-family: var(--mono); }
.messages { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.msg { display: flex; gap: 10px; max-width: 92%; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 11px; font-weight: 800; flex: 0 0 auto; }
.msg.user .msg-avatar { background: linear-gradient(135deg, #4aa8ff, #2a6fc9); color: #041429; }
.msg.assistant .msg-avatar { background: linear-gradient(135deg, #37e0a8, #1f9c72); color: #03140d; }
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble { background: rgba(255, 207, 92, 0.06); border-color: #4d3a1c; color: #ffe6b0; font-size: 11.5px; }
.msg.system .msg-avatar { display: none; }
.bubble {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  line-height: 1.55;
  min-width: 0;
  overflow-wrap: anywhere;
}
.msg.user .bubble { background: linear-gradient(180deg, rgba(42, 111, 201, 0.35), rgba(27, 72, 132, 0.35)); border-color: #244a74; }
.bubble .msg-meta { margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 9.5px; font-family: var(--mono); }
.bubble pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: #050a10;
  border: 1px solid var(--line);
  overflow: auto;
  max-height: 420px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble code { font-family: var(--mono); font-size: 11.5px; background: rgba(255, 255, 255, 0.06); padding: 1px 5px; border-radius: 5px; }
.bubble h3, .bubble h4 { margin: 10px 0 5px; font-size: 13px; color: #eaf4ff; }
.bubble ul { margin: 6px 0; padding-left: 18px; }
.bubble p { margin: 5px 0; }
.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
.chat-compose { border-top: 1px solid var(--line); padding: 11px 13px; background: rgba(8, 14, 22, 0.85); }
.compose-box { display: flex; gap: 8px; align-items: flex-end; }
.compose-box textarea { min-height: 48px; max-height: 180px; resize: none; }
.compose-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 11px; color: var(--muted); }
.compose-meta .check { font-size: 11px; }
.activity-panel { display: flex; flex-direction: column; min-height: 0; height: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); overflow: hidden; }
.activity-list { overflow: auto; padding: 9px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.tool-card { border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); overflow: hidden; }
.tool-card summary { list-style: none; cursor: pointer; padding: 8px 10px; display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.tool-card summary::-webkit-details-marker { display: none; }
.tool-card summary .tname { font-family: var(--mono); font-weight: 700; color: var(--accent-2); }
.tool-card summary .tcmd { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; font-family: var(--mono); font-size: 10.5px; }
.tool-body { padding: 0 10px 10px; }
.tool-body pre { margin: 0; max-height: 240px; overflow: auto; padding: 8px; border-radius: 7px; background: #050a10; border: 1px solid var(--line); font-family: var(--mono); font-size: 10.5px; white-space: pre-wrap; word-break: break-word; color: #bfe9d7; }
.tool-empty { padding: 18px 10px; color: var(--muted); font-size: 11.5px; text-align: center; }

/* ---------- Modals / toasts ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(3, 6, 10, 0.78);
  backdrop-filter: blur(7px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4vh 18px 18px;
  overflow: auto;
}
.modal {
  width: min(760px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #101c2b, #0a121d);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  animation: modalIn 0.16s ease;
}
.modal.wide { width: min(1040px, 100%); }
.modal.small { width: min(480px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(-8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); background: rgba(10, 17, 27, 0.75); position: sticky; top: 0; z-index: 2; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { padding: 13px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: rgba(8, 14, 22, 0.6); }
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: #101c2b; color: var(--text); font-size: 12.5px; box-shadow: var(--shadow); animation: toastIn 0.18s ease; }
.toast.ok { border-color: var(--accent-dim); }
.toast.err { border-color: #5a2634; color: #ffd0d8; }
.toast.warn { border-color: #5a4a1d; color: #ffe6b0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row code { flex: 1; padding: 9px 11px; border-radius: 8px; border: 1px dashed var(--line); background: var(--panel-2); font-family: var(--mono); font-size: 12px; word-break: break-all; }

/* ---------- Reports ---------- */
.report-preview { max-height: 58vh; overflow: auto; padding: 18px; border-radius: 12px; border: 1px solid var(--line); background: #070d14; font-size: 12.5px; line-height: 1.6; }
.report-preview h1 { font-size: 20px; margin: 4px 0 10px; }
.report-preview h2 { font-size: 15px; margin: 18px 0 7px; color: #cfe9ff; }
.report-preview h3 { font-size: 13px; margin: 14px 0 6px; color: #e7f4ff; }
.report-preview p { margin: 7px 0; }
.report-preview ul { margin: 7px 0; padding-left: 20px; }
.report-preview pre { padding: 10px; border-radius: 8px; background: #04080d; border: 1px solid var(--line); overflow: auto; font-family: var(--mono); font-size: 11px; white-space: pre-wrap; }
.report-preview code { font-family: var(--mono); background: rgba(255, 255, 255, 0.06); padding: 1px 4px; border-radius: 4px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .chat-layout { grid-template-columns: 220px minmax(0, 1fr); }
  .activity-panel { display: none; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-8, .span-7, .span-5 { grid-column: span 12; }
  .span-4, .span-3 { grid-column: span 6; }
}
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: none; box-shadow: 0 0 80px rgba(0, 0, 0, 0.7); }
  .main { margin-left: 0; }
  .mobile-only { display: inline-grid !important; }
  .sidebar .mobile-only { display: inline-grid !important; margin-left: auto; }
  .chat-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .chat-sessions-wrap { display: none; }
  .chat-main { min-height: 70vh; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: minmax(0, 1fr); }
  .span-6, .span-4, .span-3 { grid-column: span 12; }
  .topbar { padding: 12px 14px; }
  .view { padding: 14px; }
}
@media (max-width: 640px) {
  .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .model-chip { display: none; }
  .hero { flex-direction: column; align-items: flex-start; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .stat .value { font-size: 24px; }
  .auth-card { padding: 24px; }
  .table th, .table td { padding: 8px; }
}

/* ---------- Mobile / responsiveness upgrade ---------- */
.sidebar-backdrop {
  display: none;
}
@media (max-width: 980px) {
  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(2, 5, 9, 0.66);
    backdrop-filter: blur(3px);
  }
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }
  .page-title h2 { font-size: 16px; }
  .hero {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }
  .hero h2 { font-size: 21px; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 auto; }
  .form-grid.cols-2,
  .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .section-head {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .section-head .search-input { min-width: 0; width: 100%; }
  .card { padding: 15px; }
  .view { padding: 14px 12px 26px; }

  .chat-layout {
    display: flex;
    flex-direction: column;
    gap: 14px;
    height: auto;
  }
  .chat-main {
    order: 1;
    height: auto;
    min-height: 68vh;
  }
  .chat-sessions-wrap {
    order: 2;
    display: flex;
    height: auto;
    max-height: 260px;
  }
  .activity-panel {
    order: 3;
    display: flex;
    height: auto;
    max-height: 380px;
  }
  .chat-sessions { max-height: 190px; }
  .activity-list { max-height: 300px; }
  .chat-header .row.tight { width: 100%; }
  #chat-provider { flex: 1 1 100%; max-width: none; width: 100%; }

  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table { min-width: 640px; }
  .table th, .table td { white-space: nowrap; }
  .table td .cell-sub { white-space: normal; min-width: 220px; }
}

@media (max-width: 640px) {
  .auth-screen { padding: 12px; }
  .auth-card { padding: 20px; border-radius: 18px; }
  .auth-brand h1 { font-size: 21px; }
  .logo-mark { width: 54px; height: 54px; }
  .qr-wrap.qr-large { width: min(320px, 100%); }
  .qr-fallback .copy-row { flex-wrap: wrap; }
  .qr-fallback .copy-row .btn { width: 100%; }
  .qr-fallback .row .btn { flex: 1 1 auto; }

  .top-actions { width: 100%; justify-content: space-between; }
  .top-actions .chip { max-width: 48%; }
  .model-chip { display: none; }
  .view { padding: 12px 10px 24px; }
  .card { padding: 13px; border-radius: 12px; }
  .stat { padding: 13px; }
  .stat .value { font-size: 24px; }
  .stat .value.sm { font-size: 17px; }
  .section-head h3 { font-size: 12px; }
  .section-head .btn { flex: 1 1 auto; }
  .section-head .search-input { width: 100%; }
  .row.actions { flex-direction: column; }
  .row.actions button { width: 100%; }
  .row.between { align-items: flex-start; }
  .kv { grid-template-columns: 96px 1fr; }
  .messages { padding: 12px; gap: 10px; }
  .msg { max-width: 100%; }
  .msg-avatar { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
  .bubble { padding: 10px 11px; font-size: 12.5px; }
  .bubble pre { font-size: 10.5px; }
  .compose-box { flex-direction: column; align-items: stretch; }
  .compose-box .btn { width: 100%; }
  .compose-meta { gap: 8px 12px; }
  .chat-header { padding: 10px 11px; }
  .chat-header .chat-title { flex: 1 1 100%; }
  .chat-header .row.tight .btn { flex: 1 1 auto; }
  .messages { min-height: 40vh; }
  .activity-panel { max-height: 340px; }

  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
  .span-12, .span-8, .span-7, .span-6, .span-5, .span-4, .span-3 { grid-column: span 12; }
  .table { min-width: 560px; }
  .table th, .table td { padding: 7px 8px; }
  .sidebar { width: min(280px, 86vw); }
}

@media (max-width: 420px) {
  .brand small { display: none; }
  .auth-card { padding: 16px; }
  .auth-brand { gap: 11px; }
  .auth-brand h1 { font-size: 19px; }
  .auth-brand p { font-size: 10px; letter-spacing: 1px; }
  .stat .value { font-size: 21px; }
  .section-head .btn, .top-actions .btn { font-size: 11px; padding: 7px 9px; }
  .hero h2 { font-size: 18px; }
  .hero p { font-size: 11.5px; }
}

/* ---------- Searchable model picker ---------- */
.model-picker {
  position: relative;
  flex: 0 1 340px;
  min-width: 220px;
  max-width: 340px;
}
.model-picker-input {
  width: 100%;
  height: 34px;
  padding: 7px 28px 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  outline: none;
  text-overflow: ellipsis;
}
.model-picker-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(55, 224, 168, 0.1);
}
.model-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 10px;
  pointer-events: none;
}
.model-picker-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 340px;
  overflow: auto;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c1420;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.model-group-label {
  padding: 8px 8px 3px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.model-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.model-option:hover,
.model-option:focus {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--line);
  outline: none;
}
.model-option.active {
  border-color: var(--accent-dim);
  background: rgba(55, 224, 168, 0.08);
}
.model-option-name {
  max-width: 100%;
  font-size: 11.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-option-id {
  max-width: 100%;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.model-empty {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
}
@media (max-width: 980px) {
  .model-picker { flex: 1 1 100%; max-width: none; min-width: 0; }
  .model-picker-menu { max-height: 50vh; }
}

/* ---------- Sidebar scroll fix ---------- */
.sidebar { overflow: hidden; }
.sidebar-brand, .sidebar-user { flex: 0 0 auto; }
.nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav-item { flex: 0 0 auto; }
@media (max-width: 980px) {
  body.sidebar-open { overflow: hidden; }
  .sidebar { padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .sidebar .nav { padding-bottom: 8px; }
}

/* ---------- Strix ---------- */
.strix-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}
.strix-run-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.strix-target {
  margin: 7px 0 3px;
  font-size: 16px;
  word-break: break-all;
}
.strix-stats { margin-top: 4px; }
.strix-stats .stat .value.sm { font-size: 16px; }
.strix-console {
  height: 340px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #050a10;
  color: #bfe9d7;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}
.strix-scroll { max-height: 320px; overflow: auto; }
.strix-table-wrap { max-height: 300px; }
.strix-summary {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}
.strix-summary summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.strix-summary .report-preview {
  max-height: 320px;
  margin-top: 10px;
  background: #070d14;
}
.strix-form-card .scope-list { margin-bottom: 12px; }
@media (max-width: 980px) {
  .form-grid > *[style*="grid-column"] {
    grid-column: auto / span 1 !important;
  }
  .strix-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .strix-console { height: 280px; }
  .strix-scroll { max-height: 260px; }
}
