:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #162018;
  --muted: #667064;
  --line: #d8ded5;
  --accent: #2f6f4e;
  --accent-dark: #24583e;
  --warn: #fff3cd;
  --warn-line: #e1bd55;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--accent-dark); }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  min-height: 56px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  align-self: center;
}

nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

nav a {
  color: var(--muted);
  font-weight: 650;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
}

nav a:hover {
  color: var(--ink);
  background: var(--bg);
}

nav a.active {
  color: var(--accent);
  font-weight: 800;
  background: #fff;
  border-color: var(--line);
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1, h2 {
  margin: 0 0 14px;
  line-height: 1.15;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.2rem; margin-top: 28px; }

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

.filters {
  display: flex;
  gap: 10px;
  margin: 0 0 16px;
}

.mode-form {
  margin: 0;
}

.mode-form label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.mode-form select {
  width: auto;
  min-width: 150px;
}

input, select, textarea, button, .button {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

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

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover, .button:hover { background: var(--accent-dark); }

button.secondary {
  background: #ffffff;
  color: var(--accent-dark);
}

button.secondary:hover {
  background: #eef2eb;
}

button.danger {
  background: #a2352a;
  border-color: #a2352a;
}

button.danger:hover {
  background: #84291f;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}

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

th {
  background: #eef2eb;
  font-size: .9rem;
}

.empty {
  color: var(--muted);
  text-align: center;
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.summary div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.summary span {
  display: block;
  color: var(--muted);
  font-size: .85rem;
  margin-bottom: 4px;
}

.summary strong { font-size: 1.25rem; }

.copy-panel {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
  max-width: 920px;
}

.copy-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 650;
}

.copy-panel textarea {
  min-height: 90px;
}

.copy-panel button {
  justify-self: start;
}

.form {
  display: grid;
  gap: 14px;
  max-width: 920px;
}

.form label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.row-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}

.checkbox {
  display: inline-flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
}

.checkbox input {
  width: auto;
}

.actions {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 12px;
}

.alert {
  border: 1px solid var(--warn-line);
  background: var(--warn);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 18px;
}

.alert p { margin: 4px 0; }
.alert.success { border-color: var(--line); background: var(--bg); }
.plain-list { padding-left: 20px; }
.notes { white-space: pre-wrap; }

.vote-sheet th,
.vote-sheet td {
  white-space: nowrap;
}

.vote-sheet td:first-child,
.vote-sheet th:first-child,
.vote-sheet td:last-child,
.vote-sheet th:last-child {
  white-space: normal;
}

.number {
  text-align: right;
}

.vote-sheet input[type="radio"] {
  width: auto;
  min-width: 18px;
}

.notes-input {
  min-width: 180px;
}

.print-title {
  display: none;
}

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-container {
  width: min(420px, calc(100% - 32px));
  margin: 0;
}

.login-container h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 24px;
}

.login-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

/* User list row actions */
.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-actions a {
  font-weight: 650;
  font-size: 0.9rem;
}

.row-actions button {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.85rem;
}

.delete-form {
  display: inline;
}

.logout-link {
  color: var(--muted) !important;
  font-weight: 400 !important;
  font-size: 0.9rem;
}

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

  .topbar {
    padding-bottom: 0;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}

@media print {
  body {
    background: #fff;
    color: #000;
    font-size: 11px;
  }

  .topbar,
  .print-hidden,
  .filters,
  .button,
  button {
    display: none !important;
  }

  .page {
    width: 100%;
    margin: 0;
  }

  .print-title {
    display: block;
  }

  h1 {
    font-size: 18px;
  }

  .summary {
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin: 8px 0;
  }

  .summary div,
  table {
    border-color: #999;
  }

  .summary div {
    padding: 5px;
  }

  th,
  td {
    padding: 4px;
  }

  input {
    border: 0;
    padding: 0;
    min-height: 0;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}
