:root {
  --bg: #f4f6f2;
  --panel: #ffffff;
  --panel-strong: #f9faf7;
  --ink: #17201b;
  --muted: #69746f;
  --border: #d8ded8;
  --accent: #21695a;
  --accent-soft: #dceee8;
  --red: #a33a36;
  --red-soft: #f5dfdc;
  --amber: #9a6a1c;
  --amber-soft: #f7ecd0;
  --green: #1f7a54;
  --green-soft: #dcefe4;
  --gray-soft: #ecefed;
  --shadow: 0 16px 40px rgb(23 32 27 / 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #aeb9b1;
}

input,
select {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border);
  background: #fbfcfa;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  letter-spacing: 0;
}

.unlock-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.unlock-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.unlock-card h1 {
  margin-bottom: 24px;
}

.unlock-card label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.unlock-card input,
.unlock-card button {
  width: 100%;
}

.unlock-card button {
  margin-top: 12px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.unlock-error {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.8fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: stretch;
}

.result-panel,
.metric,
.mode-bar,
.scenario-bar,
.status-strip,
.side-panel,
.main-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mode-tabs button {
  min-width: 150px;
  padding: 0 14px;
}

.mode-tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.toggle-control input {
  width: 18px;
  min-height: 18px;
}

.result-panel {
  padding: 18px;
  border-left: 8px solid var(--muted);
}

.result-pass {
  border-left-color: var(--green);
}

.result-close {
  border-left-color: var(--amber);
}

.result-fail {
  border-left-color: var(--red);
}

.result-badge {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--gray-soft);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-pass .result-badge {
  background: var(--green-soft);
  color: var(--green);
}

.result-close .result-badge {
  background: var(--amber-soft);
  color: var(--amber);
}

.result-fail .result-badge {
  background: var(--red-soft);
  color: var(--red);
}

.result-panel h2 {
  margin: 14px 0 10px;
  font-size: 20px;
}

.bottleneck {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.metric {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 130px;
}

.metric span,
.status-strip span,
.critical-list span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 32px;
  letter-spacing: 0;
}

.metric small {
  color: var(--muted);
}

.scenario-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
}

.scenario-tabs,
.scenario-actions,
.toolbar,
.bulk-bar,
.status-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scenario-tab {
  padding: 0 14px;
  min-width: 110px;
}

.scenario-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.scenario-actions input {
  width: 180px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  margin-top: 16px;
  overflow: hidden;
  background: var(--border);
}

.status-strip div {
  padding: 14px 16px;
  background: #fff;
}

.status-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 26px;
}

.workbench {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  min-width: 0;
}

.side-panel,
.main-panel {
  min-width: 0;
  padding: 16px;
}

.main-panel {
  overflow: hidden;
}

.side-panel {
  align-self: start;
  position: sticky;
  top: 12px;
}

.critical-list {
  margin: 0;
  padding-left: 22px;
}

.critical-list li {
  margin-bottom: 12px;
}

.critical-list strong,
.critical-list span {
  display: block;
}

.faction-box,
.source-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.faction-counts {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.faction-counts li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--panel-strong);
}

.faction-counts span {
  color: var(--muted);
  font-weight: 800;
}

.source-box p {
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 0;
}

.toolbar {
  margin-bottom: 12px;
}

.toolbar input {
  flex: 1 1 260px;
}

.toolbar select {
  flex: 0 1 210px;
}

.bulk-bar {
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  border-radius: 8px;
  background: var(--panel-strong);
}

#visibleCount {
  margin-right: auto;
  color: var(--muted);
  font-weight: 700;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1320px;
  background: #fff;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8faf8;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td:first-child {
  min-width: 260px;
}

tbody tr:hover {
  background: #fbfcfb;
}

.mobile-meta {
  display: none;
}

.row-meta {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.vote-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  margin-left: 6px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--gray-soft);
  color: #4f5b55;
  font-size: 12px;
  font-weight: 800;
}

tr.non-voting {
  color: #5c6660;
  background: #fafbfa;
}

tr.non-voting .status-buttons,
tr.non-voting .probability-input,
tr.non-voting .percent {
  opacity: 0.55;
}

.list-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  margin-right: 6px;
  border-radius: 6px;
  background: var(--gray-soft);
  color: #4f5b55;
  font-size: 12px;
  font-weight: 800;
}

.faction-select {
  width: 190px;
}

.status-buttons {
  min-width: 420px;
}

.status-button {
  min-width: 78px;
  height: 32px;
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

.status-button.active {
  font-weight: 800;
  border-width: 2px;
}

.status-for.active {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green);
}

.status-against.active {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
}

.status-abstain.active {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.status-unknown.active,
.status-absent.active {
  border-color: #859089;
  background: var(--gray-soft);
  color: #4f5b55;
}

.probability-input {
  width: 74px;
}

.percent {
  margin-left: 4px;
  color: var(--muted);
}

.note-input {
  width: min(260px, 28vw);
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .result-panel {
    grid-column: 1 / -1;
  }

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

  .side-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  main {
    padding: 14px;
  }

  .summary-grid,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .scenario-bar,
  .mode-bar,
  .bulk-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .scenario-tabs,
  .scenario-actions,
  .toolbar {
    flex-direction: column;
  }

  .scenario-actions input,
  .toolbar select,
  .note-input {
    width: 100%;
  }

  table {
    min-width: 1180px;
  }

  .mobile-meta {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
  }
}
