/* ==========================================================================
   Anonymes Abstimmungssystem - eigenes, schlankes Stylesheet.
   Keine Fremdbibliothek, keine externen Schriften, keine Netzverbindung.
   ========================================================================== */

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --text:      #1f2430;
  --muted:     #6b7280;
  --primary:   #2f6feb;
  --primary-d: #2357bd;
  --ok-bg:     #e7f6ec;  --ok-fg:   #1a6b38;  --ok-bd:   #b7e2c6;
  --err-bg:    #fdeaea;  --err-fg:  #a12626;  --err-bd:  #f3c2c2;
  --warn-bg:   #fef6e7;  --warn-fg: #8a5a00;  --warn-bd: #f2ddb0;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

a { color: var(--primary); }

/* ------------------------------------------------------------- Kopfzeile */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.topbar-inner {
  max-width: 1000px; margin: 0 auto;
  display: flex; align-items: center; gap: 28px;
  min-height: 58px; flex-wrap: wrap;
}
.brand { font-weight: 700; font-size: 16px; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 20px; flex: 1; }
.topbar nav a {
  text-decoration: none; color: var(--muted); font-weight: 600;
  padding: 6px 0; border-bottom: 2px solid transparent;
}
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.topbar .who { color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- Layout */
.wrap { max-width: 1000px; margin: 0 auto; padding: 28px 24px 64px; }
.wrap.narrow { max-width: 460px; }
.wrap.mid { max-width: 680px; }

.centered { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }

h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 28px 0 10px; }
.lead { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 18px;
}
.card.tight { padding: 18px 20px; }

/* ------------------------------------------------------------ Formulare */
label { display: block; font-weight: 600; margin-bottom: 6px; }
.field { margin-bottom: 18px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 4px; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=datetime-local] {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff;
}
input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

input.code {
  font-size: 26px; letter-spacing: 10px; text-align: center;
  font-family: "Consolas", ui-monospace, monospace; padding: 12px;
}

.btn {
  display: inline-block; border: 0; border-radius: 6px;
  background: var(--primary); color: #fff;
  padding: 10px 20px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--primary-d); }
