:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #d9e0e8;
  --border-strong: #b8c4d2;
  --text: #142033;
  --muted: #5d6b7c;
  --subtle: #748094;
  --primary: #174ea6;
  --primary-strong: #123b80;
  --primary-soft: #e8f0fe;
  --success: #0f766e;
  --success-soft: #e6f4f1;
  --warning: #9a5b00;
  --warning-soft: #fff4db;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --code-bg: #152033;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 8px 24px rgba(20, 32, 51, .06);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: var(--primary);
}

.shell {
  min-height: 100vh;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
}

.site-nav,
.page,
.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.site-nav {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand-logo {
  display: block;
  width: 150px;
  height: auto;
}

.brand-logo + .brand-logo {
  margin-left: 16px;
}

.brand-block {
  display: flex;
  width: fit-content;
}

.center-card .brand-logo {
  width: 190px;
}

.nav-links,
.topbar-actions,
.actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.nav-links a:hover {
  color: var(--text);
}

.page {
  padding: 34px 0 54px;
}

.page-narrow {
  width: min(860px, calc(100% - 40px));
}

.page-header {
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.lead {
  max-width: 760px;
  color: var(--muted);
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.mt-0 {
  margin-top: 0;
}

.mt-14 {
  margin-top: 14px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-18 {
  margin-top: 18px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.ml-8 {
  margin-left: 8px;
}

.mb-20 {
  margin-bottom: 20px;
}

.grid-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 24px;
  align-items: start;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.grid-2,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel,
.card,
.topbar,
.section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel,
.card,
.section {
  padding: 24px;
}

.topbar {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar-info {
  color: var(--muted);
  font-size: 14px;
}

.topbar-info strong {
  color: var(--text);
}

.section + .section,
.card + .card {
  margin-top: 16px;
}

.stat-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.stat-list li + li {
  margin-top: 6px;
}

.btn,
button.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-strong);
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.checkbox-line {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.checkbox-line input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

label {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
.btn:focus-visible,
.tab:focus-visible {
  outline: 3px solid rgba(23, 78, 166, .22);
  outline-offset: 2px;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.btn:disabled,
button.btn:disabled {
  opacity: .72;
  cursor: wait;
}

.download-busy {
  cursor: wait;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(20, 32, 51, .36);
}

.loading-overlay.active {
  display: flex;
}

.loading-panel {
  width: min(440px, 100%);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 20px 70px rgba(20, 32, 51, .22);
}

.loading-panel h2 {
  margin-bottom: 4px;
}

.loading-panel p {
  margin-bottom: 0;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 4px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: intradb-spin .85s linear infinite;
}

@keyframes intradb-spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.alert-success {
  background: var(--success-soft);
  border-color: #a9d8d1;
  color: #09433f;
}

.alert-warning {
  background: var(--warning-soft);
  border-color: #ffd58a;
  color: #653c00;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #f3b8b3;
  color: #7a1811;
}

.token-box,
pre {
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.token-box {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  word-break: break-all;
}

pre {
  margin: 12px 0 0;
  padding: 16px;
  overflow-x: auto;
  background: var(--code-bg);
  color: #edf3fb;
  line-height: 1.55;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-top: 20px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 10px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.site-footer {
  padding: 22px 0;
  border-top: 1px solid var(--border);
  color: var(--subtle);
  font-size: 13px;
}

.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.center-card {
  width: min(520px, 100%);
}

@media (max-width: 760px) {
  .site-nav,
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid-hero,
  .grid-3,
  .grid-2,
  .form-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 28px;
  }

  .page,
  .page-narrow,
  .site-nav,
  .site-footer {
    width: min(100% - 28px, 1180px);
  }
}
/* Tabellen: auf kleinen Geraeten horizontal scrollbar */
table.stat-table {
  display: block;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}

/* Tablet (kleine Notebooks) */
@media (max-width: 1024px) {
  .grid-hero,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .brand-logo {
    width: auto;
    height: 56px !important;
  }
}

/* Smartphone */
@media (max-width: 760px) {
  .site-nav {
    gap: 12px;
  }
  .brand {
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand-logo {
    width: auto !important;
    height: 40px !important;
    margin-left: 0 !important;
    max-width: 30vw;
    object-fit: contain;
  }
  .brand-logo[src*="msom"] {
    height: 30px !important;
    max-width: 22vw;
  }
  .nav-links {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-actions {
    flex-wrap: wrap;
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1 1 auto;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .stats-grid .full {
    grid-column: span 1;
  }
  .filter-row {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-row .btn,
  .filter-row .form-field {
    width: 100%;
  }
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .actions .btn {
    width: 100%;
  }
  h1 {
    font-size: 24px;
  }
  .panel,
  .card,
  .section {
    padding: 16px;
  }
}

/* sehr kleines Smartphone */
@media (max-width: 480px) {
  .brand-logo {
    height: 32px !important;
    max-width: 28vw;
  }
  .brand-logo[src*="msom"] {
    height: 24px !important;
    max-width: 20vw;
  }
  .site-nav,
  .page,
  .site-footer {
    width: min(100% - 16px, 1180px);
  }
}
/* Kompakte Buttons in Admin-Tabellen */
.stat-table .btn {
  min-height: 26px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 5px;
}

.stat-table td form {
  display: inline-block;
  margin-right: 4px;
}
.stat-table td form:last-child {
  margin-right: 0;
}

/* Browser-eigene Checkbox, nur kleiner */
.stat-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  margin: 0;
  cursor: pointer;
  vertical-align: middle;
  accent-color: var(--primary);
}

/* Datei-Upload: nativen Input verstecken, eigenes Label nutzen */
.file-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.file-upload input[type="file"] {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0);
  border: 0 !important;
  opacity: 0;
}
.file-upload label.btn {
  cursor: pointer;
}
