:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #151b23;
  --muted: #5f6b7a;
  --line: #d9dee7;
  --green: #e0525e;
  --accent: #e0525e;
  --accent-dark: #b4232c;
  --accent-soft: #fff1f2;
  --accent-border: #fecdd3;
  --accent-text: #9f1239;
  --green-dark: #b4232c;
  --blue: #b4232c;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 48%) minmax(360px, 52%);
  gap: 2.25rem;
  min-height: 100vh;
  padding: 1.5rem 2rem;
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
}

.card {
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.05);
  border-radius: 9px;
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 1.45rem;
}

.card h2 {
  margin: 0 0 1rem;
  text-align: center;
  font-size: 1.1rem;
}

.compact { padding: 1.25rem 1.5rem; }
.compact h2 { text-align: left; margin-bottom: .65rem; }

.radio-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .75rem;
}

.radio-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-grid label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .65rem 1.15rem;
  border: 1px solid #cfd4dc;
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}

.radio-grid label:hover { transform: translateY(-1px); }
.radio-grid input:checked + label {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.radio-grid input:focus-visible + label {
  outline: 3px solid rgba(224, 82, 94, .24);
  outline-offset: 2px;
}

.results-panel { min-width: 0; }
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.search-wrap input {
  min-width: min(28rem, 42vw);
  padding: .75rem .85rem;
  border: 1px solid #cfd4dc;
  border-radius: 7px;
  font-size: 1rem;
  background: white;
}

.results-card {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 7.2rem);
  padding: 1.25rem;
}

.status, .counting-note, .fine-print {
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.45;
}

.counting-note {
  margin: .2rem 0 1rem;
  padding: .75rem .9rem;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.counting-note:empty { display: none; }

.checkbox-line {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-bottom: .6rem;
}

.option-group {
  margin: 0 0 .9rem;
  padding: .75rem 0 .85rem;
  border-bottom: 1px solid var(--line);
}
.option-group h3 {
  margin: 0 0 .55rem;
  font-size: .92rem;
  color: var(--muted);
  font-weight: 700;
}
.radio-grid.small {
  justify-content: flex-start;
  gap: .45rem;
}
.radio-grid.small label {
  min-height: 2.15rem;
  padding: .45rem .7rem;
  font-size: .9rem;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
}

th, td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: .72rem .75rem;
  vertical-align: middle;
}

th:last-child, td:last-child { border-right: 0; }
tr:last-child td { border-bottom: 0; }

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f0f2f5;
  text-align: left;
  font-weight: 700;
}

td.numeric, th.numeric { text-align: right; }
td.center, th.center { text-align: center; }

.group-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
.group-button:hover { text-decoration: underline; }

.chip {
  display: inline-flex;
  align-items: center;
  margin: .12rem .18rem .12rem 0;
  padding: .16rem .45rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: .8rem;
}

#detail-dialog {
  max-width: min(900px, 94vw);
  border: 0;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
  padding: 1.35rem 1.5rem 1.5rem;
}
#detail-dialog::backdrop { background: rgba(15,23,42,.45); }
.dialog-close {
  position: absolute;
  top: .7rem;
  right: .8rem;
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  cursor: pointer;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .75rem;
  margin: 1rem 0;
}
.metric {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: .75rem;
  background: #fbfcfe;
}
.metric strong { display: block; font-size: 1.15rem; }
.question-list {
  max-height: 18rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .25rem .75rem;
}
.question-list li { margin: .45rem 0; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; padding: 1rem; }
  .results-card { height: 72vh; }
  .search-wrap input { min-width: 0; width: 100%; }
  .results-header { align-items: stretch; flex-direction: column; }
}

.pdf-actions-inline {
  display: inline-flex;
  gap: .35rem;
  justify-content: center;
  align-items: center;
}
.pdf-button {
  border: 1px solid #cfd4dc;
  border-radius: 6px;
  background: #fff;
  padding: .35rem .55rem;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}
.pdf-button-secondary {
  font-size: .82rem;
  color: var(--muted);
}
.pdf-button:not(:disabled):hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}
.pdf-button:disabled {
  opacity: .35;
  cursor: not-allowed;
}
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  margin: .8rem 0 1rem;
}
.primary-action, .secondary-action {
  border-radius: 7px;
  padding: .65rem 1rem;
  font: inherit;
  cursor: pointer;
}
.primary-action {
  background: var(--green);
  border: 1px solid var(--green);
  color: #fff;
  font-weight: 700;
}
.primary-action:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.secondary-action {
  background: #fff;
  border: 1px solid #cfd4dc;
}
.asset-ok, .asset-missing {
  display: inline-flex;
  margin-left: .35rem;
  padding: .08rem .35rem;
  border-radius: 999px;
  font-size: .75rem;
}
.asset-ok {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.asset-missing {
  background: #f3f4f6;
  color: #6b7280;
}
