:root {
  --bg: #ffffff;
  --ink: #071d36;
  --muted: #607086;
  --line: #d7e2ed;
  --primary: #003b71;
  --accent: #00a3e0;
  --surface: #ffffff;
  --surface-strong: #f5f8fb;
  --page-accent: #f58220;
  font-family: "Segoe UI", Arial, sans-serif;
}

body[data-theme="classic"] {
  --bg: #f7f9fc;
  --ink: #18212f;
  --muted: #667085;
  --line: #d0d5dd;
  --primary: #1f2937;
  --accent: #0f766e;
  --surface-strong: #eef2f7;
  --page-accent: #0f766e;
}

body[data-theme="union"] {
  --bg: #fffdf8;
  --ink: #2b1d1b;
  --muted: #735b55;
  --line: #ead5c8;
  --primary: #8f1d14;
  --accent: #f2b705;
  --surface-strong: #fff5eb;
  --page-accent: #f2b705;
}

body[data-theme="sport"] {
  --bg: #f8fbf7;
  --ink: #10251a;
  --muted: #557063;
  --line: #cfe3d7;
  --primary: #0b6b3a;
  --accent: #9bd326;
  --surface-strong: #edf7ef;
  --page-accent: #9bd326;
}

body[data-theme="minimal"] {
  --bg: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #111827;
  --accent: #d1d5db;
  --surface-strong: #f9fafb;
  --page-accent: #9ca3af;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    linear-gradient(90deg, var(--page-accent) 0 8px, transparent 8px),
    var(--bg);
  color: var(--ink);
}
a { color: inherit; font-weight: 800; }
h1, h2, h3 { overflow-wrap: anywhere; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 22px clamp(16px, 4vw, 48px);
  color: white;
  background: linear-gradient(120deg, #001f3f, #003b71, #006da8);
  border-bottom: 5px solid var(--page-accent);
}
body[data-theme="classic"] .topbar { background: linear-gradient(120deg, #111827, #374151); }
body[data-theme="union"] .topbar { background: linear-gradient(120deg, #6f130d, #8f1d14); }
body[data-theme="sport"] .topbar { background: linear-gradient(120deg, #064e2a, #0b6b3a); }
body[data-theme="minimal"] .topbar { background: #111827; }
.topbar h1 { margin: 0; }
.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 18px;
  padding: 24px clamp(16px, 4vw, 48px);
}
.panel, .login-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(0, 31, 63, .10);
  padding: 18px;
}

.panel h2, .login-card h1 {
  border-left: 6px solid var(--page-accent);
  padding-left: 10px;
}
.wide { grid-column: 1 / -1; }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(0,59,113,.08), white);
}
.login-card { width: min(440px, calc(100vw - 32px)); }
.language-form {
  margin-bottom: 14px;
}
.language-form.compact {
  margin: 0;
}
.language-form.compact label {
  color: white;
}
.language-form.compact select {
  min-height: 34px;
  padding: 5px 8px;
}
form { display: grid; gap: 12px; }
.inline-settings {
  max-width: 360px;
  margin-bottom: 14px;
}
td form { display: flex; flex-wrap: wrap; gap: 8px; }
.member-editor form { display: grid; }
label { display: grid; gap: 5px; color: var(--muted); font-weight: 750; }
input, button, textarea, select {
  min-height: 44px;
  border-radius: 4px;
  font: inherit;
}
input, textarea, select {
  border: 1px solid var(--line);
  padding: 9px 10px;
  background: white;
}
button {
  border: 0;
  background: var(--primary);
  color: white;
  padding: 9px 14px;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 4px;
  padding: 9px 14px;
  text-decoration: none;
  font-weight: 900;
}
.danger-button { background: #b42318; color: white; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; }
.alert { border: 1px solid #f4b4b4; background: #fff0f0; padding: 10px; color: #8a1f1f; }
.notice { border: 1px solid #9bd2ad; background: #effaf2; padding: 10px; color: #17652d; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0; }
.audit-list { display: grid; gap: 8px; color: var(--muted); }
.poll-card { border-left: 5px solid var(--primary); padding: 12px; background: var(--surface-strong); }
body[data-theme="union"] .poll-card { border-left-color: var(--page-accent); }
body[data-theme="sport"] .poll-card { border-left-color: var(--page-accent); }
body[data-theme="minimal"] .poll-card { border-left-color: var(--line); }
.secondary-form { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 18px; }
.secondary-button { background: var(--accent); color: #05263d; }
.checkline { display: flex; grid-template-columns: none; align-items: center; gap: 10px; }
.checkline input { min-height: auto; width: auto; }
.poll-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.poll-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.poll-actions form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.result-list, .vote-grid { display: grid; gap: 10px; margin-top: 12px; }
.result-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 3fr) 48px;
  gap: 10px;
  align-items: center;
}
.bar { height: 12px; background: #d9e7f2; border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }
.vote-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.vote-box {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}
.vote-box span { display: block; color: var(--muted); margin: 3px 0 10px; }
.voted { color: #17652d; font-weight: 850; }
details summary { cursor: pointer; list-style-position: outside; }
.member-editor {
  display: grid;
  gap: 14px;
  margin-top: 14px;
  max-width: 760px;
}
.delegation-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: white;
}
.delegation-box h3 { margin-top: 0; }
.danger-zone {
  border: 1px solid #f4b4b4;
  border-radius: 8px;
  background: #fff7f7;
  margin-bottom: 16px;
  padding: 12px;
}
.danger-zone summary {
  color: #8a1f1f;
  font-weight: 900;
}
.plain-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}
.plain-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inline-form { display: inline-flex; }
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #fff0f0;
  color: #8a1f1f;
  font-size: .78rem;
  font-weight: 850;
}
.badge.success {
  background: #e8f7ee;
  color: #146b39;
}
.badge.warning {
  background: #fff5d7;
  color: #7a4d00;
}
.print-report {
  max-width: 920px;
  margin: 0 auto;
  padding: 30px 18px;
}
.report-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 12px;
}
.report-meta div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.report-meta dt { color: var(--muted); font-weight: 800; }
.report-meta dd { margin: 4px 0 0; font-size: 1.2rem; font-weight: 900; }

@media print {
  .no-print { display: none !important; }
  body { background: white; }
  .print-report { padding: 0; max-width: none; }
  .panel {
    box-shadow: none;
    border: 0;
    padding: 0;
  }
  .bar { border: 1px solid #c8d6e2; }
}

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

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px 16px;
  }
  .topbar nav {
    width: 100%;
    justify-content: space-between;
  }
  .layout {
    padding: 16px;
    gap: 14px;
  }
  .panel, .login-card {
    padding: 14px;
    box-shadow: 0 8px 22px rgba(0, 31, 63, .08);
  }
  .login-page {
    align-items: start;
    padding: 16px 0;
  }
  input, button, textarea, select, .button-link {
    width: 100%;
  }
  td form, .poll-actions, .poll-actions form {
    display: grid;
    width: 100%;
  }
  table {
    display: grid;
    gap: 12px;
    border-collapse: separate;
    white-space: normal;
  }
  thead {
    display: none;
  }
  tbody, tr, td {
    display: block;
    width: 100%;
  }
  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    padding: 10px;
  }
  td {
    border-bottom: 0;
    padding: 8px 0;
  }
  td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .02em;
  }
  th, td {
    vertical-align: top;
  }
  .poll-head {
    flex-direction: column;
  }
  .result-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .vote-grid {
    grid-template-columns: 1fr;
  }
  .plain-list li {
    display: grid;
    justify-items: start;
  }
  .report-meta {
    grid-template-columns: 1fr;
  }
  details summary {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .member-editor {
    max-width: none;
  }
  .delegation-box {
    padding: 10px;
  }
}

@media (max-width: 430px) {
  .topbar h1 {
    font-size: 1.2rem;
  }
  .topbar nav {
    display: grid;
    gap: 10px;
  }
  .language-form.compact label {
    width: 100%;
  }
  h2 {
    font-size: 1.1rem;
  }
  .panel, .login-card {
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .layout {
    padding: 12px 0;
  }
  .poll-card {
    border-left-width: 3px;
    padding: 10px;
  }
}
