/* =========================================================================
   MAICSA CoSec Copilot — demo UI
   Design system: .claude/skills/demo-ui/SKILL.md
   ========================================================================= */

/* -------------------------------------------------------------------------
   1. Tokens (demo-ui skill §2 — pasted verbatim)
   ------------------------------------------------------------------------- */
:root {
  /* light (default) */
  --bg: #f5f6f9;            /* app ground — slate-biased near-white */
  --surface: #ffffff;      /* cards */
  --surface-2: #eef1f6;    /* insets, quiet fills */
  --border: #e0e4ee;
  --border-strong: #ccd2e0;
  --ink: #1a1f2e;          /* primary text (indigo-black, not pure black) */
  --ink-2: #58607a;        /* secondary */
  --ink-3: #838ba3;        /* muted / captions */
  --accent: #4f46e5;       /* THE accent — deep indigo */
  --accent-ink: #4338ca;   /* accent text on light */
  --accent-soft: #ecebfd;  /* accent tint bg */
  --warm: #d9611c;         /* secondary nod — use sparingly */
  --good: #157a44;  --good-soft: #e6f4ec;
  --warn: #a65a08;  --warn-soft: #f9efdd;
  --bad:  #bc2626;  --bad-soft:  #fbe9e9;
  --shadow: 0 1px 2px rgba(20,26,48,.04), 0 6px 20px -8px rgba(20,26,48,.12);
  --radius: 14px;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#0d0f15; --surface:#161923; --surface-2:#1d212d; --border:#2a2f3d; --border-strong:#363c4d;
    --ink:#e9ecf4; --ink-2:#a2abc0; --ink-3:#757e96;
    --accent:#8f8bf6; --accent-ink:#a6a2f8; --accent-soft:#211f39; --warm:#ef8a4c;
    --good:#58c07f; --good-soft:#14251b; --warn:#e0a441; --warn-soft:#2a2113; --bad:#ef6b6b; --bad-soft:#2a1717;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5);
  }
}
/* Viewer toggle must win over the OS media query, both directions */
:root[data-theme="light"] {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --border: #e0e4ee;
  --border-strong: #ccd2e0;
  --ink: #1a1f2e;
  --ink-2: #58607a;
  --ink-3: #838ba3;
  --accent: #4f46e5;
  --accent-ink: #4338ca;
  --accent-soft: #ecebfd;
  --warm: #d9611c;
  --good: #157a44;  --good-soft: #e6f4ec;
  --warn: #a65a08;  --warn-soft: #f9efdd;
  --bad:  #bc2626;  --bad-soft:  #fbe9e9;
  --shadow: 0 1px 2px rgba(20,26,48,.04), 0 6px 20px -8px rgba(20,26,48,.12);
}
:root[data-theme="dark"] {
  --bg:#0d0f15; --surface:#161923; --surface-2:#1d212d; --border:#2a2f3d; --border-strong:#363c4d;
  --ink:#e9ecf4; --ink-2:#a2abc0; --ink-3:#757e96;
  --accent:#8f8bf6; --accent-ink:#a6a2f8; --accent-soft:#211f39; --warm:#ef8a4c;
  --good:#58c07f; --good-soft:#14251b; --warn:#e0a441; --warn-soft:#2a2113; --bad:#ef6b6b; --bad-soft:#2a1717;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -10px rgba(0,0,0,.5);
}

/* -------------------------------------------------------------------------
   2. Layout frame (demo-ui skill §5 — adapted for a dashboard shell:
      fixed-width sidebar + fluid main content, instead of a single
      readable column)
   ------------------------------------------------------------------------- */
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 22px 18px;
}
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
#view-root {
  flex: 1;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1240px;
  width: 100%;
}

/* -------------------------------------------------------------------------
   3. Component recipes (demo-ui skill §4 — pasted verbatim)
   ------------------------------------------------------------------------- */

/* Card (the base surface) */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; }

/* Section header */
.sechead { display:flex; align-items:baseline; gap:12px; margin-bottom:6px; }
.secnum  { font-family:var(--mono); font-size:13px; font-weight:600; color:var(--accent-ink);
  background:var(--accent-soft); border-radius:6px; padding:2px 8px; }
