:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #101827;
  --muted: #667085;
  --line: #e1e6ee;
  --line-strong: #cbd3df;
  --dark: #171d26;
  --dark-2: #202834;
  --accent: #9b1c20;
  --accent-dark: #711417;
  --soft-accent: #fff4f4;
  --danger: #b4232a;
  --success: #16803d;
  --shadow: 0 10px 28px rgba(16, 24, 39, 0.07);
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.topbar {
  min-height: 66px;
  background: var(--dark);
  color: white;
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 2px solid var(--accent);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .04em;
}

.topbar h1 {
  margin: 0 0 2px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
}

.topbar p {
  margin: 0;
  color: #b7c0cd;
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
}

.nav-link, .admin-link, button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.15);
  color: white;
  text-decoration: none;
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1;
  font-weight: 800;
  cursor: pointer;
  border-radius: 7px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.nav-link:hover, .admin-link:hover, button:hover { background: rgba(255,255,255,.08); }
.nav-link.active, .nav-link.export { background: var(--accent); border-color: var(--accent); }

.shell {
  max-width: 720px;
  margin: 26px auto;
  padding: 0 18px;
}

.two-col-shell {
  max-width: 1040px;
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  align-items: start;
}

.wide-shell {
  max-width: 1180px;
  margin: 22px auto;
  padding: 0 18px;
}

.panel, .table-panel, .hero-card, .chart-panel, .summary-card, .gate-section-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel, .table-panel { padding: 20px; }

.hero-card {
  padding: 20px;
  position: sticky;
  top: 18px;
}

.hero-card h2, .requirements-control h2, .section-heading h2 {
  margin: 4px 0 8px;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -.02em;
}

.hero-card p, .muted-copy {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 14px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 0;
}

label, legend {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 13px;
}

.field-note {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  display: block;
  margin-top: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
}

textarea { resize: vertical; min-height: 88px; }

input:focus, textarea:focus, select:focus {
  outline: 3px solid rgba(155, 28, 32, .10);
  border-color: var(--accent);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

fieldset {
  border: 1px solid var(--line);
  margin: 0 0 14px;
  padding: 14px;
  border-radius: var(--radius);
}

.pass-card { background: #fbfcfd; }

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.radio-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-weight: 900;
}

.radio-tile input { width: auto; margin: 0; }

.failure-card {
  background: var(--soft-accent);
  border: 1px solid #f0c9ca;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  border-color: var(--accent);
  padding: 12px 15px;
  font-size: 14px;
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--dark-2);
  color: white;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
}
.secondary-link.full { width: 100%; text-align: center; }

.hidden { display: none; }

.message {
  min-height: 18px;
  font-weight: 800;
  margin: 12px 0 0;
}

