:root {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #101114;
  --surface-2: #15161a;
  --surface-3: #1b1c21;
  --border: #282a30;
  --border-strong: #373a43;
  --text: #f5f6f8;
  --muted: #9ba0aa;
  --muted-2: #6f7580;
  --orange: #f48120;
  --orange-2: #ff9f43;
  --orange-soft: rgba(244, 129, 32, 0.11);
  --green: #45d483;
  --green-soft: rgba(69, 212, 131, 0.11);
  --yellow: #f7c948;
  --yellow-soft: rgba(247, 201, 72, 0.11);
  --red: #ff6b6b;
  --red-soft: rgba(255, 107, 107, 0.11);
  --blue: #70a5ff;
  --blue-soft: rgba(112, 165, 255, 0.11);
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --sidebar: 312px;
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
::selection { background: rgba(244,129,32,.35); }

.app-shell { min-height: 100vh; }
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  background:
    radial-gradient(circle at 78% -10%, rgba(244, 129, 32, 0.08), transparent 30rem),
    var(--bg);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(11, 11, 13, 0.93);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.brand {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--orange);
  color: #111;
  box-shadow: 0 8px 24px rgba(244, 129, 32, 0.2);
}
.brand-mark svg { width: 21px; height: 21px; }
.brand-copy strong { display: block; font-size: 14px; letter-spacing: -0.01em; }
.brand-copy span { display: block; color: var(--muted-2); font-size: 11px; margin-top: 2px; }

.sidebar-body { padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1; }
.new-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid rgba(244, 129, 32, 0.48);
  border-radius: 11px;
  background: var(--orange-soft);
  color: #ffad69;
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: 160ms ease;
}
.new-button:hover { background: rgba(244, 129, 32, 0.17); border-color: rgba(244,129,32,.68); }
.new-button:active { transform: translateY(1px); }

