:root {
  color-scheme: dark;
  --bg: #0b0b12;
  --surface: #14141d;
  --surface-2: #1b1a27;
  --border: #2b2938;
  --border-soft: #22212d;
  --text: #f4f2fa;
  --muted: #aaa6b8;
  --purple: #8d4cff;
  --purple-2: #6d36d9;
  --purple-soft: rgba(141, 76, 255, .14);
  --green: #44d68a;
  --yellow: #f4bf4f;
  --red: #ff667d;
  --blue: #66a7ff;
  --radius: 18px;
  --shadow: 0 18px 55px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -5%, rgba(109, 54, 217, .22), transparent 32rem),
    radial-gradient(circle at 96% 12%, rgba(69, 103, 255, .12), transparent 27rem),
    var(--bg);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { touch-action: manipulation; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 56px);
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: rgba(11, 11, 18, .84);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 14px;
  background: linear-gradient(135deg, var(--purple), #4f24ab);
  box-shadow: 0 8px 24px rgba(109, 54, 217, .35);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { color: var(--muted); font-size: 11px; }
.topnav { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.topnav > a:hover { color: var(--text); }
.user-chip { display: flex; align-items: center; gap: 8px; color: var(--text); }
.user-chip img, .avatar-fallback { width: 30px; height: 30px; border-radius: 50%; }
.avatar-fallback { display: grid; place-items: center; background: var(--purple-2); font-weight: 800; }

.page-shell { width: min(1480px, calc(100% - 36px)); margin: 0 auto; padding: 44px 0 70px; }
.footer { padding: 28px; border-top: 1px solid var(--border-soft); color: #777382; text-align: center; font-size: 12px; }
.page-heading, .patient-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 30px;
}
.page-heading h1, .patient-hero h1, .center-card h1 { margin: 4px 0 6px; font-size: clamp(30px, 4vw, 48px); line-height: 1.08; letter-spacing: -.035em; }
.page-heading p, .patient-hero p, .center-card > p { max-width: 720px; margin: 0; color: var(--muted); }
.compact-heading h1 { font-size: clamp(28px, 3vw, 40px); }
.eyebrow { color: #b990ff; font-size: 11px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 750;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); border-color: #4b465d; }
.button-primary { border-color: transparent; background: linear-gradient(135deg, var(--purple), var(--purple-2)); box-shadow: 0 8px 24px rgba(109, 54, 217, .25); }
.button-danger { border-color: transparent; background: linear-gradient(135deg, #ff647c, #be2f4f); }
.button-small { min-height: 36px; padding: 7px 12px; font-size: 13px; }
.button-large { min-height: 50px; padding: 13px 22px; }
.button-full { width: 100%; }
.button-link { min-height: 0; padding: 0; border: 0; color: #ceb6ff; background: transparent; }
.hidden { display: none !important; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 30px; }
.stat-card {
  min-height: 140px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(255,255,255,.025), transparent), var(--surface);
  box-shadow: var(--shadow);
}
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 8px 0 3px; font-size: 36px; letter-spacing: -.04em; }
.stat-free strong { color: var(--green); }
.stat-clean strong { color: var(--blue); }
.stat-reserved strong { color: var(--yellow); }

.station-section, .jobs-panel, .info-card {
  margin-top: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(20, 20, 29, .86);
  box-shadow: var(--shadow);
}
.station-header, .room-title, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.station-header > div { display: flex; align-items: center; gap: 14px; }
.station-header h2, .section-title h2, .info-card h2 { margin: 0; font-size: 21px; letter-spacing: -.02em; }
.station-header p { margin: 2px 0 0; color: var(--muted); }
.station-icon { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid #3a3350; border-radius: 14px; background: var(--purple-soft); font-size: 23px; }
.station-count, .room-title span { color: var(--muted); font-size: 12px; }
.room-block { margin-top: 24px; }
.room-title { margin-bottom: 10px; }
.room-title h3 { margin: 0; font-size: 14px; }
.bed-grid { display: grid; grid-template-columns: repeat(4, minmax(210px, 1fr)); gap: 12px; }
.bed-card { min-height: 180px; padding: 16px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); }
.bed-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bed-card-head > div { display: flex; align-items: center; gap: 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #777; box-shadow: 0 0 0 4px rgba(120,120,120,.1); }
.status-label { color: var(--muted); font-size: 11px; text-transform: capitalize; }
.status-frei .status-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(68,214,138,.1); }
.status-belegt .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(255,102,125,.1); }
.status-reinigung .status-dot { background: var(--blue); box-shadow: 0 0 0 4px rgba(102,167,255,.1); }
.status-reserviert .status-dot { background: var(--yellow); box-shadow: 0 0 0 4px rgba(244,191,79,.1); }
.patient-preview { display: grid; gap: 3px; margin: 22px 0; }
.patient-preview strong { font-size: 17px; }
.patient-preview span, .bed-note { color: var(--muted); font-size: 12px; }
.bed-note { min-height: 56px; margin: 25px 0 12px; }
.card-link { color: #ceb6ff; font-size: 13px; font-weight: 800; }
.card-link:hover { color: #e1d2ff; }

.job-list { display: grid; margin-top: 16px; }
.job-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--border-soft); }
.job-row:first-child { border-top: 0; }
.job-row small { display: block; color: var(--muted); }
.job-status { width: 10px; height: 10px; border-radius: 50%; background: var(--yellow); }
.job-done { background: var(--green); }
.job-failed { background: var(--red); }
.job-label { color: var(--muted); text-transform: capitalize; }

.form-layout { display: grid; gap: 18px; }
.form-card, .action-card {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.form-card-title { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.form-card-title > span { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--purple-soft); color: #d5c0ff; font-weight: 900; }
.form-card-title h2, .action-card h2 { margin: 0; font-size: 18px; }
.form-card-title p, .action-card > p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { position: relative; display: grid; align-content: start; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field-wide { grid-column: 1 / -1; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #343141;
  border-radius: 11px;
  outline: none;
  color: var(--text);
  background: #0f0f17;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(141,76,255,.12); }
.form-submit { position: sticky; bottom: 14px; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 1px solid #403457; border-radius: 16px; background: rgba(22, 19, 32, .94); backdrop-filter: blur(14px); box-shadow: var(--shadow); }
.form-submit strong, .form-submit span { display: block; }
.form-submit span { color: var(--muted); font-size: 12px; }

.member-selected { min-height: 36px; padding: 8px 10px; border: 1px dashed #3c374a; border-radius: 10px; color: #8e899a; font-weight: 500; }
.member-selected.has-member { border-style: solid; border-color: rgba(141,76,255,.5); color: var(--text); background: var(--purple-soft); }
.member-results { position: absolute; z-index: 15; top: 72px; left: 0; right: 0; max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 12px; background: #171620; box-shadow: var(--shadow); }
.member-results:empty { display: none; }
.member-option { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px; border: 0; border-bottom: 1px solid var(--border-soft); color: var(--text); background: transparent; text-align: left; cursor: pointer; }
.member-option:hover, .member-option:focus { background: var(--purple-soft); }
.member-option img, .member-option .mini-avatar { width: 32px; height: 32px; border-radius: 50%; }
.mini-avatar { display: grid; place-items: center; background: var(--purple-2); }
.member-option small { display: block; color: var(--muted); }
.member-self-button { justify-self: start; padding: 8px 11px; border: 1px solid rgba(141,76,255,.4); border-radius: 10px; color: #d9c8ff; background: rgba(141,76,255,.1); font: inherit; cursor: pointer; }
.member-self-button:hover, .member-self-button:focus { border-color: var(--purple); background: rgba(141,76,255,.18); }
.patient-copy-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 18px; padding: 14px 16px; border: 1px solid rgba(68,214,138,.28); border-radius: 14px; background: rgba(68,214,138,.07); }
.patient-copy-note > span { font-size: 24px; }
.patient-copy-note strong, .patient-copy-note small { display: block; }
.patient-copy-note small { margin-top: 3px; color: var(--muted); line-height: 1.45; }

.patient-hero { padding: 28px; border: 1px solid #352d47; border-radius: 22px; background: linear-gradient(135deg, rgba(141,76,255,.14), rgba(20,20,29,.92) 55%); }
.back-link { display: inline-block; margin-bottom: 18px; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.patient-facts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin: 18px 0; }
.patient-facts article { padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.patient-facts span, .patient-facts strong { display: block; }
.patient-facts span { color: var(--muted); font-size: 11px; }
.patient-facts strong { margin-top: 5px; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, .7fr); gap: 18px; align-items: start; }
.detail-main, .action-stack { display: grid; gap: 18px; }
.action-stack { position: sticky; top: 92px; }
.description-list { margin: 18px 0 0; }
.description-list > div { display: grid; grid-template-columns: 180px 1fr; gap: 16px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.description-list dt { color: var(--muted); }
.description-list dd { margin: 0; }
.action-card form { display: grid; gap: 12px; margin-top: 14px; }
.danger-card { border-color: rgba(255,102,125,.32); background: linear-gradient(145deg, rgba(255,102,125,.06), var(--surface)); }
.timeline { margin-top: 18px; }
.timeline-row { position: relative; display: grid; grid-template-columns: 14px 1fr; gap: 12px; padding-bottom: 20px; }
.timeline-row::before { content: ""; position: absolute; left: 4px; top: 13px; bottom: 0; width: 1px; background: var(--border); }
.timeline-dot { z-index: 1; width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--purple); }
.timeline-row small { display: block; color: var(--muted); }
.timeline-row p { margin: 5px 0 0; color: #cbc7d4; }
code { padding: 2px 5px; border-radius: 6px; background: #0d0d14; color: #d6c2ff; }

.center-card { width: min(620px, 100%); margin: 8vh auto; padding: clamp(25px, 5vw, 44px); border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); text-align: center; }
.center-card .button { margin-top: 24px; }
.status-orb { display: grid; place-items: center; width: 54px; height: 54px; margin: 0 auto 20px; border-radius: 18px; background: var(--purple-soft); color: #d9c5ff; font-size: 24px; font-weight: 900; }
.confirm-dialog { width: min(470px, calc(100% - 32px)); margin: auto; padding: 0; border: 1px solid #443753; border-radius: 18px; color: var(--text); background: #17151f; box-shadow: 0 28px 90px rgba(0,0,0,.62); }
.confirm-dialog::backdrop { background: rgba(5,5,10,.72); backdrop-filter: blur(4px); }
.confirm-dialog-panel { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 24px; }
.confirm-dialog-icon { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(141,76,255,.42); border-radius: 12px; color: #ddceff; background: var(--purple-soft); font-size: 20px; font-weight: 900; }
.confirm-dialog-copy h2 { margin: 2px 0 7px; font-size: 20px; }
.confirm-dialog-copy p { margin: 0; color: var(--muted); line-height: 1.55; }
.confirm-dialog-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.confirm-dialog-actions .button { min-width: 112px; }
.setup-list { display: grid; gap: 6px; margin: 22px 0; padding: 0; list-style: none; }
.copy-value { margin: 14px 0; padding: 14px; overflow-wrap: anywhere; border: 1px solid var(--border); border-radius: 12px; background: #0e0e16; }
.notice { margin: 18px 0; padding: 13px; border: 1px solid var(--border); border-radius: 11px; text-align: left; }
.notice.success { border-color: rgba(68,214,138,.35); background: rgba(68,214,138,.08); }
.notice.danger { border-color: rgba(255,102,125,.35); background: rgba(255,102,125,.08); }
.loader-ring { width: 46px; height: 46px; margin: 0 auto 22px; border: 4px solid #2e293a; border-top-color: var(--purple); border-radius: 50%; animation: spin .8s linear infinite; }
.job-state { display: inline-flex; margin-top: 18px; padding: 6px 11px; border-radius: 99px; background: var(--purple-soft); color: #d9c5ff; font-weight: 800; text-transform: capitalize; }
.job-state-done { background: rgba(68,214,138,.1); color: var(--green); }
.job-state-failed { background: rgba(255,102,125,.1); color: var(--red); }
.empty-state, .empty-inline { padding: 22px; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }
.empty-state { text-align: center; }

.filter-bar, .table-card {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.filter-bar { display: grid; grid-template-columns: minmax(260px, 1fr) 190px auto; gap: 14px; align-items: end; }
.responsive-table { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.pill { display: inline-flex; padding: 4px 8px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); font-size: 11px; text-transform: capitalize; }
.pill-aktiv { border-color: rgba(68,214,138,.3); color: var(--green); background: rgba(68,214,138,.08); }
.pill-entlassen, .pill-archiv { color: #aaa5b3; background: rgba(255,255,255,.04); }

.admin-create-card { margin-bottom: 20px; }
.inline-form-grid { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)) auto; gap: 12px; align-items: end; }
.inline-form-note { grid-template-columns: minmax(250px, 1fr) auto; }
.admin-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; margin: 20px 0; }
.admin-room { margin-top: 20px; padding: 18px; border: 1px solid var(--border-soft); border-radius: 16px; background: rgba(255,255,255,.015); }
.admin-room .room-title h3 { display: flex; align-items: center; gap: 8px; }
.admin-controls-grid { display: grid; grid-template-columns: repeat(3, 1fr) 150px; gap: 12px; margin: 14px 0 18px; }
.mini-form { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--border-soft); border-radius: 12px; background: #11111a; }
.admin-bed-grid { display: grid; grid-template-columns: repeat(3, minmax(250px, 1fr)); gap: 12px; }
.admin-bed { display: grid; align-content: start; gap: 11px; min-height: 180px; padding: 15px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.mono-id { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; overflow-wrap: anywhere; }
.reservation-box { padding: 11px; border: 1px solid rgba(244,191,79,.28); border-radius: 10px; background: rgba(244,191,79,.06); }
.reservation-box strong, .reservation-box small { display: block; }
.reservation-box small { margin-top: 3px; color: var(--muted); }
.reservation-box p { margin: 7px 0 10px; color: #cec8b9; font-size: 12px; }
details > summary { cursor: pointer; color: #d7c8f7; font-weight: 800; }
.admin-bed details { padding: 10px; border: 1px solid var(--border-soft); border-radius: 10px; }
.admin-bed details .mini-form { margin-top: 10px; padding: 0; border: 0; background: transparent; }

.detail-grid-wide { grid-template-columns: minmax(0, 1.55fr) minmax(330px, .75fr); }
.action-card[open] > summary { margin-bottom: 14px; }
.action-card > summary { font-size: 17px; }
.action-card > form + form { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-soft); }
.record-list { display: grid; margin-top: 16px; }
.record-list > div { display: grid; gap: 5px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.record-list small { color: var(--muted); }
.document-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.document-card { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.document-card:hover { border-color: #52436d; }
.document-card strong, .document-card small { display: block; overflow-wrap: anywhere; }
.document-card small, .document-card p { color: var(--muted); }
.document-card p { margin: 6px 0 0; font-size: 12px; }

.report-type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; margin-bottom: 22px; }
.report-type-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; min-height: 110px; padding: 20px; border: 1px solid var(--border); border-radius: 18px; background: linear-gradient(145deg, rgba(141,76,255,.08), var(--surface)); box-shadow: var(--shadow); }
.report-type-card:hover { transform: translateY(-2px); border-color: #5a4777; }
.report-type-card > span { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--purple-soft); font-size: 25px; }
.report-type-card strong, .report-type-card small { display: block; }
.report-type-card small { margin-top: 4px; color: var(--muted); }
.report-type-card b { color: #ccb4ff; }
.report-stats .stat-card { min-height: 120px; }
.verdict { display: inline-flex; padding: 5px 9px; border-radius: 99px; font-size: 11px; font-weight: 900; }
.verdict-positiv { color: var(--green); background: rgba(68,214,138,.1); }
.verdict-negativ { color: var(--red); background: rgba(255,102,125,.1); }
.report-status-sent { border-color: rgba(68,214,138,.3); color: var(--green); }
.report-status-failed { border-color: rgba(255,102,125,.3); color: var(--red); }
.report-status-queued, .report-status-processing { border-color: rgba(244,191,79,.3); color: var(--yellow); }
.type-tabs { display: flex; flex-wrap: wrap; gap: 9px; margin: -8px 0 24px; }
.type-tabs a { padding: 10px 14px; border: 1px solid var(--border); border-radius: 99px; color: var(--muted); background: var(--surface); }
.type-tabs a.active { border-color: #7551ae; color: #e2d4ff; background: var(--purple-soft); }
.justice-form { max-width: 980px; margin: 0 auto; }
.verdict-choice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.verdict-choice label { cursor: pointer; }
.verdict-choice input { position: absolute; opacity: 0; pointer-events: none; }
.verdict-choice span { display: grid; gap: 5px; min-height: 110px; padding: 20px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); }
.verdict-choice small { color: var(--muted); }
.verdict-choice input:checked + .verdict-positive { border-color: var(--green); box-shadow: 0 0 0 3px rgba(68,214,138,.12); }
.verdict-choice input:checked + .verdict-negative { border-color: var(--red); box-shadow: 0 0 0 3px rgba(255,102,125,.12); }
.upload-drop { display: grid; place-items: center; min-height: 220px; padding: 28px; border: 1px dashed #5e4a7b; border-radius: 18px; background: var(--purple-soft); text-align: center; cursor: pointer; }
.upload-drop > span { font-size: 42px; }
.upload-drop strong { margin: 10px 0 4px; }
.upload-drop small { color: var(--muted); }
.upload-drop input { margin-top: 18px; max-width: 100%; }
.justice-hero { align-items: center; }
.report-state { display: inline-flex; padding: 9px 14px; border: 1px solid var(--border); border-radius: 99px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.report-state-sent { color: var(--green); border-color: rgba(68,214,138,.3); background: rgba(68,214,138,.08); }
.report-state-failed { color: var(--red); border-color: rgba(255,102,125,.3); background: rgba(255,102,125,.08); }
.report-state-queued, .report-state-processing { color: var(--yellow); border-color: rgba(244,191,79,.3); background: rgba(244,191,79,.08); }
.prewrap { white-space: pre-wrap; }
.staff-account-layout { grid-template-columns: minmax(420px, 1fr) minmax(300px, .7fr); margin-bottom: 20px; }
.staff-account-layout .form-card form { display: grid; gap: 14px; }
.security-card { margin-top: 0; }
.portal-module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; max-width: 1050px; }
.portal-module-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; min-height: 250px; padding: 28px; border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(145deg, rgba(141,76,255,.1), var(--surface) 55%); box-shadow: var(--shadow); }
.portal-module-card:hover { transform: translateY(-2px); border-color: #5f4980; }
.portal-module-card > span { display: grid; place-items: center; width: 62px; height: 62px; border-radius: 18px; background: var(--purple-soft); font-size: 31px; }
.portal-module-card h2 { margin: 5px 0 9px; font-size: 25px; }
.portal-module-card p { min-height: 75px; margin: 0 0 18px; color: var(--muted); line-height: 1.55; }
.portal-module-card b { color: #d6c0ff; }
.role-lock { display: inline-flex; align-items: center; padding: 9px 13px; border: 1px solid rgba(141,76,255,.38); border-radius: 99px; color: #d7c3ff; background: var(--purple-soft); font-size: 12px; font-weight: 800; }
.dm-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 390px); align-items: start; gap: 20px; }
.dm-compose-card { background: linear-gradient(145deg, rgba(141,76,255,.08), var(--surface) 42%); }
.dm-safety-note { display: flex; align-items: flex-start; gap: 12px; margin-top: 20px; padding: 14px 16px; border: 1px solid rgba(141,76,255,.3); border-radius: 14px; background: rgba(141,76,255,.07); }
.dm-safety-note > span { font-size: 23px; }
.dm-safety-note strong, .dm-safety-note small { display: block; }
.dm-safety-note small { margin-top: 3px; color: var(--muted); line-height: 1.45; }
.dm-history-card { position: sticky; top: 88px; }
.dm-history-list { display: grid; gap: 0; }
.dm-history-list article { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 13px 0; border-top: 1px solid var(--border-soft); }
.dm-history-list article:first-child { border-top: 0; }
.dm-history-list strong, .dm-history-list small { display: block; overflow-wrap: anywhere; }
.dm-history-list small { margin-top: 3px; color: var(--muted); }
.dm-history-list p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

.brand-logo { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 13px; object-fit: cover; background: #fff; box-shadow: 0 0 0 1px rgba(255,255,255,.12); }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.portal-hero { max-width: 900px; margin: 20px auto 34px; text-align: center; }
.portal-hero h1 { margin: 8px 0 14px; font-size: clamp(36px, 6vw, 68px); line-height: 1.02; letter-spacing: -.045em; }
.portal-hero p { max-width: 760px; margin: 0 auto; color: var(--muted); font-size: 18px; line-height: 1.65; }
.area-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; max-width: 1180px; margin: 0 auto; }
.area-card { position: relative; display: grid; grid-template-columns: 128px 1fr; gap: 24px; align-items: center; min-height: 310px; padding: 34px; overflow: hidden; border: 1px solid var(--border); border-radius: 26px; color: var(--text); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; transition: transform .2s ease, border-color .2s ease; }
.area-card:hover { transform: translateY(-4px); border-color: #79619d; }
.area-card::after { content: ""; position: absolute; inset: auto -80px -120px auto; width: 270px; height: 270px; border-radius: 50%; background: rgba(255,255,255,.035); }
.area-card img { width: 128px; height: 128px; border-radius: 25px; object-fit: cover; background: #fff; }
.area-card h2 { margin: 10px 0; font-size: 27px; line-height: 1.16; }
.area-card p { min-height: 82px; margin: 0 0 20px; color: var(--muted); line-height: 1.55; }
.area-card strong { color: #fff; }
.area-card.area-mhr { background: linear-gradient(145deg, rgba(33,112,177,.18), var(--surface) 58%); }
.area-card.area-psd { background: linear-gradient(145deg, rgba(141,76,255,.18), var(--surface) 58%); }
.area-tag { display: inline-flex; padding: 7px 11px; border: 1px solid rgba(255,255,255,.13); border-radius: 99px; color: #dfeeff; background: rgba(255,255,255,.05); font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.mhr-heading { padding: 28px; border: 1px solid rgba(70,151,210,.22); border-radius: 22px; background: linear-gradient(145deg, rgba(33,112,177,.13), rgba(19,22,29,.9)); }
.mhr-system-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.mhr-system-card { display: grid; grid-template-columns: 56px 1fr; gap: 18px; padding: 24px; border: 1px solid var(--border); border-radius: 19px; background: var(--surface); box-shadow: var(--shadow); }
.mhr-system-card > span { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: rgba(33,112,177,.15); font-size: 27px; }
.mhr-system-card h2 { margin: 2px 0 7px; font-size: 20px; }
.mhr-system-card p, .portal-note p { margin: 0; color: var(--muted); line-height: 1.55; }
.mhr-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.mhr-card-actions a, .mhr-card-actions span { display: inline-flex; align-items: center; min-height: 36px; padding: 8px 11px; border: 1px solid rgba(121,160,255,.34); border-radius: 10px; font-size: 12px; font-weight: 800; text-decoration: none; }
.mhr-card-actions a { color: #d8e3ff; background: rgba(33,112,177,.13); transition: border-color .18s ease, background .18s ease, transform .18s ease; }
.mhr-card-actions a:hover, .mhr-card-actions a:focus { border-color: #739cff; background: rgba(33,112,177,.24); transform: translateY(-1px); }
.mhr-card-actions span { color: var(--muted); border-color: var(--border); background: rgba(255,255,255,.025); }
.portal-note { margin-top: 20px; padding: 22px 24px; border: 1px solid rgba(68,214,138,.2); border-radius: 18px; background: rgba(68,214,138,.055); }
.portal-note strong { display: block; margin-bottom: 6px; }

@media (max-width: 1100px) {
  .bed-grid { grid-template-columns: repeat(3, minmax(200px, 1fr)); }
  .patient-facts { grid-template-columns: repeat(3, 1fr); }
  .admin-controls-grid, .admin-bed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-type-grid { grid-template-columns: 1fr; }
  .dm-layout { grid-template-columns: 1fr; }
  .dm-history-card { position: static; }
}
@media (max-width: 820px) {
  .topbar { align-items: flex-start; }
  .topnav { justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
  .topnav > a:not(.button), .user-chip { font-size: 12px; }
  .page-shell { width: min(100% - 24px, 1480px); padding-top: 28px; }
  .page-heading, .patient-hero, .form-submit { align-items: stretch; flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .bed-grid { grid-template-columns: repeat(2, minmax(190px, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .staff-account-layout { grid-template-columns: 1fr; }
  .portal-module-grid { grid-template-columns: 1fr; }
  .area-grid, .mhr-system-grid { grid-template-columns: 1fr; }
  .action-stack { position: static; }
  .admin-row, .admin-controls-grid { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .brand small, .topnav > a:not(.button), .user-chip { display: none; }
  .topbar { min-height: 62px; padding: 9px 13px; }
  .brand-mark { width: 38px; height: 38px; }
  .brand-logo { width: 38px; height: 38px; flex-basis: 38px; }
  .area-card { grid-template-columns: 1fr; padding: 24px; }
  .area-card img { width: 88px; height: 88px; border-radius: 20px; }
  .area-card p { min-height: 0; }
  .mhr-system-card { grid-template-columns: 46px 1fr; padding: 18px; }
  .mhr-system-card > span { width: 46px; height: 46px; }
  .page-heading h1, .patient-hero h1 { font-size: 31px; }
  .stats-grid, .bed-grid, .field-grid, .patient-facts { grid-template-columns: 1fr; }
  .filter-bar, .admin-bed-grid, .inline-form-grid, .document-grid { grid-template-columns: 1fr; }
  .verdict-choice { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .station-section, .jobs-panel, .info-card, .form-card, .patient-hero { padding: 17px; }
  .description-list > div { grid-template-columns: 1fr; gap: 3px; }
  .form-submit { position: static; }
  .confirm-dialog-panel { grid-template-columns: 1fr; padding: 20px; }
  .confirm-dialog-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .confirm-dialog-actions .button { min-width: 0; }
}
