:root {
  --kies: #e8ebe7;
  --papier: #f8f9f6;
  --tinte: #13262b;
  --tinte-2: #4a5d62;
  --linie: #cdd5d1;
  --tiefsee: #1b6b73;
  --tiefsee-dunkel: #12373f;
  --schilf: #7d8f2f;
  --rost: #b0402a;
  --gold: #c58a1b;
  --radius: 6px;
  --slab: Rockwell, "Roboto Slab", "Rockwell Nova", Cambria, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 15px; }
body {
  margin: 0;
  background: var(--kies);
  color: var(--tinte);
  font-family: var(--sans);
  line-height: 1.45;
}

h1, h2, h3 { font-family: var(--slab); font-weight: 700; line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--tiefsee); outline-offset: 2px; }

/* ---------- Kopfzeile ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  min-height: 56px;
  background: var(--tiefsee-dunkel);
  color: #eef3f1;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .65rem; }
.brand img { height: 26px; width: auto; }
.brand h1 { font-size: 1.15rem; color: #fff; letter-spacing: .01em; }
.tabs { display: flex; gap: .15rem; align-self: stretch; margin-right: auto; }
.tabs a {
  display: flex;
  align-items: center;
  padding: 0 .9rem;
  color: #b9cdd0;
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: #fff; }
.tabs a[aria-current="page"] { color: #fff; border-bottom-color: var(--gold); }
.userbox { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: #cfdcdc; }
.userbox .who strong { color: #fff; font-weight: 600; }
.userbox .btn { color: #fff; border-color: #3f6870; background: transparent; padding: .3rem .7rem; }
.userbox .btn:hover { background: #1c4a54; }

main { padding: 1rem 1.25rem 2rem; }
.view-title { display: flex; align-items: baseline; gap: .75rem; flex-wrap: wrap; margin-bottom: .75rem; }
.view-title h2 { font-size: 1.4rem; }
.muted { color: var(--tinte-2); }
.small { font-size: .85rem; }

/* ---------- Buttons & Felder ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem .9rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: var(--papier);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--tinte-2); }
.btn.primary { background: var(--tiefsee); border-color: var(--tiefsee); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #155860; }
.btn.danger { background: var(--rost); border-color: var(--rost); color: #fff; font-weight: 600; }
.btn.danger-outline { color: var(--rost); border-color: #dbb3a9; }
.btn.danger-outline:hover { background: #f7e7e3; border-color: var(--rost); }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { border: 0; background: transparent; font-size: 1.5rem; line-height: 1; cursor: pointer; padding: .1rem .5rem; color: var(--tinte-2); }
.icon-btn:hover { color: var(--tinte); }

input[type=text], input[type=search], input[type=email], input[type=tel], input[type=date],
input[type=number], input[type=password], select, textarea {
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  background: #fff;
}
textarea { min-height: 5rem; resize: vertical; }
input[aria-invalid=true], select[aria-invalid=true] { border-color: var(--rost); }
.err { color: var(--rost); font-size: .83rem; margin-top: .2rem; }

/* ---------- Werkzeugleiste ---------- */
.summary {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.summary a, .summary span.none {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid var(--linie);
  background: var(--papier);
  text-decoration: none;
  color: var(--tinte);
  font-size: .9rem;
}
.summary a:hover { border-color: var(--tiefsee); }
.summary .none { color: var(--tinte-2); }

.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .5rem; }
.searchbox { flex: 1 1 280px; max-width: 460px; }
.toolbar .spacer { flex: 1; }
.hint { font-size: .82rem; color: var(--tinte-2); margin: 0 0 .5rem; }