h2 { font-size:22px; letter-spacing:-.02em; margin:0; font-weight:700; text-wrap:balance; }
.act-time { margin-left:auto; font-family:var(--mono); font-size:12px; color:var(--ink-3); font-weight:600; }

/* KPI / stat tiles */
.nums { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; }
.num  { background:var(--surface-2); border:1px solid var(--border); border-radius:10px; padding:12px 14px; }
.num .v { font-size:24px; font-weight:700; letter-spacing:-.02em; font-variant-numeric:tabular-nums; color:var(--accent-ink); }
.num .k { font-size:12px; color:var(--ink-2); margin-top:2px; }

/* Pills / badges */
.pill { display:inline-flex; align-items:center; gap:6px; border-radius:999px; padding:2px 10px;
  font-size:12px; font-weight:600; }
.pill-good { background:var(--good-soft); color:var(--good); }
.pill-warn { background:var(--warn-soft); color:var(--warn); }
.pill-bad  { background:var(--bad-soft);  color:var(--bad);  }
.pill-neutral { background:var(--surface-2); color:var(--ink-2); }
.pill-info { background:var(--accent-soft); color:var(--accent-ink); }

/* Callout block — limits / warnings / "read this" (demo-ui skill §4).
   Was referenced by .field-conflict.callout below (Task D) but the base
   recipe was never pasted in, so that override only ever contributed
   spacing/font-size with no border-left/background/radius. Adding the
   base recipe now so both that block and Task C's director-delta callout
   render correctly. */
.callout { border-left:3px solid var(--warm); background:var(--warn-soft); border-radius:10px; padding:14px 16px; font-size:14.5px; }

/* -------------------------------------------------------------------------
   4. Sidebar-specific styles
   ------------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.brand-text .name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-text .by { font-size: 12px; color: var(--ink-3); }

.entity-switch { display: flex; flex-direction: column; gap: 6px; }
.entity-switch label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-3);
}
#entity-switcher {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }

/* -------------------------------------------------------------------------
   5. Top-bar-specific styles
   ------------------------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.search-input {
  flex: 1;
  max-width: 420px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
}
.search-input::placeholder { color: var(--ink-3); }
.topbar-spacer { flex: 1; }

.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }
.btn-icon { padding: 8px 10px; font-size: 15px; line-height: 1; }

/* -------------------------------------------------------------------------
   6. Motion (demo-ui skill non-negotiable)
   ------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* -------------------------------------------------------------------------
   7. Field-status rendering (Task D — Profile view)
   ------------------------------------------------------------------------- */
.field-list { display: flex; flex-direction: column; }
.field-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 4px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: 0; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-2); padding-top: 2px; }
.field-value-col { min-width: 0; }
.field-value { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14.5px; }
.fv-empty { color: var(--ink-3); }
.fv-text { font-weight: 500; }
.field-source {
  font-family: var(--mono); font-size: 12px; color: var(--accent-ink); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
}
.field-source:hover { border-bottom-color: var(--accent-ink); }
.field-conflict.callout { margin-top: 8px; padding: 10px 14px; font-size: 13px; }

.record-row { padding: 14px 0; border-bottom: 1px solid var(--border-strong); }
.record-row:last-child { border-bottom: 0; }
.record-heading { font-size: 15px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }

.empty-state { color: var(--ink-3); font-size: 14.5px; }

@media (max-width: 640px) {
  .field-row { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------------------------
   8. Upload view (Task C)
   ------------------------------------------------------------------------- */
.upload-form { display: flex; flex-direction: column; gap: 16px; max-width: 560px; }
.upload-field { display: flex; flex-direction: column; gap: 6px; }
.upload-field label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-3);
}
.upload-input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
}

