:root {
  --primary: #6d5efc;
  --primary-hover: #5b4de0;
  --bg: #f4f4f6;
  --surface: #fff;
  --text: #1c1c1f;
  --muted: #5c5c66;
  --border: #e4e4e7;
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button, input { font: inherit; }

.hidden { display: none !important; }

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

.login-card {
  width: min(440px, 100%);
  padding: 28px 24px 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(28, 28, 31, 0.08);
}

.login-brand { margin-bottom: 20px; }

.login-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.login-subtitle {
  margin: 2px 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.login-password { position: relative; }

.login-password input { padding-right: 96px; }

.login-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}

.form-actions { margin-top: 8px; }

/* Pflicht-2FA (Trello DvzZGekQ): Einrichtung, Code-Schritt, Wiederherstellungscodes. */
.mfa-hint { margin: 0 0 14px; font-size: 0.9rem; color: var(--muted); }
.mfa-qr {
  display: block;
  width: 200px;
  height: 200px;
  margin: 0 auto 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}
.mfa-secret {
  margin: 0 0 14px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  word-break: break-all;
  user-select: all;
}
.mfa-remember { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.mfa-remember input { width: auto; }
.mfa-link {
  display: block;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}
.mfa-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* Code in 6 Feldern, «–» nach dem dritten (T1c; Muster «Bildschirm koppeln» der App). */
.mfa-code-row { display: flex; align-items: center; gap: 8px; }
.mfa-code-row .mfa-code-char {
  width: 44px;
  height: 52px;
  padding: 0;
  text-align: center;
  font-weight: 700;
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
  border-radius: 10px;
}
.mfa-code-row .mfa-code-char:focus { outline: 2px solid var(--primary); border-color: var(--primary); }
.mfa-code-sep { color: var(--muted); font-weight: 700; }
.field > .field-label { margin: 0 0 6px; }
@media (max-width: 380px) {
  .mfa-code-row { gap: 6px; }
  .mfa-code-row .mfa-code-char { width: 38px; height: 48px; }
}
.mfa-recovery-list {
  margin: 0 0 14px;
  padding-left: 1.6em;
  columns: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.mfa-recovery-list li { margin-bottom: 4px; }

.primary-btn, .secondary-btn, .danger-btn {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

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

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

.secondary-btn {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.danger-btn {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

.danger-btn:hover { background: #9a1e14; border-color: #9a1e14; }

.form-error { color: var(--danger); }

.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  width: 220px;
  flex: 0 0 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover { background: rgba(109, 94, 252, 0.08); }

.nav-link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.nav-link.is-current {
  background: rgba(109, 94, 252, 0.14);
  color: var(--primary);
  font-weight: 600;
}

.nav-sub {
  margin: 0 0 4px 14px;
  padding-left: 8px;
  border-left: 2px solid rgba(109, 94, 252, 0.35);
}

.nav-logout {
  margin-top: auto;
  align-self: flex-start;
}

.app-main {
  flex: 1;
  min-width: 0;
}

.app-view {
  max-width: 1100px;
  margin: 0;
  padding: 24px 16px 48px;
}

@media (max-width: 640px) {
  .app-shell { flex-direction: column; align-items: stretch; }

  .side-nav {
    position: static;
    width: 100%;
    flex: none;
    min-height: 0;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }

  .nav-sub {
    flex: 1 0 100%;
    margin: 0;
    border-left: 0;
    padding-left: 0;
  }

  .nav-sub .nav-link { padding-left: 22px; }

  .nav-logout { margin-top: 0; }
}

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

.topbar h1 { margin: 0; }

.topbar-actions, .inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.switch-field {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.panel, .link-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  margin-bottom: 20px;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.org-row { cursor: pointer; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.tile span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.tile strong { font-size: 1.4rem; }

.link-list { padding-left: 18px; }

.row-actions {
  position: relative;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.row-menu-wrap { position: relative; }

.row-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 5;
  min-width: 12rem;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(28, 28, 31, 0.12);
}

tr.is-open .row-actions { z-index: 3; }

.row-menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.row-menu-item:hover,
.row-menu-item:focus-visible { background: rgba(109, 94, 252, 0.08); }

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

.org-invites { margin-bottom: 28px; }

.org-invites .data-table { margin-bottom: 12px; }

.org-invites .empty { margin: 0 0 12px; }


a.secondary-btn {
  display: inline-block;
  text-decoration: none;
  line-height: 1.2;
}

.invite-email {
  margin: 0 0 14px;
  font-weight: 600;
}

body.platform-is-updating #app-shell {
  pointer-events: none;
}

.platform-update-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(28, 28, 31, 0.45);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.platform-update-overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 36px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  text-align: center;
}

.platform-update-spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: platform-update-spin 0.75s linear infinite;
}

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

.platform-update-overlay-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.platform-update-banner {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 32px);
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(28, 28, 31, 0.12);
}

.platform-update-reload {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
}

/* Org-Seite mit Kopf und Registern (Trello 7oyEMnWO) */
.muted { color: var(--muted); }

.small { font-size: 0.82rem; font-weight: 400; }

.org-header { margin-bottom: 12px; }

.breadcrumb {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

.breadcrumb a { color: inherit; text-decoration: none; }

.breadcrumb a:hover { color: var(--primary); text-decoration: underline; }

.org-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.org-head h1 { margin: 0 0 10px; font-size: 1.75rem; }

.org-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.org-head-actions .link-panel {
  display: flex;
  gap: 8px;
  width: min(420px, 100%);
  margin: 0;
  padding: 8px;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ececf0;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge-ok { background: #e7f6ec; color: #1f7a3d; }

.badge-warn { background: #fdf1e3; color: #9a5b00; }

.badge-muted { background: #ececf0; color: var(--muted); }

.badge[title] { cursor: help; }

.org-meta { margin: 8px 0 0; font-size: 0.82rem; color: var(--muted); }

.org-slug { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.org-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.org-tabs::-webkit-scrollbar { display: none; }

.org-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.org-tab:hover { color: var(--text); }

.org-tab:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: 8px 8px 0 0; }

.org-tab.is-current {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  padding: 0 7px;
  border-radius: 999px;
  background: #ececf0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.tab-panel h2 { font-size: 1.05rem; margin: 20px 0 10px; }

.tab-panel > h2:first-child, .tab-panel .panel h2 { margin-top: 0; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}

.card-link:hover { border-color: rgba(109, 94, 252, 0.45); }

.card-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.card-head { display: flex; justify-content: space-between; gap: 8px; }

.card-state { color: var(--primary); font-weight: 600; }

.card-line { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.88rem; }

.status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a1a1aa;
}

.status-dot.is-ok { background: #1f9d4c; }

.status-dot.is-warn { background: var(--danger); }

.change-list {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.9rem;
}

.change-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

.module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.module-head p { margin: 4px 0 0; font-size: 0.88rem; }

.module-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
}

.module-check p { margin: 0; flex: 0 1 auto; }

.module-check .secondary-btn { margin-left: auto; }

.switch-field input[role="switch"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 40px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #d4d4d8;
  cursor: pointer;
  transition: background 0.15s;
}

.switch-field input[role="switch"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch-field input[role="switch"]:checked { background: var(--primary); }

.switch-field input[role="switch"]:checked::after { transform: translateX(18px); }

.switch-field input[role="switch"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.switch-field input[role="switch"]:disabled { opacity: 0.6; cursor: progress; }

.switch-field { font-weight: 600; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.section-head h2 { margin-bottom: 10px; }

.section-head p { margin: 0; font-size: 0.85rem; }

.inline-form button { flex: 0 0 auto; white-space: nowrap; }

.text-link { color: var(--primary); font-size: 0.88rem; text-decoration: none; }

.text-link:hover { text-decoration: underline; }

.table-scroll { overflow-x: auto; }

.info-box {
  padding: 12px 14px;
  border: 1px dashed #c9c9d1;
  border-radius: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.info-box a { color: var(--primary); }

.link-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.link-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  margin-bottom: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}

.segment {
  border: 0;
  border-radius: 999px;
  padding: 6px 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment[aria-pressed="true"] {
  background: rgba(109, 94, 252, 0.14);
  color: var(--primary);
  font-weight: 600;
}

.notice { color: #1f7a3d; }

.tab-panel .panel .field:last-child { margin-bottom: 0; }

.tab-panel .panel { max-width: 640px; }

.tab-panel .module-card { max-width: none; }

/* Alarm-Eingang (Trello QVbD1lFF): Alias mit fester Domain, Absender als Zeilen. */
.pa-form { padding-top: 14px; }

/* Alias: lokaler Teil im Feld, «@domain» fest dahinter (Domain kommt von der api). */
.pa-alias-row { display: flex; align-items: center; gap: 8px; }

.pa-alias-row input { flex: 1 1 6em; min-width: 6em; margin-bottom: 0; }

.pa-domain {
  flex: 0 0 auto;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--muted);
}

#pa-alias-hint { margin: 6px 0 0; }

.pa-subtitle { margin: 18px 0 8px; font-size: 0.95rem; }

.pa-absender { margin: 0 0 10px; padding: 0; list-style: none; }

.pa-absender-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.pa-absender-row input { margin-bottom: 0; }

.pa-form input[aria-invalid="true"], .pa-form button[aria-invalid="true"] { border-color: var(--danger); }

#pa-panel { margin-bottom: 16px; }

.danger-zone {
  max-width: 640px;
  padding: 16px;
  border: 1.5px solid var(--danger);
  border-radius: 12px;
  background: #fff8f7;
}

.danger-zone h2 { margin: 0 0 4px; color: var(--danger); }

.danger-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
}

.danger-row + .danger-row { border-top: 1px solid #f1d3cf; }

.danger-row p { margin: 2px 0 0; font-size: 0.85rem; }

.danger-row button { flex: 0 0 auto; }

.danger-outline-btn {
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fff;
  color: var(--danger);
  cursor: pointer;
}

.danger-outline-btn:hover { background: #fdecea; }

.danger-zone .panel { margin: 4px 0 0; }

/* Sicherung (Trello Qy3K2gxe PR 2) */
.tab-panel .panel.backup-panel { max-width: 860px; margin-bottom: 16px; }
.backup-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.backup-head p { margin: 4px 0 0; }
.backup-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.backup-panel h3 { margin: 16px 0 8px; font-size: 1rem; }
.backup-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.backup-row {
  display: grid;
  grid-template-columns: minmax(8.5rem, 11rem) 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.backup-row.is-fail .backup-kind { color: var(--danger); }
.backup-size { color: var(--muted); font-variant-numeric: tabular-nums; }
.backup-actions { display: flex; gap: 6px; justify-content: flex-end; }
.backup-panel .backup-restore { margin-top: 14px; border-color: var(--danger); }
@media (max-width: 640px) {
  .backup-row { grid-template-columns: 1fr auto; }
  .backup-actions { grid-column: 1 / -1; justify-content: flex-start; }
}


@media (max-width: 640px) {
  .org-head { flex-direction: column; align-items: stretch; }

  .org-head h1 { font-size: 1.45rem; }

  .org-head-actions { align-items: stretch; }

  .org-head-actions .secondary-btn { width: 100%; }

  .org-head-actions .link-panel { width: 100%; }

  .org-head-actions .link-panel .secondary-btn { width: auto; }

  .org-tabs {
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent);
    mask-image: linear-gradient(to right, #000 85%, transparent);
  }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .module-check { flex-wrap: wrap; }

  .module-check p { flex: 1 1 calc(100% - 24px); }

  .module-check .small { flex-basis: 100%; }

  .module-check .secondary-btn { margin-left: 0; width: 100%; }

  .danger-row { flex-direction: column; align-items: stretch; }

  .inline-form { flex-wrap: wrap; }

  .pa-absender-row { grid-template-columns: minmax(0, 1fr) auto; }

  .pa-absender-row .pa-adresse { grid-column: 1 / -1; }

  .pa-absender-row { padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }

  .table-scroll .data-table { min-width: 600px; }
}