.message.success { color: var(--success); }
.message.error { color: var(--danger); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stats div {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.stats strong { display: block; font-size: 24px; line-height: 1; }
.stats span { color: var(--muted); font-size: 12px; font-weight: 700; }

.table-panel { overflow-x: auto; padding: 14px 18px 16px; }
.table-title { display:flex; align-items:baseline; justify-content:space-between; gap:12px; margin:0 0 10px; }
.table-title h2 { margin:0; font-size:16px; }
.table-title p { margin:0; color:var(--muted); font-size:12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th, td {
  border-bottom: 1px solid var(--line);
  padding: 8px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7f9fb;
  color: #4b5563;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.badge {
  display: inline-block;
  min-width: 26px;
  text-align: center;
  padding: 3px 7px;
  color: white;
  font-weight: 900;
  border-radius: 999px;
  font-size: 12px;
}

.badge.ok { background: var(--success); }
.badge.bad { background: var(--danger); }

.chart-panel {
  padding: 15px 16px 12px;
  margin-bottom: 14px;
}

.chart-panel h2 { margin: 0 0 3px; font-size: 16px; }
.chart-panel p { margin: 0 0 12px; color: var(--muted); font-size: 12px; }

.chart-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 8px;
}

.toggle-row { display: flex; gap: 7px; }
.toggle { background: #f2f4f7; color: var(--text); border: 1px solid var(--line); }
.toggle.active { background: var(--accent); color: white; }

#machineChart {
  display: block;
  width: 100%;
  height: 285px;
  max-width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

/* Requirements page */
.brand-logo-block { gap: 14px; }
.brand-logo {
  display: block;
  width: 150px;
  max-height: 46px;
  object-fit: contain;
  background: #fff;
  padding: 5px 8px;
  border-radius: 6px;
}

.requirements-page { margin-top: 22px; }

.requirements-hero {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 16px;
  align-items: end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 12px;
}

.requirements-hero h2 {
  margin: 5px 0 8px;
  font-size: 26px;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.requirements-hero p {
  margin: 0;
  max-width: 740px;
  color: var(--muted);
  line-height: 1.48;
}

.hero-tools {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.requirement-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.light-btn {
  color: var(--text);
  background: white;
  border: 1px solid var(--line-strong);
}

.requirements-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 10px;
  margin-bottom: 12px;
}

.summary-card {
  padding: 14px;
}

.summary-card strong {
  display: block;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.summary-card span {
  display: block;
  font-size: 16px;
  font-weight: 900;
  line-height: 1.25;
}

.requirements-board {
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 12px;
}

.section-heading p { margin: 0; color: var(--muted); }

.clean-heading {
  padding: 18px 20px 14px;
  margin: 0;
  background: #fff;
}

.legend-chips {
  display: flex;
  gap: 7px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.legend-chip, .count-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  padding: 5px 8px;
}

.legend-chip.required, .count-pill {
  color: var(--accent-dark);
  background: var(--soft-accent);
  border: 1px solid #efc8ca;
}

.legend-chip.note {
  color: #214a73;
  background: #eef6ff;
  border: 1px solid #cde3fa;
}

.requirements-empty {
  text-align: center;
  color: var(--muted);
  background: #fbfcfd;
  padding: 48px 22px;
}

.requirements-empty h3 {
  color: var(--text);
  margin: 10px 0 5px;
  font-size: 19px;
}

.requirements-empty p { margin: 0; }

.empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  font-weight: 900;
}

.requirements-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  background: #f7f9fb;
  padding: 14px;
}

.gate-section-card {
  overflow: hidden;
  box-shadow: none;
}

.gate-section-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 15px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.gate-section-label {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.gate-section-head h3 {
  margin: 0;
  font-size: 17px;
}

.gate-items { padding: 4px 0; }

.gate-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  padding: 11px 15px;
  border-bottom: 1px solid #edf1f5;
}

.gate-item:last-child { border-bottom: 0; }

.gate-num {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--dark-2);
  color: white;
  font-size: 11px;
  font-weight: 900;
}

.gate-copy strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.gate-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

@media (max-width: 980px) {
  .requirements-hero, .requirements-summary { grid-template-columns: 1fr; }
  .requirements-card-grid { grid-template-columns: 1fr; }
  .brand-logo { width: 140px; }
}

@media (max-width: 900px) {
  .two-col-shell { grid-template-columns: 1fr; }
  .hero-card { position: static; }
}

@media (max-width: 720px) {
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .field-grid, .choice-grid { grid-template-columns: 1fr; }
  .chart-header { flex-direction: column; }
}

@media print {
  .topbar, .hero-tools, .legend-chips, .requirements-summary { display: none !important; }
  body { background: white; }
  .wide-shell { max-width: none; margin: 0; padding: 0; }
  .requirements-hero, .requirements-board, .gate-section-card { box-shadow: none; border-color: #999; }
  .requirements-hero { display: block; padding: 0 0 16px; border: 0; }
  .requirements-card-grid { grid-template-columns: 1fr; background: white; padding: 0; gap: 10px; }
  .gate-copy p { color: #333; }
}
