/* ---------------------------------------------------------------------------
 * portal.css — Shell-Layout portal.erismann.de (P-A)
 * Struktur und Masse aus "Portal UI v2"; Farben ausschliesslich ueber
 * tokens.css. Viewports: 1440 / 1194 / 834 / 390 (§5.7).
 * ------------------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--p-bg);
  color: var(--p-ink);
  font-family: var(--p-font);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  text-wrap: pretty;
}

button { font-family: inherit; cursor: pointer; border: 0; background: none; color: inherit; text-align: left; font-variant-numeric: tabular-nums; }
input, select, textarea { font-family: inherit; font-variant-numeric: tabular-nums; }
a { color: var(--p-accent); text-decoration: none; }
a:hover { color: var(--p-accent-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--p-accent-focus); outline-offset: 2px; border-radius: 4px; }

.hidden { display: none !important; }
.mono { font-family: var(--p-mono); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@keyframes p-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Bootscreen ─────────────────────────────────────────────────── */
.p-boot {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  color: var(--p-muted-2); font-size: 13.5px;
}

/* ── Kopfzeile ──────────────────────────────────────────────────── */
.p-hdr {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 24px; background: var(--p-surface); border-bottom: 1px solid var(--p-border);
}
.p-hdr-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.p-logo-box {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: var(--p-r-box);
  background: var(--p-ink-strong); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600;
}
.p-brand-name { font-size: 15px; font-weight: 600; letter-spacing: -0.016em; line-height: 1.1; }
.p-brand-sub {
  font-family: var(--p-mono); font-size: 9px; color: var(--p-muted-2);
  text-transform: uppercase; letter-spacing: 0.14em;
}
.p-hdr-right { display: flex; align-items: center; gap: 4px; }
.p-chip {
  display: flex; align-items: center; gap: 11px; padding: 6px 6px 6px 10px;
  border-radius: var(--p-r-box); transition: background 120ms;
}
.p-chip:hover { background: #F7F4F0; }
.p-chip-text { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.p-chip-name { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; line-height: 1; }
.p-chip-role {
  font-family: var(--p-mono); font-size: 9.5px; color: var(--p-muted-2);
  letter-spacing: 0.06em; white-space: nowrap; line-height: 1; text-transform: uppercase;
}
.p-avatar {
  width: 32px; height: 32px; flex: 0 0 auto; border-radius: 16px;
  background: var(--p-ink-strong); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600;
}
.p-hdr-btn {
  min-width: var(--p-hit); min-height: var(--p-hit); padding: 0 12px;
  border-radius: var(--p-r-box); font-size: 13px; font-weight: 600; color: var(--p-muted);
  display: flex; align-items: center; justify-content: center; transition: background 120ms;
}
.p-hdr-btn:hover { background: #F7F4F0; }

/* ── Scrollflaeche ──────────────────────────────────────────────── */
.p-scroll { padding: 32px 30px 48px; }
.p-wrap { max-width: 1220px; margin: 0 auto; }

/* ── Grussband mit Dessin-Slot ──────────────────────────────────── */
.p-band {
  position: relative; overflow: hidden; margin-bottom: 26px; padding: 22px 24px;
  background: var(--p-band-bg); border: 1px solid var(--p-band-border);
  border-radius: 16px;
}
/* Die Textur liegt UNTER dem Text und ist per Maske zum Textrand hin
   ausgeblendet — so steht Text nie auf dem Muster (§5.7 Nr. 4). */
.p-band-texture {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: right center;
  opacity: var(--p-texture-opacity);
  -webkit-mask-image: linear-gradient(to right, transparent 14%, #000 72%);
          mask-image: linear-gradient(to right, transparent 14%, #000 72%);
  pointer-events: none;
}
.p-band-inner { position: relative; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.p-band-date { font-size: 12px; color: var(--p-muted-2); font-weight: 500; }
.p-h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; margin: 0; }
.p-band-sub { font-size: 14px; color: var(--p-muted); }
.p-band-caption {
  position: absolute; right: 16px; bottom: 9px; z-index: 1; pointer-events: none;
  font-family: var(--p-mono); font-size: 9.5px; color: var(--p-caption); letter-spacing: 0.03em;
}

/* ── Gruppen ────────────────────────────────────────────────────── */
.p-groups { display: flex; flex-direction: column; gap: 24px; }
.p-group { display: flex; flex-direction: column; gap: 13px; }
.p-group-head { display: flex; align-items: center; gap: 12px; }
.p-group-idx, .p-group-count { font-family: var(--p-mono); font-size: 9.5px; color: var(--p-muted-3); letter-spacing: 0.1em; }
.p-group-label {
  font-family: var(--p-mono); font-size: 9.5px; color: var(--p-muted);
  text-transform: uppercase; letter-spacing: 0.14em; font-weight: 500;
}
.p-group-rule { flex: 1; height: 1px; background: var(--p-rule); }

/* ── Kacheln ────────────────────────────────────────────────────── */
.p-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; }
.p-tile {
  display: flex; flex-direction: column; width: 100%; padding: 18px; min-height: 164px;
  background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-r-card);
  transition: border-color 140ms, box-shadow 140ms, transform 140ms;
}
.p-tile:hover { border-color: #D3BCA5; box-shadow: var(--p-shadow-tile); transform: translateY(-1px); }
.p-tile-top { display: flex; align-items: flex-start; gap: 14px; }
.p-iconbox {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: var(--p-r-box);
  background: var(--p-iconbox); display: flex; align-items: center; justify-content: center;
}
.p-tile-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.p-tile-name { font-size: 16px; font-weight: 600; letter-spacing: -0.016em; line-height: 1.2; }
.p-tile-meta {
  font-size: 13px; color: var(--p-muted); line-height: 1.5; min-height: 39px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.p-tile-spacer { flex: 1; }
.p-netz {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 16px;
  padding: 4px 9px 4px 7px; border-radius: var(--p-r-pill);
  background: var(--p-netz-bg); color: var(--p-netz-ink); font-size: 11.5px; font-weight: 500;
  align-self: flex-start;
}

/* ── Leerzustand ────────────────────────────────────────────────── */
.p-empty {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  align-items: center; text-align: center;
  background: var(--p-empty-bg); border: 1px dashed var(--p-empty-border);
  border-radius: 16px; padding: 52px 40px;
}
.p-empty-texture {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: var(--p-texture-empty-opacity);
  -webkit-mask-image: radial-gradient(120% 100% at 50% 38%, #000, transparent 76%);
          mask-image: radial-gradient(120% 100% at 50% 38%, #000, transparent 76%);
  pointer-events: none;
}
.p-empty-inner { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; width: 100%; }
.p-empty-kicker { font-family: var(--p-mono); font-size: 9.5px; color: var(--p-muted-3); text-transform: uppercase; letter-spacing: 0.14em; }
.p-empty-title { font-size: 19px; font-weight: 600; letter-spacing: -0.022em; margin-top: 14px; }
.p-empty-text { font-size: 13.5px; color: var(--p-muted); line-height: 1.55; margin-top: 8px; max-width: 400px; }
.p-empty-foot { display: flex; align-items: center; gap: 10px; margin-top: 24px; padding-top: 16px; border-top: 1px solid #EAE2D6; width: 100%; }
.p-empty-foot .mono { font-size: 10px; color: var(--p-muted-2); letter-spacing: 0.05em; }
.p-empty-caption { margin-top: 20px; font-family: var(--p-mono); font-size: 9px; color: var(--p-caption-soft); letter-spacing: 0.1em; }

/* ── Login ──────────────────────────────────────────────────────── */
.p-login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; background: var(--p-canvas); }
.p-login-split {
  display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 0;
  width: 100%; max-width: 940px; background: var(--p-surface);
  border: 1px solid var(--p-border); border-radius: 18px; overflow: hidden;
  box-shadow: var(--p-shadow-panel); animation: p-rise 180ms ease-out;
}
.p-login-photo { position: relative; background: var(--p-band-bg); min-height: 460px; }
.p-login-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.p-login-caption {
  position: absolute; left: 16px; bottom: 12px;
  font-family: var(--p-mono); font-size: 9.5px; letter-spacing: 0.06em;
  color: #fff; background: rgba(23, 20, 15, 0.55);
  padding: 4px 8px; border-radius: 4px;
}
.p-login-pane { padding: 36px 34px; display: flex; flex-direction: column; }
.p-login-rule { height: 1px; background: var(--p-border-soft); margin: 22px 0; }
.p-login-h { font-size: 23px; font-weight: 600; letter-spacing: -0.026em; line-height: 1.2; }
.p-login-text { font-size: 13.5px; color: var(--p-muted); line-height: 1.55; margin-top: 8px; }
.p-login-mount { margin-top: 22px; min-height: 40px; }
.p-login-note { font-size: 12.5px; color: var(--p-muted); margin-top: 18px; line-height: 1.5; }
.p-login-foot { font-family: var(--p-mono); font-size: 10px; color: var(--p-muted-3); margin-top: 20px; letter-spacing: 0.1em; }

/* ── Warten auf Freischaltung (§4b Nr. 5 ii) ────────────────────── */
.p-gate { max-width: 520px; margin: 12vh auto; text-align: center; padding: 0 20px; }
.p-gate-title { font-size: 20px; font-weight: 600; letter-spacing: -0.022em; }
.p-gate-text { font-size: 13.5px; color: var(--p-muted); line-height: 1.6; margin-top: 10px; }

/* ── Portal-Admin ───────────────────────────────────────────────── */
.p-card { background: var(--p-surface); border: 1px solid var(--p-border); border-radius: var(--p-r-card); }
.p-admin-sec { margin-bottom: 28px; }
.p-admin-h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 4px; }
.p-admin-hint { font-size: 13px; color: var(--p-muted); line-height: 1.55; margin: 0 0 14px; }
.p-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.p-table th {
  text-align: left; font-family: var(--p-mono); font-size: 9.5px; font-weight: 500;
  color: var(--p-muted); text-transform: uppercase; letter-spacing: 0.12em;
  padding: 10px 12px; border-bottom: 1px solid var(--p-border);
}
.p-table td { padding: 11px 12px; border-bottom: 1px solid var(--p-border-soft); vertical-align: top; }
.p-table tr:last-child td { border-bottom: 0; }
.p-url { font-family: var(--p-mono); font-size: 11.5px; color: var(--p-muted-2); word-break: break-all; }
.p-pill {
  display: inline-flex; align-items: center; padding: 3px 9px; border-radius: var(--p-r-pill);
  font-size: 11.5px; font-weight: 500; background: var(--p-netz-bg); color: var(--p-netz-ink);
}
.p-pill-on  { background: #E4EFE7; color: var(--p-ok); }
.p-pill-off { background: #F2EEE7; color: var(--p-muted-2); }
.p-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.p-field label { font-size: 12px; font-weight: 600; color: var(--p-muted); }
.p-field input, .p-field select {
  min-height: var(--p-hit); padding: 0 12px; font-size: 13.5px;
  border: 1px solid var(--p-border-strong); border-radius: 10px; background: var(--p-surface); color: var(--p-ink);
}
.p-btn {
  min-height: var(--p-hit); padding: 0 18px; border-radius: 10px;
  border: 1px solid var(--p-border-strong); background: var(--p-surface);
  font-size: 13.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
}
.p-btn:hover { border-color: #C6B8A8; background: var(--p-surface-soft); }
.p-btn-primary { background: var(--p-accent); border-color: var(--p-accent); color: #fff; }
.p-btn-primary:hover { background: var(--p-accent-hover); border-color: var(--p-accent-hover); color: #fff; }
.p-msg { font-size: 13px; margin-top: 10px; }
.p-msg-ok  { color: var(--p-ok); }
.p-msg-err { color: var(--p-crit); }

/* ── Viewports ──────────────────────────────────────────────────── */
@media (max-width: 1194px) {
  .p-scroll { padding: 26px 26px 44px; }
  .p-grid { grid-template-columns: repeat(auto-fill, minmax(316px, 1fr)); gap: 10px; }
  .p-login-split { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 834px) {
  .p-login-split { grid-template-columns: 1fr; max-width: 520px; }
  .p-login-photo { min-height: 200px; }
}
@media (max-width: 640px) {
  .p-hdr { padding: 7px 12px 7px 16px; }
  .p-scroll { padding: 18px 16px 28px; }
  .p-h1 { font-size: 23px; }
  .p-band { padding: 18px 20px; }
  .p-band-caption { display: none; }   /* zu wenig Platz — Muster bleibt, Text nicht */
  .p-groups { gap: 14px; }
  .p-grid { display: flex; flex-direction: column; gap: 9px; }
  .p-tile { flex-direction: row; align-items: center; gap: 13px; min-height: 72px; padding: 12px 14px; border-radius: 13px; }
  .p-tile-top { flex: 1; align-items: center; gap: 13px; min-width: 0; }
  .p-tile-meta { min-height: 0; -webkit-line-clamp: 1; }
  .p-tile-spacer { display: none; }
  .p-netz { margin-top: 0; margin-left: auto; }
  .p-empty { padding: 32px 22px; }
  .p-login-pane { padding: 26px 22px; }
  /* Safe Area der PWA respektieren */
  body { padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Microsoft-Anmeldeknopf ─────────────────────────────────────── */
.p-ms-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: var(--p-hit); margin-top: 22px; padding: 0 16px;
  border: 1px solid var(--p-border-strong); border-radius: 10px;
  background: var(--p-surface); font-size: 14px; font-weight: 600;
  transition: border-color 140ms, background 140ms;
}
.p-ms-btn:hover { border-color: #C6B8A8; background: var(--p-surface-soft); }
/* Microsofts Vierfeld-Logo — Markenfarben, deshalb bewusst keine Tokens. */
.p-ms-logo { display: grid; grid-template-columns: 9px 9px; grid-template-rows: 9px 9px; gap: 2px; flex: 0 0 auto; }
.p-ms-logo span:nth-child(1) { background: #F25022; }
.p-ms-logo span:nth-child(2) { background: #7FBA00; }
.p-ms-logo span:nth-child(3) { background: #00A4EF; }
.p-ms-logo span:nth-child(4) { background: #FFB900; }
.p-login-divider { display: flex; align-items: center; gap: 9px; margin-top: 20px; }
.p-login-divider span:first-child, .p-login-divider span:last-child { flex: 1; height: 1px; background: var(--p-border-soft); }
.p-login-divider .mono { font-size: 9.5px; color: var(--p-muted-3); letter-spacing: 0.12em; }

/* ── Profil-Menue ───────────────────────────────────────────────── */
.p-profile { position: relative; }
.p-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 244px;
  background: var(--p-surface); border: 1px solid var(--p-border);
  border-radius: var(--p-r-card); box-shadow: var(--p-shadow-panel);
  overflow: hidden; animation: p-rise 140ms ease-out;
}
.p-menu-head { padding: 14px 16px; border-bottom: 1px solid var(--p-border-soft); }
.p-menu-name { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.p-menu-mail { font-size: 12.5px; color: var(--p-muted); margin-top: 2px; word-break: break-all; }
.p-menu-meta { font-size: 9px; color: var(--p-muted-3); letter-spacing: 0.12em; margin-top: 8px; }
.p-menu-item {
  display: block; width: 100%; min-height: var(--p-hit); padding: 0 16px;
  font-size: 13.5px; font-weight: 600; color: var(--p-ink);
}
.p-menu-item:hover { background: var(--p-surface-soft); }