.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; color: var(--muted-2); pointer-events: none; }
.search-wrap input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 34px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.search-wrap input:focus { border-color: var(--border-strong); box-shadow: 0 0 0 3px rgba(255,255,255,.035); }
.search-wrap input::placeholder { color: #595e68; }

.sidebar-section-head { display: flex; align-items: center; justify-content: space-between; padding: 0 5px; }
.sidebar-section-head span:first-child { font-size: 10px; letter-spacing: .11em; font-weight: 700; color: var(--muted-2); }
.count-pill { min-width: 22px; height: 20px; padding: 0 6px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 10px; }

.incident-list { overflow: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; scrollbar-width: thin; }
.incident-row {
  width: 100%;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  padding: 11px 11px 10px;
  cursor: pointer;
  transition: 150ms ease;
}
.incident-row:hover { background: var(--surface); }
.incident-row.active { background: var(--surface-2); border-color: var(--border); }
.row-line { display: flex; align-items: center; gap: 8px; }
.row-title { min-width: 0; flex: 1; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted-2); font-size: 10.5px; margin-top: 6px; }
.row-service { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.severity-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--muted-2); box-shadow: 0 0 0 3px rgba(255,255,255,.025); }
.severity-dot.critical { background: var(--red); }
.severity-dot.high { background: #ff8b5c; }
.severity-dot.medium { background: var(--yellow); }
.severity-dot.low { background: var(--green); }

.sidebar-footer { padding: 13px 16px 16px; border-top: 1px solid var(--border); }
.platform-card { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 10.5px; }
.cf-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 14px rgba(244,129,32,.6); }
.platform-card strong { color: #cfd2d8; font-weight: 600; }

.main { min-width: 0; }
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 30px;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 11, 0.72);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted-2); font-size: 12px; }
.breadcrumb strong { color: #dfe1e5; max-width: 42vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb .slash { color: #3f424a; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.health-chip { display: flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 10.5px; background: var(--surface); }
.health-chip .health-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.health-chip.offline .health-dot { background: var(--red); }
.mobile-menu { display: none; }

.content { width: min(1260px, calc(100% - 56px)); margin: 0 auto; padding: 34px 0 64px; }

.empty-state {
  min-height: calc(100vh - 160px);
  display: grid;
  place-items: center;
  text-align: center;
}
.empty-inner { width: min(610px, 100%); }
.empty-icon {
  width: 64px; height: 64px; margin: 0 auto 20px; border: 1px solid var(--border); border-radius: 18px;
  display: grid; place-items: center; background: linear-gradient(145deg, var(--surface-2), var(--surface)); color: var(--orange);
  box-shadow: var(--shadow);
}
.empty-icon svg { width: 30px; height: 30px; }
.empty-state h1 { margin: 0; font-size: clamp(27px, 4vw, 42px); letter-spacing: -.045em; line-height: 1.04; }
.empty-state p { color: var(--muted); line-height: 1.65; font-size: 14px; max-width: 540px; margin: 14px auto 24px; }
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.incident-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.incident-title-wrap { min-width: 0; }
.kicker-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.eyebrow { margin: 0; color: var(--muted-2); font-size: 9.5px; font-weight: 750; letter-spacing: .13em; }
.incident-header h1 { margin: 0; font-size: clamp(25px, 3vw, 38px); line-height: 1.08; letter-spacing: -.037em; }
.header-meta { margin-top: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 11.5px; }
.header-meta span { display: inline-flex; align-items: center; gap: 6px; }
.header-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 25px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.badge.critical { color: #ff9b9b; border-color: rgba(255,107,107,.28); background: var(--red-soft); }
.badge.high { color: #ffb184; border-color: rgba(255,139,92,.26); background: rgba(255,139,92,.1); }
.badge.medium { color: #f9d875; border-color: rgba(247,201,72,.25); background: var(--yellow-soft); }
.badge.low, .badge.resolved { color: #7fe2a8; border-color: rgba(69,212,131,.25); background: var(--green-soft); }
.badge.investigating, .badge.queued { color: #9dc0ff; border-color: rgba(112,165,255,.25); background: var(--blue-soft); }
.badge.needs_attention { color: #ffb184; border-color: rgba(255,139,92,.26); background: rgba(255,139,92,.1); }
.badge.monitoring { color: #f9d875; border-color: rgba(247,201,72,.25); background: var(--yellow-soft); }

.button { min-height: 39px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: #e9eaed; font-size: 11.5px; font-weight: 650; cursor: pointer; transition: 150ms ease; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button:hover { border-color: var(--border-strong); background: var(--surface-3); }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button.primary { border-color: rgba(244,129,32,.55); background: var(--orange); color: #101010; }
.button.primary:hover { background: var(--orange-2); }
.button.ghost { background: transparent; }
.button.danger-soft { border-color: rgba(255,107,107,.24); color: #ff9b9b; background: var(--red-soft); }
.icon-button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.icon-button:hover { color: var(--text); border-color: var(--border-strong); }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.metric { border: 1px solid var(--border); border-radius: 13px; background: linear-gradient(145deg, rgba(21,22,26,.88), rgba(16,17,20,.88)); padding: 15px; min-height: 88px; }
.metric-label { color: var(--muted-2); font-size: 9px; font-weight: 750; letter-spacing: .1em; text-transform: uppercase; }
.metric-value { margin-top: 8px; font-size: 21px; font-weight: 650; letter-spacing: -.035em; }
.metric-value.small { font-size: 14px; line-height: 1.35; letter-spacing: -.01em; }
.metric-sub { margin-top: 4px; color: var(--muted-2); font-size: 10px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .9fr); gap: 14px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: rgba(16,17,20,.86); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 17px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; font-size: 11px; letter-spacing: .075em; text-transform: uppercase; color: #d7d9de; }
.card-head span { color: var(--muted-2); font-size: 9.5px; }
.card-body { padding: 18px; }

.analysis-summary { font-size: 14px; line-height: 1.66; color: #e7e8eb; margin: 0; }
.hypothesis { margin-top: 16px; padding: 13px 14px; border-left: 2px solid var(--orange); background: rgba(244,129,32,.055); border-radius: 0 10px 10px 0; }
.hypothesis-label { color: #f1a55f; font-size: 9px; font-weight: 750; letter-spacing: .11em; text-transform: uppercase; }
.hypothesis p { margin: 7px 0 0; color: #d7d9de; font-size: 12.5px; line-height: 1.55; }

.signal-list { display: flex; flex-direction: column; gap: 12px; }
.signal-row { display: grid; grid-template-columns: minmax(115px, 180px) 1fr auto; align-items: center; gap: 12px; }
.signal-name { font-size: 11px; color: #d5d7dc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.signal-bar { height: 5px; background: #202228; border-radius: 999px; overflow: hidden; }
.signal-fill { height: 100%; min-width: 4px; border-radius: inherit; background: linear-gradient(90deg, var(--orange), #ffb15f); }
.signal-count { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted-2); font-size: 10px; }
.empty-compact { color: var(--muted); font-size: 12px; line-height: 1.6; }

.number-list, .plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.number-list li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; color: #d8dadf; font-size: 12px; line-height: 1.55; }
.number-list .num { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border); color: var(--muted); font-size: 9px; font-weight: 700; }
.plain-list li { position: relative; padding-left: 16px; color: #ced1d7; font-size: 12px; line-height: 1.55; }
.plain-list li::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: #555b66; position: absolute; left: 1px; top: .63em; }

.plan-section { display: flex; flex-direction: column; gap: 10px; }
.plan-section + .plan-section { margin-top: 22px; }
.section-label { margin: 0; color: var(--muted-2); font-size: 9.5px; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; }
.plan-section .plain-list,
.plan-section .number-list { width: 100%; }
.plan-section .plain-list li,
.plan-section .number-list li span:last-child,
.related-list li { overflow-wrap: anywhere; }
.number-list li { grid-template-columns: 28px minmax(0, 1fr); }
.number-list .num { margin-top: 1px; }
.related-list strong { color: var(--text-strong); }


.guardrail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.guardrail { border: 1px solid var(--border); border-radius: 11px; padding: 12px; background: #0d0e11; }
.guardrail strong { display: block; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 7px; }
.guardrail p { margin: 0; color: #c8cbd1; font-size: 10.5px; line-height: 1.5; }

.timeline { position: relative; padding-left: 2px; }
.timeline-item { display: grid; grid-template-columns: 18px 1fr; gap: 10px; position: relative; padding-bottom: 16px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline-item:last-child::before { display: none; }
.timeline-node { width: 15px; height: 15px; margin-top: 1px; border-radius: 50%; border: 3px solid var(--surface); background: #656b76; box-shadow: 0 0 0 1px var(--border); z-index: 1; }
.timeline-node.ai { background: var(--orange); }
.timeline-node.error { background: var(--red); }
.timeline-node.human { background: var(--green); }
.timeline-content strong { display: block; font-size: 11px; color: #d9dbe0; font-weight: 600; line-height: 1.4; }
.timeline-content span { display: block; color: var(--muted-2); font-size: 9.5px; margin-top: 3px; }

.log-box { margin: 0; max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word; padding: 15px; border-radius: 11px; background: #090a0c; border: 1px solid #202228; color: #aeb4bf; font: 10.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; scrollbar-width: thin; }

.copilot-card { position: static; isolation: isolate; }
.copilot-status { display: inline-flex; align-items: center; gap: 5px; color: var(--muted-2); }
.copilot-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.chat {
  flex: 1 1 auto;
  min-height: 330px;
  max-height: min(52vh, 520px);
  overflow: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}
.chat-empty { margin: auto; text-align: center; color: var(--muted); font-size: 11.5px; line-height: 1.6; max-width: 250px; }
.chat-bubble { max-width: 92%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 11px; font-size: 11.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.chat-bubble.user { align-self: flex-end; background: rgba(244,129,32,.10); border-color: rgba(244,129,32,.22); color: #f3e1d0; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: #111216; color: #d5d8de; border-bottom-left-radius: 4px; }
.chat-meta { display: block; color: var(--muted-2); font-size: 8.5px; margin-top: 5px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); position: relative; z-index: 1; }
.chat-form textarea { flex: 1; min-height: 42px; max-height: 110px; resize: vertical; border: 1px solid var(--border); border-radius: 10px; background: #0c0d10; color: var(--text); padding: 10px 11px; outline: none; font-size: 11.5px; line-height: 1.45; }
.chat-form textarea:focus { border-color: #4c505b; }
.chat-form button { width: 42px; height: 42px; flex: 0 0 auto; padding: 0; border: 1px solid rgba(244,129,32,.4); border-radius: 10px; background: var(--orange); color: #111; cursor: pointer; display: grid; place-items: center; font-weight: 800; }
.chat-form button:disabled { opacity: .45; cursor: not-allowed; }

.processing-banner { display: flex; align-items: center; gap: 11px; border: 1px solid rgba(112,165,255,.18); border-radius: 12px; background: rgba(112,165,255,.055); padding: 12px 14px; margin-bottom: 14px; color: #bcd2ff; font-size: 11.5px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(112,165,255,.25); border-top-color: var(--blue); animation: spin .8s linear infinite; flex: 0 0 auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, #131419 25%, #1b1d22 50%, #131419 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.dialog { width: min(740px, calc(100vw - 28px)); max-height: calc(100vh - 32px); overflow: auto; margin: auto; padding: 0; border: 1px solid var(--border-strong); border-radius: 18px; background: #111216; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.65); }
.dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(5px); }
.dialog form { padding: 22px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.dialog-head h2 { margin: 5px 0 6px; font-size: 21px; letter-spacing: -.025em; }
.dialog-head p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.5; }
.scenario-strip { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 18px; }
.scenario-chip { padding: 7px 10px; border-radius: 999px; border: 1px solid var(--border); background: #0d0e11; color: var(--muted); font-size: 10px; cursor: pointer; }
.scenario-chip:hover { color: #e0e2e6; border-color: var(--border-strong); }
.form-grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: block; margin-bottom: 13px; }
.field > span { display: flex; align-items: baseline; gap: 6px; margin-bottom: 6px; color: #cfd2d8; font-size: 10.5px; font-weight: 600; }
.field em { color: var(--muted-2); font-size: 9px; font-style: normal; font-weight: 400; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--border); border-radius: 10px; background: #0b0c0f; color: var(--text); padding: 10px 11px; outline: none; font-size: 11.5px; transition: 140ms ease; }
.field input { height: 42px; }
.field textarea { resize: vertical; line-height: 1.55; }
.field select { height: 42px; color-scheme: dark; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #50545f; box-shadow: 0 0 0 3px rgba(255,255,255,.025); }
.field [aria-invalid="true"] { border-color: rgba(255,107,107,.5); }
.field small { min-height: 14px; display: block; margin-top: 4px; color: #ff8f8f; font-size: 9.5px; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; }
.form-note { display: flex; align-items: flex-start; gap: 8px; border-radius: 10px; background: rgba(255,255,255,.025); padding: 10px 11px; color: var(--muted); font-size: 10px; line-height: 1.5; }
.note-dot { width: 6px; height: 6px; flex: 0 0 auto; border-radius: 50%; background: var(--orange); margin-top: 4px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 36px)); pointer-events: none; }
.toast { border: 1px solid var(--border-strong); border-radius: 12px; background: #15161a; box-shadow: var(--shadow); padding: 12px 14px; color: #e6e8eb; font-size: 11.5px; line-height: 1.45; animation: toast-in .18s ease-out; }
.toast.error { border-color: rgba(255,107,107,.3); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

.loading-screen { min-height: 100vh; display: grid; place-items: center; }
.loading-brand { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 12px; }

*:focus-visible { outline: 2px solid rgba(244,129,32,.9); outline-offset: 2px; }

@media (max-width: 1060px) {
  :root { --sidebar: 276px; }
  .content { width: min(100% - 36px, 1120px); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .right-rail { position: static; }
  .copilot-card { position: static; }
  .chat { max-height: 430px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(310px, 88vw); height: 100dvh; transform: translateX(-102%); transition: transform .2s ease; box-shadow: 28px 0 80px rgba(0,0,0,.5); }
  .shell.sidebar-open .sidebar { transform: translateX(0); }
  .shell.sidebar-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 15; }
  .mobile-menu { display: grid; }
  .topbar { min-height: 66px; padding: 0 14px; }
  .breadcrumb .slash, .breadcrumb > span:first-child { display: none; }
  .breadcrumb strong { max-width: 48vw; }
  .health-chip span:last-child { display: none; }
  .content { width: calc(100% - 28px); padding-top: 24px; }
  .incident-header { flex-direction: column; gap: 16px; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .guardrail-grid { grid-template-columns: 1fr; }
  .form-grid.two { grid-template-columns: 1fr; gap: 0; }
  .dialog form { padding: 18px; }
}

@media (max-width: 480px) {
  .content { width: calc(100% - 22px); }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 76px; }
  .signal-row { grid-template-columns: minmax(100px, 135px) 1fr auto; gap: 8px; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .top-actions .button { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* --- Final UI polish: dual theme, desktop navigation control, stronger responsive behavior --- */
:root {
  --sidebar-bg: rgba(11, 11, 13, 0.94);
  --topbar-bg: rgba(9, 9, 11, 0.78);
  --card-bg: rgba(16, 17, 20, 0.88);
  --surface-subtle: #0d0e11;
  --surface-input: #0b0c0f;
  --track: #202228;
  --text-strong: #e7e8eb;
  --text-soft: #cfd2d8;
  --code-bg: #090a0c;
  --code-text: #aeb4bf;
  --user-chat-text: #f3e1d0;
  --backdrop: rgba(0, 0, 0, 0.58);
  --card-shadow: 0 10px 34px rgba(0, 0, 0, 0.12);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f2f4f7;
  --surface-3: #e9edf2;
  --border: #dde1e7;
  --border-strong: #c7cdd6;
  --text: #16191e;
  --muted: #626a76;
  --muted-2: #858d99;
  --orange-soft: rgba(244, 129, 32, 0.1);
  --green-soft: rgba(31, 153, 88, 0.09);
  --yellow-soft: rgba(184, 125, 0, 0.09);
  --red-soft: rgba(194, 48, 48, 0.08);
  --blue-soft: rgba(51, 103, 209, 0.08);
  --shadow: 0 24px 70px rgba(36, 42, 52, 0.12);
  --sidebar-bg: rgba(255, 255, 255, 0.94);
  --topbar-bg: rgba(246, 247, 249, 0.84);
  --card-bg: #ffffff;
  --surface-subtle: #f7f8fa;
  --surface-input: #ffffff;
  --track: #e6e9ee;
  --text-strong: #20242a;
  --text-soft: #444b55;
  --code-bg: #11141a;
  --code-text: #d8dee9;
  --user-chat-text: #64320b;
  --backdrop: rgba(25, 31, 40, 0.35);
  --card-shadow: 0 10px 28px rgba(39, 47, 58, 0.055);
}

body,
.shell,
.sidebar,
.topbar,
.card,
.metric,
.dialog,
.button,
.icon-button,
.search-wrap input,
.field input,
.field textarea,
.field select,
.chat-form textarea {
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.shell {
  transition: grid-template-columns 200ms ease;
  background:
    radial-gradient(circle at 78% -8%, rgba(244, 129, 32, 0.09), transparent 31rem),
    radial-gradient(circle at 4% 92%, rgba(112, 165, 255, 0.035), transparent 27rem),
    var(--bg);
}

.sidebar {
  width: var(--sidebar);
  background: var(--sidebar-bg);
  transition: transform 200ms ease, opacity 160ms ease;
}

.shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.shell.sidebar-collapsed .sidebar {
  transform: translateX(-102%);
  opacity: 0;
  pointer-events: none;
}

.topbar { background: var(--topbar-bg); }
.card { background: var(--card-bg); box-shadow: var(--card-shadow); }
.metric { background: linear-gradient(145deg, color-mix(in srgb, var(--surface-2) 88%, transparent), color-mix(in srgb, var(--surface) 92%, transparent)); box-shadow: var(--card-shadow); }
.platform-card strong,
.breadcrumb strong,
.button,
.card-head h2,
.analysis-summary,
.hypothesis p,
.signal-name,
.number-list li,
.plain-list li,
.guardrail p,
.timeline-content strong,
.field > span { color: var(--text-strong); }
.guardrail,
.scenario-chip { background: var(--surface-subtle); }
.signal-bar { background: var(--track); }
.log-box { background: var(--code-bg); color: var(--code-text); border-color: color-mix(in srgb, var(--border) 86%, transparent); }
.chat-bubble.user { color: var(--user-chat-text); }
.chat-bubble.assistant { background: var(--surface-subtle); color: var(--text-strong); }
.chat-form textarea,
.field input,
.field textarea,
.field select { background: var(--surface-input); }
.dialog { background: var(--surface); box-shadow: 0 30px 100px rgba(0, 0, 0, .28); }
.toast { background: var(--surface-2); color: var(--text-strong); }
.form-note { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.search-wrap input::placeholder { color: var(--muted-2); }

html[data-theme="light"] .badge.critical { color: #a61b1b; }
html[data-theme="light"] .badge.high,
html[data-theme="light"] .badge.needs_attention { color: #9a3d12; }
html[data-theme="light"] .badge.medium,
html[data-theme="light"] .badge.monitoring { color: #7b5700; }
html[data-theme="light"] .badge.low,
html[data-theme="light"] .badge.resolved { color: #126a3d; }
html[data-theme="light"] .badge.investigating,
html[data-theme="light"] .badge.queued { color: #2458a6; }
html[data-theme="light"] .processing-banner { color: #285aa4; }
html[data-theme="light"] .hypothesis-label { color: #a64d00; }
html[data-theme="light"] .field select { color-scheme: light; }
html[data-theme="dark"] .field select { color-scheme: dark; }

.nav-toggle,
.theme-toggle { display: grid; flex: 0 0 auto; }
.nav-toggle svg,
.theme-toggle svg,
.sidebar-close svg { width: 18px; height: 18px; }
.sidebar-close { display: none; margin-left: auto; }
.nav-backdrop { display: none; }

.brand { min-width: 0; }
.brand-copy { min-width: 0; }
.brand-copy strong,
.brand-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { width: min(1320px, calc(100% - 64px)); padding-top: 36px; }
.incident-header { margin-bottom: 26px; }
.incident-header h1 { max-width: 920px; text-wrap: balance; }
.metrics { gap: 12px; margin-bottom: 20px; }
.metric { position: relative; overflow: hidden; padding: 16px; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 2px; background: linear-gradient(180deg, rgba(244,129,32,.72), rgba(244,129,32,0)); opacity: .8; }
.metric-value.small { overflow-wrap: anywhere; }
.dashboard-grid { gap: 18px; }
.stack { gap: 18px; }
.right-rail {
  position: sticky;
  top: 94px;
  align-self: start;
  min-width: 0;
}
.card { border-radius: 17px; }
.card-head { min-height: 52px; }
.card-body { padding: 19px; }
.copilot-card { border-color: color-mix(in srgb, var(--orange) 22%, var(--border)); }
.copilot-card .card-head,
.copilot-card .chat,
.copilot-card .chat-form { background: var(--card-bg); }
.copilot-card .chat-form textarea { min-width: 0; }


.icon-button { padding: 0; }
.icon-button:hover { transform: translateY(-1px); }
.icon-button:active { transform: translateY(0); }
.theme-toggle { border-radius: 999px; }
.new-button { min-height: 44px; }

@media (max-width: 1180px) {
  :root { --sidebar: 278px; }
  .content { width: min(100% - 40px, 1160px); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .copilot-card { position: static; }
  .chat { max-height: 430px; }
}

@media (max-width: 900px) and (min-width: 761px) {
  :root { --sidebar: 250px; }
  .topbar { padding-inline: 20px; }
  .content { width: calc(100% - 32px); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .shell.sidebar-collapsed { display: block; }
  .shell.sidebar-collapsed .sidebar { opacity: 1; pointer-events: auto; }
  .sidebar { width: min(330px, 88vw); background: var(--sidebar-bg); }
  .shell.sidebar-open::after { content: none; }
  .shell.sidebar-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 15;
    border: 0;
    padding: 0;
    background: var(--backdrop);
    backdrop-filter: blur(2px);
    cursor: default;
  }
  .sidebar-close { display: grid; }
  .topbar { padding-inline: 12px; gap: 10px; }
  .breadcrumb { gap: 7px; flex: 1; }
  .breadcrumb strong { max-width: min(45vw, 330px); }
  .top-actions { gap: 7px; }
  .content { width: calc(100% - 28px); padding: 24px 0 44px; }
  .incident-header h1 { font-size: clamp(25px, 7vw, 34px); }
  .metrics { gap: 9px; }
  .dashboard-grid,
  .stack { gap: 12px; }
  .card-head { padding: 14px 15px; }
  .card-body { padding: 15px; }
  .chat { min-height: 260px; max-height: 360px; }
}

@media (max-width: 560px) {
  .health-chip { display: none; }
  .incident-header { gap: 14px; }
  .header-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .header-meta { gap: 6px 10px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric { min-height: 82px; padding: 13px; }
  .chat { min-height: 210px; max-height: 300px; }
  .signal-row { grid-template-columns: minmax(90px, 125px) minmax(60px, 1fr) auto; gap: 8px; }
  .dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); border-radius: 16px; }
  .dialog form { padding: 16px; }
  .dialog-head { gap: 12px; }
  .scenario-strip { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .scenario-strip::-webkit-scrollbar { display: none; }
  .scenario-chip { flex: 0 0 auto; }
}

@media (max-width: 420px) {
  .topbar { min-height: 62px; }
  .top-actions .button { display: none; }
  .theme-toggle { width: 36px; height: 36px; }
  .nav-toggle { width: 36px; height: 36px; }
  .breadcrumb strong { max-width: 46vw; }
  .content { width: calc(100% - 20px); padding-top: 20px; }
  .metrics { grid-template-columns: 1fr; }
  .header-actions { grid-template-columns: 1fr; }
  .signal-row { grid-template-columns: 1fr auto; }
  .signal-bar { grid-column: 1 / -1; grid-row: 2; }
  .signal-count { grid-column: 2; grid-row: 1; }
  .chat-form { padding: 10px; }
  .chat-form textarea { min-width: 0; }
}

/* --- Shareable durable workspace --- */
.workspace-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-subtle);
}
.workspace-card-copy { min-width: 0; }
.workspace-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted-2);
  font-size: 8.5px;
  font-weight: 750;
  letter-spacing: .11em;
}
.workspace-card-copy strong {
  display: block;
  color: var(--text-strong);
  font: 600 10.5px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .02em;
}
 .workspace-hint {
  display: block;
  margin-top: 4px;
  max-width: 175px;
  color: var(--muted-2);
  font-size: 8px;
  line-height: 1.35;
}
.workspace-copy {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}
.workspace-copy:hover { color: var(--text); border-color: var(--border-strong); }
.workspace-copy svg { width: 15px; height: 15px; }
.workspace-share { background: transparent; white-space: nowrap; }
.workspace-share svg { width: 14px; height: 14px; }

@media (max-width: 1180px) {
  .right-rail { position: static; top: auto; }
}

@media (max-width: 760px) {
  .workspace-share { display: none; }
}

/* --- Account identity + D1-backed authentication --- */
.hidden { display: none !important; }
.auth-dialog { width: min(900px, calc(100vw - 32px)); overflow: hidden; }
.auth-dialog::backdrop { background: rgba(0, 0, 0, .68); backdrop-filter: blur(6px); }
.auth-shell { display: grid; grid-template-columns: minmax(260px, .86fr) minmax(360px, 1.14fr); min-height: 540px; }
.auth-visual {
  padding: 34px;
  border-right: 1px solid var(--border);
  background:
    radial-gradient(circle at 12% 8%, rgba(244,129,32,.2), transparent 17rem),
    linear-gradient(160deg, color-mix(in srgb, var(--surface-2) 86%, transparent), var(--surface-subtle));
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-visual-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  margin-bottom: 28px;
  border: 1px solid rgba(244,129,32,.58);
  border-radius: 14px;
  background: var(--orange);
  color: #111216;
  box-shadow: 0 10px 28px rgba(244,129,32,.16);
}
.auth-visual-mark svg { width: 25px; height: 25px; }
.auth-visual h2 { margin: 8px 0 12px; max-width: 330px; font-size: 30px; line-height: 1.08; letter-spacing: -.045em; }
.auth-visual > p:not(.eyebrow) { margin: 0; max-width: 360px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.auth-proof-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 32px; }
.auth-proof-grid > div { min-width: 0; min-height: 64px; padding: 10px; border: 1px solid var(--border); border-radius: 11px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.auth-proof-grid strong { display: block; color: var(--text-strong); font-size: 10px; line-height: 1.25; }
.auth-proof-grid span { display: block; margin-top: 4px; color: var(--muted-2); font-size: 8.25px; line-height: 1.3; }
.auth-panel { padding: 28px; background: var(--surface); }
.auth-head { margin-bottom: 15px; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin-bottom: 20px; padding: 4px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-subtle); }
.auth-tab { min-height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 10.5px; font-weight: 700; }
.auth-tab.active { background: var(--surface); color: var(--text-strong); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.auth-form { display: flex; flex-direction: column; }
.auth-form .field { margin-bottom: 10px; }
.auth-form .auth-submit { width: 100%; margin-top: 4px; min-height: 44px; }
.auth-footnote { margin: 12px 2px 0; color: var(--muted-2); font-size: 9px; line-height: 1.55; text-align: center; }
.auth-claim-note { margin: 2px 0 10px; }

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface-subtle);
}
.account-avatar { width: 31px; height: 31px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: var(--orange-soft); color: var(--orange); font-size: 10px; font-weight: 800; }
.account-copy { min-width: 0; flex: 1; }
.account-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); font-size: 10.5px; }
.account-copy span { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted-2); font-size: 8.5px; }
.account-logout { width: 30px; height: 30px; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; }
.account-logout:hover { color: var(--red); border-color: rgba(255,107,107,.28); }
.account-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 38px; max-width: 190px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 10px; }
.account-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.demo-account-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 12px; }
.demo-account-actions .button { min-width: 0; padding-inline: 8px; }
.identity-banner { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 18px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 12px; background: color-mix(in srgb, var(--surface) 78%, transparent); color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.identity-banner strong { color: var(--text-strong); }
.identity-banner .identity-dot { width: 7px; height: 7px; flex: 0 0 auto; margin-top: 4px; border-radius: 50%; background: var(--orange); }
.identity-banner.account .identity-dot { background: var(--green); }

@media (max-width: 760px) {
  .auth-dialog { width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow: auto; }
  .auth-shell { display: block; min-height: 0; }
  .auth-visual { display: none; }
  .auth-panel { padding: 20px 18px; }
  .account-chip { display: none; }
}

@media (max-width: 420px) {
  .demo-account-actions { grid-template-columns: 1fr; }
  .auth-panel { padding: 17px 14px; }
  .auth-tabs { margin-bottom: 16px; }
}
.auth-dialog .auth-form { padding: 0; }

/* --- V7 reviewer polish --- */
@media (max-width: 420px) {
  .workspace-hint { max-width: 210px; }
}
