:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #eef3f6;
  --ink: #182028;
  --muted: #64727f;
  --line: #dce3e8;
  --blue: #1f6feb;
  --green: #1f8a5b;
  --red: #c33b35;
  --amber: #b06a00;
  --teal: #087b83;
  --shadow: 0 16px 45px rgba(20, 31, 43, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
  font-weight: 700;
}

button.secondary {
  background: #e8eef4;
  color: var(--ink);
}

button.danger {
  background: #f5dddd;
  color: #99251f;
}

button.chip {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 34px;
}

button:hover {
  filter: brightness(0.98);
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(18px, 4vw, 48px);
  background: #0f1f2e;
  color: #fff;
}

.app-header h1 {
  margin: 4px 0 6px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  letter-spacing: 0;
}

.lead {
  margin: 0;
  color: #d9e5ee;
  max-width: 760px;
}

.eyebrow {
  margin: 0;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-header .eyebrow {
  color: #81d6da;
}

.header-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

main {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px clamp(14px, 3vw, 34px) 48px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.section-heading {
  margin-bottom: 16px;
}

.section-heading h2,
.chart-panel h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 92px;
}

.kpi-card span {
  color: var(--muted);
  font-size: 13px;
}

.kpi-card strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1.1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 410px) 1fr;
  gap: 16px;
  align-items: start;
}

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

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input[type="color"] {
  padding: 2px;
  min-width: 44px;
}

.suffix-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.suffix-input input {
  border-radius: var(--radius) 0 0 var(--radius);
}

.suffix-input span {
  display: flex;
  align-items: center;
  min-height: 38px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--surface-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 0;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

.check-row span {
  margin: 0;
  color: var(--ink);
}

.manual-delegates {
  display: none;
  margin-top: 12px;
}

.manual-delegates.is-visible {
  display: block;
}

.college-box {
  margin-top: 14px;
}

.scenario-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.table-scroll {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #4d5b66;
  font-size: 12px;
  text-transform: uppercase;
}

.compact-table input {
  min-width: 82px;
}

.data-table input {
  min-width: 96px;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.candidate-name {
  min-width: 160px;
}

.helper {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.college-votes {
  display: table-cell;
}

.single-votes {
  display: none;
}

body.single-mode .college-votes {
  display: none;
}

body.single-mode .single-votes {
  display: table-cell;
}

body.single-mode #collegeBox {
  display: none;
}

.notice-stack {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.notice {
  border-left: 4px solid var(--amber);
  background: #fff8ea;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #5b3a05;
}

.notice.critical {
  border-left-color: var(--red);
  background: #fff0ef;
  color: #77201b;
}

.notice.good {
  border-left-color: var(--green);
  background: #ecf8f2;
  color: #155c3e;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 9px;
  min-width: 48px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.yes {
  background: #dff4ea;
  color: var(--green);
}

.status-pill.no {
  background: #f8dddd;
  color: var(--red);
}

.status-pill.neutral {
  background: #e9eef3;
  color: #4c5964;
}

.represent-row.yes {
  background: #f3fbf7;
}

.represent-row.no {
  background: #fff6f5;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}

.allocation-grid {
  display: grid;
  gap: 16px;
}

.allocation-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.allocation-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: 0;
}

.allocation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.allocation-meta span {
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 5px 9px;
  color: #41505c;
  font-size: 12px;
  font-weight: 700;
}

.inline-select {
  min-width: min(260px, 100%);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.chart-panel canvas {
  width: 100%;
  max-width: 100%;
}

.objective-panel {
  margin-top: 16px;
}

.instructions {
  margin-top: 16px;
}

.instruction-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  color: #42505b;
}

.instruction-grid p {
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 1120px) {
  .kpi-grid,
  .charts-grid,
  .instruction-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-header {
    display: block;
  }

  .header-actions {
    margin-top: 18px;
  }

  .field-grid,
  .kpi-grid,
  .charts-grid,
  .instruction-grid {
    grid-template-columns: 1fr;
  }

  .with-action {
    display: block;
  }

  .with-action button,
  .with-action label {
    margin-top: 12px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-header,
  .panel,
  .kpi-card {
    box-shadow: none;
  }

  button,
  .header-actions,
  .scenario-buttons,
  #addCandidateBtn,
  .danger {
    display: none !important;
  }

  main {
    padding: 16px;
  }

  .workspace-grid,
  .charts-grid,
  .instruction-grid {
    grid-template-columns: 1fr;
  }
}
