:root {
  --navy: #0b2e45;
  --navy-deep: #082438;
  --blue: #184c70;
  --gold: #f2b23f;
  --gold-soft: #ffd783;
  --ink: #132b3a;
  --muted: #62727e;
  --paper: #f5f7f8;
  --white: #ffffff;
  --line: #dce3e7;
  --line-strong: #c7d2d9;
  --surface-blue: #edf4f7;
  --success: #197451;
  --warning: #a56709;
  --danger: #a43d3d;
  --shadow: 0 22px 70px rgba(5, 31, 47, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }

.site-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px clamp(22px, 5vw, 76px);
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.brand img { display: block; width: min(232px, 50vw); height: 54px; object-fit: contain; object-position: left center; }
.portal-nav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.portal-nav a { padding: 10px 14px; border-radius: 8px; color: var(--muted); font-size: 0.9rem; font-weight: 750; text-decoration: none; }
.portal-nav a:hover, .portal-nav a.active { color: var(--navy); background: var(--surface-blue); }
.account { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 0.92rem; }
.account form { margin: 0; }

.page-shell { width: min(1280px, calc(100% - 40px)); margin: 0 auto; padding: clamp(42px, 7vw, 92px) 0; min-height: calc(100vh - 164px); }
.hero { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: clamp(34px, 6vw, 90px); align-items: center; }
.hero h1, .intro h1, .message-card h1 { margin: 0 0 24px; max-width: 850px; font-size: clamp(2.8rem, 6vw, 5.6rem); line-height: 0.98; letter-spacing: -0.055em; color: var(--navy); }
.lead, .intro > p:last-child, .message-card > p { max-width: 720px; font-size: clamp(1.05rem, 1.7vw, 1.25rem); line-height: 1.75; color: var(--muted); }
.eyebrow { margin: 0 0 18px; color: #9a680f; font-weight: 800; font-size: 0.78rem; letter-spacing: 0.17em; }

.hero-card, .message-card, .status-panel, .empty-state { background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.hero-card { padding: clamp(28px, 4vw, 52px); }
.hero-card .cross { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 14px; color: var(--navy); background: #edf2f5; font-size: 2rem; }
.hero-card h2 { margin: 28px 0 12px; font-size: 1.55rem; color: var(--navy); }
.hero-card p { color: var(--muted); line-height: 1.65; }
.hero-card .note { padding-top: 18px; border-top: 1px solid var(--line); font-size: 0.9rem; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 22px; border: 0; border-radius: 9px; font: inherit; font-weight: 800; text-decoration: none; cursor: pointer; }
.button-primary { background: var(--gold); color: var(--navy-deep); box-shadow: 0 10px 28px rgba(242, 178, 63, 0.24); }
.hero .button-primary { margin-top: 24px; }
.button-primary:hover { background: var(--gold-soft); }
.button-quiet { background: #edf2f5; color: var(--navy); }
.button-secondary { min-height: 44px; color: var(--navy); background: var(--surface-blue); border: 1px solid #d4e1e7; }
.button-secondary:hover { background: #e3edf2; }
.button-icon { gap: 8px; }
.button-full { width: 100%; }

.intro { margin-bottom: 48px; }
.intro h1 { font-size: clamp(2.5rem, 5vw, 4.6rem); }
.intro.compact { max-width: 800px; }
.back-link { display: inline-block; margin-bottom: 34px; color: var(--blue); font-weight: 750; text-decoration: none; }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.module-card { position: relative; min-height: 250px; padding: 28px; overflow: hidden; text-decoration: none; background: var(--white); border: 1px solid var(--line); border-radius: 16px; transition: transform 160ms ease, box-shadow 160ms ease; }
.module-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.module-card h2 { margin: 46px 0 10px; font-size: 1.45rem; color: var(--navy); }
.module-card p { min-height: 54px; color: var(--muted); line-height: 1.55; }
.module-index { position: absolute; top: 24px; right: 26px; color: #aebbc3; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; }
.module-link { color: #9a680f; font-weight: 800; font-size: 0.88rem; }

.status-panel { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; padding: 22px 26px; }
.status-panel div { display: flex; align-items: center; gap: 12px; }
.status-panel p { margin: 0; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #1d9c65; box-shadow: 0 0 0 5px rgba(29, 156, 101, 0.12); }

.message-card { max-width: 760px; margin: 20px auto; padding: clamp(32px, 6vw, 68px); }
.message-card h1 { font-size: clamp(2.3rem, 5vw, 4rem); }
.message-card .button { margin-top: 16px; }
.error-card { border-top: 5px solid var(--gold); }
.empty-state { padding: 54px; text-align: center; }
.empty-state > span { color: var(--gold); font-size: 2rem; }
.empty-state h2 { color: var(--navy); font-size: 1.6rem; }
.empty-state p { color: var(--muted); }

.module-hero, .profile-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 24px;
  padding: clamp(32px, 5vw, 58px);
  overflow: hidden;
  color: var(--white);
  background: var(--navy);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(8, 36, 56, 0.16);
}
.module-hero::after, .profile-hero::after {
  content: "✝";
  position: absolute;
  right: 22%;
  top: -45px;
  color: rgba(255,255,255,0.045);
  font-size: 15rem;
  line-height: 1;
  transform: rotate(4deg);
  pointer-events: none;
}
.module-hero > *, .profile-hero > * { position: relative; z-index: 1; }
.module-hero h1, .profile-hero h1, .form-hero h1 { margin: 0; font-size: clamp(2.3rem, 4.6vw, 4.4rem); line-height: 1.02; letter-spacing: -0.05em; }
.module-hero > div > p:last-child { max-width: 670px; margin: 20px 0 0; color: #c9d7df; font-size: 1.04rem; line-height: 1.7; }
.module-hero .eyebrow { color: var(--gold-soft); }
.module-hero .back-link, .profile-hero .back-link { color: #d8e3e9; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.metric-card { display: grid; gap: 7px; min-height: 148px; padding: 22px 24px; text-decoration: none; background: var(--white); border: 1px solid var(--line); border-radius: 14px; transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
.metric-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: 0 14px 34px rgba(5, 31, 47, 0.08); }
.metric-card.active { border-color: var(--blue); box-shadow: inset 0 3px 0 var(--blue); }
.metric-card strong { align-self: end; color: var(--navy); font-size: 2.2rem; line-height: 1; }
.metric-label { color: var(--ink); font-weight: 800; }
.metric-caption { color: var(--muted); font-size: 0.82rem; }
.metric-active strong { color: var(--success); }
.metric-attention strong { color: var(--warning); }

.content-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 14px 45px rgba(5, 31, 47, 0.07); }
.content-card-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 26px; border-bottom: 1px solid var(--line); }
.content-card-header h2 { margin: 3px 0 0; color: var(--navy); font-size: 1.35rem; }
.section-kicker { margin: 0; color: #9a680f; font-size: 0.7rem; font-weight: 850; letter-spacing: 0.16em; }
.directory-header { align-items: flex-end; }
.filter-bar { display: flex; align-items: center; gap: 10px; }
.filter-bar select, .filter-bar input, .field input, .field select, .field textarea { width: 100%; color: var(--ink); background: var(--white); border: 1px solid var(--line-strong); border-radius: 9px; font: inherit; }
.filter-bar select { min-width: 150px; height: 44px; padding: 0 36px 0 12px; }
.search-field { display: flex; align-items: center; min-width: 280px; height: 44px; padding-left: 13px; color: var(--muted); background: var(--white); border: 1px solid var(--line-strong); border-radius: 9px; }
.search-field input { height: 40px; padding: 0 12px; border: 0; outline: 0; }

.member-table { overflow: hidden; }
.member-row { display: grid; grid-template-columns: minmax(230px, 1.4fr) minmax(190px, 1fr) 150px 100px 28px; align-items: center; gap: 18px; min-height: 86px; padding: 15px 26px; color: inherit; text-decoration: none; border-top: 1px solid #e8edef; }
.member-row:not(.member-row-head):hover { background: #f8fafb; }
.member-row-head { min-height: 46px; color: var(--muted); background: #f8fafb; border-top: 0; font-size: 0.73rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.member-identity { display: flex; align-items: center; gap: 14px; min-width: 0; }
.member-identity > span:last-child, .member-contact { display: grid; gap: 4px; min-width: 0; }
.member-identity strong, .member-contact strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-identity small, .member-contact small, .relationship-count small { color: var(--muted); font-size: 0.8rem; }
.avatar { display: inline-grid; flex: 0 0 auto; place-items: center; width: 46px; height: 46px; color: var(--navy); background: #e2edf2; border: 1px solid #d1e0e7; border-radius: 12px; font-size: 0.8rem; font-weight: 900; letter-spacing: 0.04em; }
.relationship-count { display: grid; gap: 2px; }
.relationship-count strong { color: var(--navy); font-size: 1.08rem; }
.row-arrow { color: var(--blue); font-size: 1.2rem; }
.status-badge { display: inline-flex; align-items: center; width: fit-content; padding: 7px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 850; white-space: nowrap; }
.status-aktiv { color: #136144; background: #e5f4ed; }
.status-eingeladen { color: #345d78; background: #e9f1f5; }
.status-angelegt { color: #5e6870; background: #edf0f2; }
.status-in_klaerung { color: #8c590b; background: #fff2d6; }
.status-ausgetreten, .status-verzogen { color: #75515a; background: #f3e9ec; }
.empty-directory { box-shadow: none; border: 0; border-radius: 0 0 16px 16px; }
.empty-directory .button { margin-top: 16px; }
.empty-mark { display: inline-grid; place-items: center; width: 54px; height: 54px; color: var(--navy) !important; background: var(--surface-blue); border-radius: 50%; }

.form-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 40px; margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.form-hero h1 { color: var(--navy); }
.form-hero > div:first-child > p:last-child { max-width: 720px; color: var(--muted); line-height: 1.65; }
.privacy-note { display: flex; align-items: center; gap: 12px; min-width: 220px; padding: 15px 18px; color: var(--navy); background: var(--surface-blue); border-radius: 12px; }
.privacy-note > span { font-size: 1.3rem; }
.privacy-note div { display: grid; gap: 3px; }
.privacy-note small { color: var(--muted); }
.alert { margin-bottom: 20px; padding: 16px 20px; border-radius: 10px; line-height: 1.55; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert-error { color: #7b2e2e; background: #fff0f0; border: 1px solid #efc6c6; }
.alert-success { color: #12593f; background: #e8f6ef; border: 1px solid #bfdfd0; }
.member-form { display: grid; gap: 18px; }
.form-section { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 34px; padding: 30px; background: var(--white); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 36px rgba(5, 31, 47, 0.055); }
.form-section-heading { display: flex; align-items: flex-start; gap: 14px; }
.form-section-heading > span { display: inline-grid; place-items: center; width: 34px; height: 34px; color: #8d641b; background: #fff4dc; border-radius: 9px; font-size: 0.72rem; font-weight: 900; }
.form-section-heading h2 { margin: 1px 0 8px; color: var(--navy); font-size: 1.15rem; }
.form-section-heading p { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { display: grid; align-content: start; gap: 8px; min-width: 0; color: var(--ink); font-size: 0.88rem; font-weight: 750; }
.field input, .field select { height: 46px; padding: 0 13px; }
.field textarea { min-height: 100px; padding: 12px 13px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .filter-bar select:focus { border-color: var(--blue); outline: 3px solid rgba(24, 76, 112, 0.12); }
.field small, .check-field small { color: var(--muted); font-size: 0.76rem; font-weight: 500; line-height: 1.45; }
.field-wide { grid-column: 1 / -1; }
.check-field { display: flex; align-items: flex-start; gap: 12px; padding: 13px 14px; background: #f8fafb; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.check-field input, .choice-card input { width: 18px; height: 18px; accent-color: var(--blue); }
.check-field span { display: grid; gap: 3px; }
.language-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr); gap: 24px; align-items: end; }
.choice-group { margin: 0; padding: 0; border: 0; }
.choice-group legend { margin-bottom: 9px; font-size: 0.88rem; font-weight: 750; }
.choice-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.choice-card { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 10px 12px; background: #f8fafb; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.choice-card span { display: grid; gap: 2px; }
.choice-card small { color: var(--muted); font-size: 0.68rem; letter-spacing: 0.1em; }
.form-actions { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 12px; padding: 18px 0 4px; background: var(--paper); }

.profile-hero { align-items: center; }
.profile-main { flex: 1; }
.profile-title-row { display: flex; align-items: center; gap: 22px; }
.avatar-large { width: 78px; height: 78px; color: var(--navy); background: var(--gold); border: 0; border-radius: 18px; font-size: 1.15rem; }
.profile-hero h1 { font-size: clamp(2.3rem, 4vw, 4rem); }
.profile-title-row p { margin: 7px 0 0; color: #c9d7df; }
.profile-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; color: #c9d7df; font-size: 0.82rem; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, 0.7fr); gap: 20px; align-items: start; }
.detail-main, .detail-sidebar { display: grid; gap: 20px; }
.detail-card .content-card-header { padding-bottom: 20px; }
.section-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; color: var(--navy); background: var(--surface-blue); border-radius: 10px; font-weight: 900; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; margin: 0; padding: 8px 26px 24px; }
.detail-grid > div { min-width: 0; padding: 18px 0; border-bottom: 1px solid #e9edef; }
.detail-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.detail-grid > div:nth-child(odd) { padding-right: 20px; }
.detail-grid > div:nth-child(even) { padding-left: 20px; border-left: 1px solid #e9edef; }
.detail-grid .detail-wide { grid-column: 1 / -1; padding-left: 0 !important; padding-right: 0 !important; border-left: 0 !important; }
.detail-grid dt { margin-bottom: 7px; color: var(--muted); font-size: 0.75rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.07em; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; line-height: 1.55; }
.inline-tag { display: inline-flex; margin: 3px 5px 3px 0; padding: 5px 8px; color: #31566d; background: #eaf2f6; border-radius: 6px; font-size: 0.72rem; font-weight: 800; }
.sensitive-card { border-top: 3px solid var(--gold); }
.preline { white-space: pre-line; }
.count-bubble { display: inline-grid; place-items: center; width: 34px; height: 34px; color: var(--navy); background: var(--surface-blue); border-radius: 50%; }
.relationship-list { padding: 8px 20px 14px; }
.relationship-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0; border-bottom: 1px solid #e9edef; }
.relationship-item:last-child { border-bottom: 0; }
.relationship-item > a { display: flex; align-items: center; gap: 11px; min-width: 0; text-decoration: none; }
.relationship-item > a > span:last-child { display: grid; gap: 3px; min-width: 0; }
.relationship-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.88rem; }
.relationship-item small { color: var(--muted); font-size: 0.75rem; }
.avatar-small { width: 36px; height: 36px; border-radius: 9px; font-size: 0.68rem; }
.icon-button { display: inline-grid; place-items: center; width: 30px; height: 30px; color: var(--muted); background: transparent; border: 0; border-radius: 7px; font-size: 1.2rem; cursor: pointer; }
.icon-button:hover { color: var(--danger); background: #fff0f0; }
.relationship-form { display: grid; gap: 13px; margin: 0 20px 20px; padding: 18px; background: #f8fafb; border: 1px solid var(--line); border-radius: 12px; }
.card-empty { margin: 0; padding: 24px; color: var(--muted); line-height: 1.55; }
.audit-list { list-style: none; margin: 0; padding: 18px 24px 24px; }
.audit-list li { display: flex; gap: 12px; padding: 0 0 18px; }
.audit-list li:last-child { padding-bottom: 0; }
.audit-list li > span { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; background: var(--gold); border-radius: 50%; box-shadow: 0 0 0 5px #fff4dc; }
.audit-list div { display: grid; gap: 4px; }
.audit-list strong { font-size: 0.84rem; }
.audit-list small { color: var(--muted); font-size: 0.72rem; line-height: 1.45; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }

.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 26px clamp(22px, 5vw, 76px); color: #c4d0d7; background: var(--navy-deep); font-size: 0.86rem; }
.site-footer a { color: var(--gold-soft); text-decoration: none; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-panel { align-items: flex-start; flex-direction: column; }
  .account-name { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory-header { align-items: stretch; flex-direction: column; }
  .filter-bar { flex-wrap: wrap; }
  .search-field { flex: 1 1 260px; }
  .member-row { grid-template-columns: minmax(210px, 1.4fr) minmax(160px, 1fr) 130px 26px; }
  .member-row > :nth-child(4) { display: none; }
  .form-section { grid-template-columns: 1fr; }
  .form-section-heading { max-width: 480px; }
  .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .site-header { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 12px 16px; }
  .brand img { width: 174px; height: 46px; }
  .portal-nav { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 4px 0 0; overflow-x: auto; }
  .account { justify-content: flex-end; }
  .page-shell { width: min(100% - 28px, 1180px); }
  .module-grid { grid-template-columns: 1fr; }
  .module-card { min-height: 220px; }
  .site-footer { flex-direction: column; }
  .module-hero, .profile-hero, .form-hero { align-items: flex-start; flex-direction: column; }
  .module-hero, .profile-hero { padding: 28px 22px; }
  .module-hero h1 { font-size: 2.45rem; }
  .module-hero .button, .profile-hero .button { width: 100%; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 126px; padding: 18px; }
  .filter-bar { display: grid; grid-template-columns: 1fr; }
  .search-field { min-width: 0; width: 100%; }
  .member-row-head { display: none; }
  .member-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 17px 18px; }
  .member-row > :nth-child(2), .member-row > :nth-child(4) { display: none; }
  .member-row > :nth-child(3) { grid-column: 1; padding-left: 60px; }
  .member-row > :nth-child(5) { grid-column: 2; grid-row: 1 / span 2; }
  .form-section { padding: 22px 18px; }
  .form-grid, .language-layout { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .profile-title-row { align-items: flex-start; }
  .avatar-large { width: 60px; height: 60px; border-radius: 14px; }
  .profile-meta { align-items: flex-start; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid > div { padding: 16px 0 !important; border-left: 0 !important; border-bottom: 1px solid #e9edef !important; }
  .detail-grid > div:last-child { border-bottom: 0 !important; }
}

:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
