
:root {
  color-scheme: light;
  --ink: #19201d;
  --muted: #5f6f68;
  --line: #d7ded9;
  --paper: #f7f8f5;
  --panel: #ffffff;
  --accent: #176b5b;
  --accent-dark: #0f463d;
  --warn: #b42318;
  --ok: #1f7a45;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea,
.panel,
.result,
.result-main,
.result-main > *,
.vote-form,
.vote-form > *,
label,
.app-grid > *,
.panel-header > * {
  min-width: 0;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--ink);
  text-decoration: none;
  font-weight: 800;
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand span {
  overflow-wrap: anywhere;
}

.brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 6px;
  flex: 0 0 auto;
}

nav {
  display: flex;
  gap: 10px;
  align-items: center;
}

nav form {
  margin: 0;
}

.nav-link,
.icon-button,
.secondary,
.link-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

.primary {
  border: 0;
  background: var(--accent);
  color: white;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

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

.primary:disabled {
  cursor: wait;
  opacity: .72;
}

.danger {
  border: 1px solid #b42318;
  background: #fff;
  color: #b42318;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.danger:hover {
  background: #fff0ee;
}

.login-page {
  min-height: calc(100vh - 64px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(560px, 100%);
  display: grid;
  gap: 24px;
}

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

h1 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.12;
}

h2 {
  margin-bottom: 4px;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.muted,
.result p {
  color: var(--muted);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 20px;
  padding: 24px;
  align-items: start;
}

.backoffice {
  padding: 24px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  overflow: hidden;
}

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

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #dfeee8;
  color: var(--accent-dark);
  font-weight: 800;
  flex: 0 0 auto;
}

.notice {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid;
}

.notice.success {
  color: var(--ok);
  background: #edf8f0;
}

.notice.error {
  color: var(--warn);
  background: #fff0ee;
}

.vote-form,
.category-stack,
.json-form,
.settings-form,
.publish-form {
  display: grid;
  gap: 16px;
}

.publish-form {
  justify-items: start;
}

.admin-panel {
  margin-bottom: 20px;
}

.admin-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.admin-form input,
.settings-form input,
.email-login-form input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.nav-login {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}

.email-login-form {
  display: grid;
  gap: 12px;
}

.email-login-form.compact {
  display: flex;
  align-items: center;
  gap: 8px;
}

.email-login-form.compact input {
  width: 190px;
  min-height: 38px;
  padding: 8px 10px;
}

.nav-login .primary,
.nav-login .secondary {
  min-height: 38px;
  padding: 8px 12px;
  white-space: nowrap;
}

.settings-form {
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1.5fr) auto;
  align-items: end;
}

.logo-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.local-logo-help {
  margin: 12px 0 0;
  font-size: 14px;
}

.local-logo-help code {
  color: var(--ink);
  background: #eef3ef;
  padding: 2px 5px;
  border-radius: 5px;
}

.admin-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.admin-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.admin-row span {
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 8px;
  font-weight: 700;
}

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

select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

option {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.range-row {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 1.4fr) 40px;
  align-items: center;
  gap: 12px;
}

.range-row small {
  color: var(--muted);
  font-weight: 600;
}

output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.own-votes {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.own-vote-list {
  display: grid;
  gap: 10px;
}

.own-vote {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.own-vote-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.own-vote-header strong {
  overflow-wrap: anywhere;
}

.own-vote-header span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.own-vote-score {
  margin-top: 8px;
  color: var(--accent-dark);
  font-weight: 800;
}

.own-vote-categories {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.own-vote-categories span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--muted);
  font-size: 13px;
}

.result-list {
  display: grid;
  gap: 12px;
}

.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.result-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
}

.result h2,
.result p {
  overflow-wrap: anywhere;
  word-break: normal;
}

.score {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  justify-self: end;
  line-height: 1;
}

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

summary {
  cursor: pointer;
  font-weight: 700;
}

.votes-table {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 80px 150px;
  gap: 8px 12px;
  margin-top: 12px;
  font-size: 14px;
}

.table-head {
  color: var(--muted);
  font-weight: 800;
}

.voter-status {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.section-heading h2 {
  margin-bottom: 12px;
}

.voter-list {
  display: grid;
  gap: 12px;
}

.voter-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

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

.voter-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.voter-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.voter-header span {
  color: var(--accent-dark);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.project-status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.project-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 4px;
}

.project-status span {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.project-status strong {
  font-size: 18px;
}

.project-status.is-voted {
  background: #eef8f3;
}

.project-status.is-missing {
  background: #fff7ed;
}

.project-status.is-missing strong {
  color: #9a3412;
  font-size: 14px;
}

textarea {
  min-height: 520px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

@media (max-width: 820px) {
  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 12px;
  }

  .brand {
    flex: 1 1 220px;
    min-width: 0;
  }

  nav {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .nav-login {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .email-login-form.compact {
    flex: 1 1 260px;
    min-width: 0;
  }

  .email-login-form.compact input {
    flex: 1 1 160px;
    width: auto;
    min-width: 0;
  }

  .app-grid {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .backoffice {
    padding: 16px;
  }

  .admin-form,
  .settings-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-row {
    align-items: stretch;
    flex-direction: column;
  }

  .range-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .result-main {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
  }

  .score {
    font-size: 28px;
  }

  .votes-table {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-head {
    display: none;
  }
}
