/* SOC CoPilot web console — light admin-dashboard theme.
   Accents: indigo (actions/links), dark teal pills (metadata badges), card
   layout per the report mock. All assets local; system font stack. */

:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --pill: #155e75;
  --pill-text: #ffffff;
  --ok: #16a34a;
  --warn: #ca8a04;
  --bad: #dc2626;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.07), 0 1px 2px rgba(15, 23, 42, 0.05);
  --font: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
}
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 700; }
button { font: inherit; }
a { color: var(--primary); }

/* ---------- shared ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-outline { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--primary); }
.btn-wide { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--pill);
  color: var(--pill-text);
  white-space: nowrap;
}
.chip-muted { background: #f1f5f9; color: var(--text-muted); }
.chip-ok { background: #dcfce7; color: #166534; }
.chip-warn { background: #fef9c3; color: #854d0e; }
.chip-bad { background: #fee2e2; color: #991b1b; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- login ---------- */
.view-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(1200px 500px at 20% -10%, #e0e7ff 0%, transparent 60%),
    radial-gradient(1000px 500px at 110% 110%, #ccfbf1 0%, transparent 55%),
    var(--bg);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12);
  width: min(400px, 92vw);
  padding: 40px 36px;
  text-align: center;
}
.brand-mark { margin-bottom: 14px; }
.login-logo { height: 34px; width: auto; }
.login-card h1 { font-size: 24px; letter-spacing: -0.02em; }
.login-sub {
  margin: 2px 0 18px;
  color: var(--pill);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 11.5px;
}
.login-detail { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.login-waiting { margin-top: 16px; color: var(--text-muted); font-size: 13.5px; }
.dev-login { display: flex; gap: 8px; margin-top: 14px; }
.dev-login input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  outline: none;
}
.dev-login input:focus { border-color: var(--primary); }

/* ---------- topbar ---------- */
.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 15px;
}
.topbar-brand span { color: var(--text-muted); font-weight: 600; }
.brand-logo { height: 22px; width: auto; display: block; }
.brand-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.mcp-health { display: inline-flex; gap: 5px; }
.mcp-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border);
}
.mcp-dot.ok { background: var(--ok); }
.mcp-dot.bad { background: var(--bad); }