/* ---------- Tabelle ---------- */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 250px);
  min-height: 220px;
  background: var(--papier);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
}
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .92rem; }
th, td { padding: .42rem .7rem; text-align: left; white-space: nowrap; border-bottom: 1px solid #e1e6e2; }
thead th { position: sticky; background: #dfe7e4; z-index: 2; }
thead tr.heads th { top: 0; height: 38px; border-bottom: 1px solid var(--linie); font-weight: 600; }
thead tr.filters th { top: 38px; padding: .3rem .4rem; background: #eaf0ed; font-weight: 400; }
thead tr.filters input, thead tr.filters select { padding: .25rem .4rem; font-size: .85rem; min-width: 5.5rem; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #d3dedb; }
th .arrow { display: inline-block; width: 1em; color: var(--tiefsee); }
tbody tr { cursor: pointer; }
tbody tr:nth-child(even) { background: #f1f4f1; }
tbody tr:hover { background: #e2edeb; }
tbody tr:focus-visible { outline-offset: -2px; }
td.num { font-variant-numeric: tabular-nums; }
td.actions { text-align: right; width: 1%; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--tinte-2); }

.pill { display: inline-block; padding: .05rem .6rem; border-radius: 999px; font-size: .8rem; border: 1px solid transparent; background: none; }
.pill.bezahlt { background: #e3ecc8; color: #46550f; border-color: #c7d79a; }
.pill.offen { background: #f7e4c4; color: #7a4f06; border-color: #e6c88c; }
button.pill { cursor: pointer; }
button.pill:hover { filter: brightness(.95); }

.badge { margin-left: .35rem; font-size: .95rem; cursor: help; }

/* ---------- Dialoge ---------- */
dialog.dlg {
  border: 0;
  border-radius: 10px;
  padding: 0;
  width: min(640px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  background: var(--papier);
  color: var(--tinte);
  box-shadow: 0 18px 50px rgba(8, 25, 30, .35);
}
dialog.dlg.wide { width: min(820px, calc(100vw - 1.5rem)); }
dialog.dlg::backdrop { background: rgba(10, 30, 35, .5); }
dialog.dlg > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .8rem 1rem .8rem 1.25rem;
  border-bottom: 1px solid var(--linie);
  background: #e4ebe8;
  position: sticky; top: 0;
}
dialog.dlg h2 { font-size: 1.15rem; }
.dlg-body { padding: 1.1rem 1.25rem 1.25rem; }
.dlg-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.1rem; align-items: center; }
.dlg-actions .left { margin-right: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem 1rem; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .2rem; }
.field .req { color: var(--rost); }
.field.wide { grid-column: 1 / -1; }
dl.details { display: grid; grid-template-columns: 11rem 1fr; gap: .45rem 1rem; margin: 0; }
dl.details dt { color: var(--tinte-2); }
dl.details dd { margin: 0; font-weight: 500; }

/* ---------- Panels (Einstellungen u. a.) ---------- */
.panel { background: var(--papier); border: 1px solid var(--linie); border-radius: var(--radius); padding: 1rem 1.25rem 1.25rem; margin-bottom: 1rem; max-width: 900px; }
.panel h3 { font-size: 1.05rem; margin-bottom: .2rem; }
.panel > p.muted { margin: 0 0 .9rem; }
.rows { display: grid; gap: .9rem; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.lead { display: grid; grid-template-columns: 1fr 5.5rem 7rem; gap: .5rem; align-items: center; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .35rem .8rem; }
.checks label { display: flex; gap: .45rem; align-items: center; font-weight: 400; }
.notice { padding: .6rem .8rem; border-radius: var(--radius); border: 1px solid var(--linie); background: #eef2ef; font-size: .9rem; }
.notice.warn { background: #fbf0d9; border-color: #ebce94; }
.notice.bad { background: #f8e4df; border-color: #e1b1a6; }
.notice.ok { background: #e8f0d3; border-color: #c9d99b; }
.savebar { position: sticky; bottom: 0; display: flex; gap: .75rem; align-items: center; padding: .75rem 0; max-width: 900px; }

.tag { display: inline-block; padding: .05rem .55rem; border-radius: 4px; font-size: .82rem; background: #e0e8e4; }
.tag.round_birthday { background: #f6e1b3; }
.tag.birthday { background: #d9e8ea; }
.tag.anniversary { background: #e1e8c4; }
.plain-table { background: var(--papier); border: 1px solid var(--linie); border-radius: var(--radius); overflow: auto; max-width: 1000px; }

/* ---------- Anmeldung: Fischerkarte ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: var(--tiefsee-dunkel); }
.license {
  display: grid;
  grid-template-columns: 11rem 1fr;
  width: min(640px, 100%);
  background: var(--papier);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.license .stub {
  background: var(--tiefsee);
  color: #e9f2f0;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 2px dashed #a9c9c6;
  position: relative;
}
.license .stub img { width: 72px; filter: brightness(0) invert(1); opacity: .9; }
.license .stub p { margin: 0; font-size: .8rem; line-height: 1.35; opacity: .85; }
.license .body { padding: 1.75rem 1.75rem 1.5rem; }
.license h1 { font-size: 1.5rem; margin-bottom: .25rem; }
.license .sub { margin: 0 0 1.25rem; color: var(--tinte-2); }
.license form { display: grid; gap: .85rem; }
.license .btn { justify-content: center; padding: .6rem 1rem; }

/* ---------- Meldungen ---------- */
#toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: grid; gap: .5rem; z-index: 50; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { padding: .65rem 1rem; border-radius: var(--radius); background: var(--tinte); color: #fff; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.toast.error { background: var(--rost); }

.print-only { display: none; }

/* ---------- Beitrag ---------- */
.plain-table tbody tr { cursor: default; }
.plain-table td.actions { text-align: right; }
.plain-table th:first-child, .plain-table td:first-child { width: 2.2rem; padding-right: 0; }
.space { margin-bottom: .75rem; }
label.inline { display: inline-flex; align-items: center; gap: .45rem; font-weight: 400; }
.narrow { display: inline-block; }
.narrow input[type=number] { width: 6.5rem; }
.wide-sel select { width: auto; }
.sendbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: .75rem; max-width: 1000px; padding: .75rem 0; background: linear-gradient(to top, var(--kies) 70%, transparent); }
.preview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 1.25rem; align-items: start; }
pre.mailtext { white-space: pre-wrap; font-family: var(--sans); background: #fff; border: 1px solid var(--linie); border-radius: var(--radius); padding: .8rem 1rem; margin: .9rem 0 0; font-size: .92rem; }
.qrbox { text-align: center; }
img.qr { width: 240px; height: 240px; image-rendering: pixelated; border: 1px solid var(--linie); border-radius: var(--radius); background: #fff; }

@media (max-width: 720px) {
  .preview-grid { grid-template-columns: 1fr; }
  .form-grid, .row2 { grid-template-columns: 1fr; }
  .license { grid-template-columns: 1fr; }
  .license .stub { flex-direction: row; align-items: center; border-right: 0; border-bottom: 2px dashed #a9c9c6; padding: .9rem 1.1rem; gap: 1rem; }
  .license .stub img { width: 48px; }
  dl.details { grid-template-columns: 1fr; gap: 0; }
  dl.details dd { margin-bottom: .5rem; }
  .lead { grid-template-columns: 1fr 5rem 6.5rem; }
  .table-wrap { max-height: calc(100vh - 330px); }
}

@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 9pt; }
  .app-header, .toolbar, .summary, .hint, #toasts, .no-print, thead tr.filters, td.actions, th.actions { display: none !important; }
  main { padding: 0; }
  .table-wrap { max-height: none; overflow: visible; border: 0; background: #fff; }
  table { font-size: 8pt; }
  th, td { padding: 2px 5px; white-space: normal; }
  thead th { position: static; background: #fff; border-bottom: 1.5px solid #000; }
  tbody tr:nth-child(even) { background: #f3f3f3; }
  .print-only { display: block; margin-bottom: 6mm; }
  .print-only h2 { font-size: 14pt; }
  .badge { display: none; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}
