/* Security Questionnaire Filler - UI styles.
   No build step, no dependencies, no framework.
   Visual system: deep navy chrome + light content areas, a single restrained
   accent, subtle borders, moderate radii and minimal shadows. Deliberately not
   a gradient-heavy "AI" dashboard: this is meant to read as a GRC/security
   operations tool. */
:root {
  /* chrome */
  --navy: #0f1c2e;
  --navy-2: #16263c;
  --navy-line: #26374f;
  /* content */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-3: #eef1f5;
  --line: #e2e6eb;
  --line-2: #cfd6de;
  --fg: #182430;
  --fg-dim: #5a6673;
  --muted: #8592a0;
  /* one accent */
  --accent: #1d4ed8;
  --accent-strong: #1739a8;
  --accent-bg: #e8eefc;
  --accent-line: #c2d2f7;
  /* status */
  --ok: #1a7f45;      --ok-bg: #e9f6ee;   --ok-line: #b6e0c6;
  --warn: #8a5a00;    --warn-bg: #fdf4e3; --warn-line: #f0d9a8;
  --bad: #b3261e;     --bad-bg: #fdecea;  --bad-line: #f3c5c1;
  --info: #1d4ed8;    --info-bg: #e8eefc; --info-line: #c2d2f7;
  --radius: 6px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
/* Elements toggled with [hidden] must actually stay hidden: an author `display`
   rule would otherwise win over the user-agent `[hidden] { display: none }`. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: var(--fg); }
h1 { font-size: 20px; font-weight: 650; letter-spacing: -.1px; }
h2 { font-size: 15.5px; font-weight: 650; }
h3 { font-size: 12px; margin-top: 1.1rem; text-transform: uppercase; letter-spacing: .7px; color: var(--fg-dim); font-weight: 650; }
h4 { font-size: 13px; font-weight: 650; }
p { margin: 0 0 .6rem; }
code, .mono { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: #24303d; }
a { color: var(--accent); }
.muted { color: var(--fg-dim); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.info { color: var(--info); }
.nowrap { white-space: nowrap; }
.tight { margin-top: 4px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 18px; background: var(--navy); border-bottom: 1px solid var(--navy-line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  font-weight: 800; letter-spacing: 1.5px; background: var(--accent); color: #fff;
  border-radius: 5px; padding: 6px 8px; font-size: 12.5px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 14px; color: #fff; }
.brand-text .muted { color: #93a3b8; font-size: 11.5px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.topbar .pill { background: #1b2b42; border-color: var(--navy-line); color: #b7c5d8; }

/* ---------- demo banner ---------- */
.demo-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff8e6; border-bottom: 1px solid var(--warn-line);
  padding: 5px 18px; font-size: 12px; color: #6d4a00;
}
.demo-banner .tag {
  font-weight: 700; letter-spacing: .6px; background: var(--warn); color: #fff;
  border-radius: 4px; padding: 1px 7px; font-size: 10.5px;
}
.demo-banner .sep-dot { color: var(--warn-line); }

/* ---------- loading strip ---------- */
.loading {
  display: flex; align-items: center; gap: 9px; padding: 7px 18px;
  background: var(--accent-bg); border-bottom: 1px solid var(--accent-line);
  font-size: 12.5px; color: var(--accent-strong);
}
.spinner {
  width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  border: 2px solid var(--accent-line); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- buttons / inputs ---------- */
.btn {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 6px 12px; font-size: 13px; font-family: inherit;
  cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--surface); color: var(--fg); border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-3); border-color: var(--muted); }
