:root {
  --bg: #e8f5e9;
  --panel: #ffffff;
  --border: #d1d5db;
  --text: #101827;
  --muted: #5b6472;
  --green: #3f9b45;
  --green-dark: #08751b;
  --danger: #b42318;
  --focus: #1a73e8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

.shell {
  width: min(800px, calc(100% - 24px));
  margin: 4px auto 32px;
}

body:has(.admin-workspace) .shell {
  width: min(1120px, calc(100% - 24px));
}

.panel {
  position: relative;
  margin: 14px 0;
  padding: 30px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.accent {
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 10px;
  border-radius: 8px 8px 0 0;
  background: var(--green);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.2;
}

h2,
h3 {
  margin: 0 0 18px;
  line-height: 1.25;
}

.lead {
  margin-top: 16px;
}

ol {
  margin: 44px 0 18px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #aeb4bd;
  border-radius: 4px;
  background: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid color-mix(in srgb, var(--focus) 20%, transparent);
  border-color: var(--focus);
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}

button {
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 4px;
  background: var(--green-dark);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  background: #c6cec8;
  color: #66706a;
  cursor: not-allowed;
}

.secondary {
  border: 1px solid var(--green-dark);
  background: #ffffff;
  color: var(--green-dark);
}

.danger {
  background: var(--danger);
}

.inline-form,
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 14px;
}

.toolbar {
  grid-template-columns: repeat(2, minmax(130px, 1fr)) repeat(3, auto);
  margin-bottom: 18px;
}

.message {
  margin: 14px 0 0;
  color: var(--green-dark);
  font-weight: 700;
}

#loginMessage {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.ballot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
}

.timer {
  min-width: 92px;
  padding: 8px 12px;
  border: 2px solid var(--green);
  border-radius: 4px;
  color: var(--green-dark);
  font-size: 24px;
  font-weight: 800;
  text-align: center;
}

.office {
  padding-bottom: 26px;
}

.office + .office {
  border-top: 1px solid var(--border);
  padding-top: 26px;
}

.option {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 17px 0;
  font-weight: 400;
}

.option input {
  width: 26px;
  height: 26px;
  accent-color: var(--green-dark);
}

.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
}

.link-button {
  background: transparent;
  color: var(--green-dark);
}

summary {
  cursor: pointer;
  font-weight: 800;
}

a {
  color: var(--green-dark);
  font-weight: 700;
}

.admin-grid,
.admin-workspace {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f8faf8;
}

.admin-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f3f6f4;
}

.tab-button {
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
}

.tab-button.active {
  border-color: var(--border);
  background: #ffffff;
  color: var(--green-dark);
  box-shadow: 0 1px 4px rgb(16 24 39 / 8%);
}

.admin-section {
  display: none;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
}

.admin-section.active {
  display: grid;
  gap: 18px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  align-items: end;
  gap: 14px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button-row.compact {
  justify-content: end;
}

.button-column {
  display: flex;
  align-items: end;
  gap: 10px;
}

.settings-builder,
.ballot-builder {
  display: grid;
  gap: 14px;
}

.settings-builder h2 {
  margin: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
}

.settings-grid label:last-child {
  grid-column: span 2;
}

.section-head,
.office-card-head,
.candidate-row,
.instruction-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
}

.section-head {
  align-items: center;
  margin-bottom: 14px;
}

.section-head.compact {
  margin-top: 6px;
}

.section-head h2 {
  margin: 0;
}

.office-editor {
  display: grid;
  gap: 14px;
}

.instruction-editor {
  display: grid;
  gap: 10px;
}

.office-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fafafa;
}

.candidate-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.hint {
  margin: -8px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.submission-list {
  min-height: 284px;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 700px) {
  body {
    font-size: 16px;
  }

  .panel {
    padding: 24px 18px;
  }

  .inline-form,
  .toolbar,
  .admin-tabs,
  .control-grid,
  .settings-grid,
  .section-head,
  .office-card-head,
  .candidate-row,
  .instruction-row,
  .columns {
    grid-template-columns: 1fr;
  }

  .ballot-head,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .admin-section {
    padding: 18px;
  }

  .admin-topbar,
  .button-column,
  .button-row.compact {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-grid label:last-child {
    grid-column: auto;
  }
}
