/* SMTP-Gateway UI – schlicht, responsiv, Light/Dark über prefers-color-scheme. Keine externen Ressourcen. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6877;
  --border: #d5d9e0;
  --primary: #1f5fbf;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --ok-bg: #e3f4e7;
  --ok-text: #14532d;
  --warn-bg: #fff3d6;
  --warn-text: #6b4600;
  --err-bg: #fde7e5;
  --err-text: #7a1710;
  --info-bg: #e5eefb;
  --info-text: #17407a;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181f;
    --surface: #1d232d;
    --text: #e6e9ee;
    --muted: #9aa4b2;
    --border: #343c49;
    --primary: #6aa2f5;
    --primary-text: #0d1522;
    --danger: #f2877f;
    --ok-bg: #173223;
    --ok-text: #a8e4bb;
    --warn-bg: #3a2f12;
    --warn-text: #f3d48b;
    --err-bg: #3d1b19;
    --err-text: #f6b5af;
    --info-bg: #182a47;
    --info-text: #b4cdf5;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}
a { color: var(--primary); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
code, pre, .copy { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Layout */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.5rem;
  padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { flex: 1 1 auto; }
.topbar ul { display: flex; flex-wrap: wrap; gap: .25rem 1rem; list-style: none; margin: 0; padding: 0; }
.topbar nav a { text-decoration: none; padding: .25rem 0; border-bottom: 2px solid transparent; color: var(--text); }
.topbar nav a:hover { border-bottom-color: var(--border); }
.topbar nav a[aria-current="page"] { border-bottom-color: var(--primary); font-weight: 600; }
.logout { margin: 0; }
.container { max-width: 72rem; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.container-narrow { max-width: 26rem; margin-top: 4rem; }
section { margin-bottom: 1.5rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); margin-bottom: 1.5rem; }
.grid .card { margin-bottom: 0; }

/* Formulare */
.field { margin-bottom: 1rem; border: 0; padding: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin-bottom: .25rem; padding: 0; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input:not([type]), select, textarea {
  width: 100%; max-width: 100%; padding: .5rem .6rem; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.hint { display: block; color: var(--muted); margin-top: .25rem; }
.field-invalid input, .field-invalid select, .field-invalid textarea { border-color: var(--danger); }
.field-error { display: block; color: var(--danger); margin-top: .25rem; font-weight: 600; }
.choice { display: flex; align-items: flex-start; gap: .5rem; font-weight: 400; margin-bottom: .4rem; }
.choice input { margin-top: .3rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.filter-bar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; margin-bottom: .5rem; }
.filter-bar .field { margin-bottom: 0; }
.inline-form { display: inline-flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: 0; }
.inline-form input { width: 14rem; }

/* Buttons */
.btn {
  display: inline-block; padding: .45rem .9rem; font: inherit; font-weight: 600; line-height: 1.3; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; text-decoration: none;
}
.btn:hover { border-color: var(--primary); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-small { padding: .25rem .6rem; font-size: .9rem; }
.btn-link { background: none; border: 0; color: var(--primary); padding: .25rem 0; }

/* Aufklapp-Bestätigung ohne JS */
details.confirm { display: inline-block; vertical-align: top; }
details.confirm summary { list-style: none; cursor: pointer; display: inline-block; }
details.confirm summary::-webkit-details-marker { display: none; }
details.confirm form { margin-top: .4rem; padding: .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); max-width: 22rem; }
details.confirm p { margin: 0 0 .5rem; }
td.actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: flex-start; }

/* Meldungen */
.notice { padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid transparent; }
.notice-success { background: var(--ok-bg); color: var(--ok-text); }
.notice-warning { background: var(--warn-bg); color: var(--warn-text); }
.notice-error { background: var(--err-bg); color: var(--err-text); }
.notice-info { background: var(--info-bg); color: var(--info-text); }
.error-text { color: var(--danger); }

/* Tabellen */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.cell-wrap { overflow-wrap: anywhere; word-break: break-word; max-width: 28rem; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: var(--info-bg); color: var(--info-text); }
.badge-sent { background: var(--ok-bg); color: var(--ok-text); }
.badge-queued, .badge-sending { background: var(--info-bg); color: var(--info-text); }
.badge-failed { background: var(--err-bg); color: var(--err-text); }

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 .75rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.checklist { padding-left: 1.1rem; margin: .5rem 0; }
.role { margin-right: .35rem; }
.details { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: .6rem; }
.directory-list { list-style: none; padding: 0; margin: .5rem 0 0; }
.directory-list form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.pagination { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin: .5rem 0 1rem; }

/* Passwort-Seite */
.copy-row { margin-bottom: .9rem; }
.copy-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
input.copy, textarea.copy { user-select: all; width: 100%; }
input.copy-secret { font-size: 1.05rem; font-weight: 700; border-color: var(--primary); }

@media (max-width: 40rem) {
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: .5rem; }
  .inline-form input { width: 100%; }
  .container-narrow { margin-top: 1.5rem; }
}