.btn.secondary { background: #eceef2; color: var(--text); }
.btn.secondary:hover { background: #e0e3e9; }
.btn.small { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 24px; }

/* ------------------------------------------------- Auswahlmöglichkeiten */
.choice-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.choice-row input { flex: 1; }

.option {
  display: flex; align-items: flex-start; gap: 11px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 12px 14px; margin-bottom: 9px; cursor: pointer;
  background: #fff;
}
.option:hover { border-color: var(--primary); }
.option input { margin: 3px 0 0; flex: none; width: 17px; height: 17px; cursor: pointer; }
.option span { font-weight: 500; }
.option.checked { border-color: var(--primary); background: #f5f8ff; }

/* ------------------------------------------------------------- Meldungen */
.msg { border-radius: 6px; padding: 11px 14px; margin-bottom: 18px; border: 1px solid; }
.msg.ok   { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-bd); }
.msg.err  { background: var(--err-bg);  color: var(--err-fg);  border-color: var(--err-bd); }
.msg.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.msg ul { margin: 6px 0 0; padding-left: 20px; }

/* --------------------------------------------------------------- Tabelle */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- Status */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; border: 1px solid;
}
.badge.geplant   { background: #eef1f6; color: #4a5568; border-color: #d6dbe4; }
.badge.aktiv     { background: var(--ok-bg);   color: var(--ok-fg);   border-color: var(--ok-bd); }
.badge.beendet   { background: #e8eefc; color: #23459b; border-color: #c6d5f5; }
.badge.ungueltig { background: var(--err-bg);  color: var(--err-fg);  border-color: var(--err-bd); }

/* -------------------------------------------------------------- Ergebnis */
.result-row { margin-bottom: 11px; }
.result-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.result-head b { font-variant-numeric: tabular-nums; }
.bar { height: 7px; background: #eceef2; border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--primary); }

.meta { color: var(--muted); font-size: 13px; }
.meta b { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------- QR-Code */
.qr { text-align: center; margin: 20px 0; }
.qr img { border: 1px solid var(--border); border-radius: 6px; background: #fff; padding: 8px; }
.secret {
  font-family: "Consolas", ui-monospace, monospace;
  background: #f0f2f5; border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; text-align: center; letter-spacing: 2px; word-break: break-all;
  font-size: 14px;
}

/* ---------------------------------------------------------------- Link */
.linkbox {
  font-family: "Consolas", ui-monospace, monospace; font-size: 13px;
  background: #f0f2f5; border: 1px solid var(--border); border-radius: 6px;
  padding: 11px; word-break: break-all;
}

.footnote { color: var(--muted); font-size: 13px; margin-top: 22px; }
.empty { color: var(--muted); text-align: center; padding: 34px 0; }

/* ------------------------------------------------------------- Restzeit */
.timer {
  display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 13px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.timer .timer-value { font-weight: 700; color: var(--text); }
.timer.warn .timer-value { color: var(--warn-fg); }
.timer.crit .timer-value { color: var(--err-fg); }

/* Prominente Variante auf dem Stimmzettel */
.timer-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: #f7f8fa; padding: 10px 14px; margin-bottom: 18px;
}
.timer-box .timer { font-size: 14px; }
.timer-box .timer .timer-value { font-size: 20px; }
.timer-box.warn { background: var(--warn-bg); border-color: var(--warn-bd); }
.timer-box.crit { background: var(--err-bg);  border-color: var(--err-bd); }

/* -------------------------------------------------- Kreisdiagramm */
.pie-container {
  display: flex; align-items: center; gap: 24px;
  flex-wrap: wrap; margin: 8px 0 4px;
}
.pie {
  width: 220px; height: 220px; flex: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.06));
}
.pie path, .pie circle { stroke: #fff; stroke-width: 1.5; }

.pie-legend {
  list-style: none; margin: 0; padding: 0;
  flex: 1; min-width: 240px;
}
.pie-legend li {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.pie-legend li:last-child { border-bottom: 0; }
.pie-swatch {
  display: inline-block; width: 14px; height: 14px; border-radius: 3px;
  flex: none;
}
.pie-label {
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pie-value {
  font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--text); white-space: nowrap;
}

@media (max-width: 600px) {
  .pie-container { flex-direction: column; align-items: stretch; }
  .pie { align-self: center; }
}

/* ------------------------------------------------------------- Branding */
/* Admin-Topbar: Logo + Sekundaertext */
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  min-height: 42px;                 /* damit die Zeile stabil bleibt */
}
.brand-logo {
  height: 32px; width: auto; display: block;
  /* Kein Farbkasten - das Logo steht direkt auf dem Seitenhintergrund. */
}
/* Oeffentliche Seiten: Logo oben LINKS am Seitenrand (nicht ueber der Karte).
   Absolut positioniert, damit die zentrierte Karte davon unabhaengig bleibt. */
.public-brand {
  position: absolute; top: 20px; left: 24px; z-index: 10;
  display: inline-block; line-height: 0;
}
.public-brand-logo {
  height: 40px; width: auto; display: block;
  /* Kein Farbkasten. */
}

/* Fusszeile fuer alle Seiten */
.site-foot {
  max-width: 1000px; margin: 40px auto 0;
  padding: 20px 24px 24px; text-align: center;
  color: var(--muted); font-size: 12px;
}
.site-foot::before {
  content: ""; display: block; height: 1px;
  background: var(--border); max-width: 200px; margin: 0 auto 14px;
}

/* Auf oeffentlichen Seiten sitzt der Fuss innerhalb des zentrierten Bereichs */
.centered .site-foot { max-width: none; margin-top: 24px; padding: 16px 0 0; }

/* Export-Kopf und -Fuss ergaenzen */
.export-brand { display: flex; align-items: center; gap: 10px; }
.export-brand-logo {
  height: 34px; width: auto; display: block;
  /* Kein Farbkasten. */
}
.export-devnote { margin-top: 6px; font-style: italic; }
