:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --border: #e2e5ea;
  --text: #1c2126;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-light: #eff4ff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

header.top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

header.top h1 { font-size: 22px; margin: 0; }
header.top .sub { color: var(--muted); font-size: 13px; }

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0 20px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 110px;
  display: block;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.1s ease;
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat .n { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.warn { border-color: #fecaca; background: #fff5f5; }

.header-links { display: flex; gap: 8px; flex-wrap: wrap; }
.header-links a.secondary {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  display: inline-block;
  color: var(--text);
}
.header-links a.secondary:hover { border-color: var(--accent); text-decoration: none; }

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: center;
}
.filters select, .filters input[type=text] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
}
.filters input[type=text] { min-width: 220px; }
.filters .check-inline {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.block-section { margin-bottom: 28px; }
.block-section h2 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 0;
}

table.items { width: 100%; border-collapse: collapse; }
table.items tr { border-bottom: 1px solid var(--border); }
table.items tr:hover td { background: var(--accent-light); }
table.items td { padding: 10px 6px; font-size: 14px; vertical-align: middle; }
table.items td.code { font-weight: 600; white-space: nowrap; width: 90px; }
table.items td.title a { color: var(--text); font-weight: 500; }
table.items td.title .refs { color: var(--muted); font-size: 12px; display: block; }
table.items td.title .snippet { color: var(--muted); font-size: 12px; display: block; font-style: italic; margin-top: 2px; }
table.items td.owner { color: var(--muted); font-size: 13px; white-space: nowrap; }
table.items td.qcount { text-align: right; white-space: nowrap; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
}
.badge.cat1 {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
  margin-left: 6px;
}
.qbadge {
  display: inline-block;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  font-weight: 600;
}

.empty { color: var(--muted); font-style: italic; padding: 10px 6px; }

