* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; font: 15px/1.45 system-ui, sans-serif; background: #f3f4f6; color: #1f2937; }
img { max-width: 100%; }

/* Kopfzeile */
header { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem 1.5rem; padding: .6rem 1.2rem; background: #1e3a5f; color: #fff; }
header a { color: #cfe3ff; text-decoration: none; }
header a:hover { color: #fff; }
header a.brand { display: inline-flex; align-items: center; gap: .6rem; color: #fff; font-weight: bold; }
header .menu { flex: 1; display: flex; align-items: center; gap: .4rem 1.5rem; }
header nav { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
header .user { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
header .menu-toggle { display: none; margin-left: auto; width: 2.6rem; height: 2.6rem; padding: 0; background: none; color: #fff; border-radius: 6px; line-height: 0; }
header .menu-toggle:hover, header .menu-toggle:focus-visible { background: #ffffff25; }
header .menu-toggle svg { width: 1.6rem; height: 1.6rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
header button.link { color: #cfe3ff; }
img.logo { height: 40px; width: auto; }
img.logo-login { display: block; margin: 0 auto 1rem; height: auto; }

main { width: 100%; max-width: 1000px; margin: 1.2rem auto; padding: 0 1rem; flex: 1 0 auto; }

/* Fußzeile: unten am Fensterrand (bei kurzem Inhalt), sonst unter dem Inhalt */
footer { flex-shrink: 0; padding: .9rem 1rem; text-align: center; font-size: .85rem; color: #6b7280; border-top: 1px solid #e5e7eb; overflow-wrap: anywhere; }
h1 { font-size: 1.4rem; margin: 0 0 .8rem; } h1 small { color: #6b7280; font-weight: normal; }
h2 { font-size: 1.1rem; }
.card { background: #fff; padding: 1.2rem; border-radius: 8px; box-shadow: 0 1px 3px #0002; margin-bottom: 1.2rem; }
.card.narrow { max-width: 380px; margin: 4rem auto; }

/* Formulare */
label { display: block; margin-bottom: .8rem; font-weight: 500; }
label.check { font-weight: normal; }
input, select, textarea { display: block; width: 100%; padding: .45rem .6rem; margin-top: .2rem; border: 1px solid #cbd5e1; border-radius: 5px; font: inherit; }
input[type=checkbox] { display: inline; width: auto; margin-right: .4rem; }
.toolbar form input, .toolbar form select, .row input { display: inline-block; width: auto; margin: 0; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.toolbar { display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar h1 { margin: 0; flex: 1; }
.toolbar form { display: flex; gap: .4rem; flex-wrap: wrap; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
button, .btn { padding: .45rem .9rem; border: 0; border-radius: 5px; background: #2563eb; color: #fff; font: inherit; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { background: #1d4ed8; }
button.secondary, .btn.secondary { background: #64748b; }
button.link { background: none; color: #2563eb; padding: 0; }
button.link.danger { color: #dc2626; }
form.inline { display: inline; }
.pill { padding: .1rem .7rem; border-radius: 99px; font-size: .85rem; }
.pill.on { background: #16a34a; } .pill.off { background: #9ca3af; }

/* Tabellen */
.table-wrap { overflow-x: auto; margin-bottom: 1.2rem; border-radius: 8px; box-shadow: 0 1px 3px #0002; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f1f5f9; font-size: .85rem; }
th a.sort { color: inherit; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .3rem; }
th a.sort:hover { color: #1d4ed8; }
th a.sort .arrow { font-size: .7rem; color: #94a3b8; }
th a.sort.active, th a.sort.active .arrow { color: #1d4ed8; }
.mobile-only { display: none !important; }
tr.today td { background: #fef9c3; }
td.actions { white-space: nowrap; text-align: right; }
td.actions a { margin-right: .6rem; }
td.actions .icon-btn { margin: 0 0 0 .2rem; }

/* Icon-Buttons (Bearbeiten / Löschen) */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; vertical-align: middle; border-radius: 6px; background: none; color: #64748b; line-height: 0; }
.icon-btn svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.edit:hover, .icon-btn.edit:focus-visible { background: #dbeafe; color: #1d4ed8; }
.icon-btn.delete:hover, .icon-btn.delete:focus-visible { background: #fee2e2; color: #dc2626; }
td.empty { text-align: center; color: #6b7280; padding: 2rem; }
td.email { word-break: break-all; }

.flash { padding: .6rem 1rem; border-radius: 5px; margin-bottom: 1rem; }
.flash.ok { background: #dcfce7; color: #166534; } .flash.error { background: #fee2e2; color: #991b1b; }
code { background: #e5e7eb; padding: 0 .3rem; border-radius: 3px; }
ul.errors { color: #991b1b; }

nav.pagination { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.2rem; }
nav.pagination a, nav.pagination .current { padding: .25rem .65rem; border-radius: 5px; background: #fff; box-shadow: 0 1px 2px #0002; text-decoration: none; color: #2563eb; }
nav.pagination .current { background: #2563eb; color: #fff; }
nav.pagination .info { margin-left: auto; color: #6b7280; }

/* Zu wenig Platz für das Menü: Hamburger-Icon, Menü klappt darunter auf (nur mit JavaScript) */
@media (max-width: 900px) {
  .js header .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .js header .menu { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: .2rem; padding-top: .4rem; border-top: 1px solid #ffffff30; }
  .js header.open .menu { display: flex; }
  .js header nav { flex-direction: column; gap: 0; }
  .js header nav a, .js header .user a { padding: .7rem .2rem; }
  .js header .user { margin-left: 0; justify-content: space-between; border-top: 1px solid #ffffff30; padding-top: .2rem; }
  .js header .user button.link { padding: .7rem .2rem; }
  /* ohne JavaScript: Menü bleibt sichtbar und bricht um */
  header .menu { flex-wrap: wrap; }
}

/* Tablet und Smartphone */
@media (max-width: 800px) {
  header { padding: .6rem 1rem; }
  .grid { grid-template-columns: 1fr; }
  .card.narrow { margin: 1.5rem auto; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  main { margin: .8rem auto; padding: 0 .7rem; }
  footer { padding: .7rem .7rem calc(.7rem + env(safe-area-inset-bottom)); font-size: .8rem; }
  .card { padding: 1rem; }
  /* 16px verhindert das automatische Hineinzoomen auf iOS */
  input, select, textarea { font-size: 16px; padding: .6rem .7rem; }
  input[type=checkbox] { width: 1.1rem; height: 1.1rem; }
  button, .btn { padding: .6rem 1rem; }
  button.link { padding: .5rem 0; }

  .toolbar h1 { flex-basis: 100%; }
  .toolbar form { flex: 1 1 100%; }
  .toolbar form input[type=search] { flex: 1 1 100%; width: 100%; }
  .toolbar form select { flex: 1; }
  .toolbar form select.mobile-only { display: block !important; }
  .toolbar > .btn { flex: 1 1 100%; text-align: center; }
  .row > * { flex: 1 1 100%; text-align: center; }
  .row input { width: 100%; }

  /* Tabellen als Karten */
  .table-wrap { overflow: visible; box-shadow: none; border-radius: 0; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive { background: none; }
  table.responsive thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.responsive tr { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px #0002; margin-bottom: .8rem; padding: .3rem 0; }
  table.responsive td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; padding: .3rem .9rem; text-align: right; }
  table.responsive td[data-label]::before { content: attr(data-label); font-size: .8rem; font-weight: 600; color: #6b7280; text-align: left; flex-shrink: 0; }
  table.responsive td.name { font-weight: 600; font-size: 1.05rem; }
  table.responsive td.actions { justify-content: flex-end; gap: 1.2rem; border-top: 1px solid #e5e7eb; margin-top: .3rem; padding-top: .5rem; }
  table.responsive td.actions .icon-btn { width: 2.6rem; height: 2.6rem; margin: 0; }
  table.responsive td.actions .icon-btn svg { width: 1.35rem; height: 1.35rem; }
  table.responsive tr.today { outline: 2px solid #facc15; }
  table.responsive tr.today td { background: #fef9c3; }
  table.responsive tr.today td:first-child { border-radius: 8px 8px 0 0; }
  table.responsive tr.empty-row td { justify-content: center; }

  nav.pagination { justify-content: center; }
  nav.pagination a, nav.pagination .current { padding: .5rem .8rem; }
  nav.pagination .info { flex-basis: 100%; text-align: center; margin: .3rem 0 0; }
}
