:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2c313c;
  --text: #e6e8ec;
  --muted: #9aa2b1;
  --primary: #4f8cff;
  --primary-hover: #6a9dff;
  --danger: #e5534b;
  --success: #3fb950;
  --warning: #d29922;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { font-size: 120%; } /* alle Schriften +20 % */
body {
  background: var(--bg);
  color: var(--text);
  font: .9375rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .5rem; padding: .6rem 1rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.topbar nav { display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .linkbtn {
  padding: .4rem .7rem; border-radius: 6px; color: var(--muted);
}
.topbar nav a:hover, .linkbtn:hover { color: var(--text); background: var(--surface-2); }
.topbar nav a.active { color: var(--text); background: var(--surface-2); }
.linkbtn { background: none; border: 0; font: inherit; cursor: pointer; }
.navtoggle, .burger { display: none; }

@media (max-width: 760px) {
  .burger {
    display: block; width: 36px; height: 30px; cursor: pointer; position: relative;
  }
  .burger span, .burger span::before, .burger span::after {
    position: absolute; left: 6px; right: 6px; height: 2px; background: var(--text); content: "";
  }
  .burger span { top: 14px; }
  .burger span::before { top: -7px; left: 0; right: 0; }
  .burger span::after { top: 7px; left: 0; right: 0; }
  .topbar nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
  .navtoggle:checked ~ nav { display: flex; }
  .topbar nav form, .topbar nav .linkbtn { width: 100%; text-align: left; }
}

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.center {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 1rem;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem;
}
.card.login { width: 100%; max-width: 380px; }
.card.login h1 { text-align: center; margin-bottom: .25rem; }
.card.login > .muted { text-align: center; margin-top: 0; }
.card.stat { display: flex; flex-direction: column; gap: .25rem; }
.big { font-size: 2rem; }
.forgot { text-align: center; margin: 1rem 0 0; }

.grid2, .grid3, .grid5 { display: grid; gap: 0 1rem; }
.grid2 { grid-template-columns: repeat(2, 1fr); }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 900px) { .grid5 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid2, .grid3, .grid5 { grid-template-columns: 1fr; } }
.row-between { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; margin-bottom: .75rem; }

/* Formulare */
label { display: block; margin-bottom: .9rem; color: var(--muted); font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .5rem; color: var(--text); }
input[type=text], input[type=password], input[type=email], input[type=tel],
input[type=search], input[type=date], select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  padding: .6rem .7rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
#counter.over { color: var(--danger); font-weight: 600; }

.btn {
  display: inline-block; padding: .55rem 1rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; cursor: pointer; text-align: center;
}
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-small { padding: .3rem .6rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: wait; }
form.inline { display: inline; margin: 0; }

.searchbar { display: flex; gap: .5rem; margin: 1rem 0; }
.searchbar input { margin-top: 0; }
.filters .btn { margin-right: .5rem; }

/* Meldungen */
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-error { border-color: var(--danger); background: rgba(229, 83, 75, .12); color: #ffb3ae; }
.alert-success { border-color: var(--success); background: rgba(63, 185, 80, .12); color: #a7e8b0; }
.alert-info { border-color: var(--primary); background: rgba(79, 140, 255, .12); color: #bcd3ff; }
.center .alert { width: 100%; max-width: 380px; }

/* Tabellen */
.tablewrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: .6rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.msg { min-width: 220px; }
a.sort { color: var(--muted); }
a.sort.active, a.sort:hover { color: var(--text); }

.badge { display: inline-block; padding: .15rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); white-space: nowrap; }
.badge-zugestellt { color: var(--success); border-color: var(--success); }
.badge-gesendet { color: var(--primary); border-color: var(--primary); }
.badge-gepuffert { color: var(--warning); border-color: var(--warning); }
.badge-nicht_zugestellt, .badge-fehler { color: var(--danger); border-color: var(--danger); }

.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* Tabellen auf dem Handy als Karten */
@media (max-width: 700px) {
  .tablewrap { border: 0; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: flex; flex-wrap: wrap; gap: .25rem; background: none; margin-bottom: .5rem; }
  thead tr { display: flex; flex-wrap: wrap; gap: .25rem; }
  thead th { border: 1px solid var(--border); border-radius: 6px; padding: .3rem .5rem; }
  table { background: none; }
  tbody tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .5rem 0; }
  td { border: 0; padding: .3rem .9rem; }
  td[data-label]::before { content: attr(data-label); display: block; color: var(--muted); font-size: .75rem; }
  td.actions { text-align: left; }
}

/* Logo */
.brand { display: flex; align-items: center; gap: .6rem; }
.brand img { display: block; height: 28px; width: auto; }
.brand span { color: var(--muted); font-weight: 500; font-size: .9rem; }
@media (max-width: 420px) { .brand span { display: none; } }
.card.login .logo { display: block; width: 100%; max-width: 284px; height: auto; margin: 0 auto 1rem; }
.grid-zip { display: grid; grid-template-columns: 1fr 2fr; gap: 0 .75rem; }
.searchbar select { margin-top: 0; width: auto; }
.actions-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.link-success { color: var(--success); font-weight: 600; }
.link-success:hover { color: #6fd77d; }
fieldset.checks { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .9rem .2rem; margin: 0 0 1rem; }
fieldset.checks legend { color: var(--muted); font-size: .9rem; padding: 0 .3rem; }
fieldset.checks label.check { margin-bottom: .4rem; }
.hint { display: block; margin-top: .35rem; font-size: .8rem; color: var(--muted); }
.tablewrap.spaced { margin-top: 1.25rem; }
#signature { margin-top: .3rem; }
.spaced-top { margin-top: 1.25rem; }
.sms-notes { display: flex; flex-direction: column; align-items: flex-end; text-align: right; margin-left: auto; }
.cost-note { color: #f5821f; }
/* Absender und Signatur auf gleicher Hoehe: Felder unten ausrichten */
.align-end { align-items: end; }
.align-end > div { margin-bottom: .9rem; }
.align-end > div > label.check, .align-end > div > .field-title { margin-bottom: 0; }
.align-end select { margin-top: .3rem; }
/* Kosten-Info: bei Mouseover oder Klick */
.cost-wrap { position: relative; display: inline-block; }
.cost-note { background: none; border: 0; padding: 0; font: inherit; color: #f5821f; cursor: help; text-align: right; }
.cost-note:hover { text-decoration: underline dotted; }
.cost-pop {
  display: none; position: absolute; right: 0; top: 100%; z-index: 20;
  width: min(34rem, 90vw); max-height: 60vh; overflow-y: auto; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: .8rem 1rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .45); font-size: .85rem;
}
.cost-wrap:hover .cost-pop, .cost-wrap.open .cost-pop { display: block; }
.cost-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: .15rem 1rem; margin-top: .5rem; }
.cost-list > span { display: block; }
.cost-low { color: var(--success); }
.cost-estimate { color: var(--text); }
.cost-estimate.warn { color: var(--danger); font-weight: 600; }
@media (max-width: 600px) { .cost-list { grid-template-columns: 1fr; } }