/* item detail */
.item-header { margin-bottom: 4px; }
.item-header .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.item-header h1 { margin: 0 0 4px; font-size: 24px; }
.back { font-size: 13px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card .desc { white-space: pre-wrap; }

.status-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
select, textarea, input[type=text] {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
textarea { width: 100%; resize: vertical; min-height: 60px; }
button {
  font-family: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: white;
  cursor: pointer;
}
button:hover { opacity: 0.9; }
button.secondary { background: white; color: var(--accent); }

.question { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.question.open { border-left: 4px solid #ea580c; }
.question.answered { border-left: 4px solid #16a34a; opacity: 0.85; }
.question .qtext { font-weight: 500; }
.question .qmeta { color: var(--muted); font-size: 12px; margin-top: 2px; }

.thread { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--border); }
.thread .entry { margin-bottom: 8px; font-size: 14px; }
.thread .entry .who { font-weight: 600; }
.thread .entry .when { color: var(--muted); font-size: 12px; margin-left: 6px; }

.activity .entry { padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.activity .entry.kind-STATUS_CHANGE, .activity .entry.kind-EDIT_SUGGESTION,
.activity .entry.kind-ASSIGNMENT, .activity .entry.kind-ATTACHMENT { color: #374151; }
.activity .entry .who { font-weight: 600; }
.activity .entry .when { color: var(--muted); font-size: 12px; margin-left: 6px; }

.attachment-list { list-style: none; padding: 0; margin: 0 0 12px; }
.attachment-list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.attachment-list li:last-child { border-bottom: none; }
.attachment-list .qmeta { color: var(--muted); font-size: 12px; margin-left: 6px; }

.referenced-by { margin-top: 12px; font-size: 13px; color: var(--muted); }
.referenced-by .small { font-weight: 600; margin-right: 4px; }

.inline-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.inline-form textarea { flex: 1; min-width: 220px; }

.name-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
}
.name-bar input { width: 160px; padding: 5px 8px; }

.policy-text-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 4px 0;
  list-style: none;
}
.policy-text-details summary::-webkit-details-marker { display: none; }
.policy-text-details summary::before { content: '▸ '; }
.policy-text-details[open] summary::before { content: '▾ '; }
.policy-text-details summary:hover { text-decoration: underline; }

.policy-text {
  margin-top: 12px;
  padding: 18px 20px;
  background: #fbfbfc;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 75vh;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.6;
}
.policy-text p { margin: 0 0 12px; }
.policy-text ul { margin: 0 0 12px; padding-left: 22px; }
.policy-text li { margin-bottom: 6px; }
.policy-text .policy-heading {
  margin: 22px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 15px;
}
.policy-text .policy-heading:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.policy-text .policy-note {
  color: var(--muted);
  font-style: italic;
  background: var(--accent-light);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 0 6px 6px 0;
}
.policy-text .policy-note em { font-style: italic; }
.policy-table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13px; }
.policy-table th, .policy-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.policy-table th { background: #f3f4f6; font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.small { font-size: 12px; color: var(--muted); display: block; margin-bottom: 2px; }
.gate-box {
  max-width: 360px;
  margin: 80px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}
.gate-box input { width: 100%; margin: 12px 0; text-align: center; }
.error { color: #b91c1c; font-size: 13px; }

/* ---- Compliance calendar subscription (board) ---- */
.calendar-subscribe {
  background: var(--card, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0 0 16px;
}
.calendar-subscribe summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.calendar-subscribe p.small { margin: 8px 0; }
.calendar-url {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  background: #f8fafc;
}
.due-form {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border, #e2e8f0);
  align-items: center;
}

/* ---- Change history & diff ---- */
.field-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.field-tab {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border, #e2e8f0); font-size: 13px; text-decoration: none;
  color: var(--muted, #64748b); background: #f8fafc;
}
.field-tab.active { background: #1e293b; color: #fff; border-color: #1e293b; }
.tab-count { opacity: .7; font-size: 11px; }
.compare-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.compare-form select { max-width: 320px; }
.revision-entry .rev-field { font-weight: 600; font-size: 13px; margin-top: 2px; }
.rev-inline, .rev-stats { font-size: 13px; margin-top: 2px; }
.src-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  background: #e2e8f0; color: #475569; border-radius: 4px; padding: 1px 6px; margin-left: 6px;
}
.diff-plus { color: #15803d; font-weight: 600; }
.diff-minus { color: #b91c1c; font-weight: 600; }
.diff-add, ins.diff-add { background: #dcfce7; text-decoration: none; border-radius: 2px; }
.diff-del, del.diff-del { background: #fee2e2; text-decoration: line-through; border-radius: 2px; }
.diff-block {
  margin-top: 10px; border: 1px solid var(--border, #e2e8f0); border-radius: 8px;
  overflow-x: auto; background: #fff;
}
.diff-row {
  display: flex; gap: 8px; align-items: flex-start;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; line-height: 1.55; padding: 1px 10px; white-space: pre-wrap;
  word-break: break-word;
}
.diff-row .gutter { flex: 0 0 12px; color: #94a3b8; user-select: none; }
.diff-row .diff-text { flex: 1; }
.diff-ctx { color: #475569; }
.diff-old { background: #fef2f2; }
.diff-new { background: #f0fdf4; }
.diff-gap {
  background: #f8fafc; color: #94a3b8; font-style: italic;
  border-top: 1px solid var(--border, #e2e8f0); border-bottom: 1px solid var(--border, #e2e8f0);
}

/* ---- Standards PDF cross-links ---- */
.std-ref {
  text-decoration: none;
  border-bottom: 1px dotted #94a3b8;
  color: inherit;
  white-space: nowrap;
}
a.std-ref:hover { border-bottom-style: solid; color: #1d4ed8; }
.std-ref-cat1 { border-bottom-color: #dc2626; }
abbr.std-ref-nolink { cursor: help; text-decoration: none; }
.standards-table .code { white-space: nowrap; }
.standards-table .std-page { text-align: right; white-space: nowrap; vertical-align: top; }

/* ---- Open items: short headline, detail on demand ---- */
.qhead { font-weight: 600; font-size: 15px; line-height: 1.35; }
.qdetail { margin: 4px 0 2px; }
.qdetail > summary {
  cursor: pointer; font-size: 12px; color: var(--muted, #64748b);
  list-style: none; display: inline-block;
}
.qdetail > summary::before { content: "▸ "; }
.qdetail[open] > summary::before { content: "▾ "; }
.qdetail .qtext { font-weight: 400; font-size: 13.5px; margin-top: 4px; color: #334155; }
.qedit { margin-top: 6px; }
.qedit > summary {
  cursor: pointer; font-size: 12px; color: var(--muted, #64748b);
  list-style: none; display: inline-block;
}
.qedit > summary::before { content: "✎ "; }
.qedit .due-form { margin-top: 6px; }

/* ---- Build version marker ---- */
.app-version {
  margin: 28px 0 8px;
  text-align: right;
  font-size: 11px;
  color: #94a3b8;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.app-version a { color: inherit; text-decoration: none; }
.app-version a:hover { text-decoration: underline; }
.linkbtn { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