/* ---------- tenant lock banner ---------- */
.tenant-banner {
  background: var(--pill);
  color: var(--pill-text);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tenant-banner .tb-id {
  font-family: var(--mono);
  font-weight: 400;
  opacity: 0.8;
  font-size: 12px;
}

/* ---------- chat layout ---------- */
.view-chat { height: 100vh; display: flex; flex-direction: column; }
.chat-layout {
  flex: 1;
  display: flex;
  gap: 18px;
  padding: 18px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
}
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 12px 2px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.msg { max-width: 82%; }
.msg-user { align-self: flex-end; }
.msg-user .bubble {
  background: var(--primary);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.msg-agent { align-self: flex-start; max-width: 92%; }
.msg-agent .bubble {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  padding: 10px 16px;
  box-shadow: var(--shadow);
  overflow-wrap: break-word;
}
.msg-agent .bubble > :first-child { margin-top: 4px; }
.msg-agent .bubble > :last-child { margin-bottom: 4px; }
.bubble pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
}
.bubble code { font-family: var(--mono); font-size: 0.92em; }
.bubble :not(pre) > code { background: var(--primary-soft); border-radius: 4px; padding: 1px 5px; }
.bubble table { border-collapse: collapse; margin: 8px 0; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 9px; font-size: 13px; }

.msg-system {
  align-self: center;
  color: var(--text-muted);
  font-size: 12.5px;
  background: #f1f5f9;
  border-radius: 999px;
  padding: 4px 14px;
}
.msg-error { background: #fee2e2; color: #991b1b; }

.turn-meta {
  align-self: center;
  color: #94a3b8;
  font-size: 11.5px;
}

/* permission card */
.perm-card {
  align-self: stretch;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-radius: var(--radius);
  padding: 12px 16px;
}
.perm-card h3 { font-size: 14px; margin-bottom: 4px; }
.perm-card .perm-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 8px; }
.perm-card pre {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.perm-actions { display: flex; gap: 8px; margin-top: 8px; }
.btn-approve { background: var(--ok); color: #fff; }
.btn-deny { background: var(--card); border-color: var(--border); color: var(--bad); }
.perm-resolved { opacity: 0.55; pointer-events: none; }

/* composer */
.command-hints { display: flex; flex-wrap: wrap; gap: 7px; padding: 8px 2px; }
.command-hint {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--pill);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.command-hint:hover { border-color: var(--pill); }
.composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px;
}
.composer textarea {
  flex: 1;
  border: 0;
  resize: none;
  font: inherit;
  outline: none;
  max-height: 160px;
  background: transparent;
}

/* ---------- timeline rail ---------- */
.rail { width: 320px; flex-shrink: 0; min-height: 0; display: flex; }
.rail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  width: 100%;
  overflow-y: auto;
}
.rail-card h2 { font-size: 15px; margin-bottom: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline li {
  position: relative;
  padding: 0 0 14px 26px;
  font-size: 12.5px;
}
.timeline li::before {
  content: "";
  position: absolute;
  left: 1px; top: 3px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #38bdf8;
  border: 2px solid var(--card);
  box-shadow: 0 0 0 1.5px #38bdf8;
}
.timeline li.pending::before { background: var(--card); box-shadow: 0 0 0 1.5px var(--warn); }
.timeline li.error::before { background: var(--bad); box-shadow: 0 0 0 1.5px var(--bad); }
.timeline .t-tool { font-weight: 700; }
.timeline .t-sub {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 11px;
  overflow-wrap: break-word;
  display: block;
}
.timeline img {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-top: 6px;
}

/* ---------- reports modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh;
  z-index: 50;
}
.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  width: min(560px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.3);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; }
.reports-list { list-style: none; margin: 0; padding: 8px; }
.reports-list li {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.reports-list li:hover { background: var(--primary-soft); }
.reports-list .r-ref { color: var(--pill); font-weight: 700; font-size: 12.5px; }
.reports-list .r-title { font-weight: 600; }
.reports-list .r-date { color: var(--text-muted); font-size: 12px; }
.reports-empty { color: var(--text-muted); padding: 18px; text-align: center; }

/* ---------- detail modal (KQL inspection) ---------- */
.detail-body { padding: 14px 18px; }
.detail-body .d-intent { font-size: 14px; margin: 0 0 10px; }
.detail-body .d-meta { color: var(--text-muted); font-size: 12.5px; margin: 0 0 10px; }
.detail-body pre {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  margin: 0;
}
.timeline li.inspectable { cursor: pointer; }
.timeline li.inspectable:hover .t-tool { color: var(--primary); text-decoration: underline; }

/* ---------- report feedback ---------- */
.feedback-section {
  grid-column: 1 / -1;
  padding: 12px 22px;
}
.feedback-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.feedback-label { color: var(--text-muted); font-size: 13px; }
.btn-agree { background: var(--ok); color: #fff; }
.btn-disagree { background: var(--card); border-color: var(--border); color: var(--bad); }
.feedback-recorded { font-size: 13px; font-weight: 600; }
.feedback-recorded.agree { color: var(--ok); }
.feedback-recorded.disagree { color: var(--bad); }

/* ---------- report view ---------- */
.report-root {
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px 18px 60px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 18px;
  align-items: start;
}
.report-head {
  grid-column: 1 / -1;
  padding: 18px 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.report-ref {
  color: var(--text-muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.report-title { font-size: 24px; letter-spacing: -0.01em; }
.report-client { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }
.report-pills { display: flex; gap: 8px; flex-wrap: wrap; }

.report-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.report-section { padding: 18px 22px; }
.report-section h2 { font-size: 16px; margin-bottom: 10px; }
.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; gap: 10px; flex-wrap: wrap;
}
.section-head h2 { margin-bottom: 0; }
.summary-prose { white-space: pre-wrap; }
.rationale { color: var(--text-muted); font-size: 13.5px; margin-top: 10px; }
.impact-line { margin-top: 8px; font-size: 13.5px; }

.report-grid3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th {
  text-align: left; color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border); padding: 4px 8px 6px 0;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
}
.mini-table td { padding: 6px 8px 6px 0; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.mini-table td.mono { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.empty-note { color: var(--text-muted); font-size: 13px; }

.etimeline { list-style: none; margin: 0; padding: 0; }
.etimeline li { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.etimeline .ts {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--pill);
  white-space: nowrap;
  padding-top: 2px;
}
.recommendations li { margin-bottom: 6px; }

.verdict-pill { font-size: 13px; padding: 6px 14px; }
.verdict-TRUE_POSITIVE { background: var(--bad); }
.verdict-FALSE_POSITIVE { background: var(--ok); }
.verdict-UNDETERMINED { background: var(--warn); }
.sev-High, .sev-Critical { background: var(--bad); }
.sev-Medium { background: #ea580c; }
.sev-Low { background: var(--warn); }
.sev-Informational { background: #64748b; }

.conn-banner {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: #0f172a; color: #fff;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  z-index: 100;
}

@media (max-width: 980px) {
  .rail { display: none; }
  .report-root { grid-template-columns: 1fr; }
}

@media print {
  .topbar, .conn-banner { display: none !important; }
  body { background: #fff; }
  .report-root { grid-template-columns: 1fr 260px; padding: 0; }
  .card { box-shadow: none; }
}