.file-list-rows { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.file-name {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-loading { display: flex; align-items: center; gap: 10px; color: var(--ink-2); font-size: 13.5px; }
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.upload-zones { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.upload-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 22px 14px;
  border: 2px dashed var(--border-strong); border-radius: 10px;
  background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s;
}
.upload-zone:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone-badge {
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent-ink);
  background: var(--accent-soft); border-radius: 6px; padding: 2px 10px;
}
.upload-zone-title { font-weight: 700; font-size: 14px; }
.upload-zone-sub { font-size: 12px; color: var(--ink-3); }
.upload-zone-count { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
@media (max-width: 640px) { .upload-zones { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------------
   9. Cross-Document view (Task E)
   ------------------------------------------------------------------------- */
.chain-form { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.chain-form .upload-field { flex: 1 1 200px; }
.holding-summary { margin-bottom: 8px; }

/* -------------------------------------------------------------------------
   10. Assistant view (Task F) — chat bubbles + citation chips
   ------------------------------------------------------------------------- */
.assistant-card { display: flex; flex-direction: column; gap: 16px; height: calc(100vh - 160px); max-height: 720px; }

.chat-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px;
}

/* Each .chat-msg is itself the flex column stacking a bubble over its
   citation row, aligned left/right via align-items so bubble + chips move
   together instead of the chips spanning the full row width. */
.chat-msg { display: flex; flex-direction: column; gap: 6px; max-width: 75%; }
.chat-msg-user { align-self: flex-end; align-items: flex-end; }
.chat-msg-assistant { align-self: flex-start; align-items: flex-start; }
.chat-msg-system { align-self: stretch; max-width: 100%; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14.5px;
  white-space: pre-wrap;
}
.chat-msg-user .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-msg-assistant .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}
.chat-bubble-loading { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }

.citation-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.citation-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-decoration: none;
}
.citation-chip:hover { background: color-mix(in srgb, var(--accent-soft) 60%, var(--accent) 20%); }
.citation-chip-plain { background: var(--surface-2); color: var(--ink-3); cursor: default; }

.chat-context-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
}
.chat-context-toggle input { cursor: pointer; }

.chat-input-row { display: flex; gap: 10px; }
.chat-input-row .chat-input { flex: 1; }

/* -------------------------------------------------------------------------
   11. Dashboard view — compliance risk summary
   ------------------------------------------------------------------------- */
.dash-hero { background: var(--accent); color: #fff; }
.dash-hero .dash-eyebrow {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  opacity: .85; margin-bottom: 6px;
}
.dash-hero h2 { color: #fff; }

.dash-flagged-list { display: flex; flex-direction: column; }
.dash-flagged-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border); cursor: pointer;
}
.dash-flagged-row:last-child { border-bottom: 0; }
.dash-flagged-row:hover { background: var(--surface-2); }
.dash-flagged-name { font-weight: 600; font-size: 14.5px; }
.dash-flagged-reasons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* -------------------------------------------------------------------------
   12. Onboarding tutorial — spotlight overlay (auto-starts every load, see
   docs/superpowers/specs/2026-07-11-maicsa-onboarding-tutorial-design.md)
   ------------------------------------------------------------------------- */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.tutorial-spotlight {
  position: absolute;
  border-radius: 10px;
  background: transparent;
  box-shadow: 0 0 0 4000px rgba(10, 12, 24, .6);
  pointer-events: none;
  transition: left .2s, top .2s, width .2s, height .2s;
}
.tutorial-tooltip {
  position: absolute;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.tutorial-step-count {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--accent-ink); margin-bottom: 6px;
}
.tutorial-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.tutorial-body { font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.tutorial-actions {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px;
}
.tutorial-btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: none;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer;
}
.tutorial-btn-primary:hover { filter: brightness(.9); }

/* -------------------------------------------------------------------------
   13. Documents view — flat per-entity document list
   ------------------------------------------------------------------------- */
.docs-list { display: flex; flex-direction: column; }
.docs-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.docs-row:last-child { border-bottom: 0; }
.docs-filename {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 13px; color: var(--accent-ink); text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent-ink) 35%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.docs-filename:hover { border-bottom-color: var(--accent-ink); }
.docs-date { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

/* Login page ------------------------------------------------------------ */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