.btn.danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover:not(:disabled) { background: var(--bad-bg); border-color: var(--bad); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.topbar .btn { background: var(--accent); border-color: var(--accent); }
.topbar .btn.ghost { background: transparent; color: #dce4ef; border-color: var(--navy-line); }
.topbar .btn.ghost:hover:not(:disabled) { background: var(--navy-2); }
.topbar .btn.danger { background: transparent; color: #ffb3ae; border-color: #5b2c2c; }
.topbar .btn.danger:hover:not(:disabled) { background: #3a1d1d; }
.input, select.input, textarea.input {
  background: var(--surface); color: var(--fg); border: 1px solid var(--line-2);
  border-radius: var(--radius); padding: 5px 8px; font-size: 13px; font-family: inherit;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label.inline { display: flex; align-items: center; gap: 7px; margin: 6px 0; font-size: 13px; color: var(--fg-dim); }
label.inline .input { color: var(--fg); }

/* ---------- tabs / navigation ---------- */
.tabs {
  display: flex; gap: 1px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; position: sticky; top: 0; z-index: 30;
}
.tab {
  background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--fg-dim);
  padding: 10px 11px; font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--accent-strong); border-bottom-color: var(--accent); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.badge {
  display: inline-block; min-width: 17px; text-align: center; font-size: 11px;
  background: var(--surface-3); border: 1px solid var(--line-2); border-radius: 9px;
  padding: 0 5px; margin-left: 5px; color: var(--fg-dim);
}
.tab.active .badge { background: var(--accent-bg); border-color: var(--accent-line); color: var(--accent-strong); }

main { padding: 16px 18px; max-width: 1560px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- layout ---------- */
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.grid.two.wide-left { grid-template-columns: minmax(540px, 1.5fr) minmax(320px, 1fr); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
@media (max-width: 1000px) { .grid.two.wide-left { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.empty { color: var(--muted); font-style: normal; padding: 12px 2px; }
.empty::before { content: ""; }
.scroll { overflow: auto; max-height: 320px; }
.scroll.tall { max-height: 640px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.stack-gap { display: grid; gap: 14px; }

.pill {
  display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 4px;
  background: var(--surface-3); border: 1px solid var(--line-2); color: var(--fg-dim); white-space: nowrap;
}
.pill.small { font-size: 10.5px; padding: 1px 6px; }
.pill.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.pill.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.pill.bad { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.pill.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

.callout { border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 4px; padding: 9px 12px; margin: 10px 0; font-size: 13px; }
.callout.warn { border-left-color: var(--warn); background: var(--warn-bg); border-color: var(--warn-line); }
.callout.bad { border-left-color: var(--bad); background: var(--bad-bg); border-color: var(--bad-line); }
.callout.ok { border-left-color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.callout.info { border-left-color: var(--accent); background: var(--accent-bg); border-color: var(--accent-line); }

ol.gates, ol.steps { margin: 0 0 .6rem; padding-left: 1.2rem; }
ol.gates li, ol.steps li { margin-bottom: .35rem; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.tablewrap table { border: 0; }
table { border-collapse: collapse; width: 100%; font-size: 12.8px; }
table.mini { font-size: 12.2px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--fg-dim); font-weight: 650; font-size: 10.8px; text-transform: uppercase; letter-spacing: .6px; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-family: var(--mono); }
td.qcell { max-width: 380px; }

/* ---------- filters ---------- */
.filterbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 0 12px; }
.filterbar .input { min-width: 130px; }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--surface); flex-wrap: wrap; }
.segmented button {
  background: var(--surface); border: 0; border-right: 1px solid var(--line); color: var(--fg-dim);
  padding: 5px 10px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-3); }
.segmented button.active { background: var(--accent-bg); color: var(--accent-strong); font-weight: 600; }

/* ---------- portal chrome ---------- */
.portal-chrome {
  display: flex; align-items: center; gap: 7px; background: var(--surface-3);
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; padding: 8px 12px;
}
.portal-chrome .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0,0,0,.12); }
.dot.red { background: #ff5f57; } .dot.amber { background: #febc2e; } .dot.green { background: #28c840; }
.portal-chrome .url { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); margin-left: 8px; flex: 1; }
#panel-portal #portal-body { border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); }
.portal-page { padding: 16px; background: var(--surface); }
.portal-page h2 { font-size: 17px; }
.portal-q { border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px; margin-bottom: 9px; background: var(--surface-2); }
.portal-q.filled { border-left: 3px solid var(--ok); }
.portal-q.blank { border-left: 3px solid var(--line-2); }
.portal-q .qid { font-family: var(--mono); font-size: 12px; color: var(--fg-dim); }
.portal-answer { margin-top: 7px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 13px; }
.portal-answer .cite { display: block; margin-top: 5px; font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }
.portal-empty { color: var(--muted); font-size: 12.5px; font-style: italic; }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline .step { position: relative; padding: 8px 0 12px; border-left: 2px solid var(--line-2); margin-left: -14px; padding-left: 22px; }
.timeline .step:last-child { border-left-color: transparent; }
.timeline .step .marker {
  position: absolute; left: -9px; top: 11px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface-3); border: 2px solid var(--line-2); font-size: 9px; line-height: 12px;
  text-align: center; color: var(--fg-dim); font-family: var(--mono);
}
.timeline .step.done .marker { background: var(--ok); border-color: var(--ok); color: #fff; }
.timeline .step.pending .marker { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }
.timeline .step.failed .marker { background: var(--bad); border-color: var(--bad); color: #fff; }
.timeline .step .stitle { font-weight: 600; font-size: 13.5px; }
.timeline .step .smeta { color: var(--fg-dim); font-size: 12px; }

/* ---------- items / results ---------- */
.item-list { display: flex; flex-direction: column; gap: 9px; }
.item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 12px; }
.item-head .qt { font-size: 13.5px; }
.item-head .meta { font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }
.item-body { padding: 0 12px 11px; }
.item-body .kv { display: grid; grid-template-columns: 132px 1fr; gap: 3px 10px; font-size: 12.5px; margin: 0; }
.item-body .kv dt { color: var(--muted); }
.item-body .kv dd { margin: 0; }
.item-actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; padding: 9px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.quote {
  font-family: var(--mono); font-size: 12px; background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); padding: 7px 9px; border-radius: 4px; margin: 6px 0; white-space: pre-wrap;
}
.bucket-title { display: flex; align-items: center; gap: 8px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; }
.stat .n { display: block; font-size: 20px; font-weight: 700; font-family: var(--mono); color: var(--fg); }
.stat .l { display: block; font-size: 11px; color: var(--fg-dim); text-transform: uppercase; letter-spacing: .5px; }
.stat.ok .n { color: var(--ok); } .stat.warn .n { color: var(--warn); }
.stat.bad .n { color: var(--bad); } .stat.info .n { color: var(--accent); }

/* Statistics that navigate: rendered as real buttons so they are focusable and
   keyboard-operable. Hover/focus makes it obvious the number is a link. */
button.stat.link {
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  position: relative; transition: border-color .12s, background .12s;
}
button.stat.link:hover { border-color: var(--accent); background: var(--accent-bg); }
button.stat.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.stat.link .go { position: absolute; top: 6px; right: 8px; font-size: 15px; line-height: 1; color: var(--muted); }
button.stat.link:hover .go { color: var(--accent-strong); }

.bar { display: block; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; border: 1px solid var(--line); }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.progress-row { display: grid; gap: 4px; margin: 9px 0; }
.progress-row .lbl { display: flex; justify-content: space-between; font-size: 12px; color: var(--fg-dim); }
button.progress-row.link {
  width: 100%; background: transparent; border: 0; padding: 4px 6px; margin: 5px -6px;
  border-radius: 4px; font: inherit; color: inherit; text-align: left; cursor: pointer;
}
button.progress-row.link:hover { background: var(--surface-2); }
button.progress-row.link:hover .lbl { color: var(--fg); }
button.progress-row.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }

/* Pills that navigate (top bar mode/run indicators). */
button.pill.link { font-family: inherit; cursor: pointer; }
button.pill.link:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-bg); }
.topbar button.pill.link:hover { background: #22364f; border-color: var(--accent); color: #fff; }

/* ---------- logs / audit ---------- */
.log {
  font-family: var(--mono); font-size: 11.8px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 11px; margin: 0;
}
.log div { padding: 2px 0; border-bottom: 1px solid var(--line); white-space: pre-wrap; }
.log div:last-child { border-bottom: 0; }
.log .t { color: var(--muted); }
.log .src { color: var(--accent); }
.log .evt { color: var(--muted); }

/* ---------- checklist ---------- */
.checklist { display: grid; gap: 4px; }
.check-item { display: flex; align-items: flex-start; gap: 9px; font-size: 12.8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item .box { font-family: var(--mono); font-weight: 700; width: 18px; flex: none; }
.check-item .box.yes { color: var(--ok); } .check-item .box.no { color: var(--bad); }
.check-item .box.na { color: var(--muted); }
.check-item .why { color: var(--fg-dim); font-size: 11.8px; }

/* ---------- misc ---------- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(760px, 95vw); background: var(--surface);
  border-left: 1px solid var(--line-2); z-index: 60; display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(16, 24, 40, .12);
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.drawer-body { padding: 14px; overflow: auto; flex: 1; }
.drawer-body pre { background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 10px; overflow: auto; font-size: 12px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--navy); border: 1px solid var(--navy-line); border-radius: var(--radius);
  padding: 9px 14px; font-size: 13px; z-index: 80; color: #eef2f7;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .22); max-width: 80vw;
}
.toast.ok { border-color: var(--ok); }
.toast.bad { border-color: #e0524a; }

details { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 11px; background: var(--surface-2); margin-bottom: 8px; }
details > summary { cursor: pointer; font-size: 13px; color: var(--fg); }
details[open] > summary { margin-bottom: 8px; }
.chipset { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; }
.chip {
  font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 4px; padding: 2px 7px; color: var(--fg-dim); font-family: var(--mono);
}
.chip.rej { border-color: var(--bad-line); background: var(--bad-bg); color: var(--bad); }
.chip.ok { border-color: var(--ok-line); background: var(--ok-bg); color: var(--ok); }
.chip.warn { border-color: var(--warn-line); background: var(--warn-bg); color: var(--warn); }
.score { font-family: var(--mono); }
.pass { color: var(--ok); font-weight: 700; }
.fail { color: var(--bad); font-weight: 700; }
.tc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tc-head .tc-id {
  font-family: var(--mono); font-weight: 700; font-size: 13px; background: var(--surface-3);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 8px;
}
kbd {
  background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 5px; font-family: var(--mono); font-size: 11.5px;
}
textarea.input { width: 100%; min-height: 96px; resize: vertical; line-height: 1.5; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  main { padding: 12px; }
  .item-body .kv { grid-template-columns: 1fr; }
  .item-body .kv dt { margin-top: 5px; }
  .brand-text .muted { display: none; }
}
