:root {
  --primary: #0082c9;
  --primary-dark: #006aa3;
  --primary-light: #e5f2fa;
  --text: #222;
  --text-muted: #6b6b6b;
  --border: #dbdbdb;
  --border-strong: #b8b8b8;
  --bg: #f5f5f5;
  --card: #fff;
  --success: #2d7b41;
  --success-bg: #e8f5ec;
  --warning: #a36100;
  --warning-bg: #fdf3e2;
  --error: #c9302c;
  --error-bg: #fbeaea;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.5rem; margin: 0 0 .25rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.muted { color: var(--text-muted); }
.hint { color: var(--text-muted); font-size: .85rem; font-weight: 400; margin: .25rem 0 0; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

/* ---------- Kopfleiste ---------- */
.topbar { background: var(--primary); color: #fff; }
.topbar-inner {
  max-width: 1160px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs a {
  color: #fff; text-decoration: none; padding: 8px 14px; border-radius: 999px; opacity: .85;
}
.tabs a:hover { background: rgba(255, 255, 255, .15); opacity: 1; }
.tabs a.active { background: rgba(255, 255, 255, .22); opacity: 1; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: 12px; margin-left: auto; }

/* ---------- Inhalt ---------- */
main { max-width: 1160px; margin: 0 auto; padding: 24px 16px 64px; }
.loading { text-align: center; color: var(--text-muted); padding: 48px 0; }
.view-head { margin-bottom: 16px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 20px 24px; margin-bottom: 20px;
}
.card.narrow { max-width: 640px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.auth-card { max-width: 420px; margin: 48px auto; padding: 28px 32px; }
.auth-card h1 { margin-bottom: .5rem; }

/* ---------- Formulare ---------- */
label { display: block; font-weight: 600; margin: 14px 0 6px; }
form > label:first-child, .grid-2 > div > label:first-child { margin-top: 0; }
label .hint { display: inline; margin-left: 6px; }
input, textarea, select {
  font: inherit; color: inherit; width: 100%;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 12px; background: #fff; min-height: 38px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
input[aria-invalid="true"] { border-color: var(--error); }
input[type="search"] { max-width: 320px; }
.form-error {
  color: var(--error); background: var(--error-bg); border-radius: var(--radius-sm);
  padding: 8px 12px; margin: 14px 0 0;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; border-radius: 999px; padding: 8px 18px; min-height: 38px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:focus-visible, .tabs a:focus-visible, .dropzone:focus-within { outline: 2px solid var(--primary-dark); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #f0f0f0; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a82824; }
.btn-danger-outline { background: #fff; color: var(--error); border-color: #e3a5a3; }
.btn-danger-outline:hover:not(:disabled) { background: var(--error-bg); }
.btn-on-primary { background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .5); }
.btn-on-primary:hover { background: rgba(255, 255, 255, .28); }
.btn-small { padding: 4px 12px; min-height: 30px; font-size: .9rem; }
.btn-block { width: 100%; margin-top: 20px; }

/* ---------- Drag & Drop ---------- */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 36px 20px;
  text-align: center; background: #fafafa; transition: background .15s, border-color .15s;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-light); }
.dz-icon { color: var(--primary); margin-bottom: 4px; }
.dz-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 4px; }
.dropzone .btn { margin-top: 8px; }
.upload-form { margin-top: 20px; }
.selected-files { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.file-chip {
  display: flex; align-items: center; gap: 10px; background: var(--primary-light);
  border-radius: var(--radius-sm); padding: 8px 12px; overflow: hidden;
}
.file-chip .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-chip .size { color: var(--text-muted); white-space: nowrap; margin-left: auto; }

.progress { margin-top: 16px; }
.progress-bar { height: 10px; background: #e6e6e6; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.progress-fill.working { background: repeating-linear-gradient(45deg, var(--primary) 0 12px, #33a0d9 12px 24px); }
.progress-text { margin: 6px 0 0; color: var(--text-muted); font-size: .9rem; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #ececec; vertical-align: top; }
.table th { font-size: .85rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #fafafa; }
.table .num { text-align: right; }
.table td.action { text-align: right; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.table .version { font-weight: 600; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.table .notes { color: var(--text-muted); font-size: .85rem; margin: 2px 0 0; white-space: pre-line; max-width: 420px; }
.table tr.retracted td { color: var(--text-muted); }
.table tr.confirm-row td { background: var(--warning-bg); border-bottom-color: #f0dcb8; }
.confirm-box { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.confirm-box p { margin: 0; flex: 1; min-width: 240px; }
.table tr.deadline-row td { background: var(--primary-light); border-bottom-color: #cfe5f3; }
.deadline-box { max-width: 720px; }
.deadline-box > p { margin: 0 0 8px; }
.deadline-box .actions { margin-top: 12px; }
.empty { text-align: center; padding: 24px 0 8px; margin: 0; }
.hint-strong { color: var(--warning); font-weight: 600; }

/* ---------- Frist-Auswahl ---------- */
.grace-choice { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px 10px; margin: 16px 0 0; background: #fff; }
.grace-choice legend { font-weight: 600; padding: 0 6px; }
.grace-options { display: flex; flex-direction: column; gap: 6px; }
.grace-choice label.radio {
  display: inline-flex; align-items: center; gap: 8px; margin: 0; font-weight: 400; cursor: pointer;
}
.grace-choice input[type="radio"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--primary); }
.radio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.days-input { width: 84px; min-height: 32px; padding: 4px 8px; }
.radio-row .hint { margin: 0; }
.grace-hint { margin-top: 8px; }

/* ---------- Kennzeichen ---------- */
.badge {
  display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: #eee; color: #555; white-space: nowrap;
}
.badge-ok { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: #eee; color: #666; }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge + .badge { margin-left: 4px; }

/* ---------- Zwei-Faktor ---------- */
.steps { padding-left: 20px; margin: 0 0 16px; }
.totp-grid { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 24px; align-items: start; }
@media (max-width: 560px) { .totp-grid { grid-template-columns: minmax(0, 1fr); } }
#totp-qr { border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.secret {
  display: block; background: #f3f3f3; padding: 8px 10px; border-radius: var(--radius-sm);
  word-break: break-all; font-size: .95rem; letter-spacing: .05em; margin-bottom: 4px;
}

/* ---------- Meldungen ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 10; max-width: calc(100vw - 32px); }
.toast {
  background: #fff; border-left: 4px solid var(--success); box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
  border-radius: var(--radius-sm); padding: 12px 16px; max-width: 420px;
}
.toast.error { border-left-color: var(--error); }

@media (max-width: 640px) {
  .topbar-inner { gap: 8px; padding: 8px 16px; }
  .tabs { order: 3; flex-basis: 100%; }
  .card { padding: 16px; }
  .auth-card { margin: 24px auto; padding: 20px; }
}
