:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1c2421;
  --muted: #5f6b66;
  --line: #dfe4e1;
  --brand: #0f6b5c;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ed;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --ok: #18794e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.06), 0 2px 8px rgba(16, 24, 20, 0.05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

.topbar { background: var(--brand); color: var(--brand-ink); }
.topbar .inner { max-width: 880px; margin: auto; padding: 14px 16px; display: flex; gap: 12px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.topbar .name { font-weight: 650; font-size: 1.1rem; }
.topbar .contact { font-size: 0.875rem; opacity: 0.9; }

main { max-width: 880px; margin: 0 auto; padding: 20px 16px 48px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px; }

.steps { display: flex; gap: 6px; margin: 0 0 16px; padding: 0; list-style: none; font-size: 0.85rem; color: var(--muted); flex-wrap: wrap; }
.steps li { display: flex; align-items: center; gap: 6px; }
.steps li + li::before { content: "›"; margin-right: 6px; color: var(--line); }
.steps li.active { color: var(--brand); font-weight: 600; }
.steps li.done { color: var(--text); }

.choice-list { display: grid; gap: 10px; }
.choice {
  text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; font: inherit; color: inherit; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.choice:hover, .choice:focus-visible { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px var(--brand-soft); }
.choice .title { font-weight: 600; }
.choice .meta { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }

.week-nav { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.days { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.day h3 { font-size: 0.9rem; margin-bottom: 6px; }
.day .none { font-size: 0.85rem; color: var(--muted); }
.slot-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.slot { border: 1px solid var(--brand); color: var(--brand); background: var(--card); border-radius: 6px; padding: 6px 10px; font: inherit; font-size: 0.9rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot:hover, .slot:focus-visible { background: var(--brand); color: var(--brand-ink); outline: none; }

.summary { background: var(--brand-soft); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.full { grid-column: 1 / -1; }
label { display: block; font-size: 0.875rem; font-weight: 550; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: auto; margin-top: 4px; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-row label { display: flex; gap: 6px; align-items: center; font-weight: 400; }
.radio-row input { width: auto; }
.hp { position: absolute; left: -9999px; }

.btn { font: inherit; font-weight: 600; border-radius: 7px; padding: 10px 16px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.secondary { background: var(--card); color: var(--brand); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.btn-link { background: none; border: none; color: var(--brand); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
.actions { display: flex; gap: 10px; justify-content: space-between; align-items: center; margin-top: 16px; flex-wrap: wrap; }

.alert { border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--brand-soft); color: var(--brand); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

footer { max-width: 880px; margin: 0 auto; padding: 0 16px 32px; font-size: 0.85rem; color: var(--muted); display: flex; gap: 16px; }

/* Admin */
.admin main { max-width: 1200px; }
.admin .topbar .inner { max-width: 1200px; }
.tabs { display: flex; flex-wrap: wrap; gap: 0 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { font: inherit; font-size: 0.95rem; background: none; border: none; padding: 10px 11px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--line); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--brand-soft); color: var(--ok); }
.badge.err { background: var(--danger-soft); color: var(--danger); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar > div { min-width: 140px; }
.hours-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr auto; gap: 8px; margin-bottom: 6px; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { display: flex; gap: 6px; align-items: center; font-weight: 400; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; }
.chips input { width: auto; }
.log { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; max-height: 320px; overflow: auto; background: #f3f4f2; border-radius: 8px; padding: 10px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--card); }
.kpi .v { font-size: 1.5rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 0.8rem; color: var(--muted); }
dialog { border: none; border-radius: var(--radius); padding: 20px; width: min(640px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(16, 24, 20, 0.4); }

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .hours-row { grid-template-columns: 1fr 1fr; }
}

/* Version & Changelog */
.version-btn { font: inherit; font-size: 0.75rem; font-weight: 600; margin-left: 8px; padding: 1px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.45); background: transparent; color: inherit; cursor: pointer; vertical-align: middle; }
.version-btn:hover { background: rgba(255,255,255,.15); }
.dlg-top { margin: 0 0 8px; justify-content: space-between; }
.dlg-top h2 { margin: 0; }
.md h2 { font-size: 1.1rem; margin: 14px 0 6px; }
.md h3 { font-size: 1rem; margin: 18px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
.md h4 { font-size: 0.9rem; margin: 10px 0 4px; color: var(--muted); }
.md ul { margin: 0 0 8px; padding-left: 20px; }
.md li { margin: 2px 0; }
.md p { margin: 4px 0; }
.md code { background: var(--brand-soft); padding: 0 4px; border-radius: 4px; font-size: 0.85em; }
#changelogDlg { width: min(760px, calc(100vw - 32px)); max-height: 85vh; }

.header-actions { display: flex; gap: 8px; align-items: center; }
.topbar a.btn.secondary { text-decoration: none; }

.toolbar .checks { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toolbar .grow { flex: 1; margin: 0; }
.test-row { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); align-items: end; }
.sticky-save { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--line); }
#dlg .table-wrap { max-height: 260px; overflow: auto; margin-bottom: 12px; }
#dlg textarea { min-height: 90px; }

.restart-overlay { position: fixed; inset: 0; background: rgba(16, 24, 20, .55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.restart-overlay .card { max-width: 440px; }
td.nowrap { white-space: nowrap; }

a.btn { text-decoration: none; display: inline-block; }

#dlg { max-height: 92vh; overflow: auto; }
#dlg h3 { margin: 16px 0 6px; }

/* Eingebettet (Webseiten-Box / Inline auf der Praxis-Webseite) */
.embed body { background: var(--bg); }
.embed .topbar, .embed footer { display: none; }
.embed main { padding: 14px 14px 20px; }
.embed .card { box-shadow: none; padding: 16px; }
.embed h1 { font-size: 1.15rem; }
.embed .steps { font-size: 0.78rem; margin-bottom: 10px; }
.embed-inline body, .embed-inline main { background: transparent; }
/* Außenabstand der letzten Karte muss zur gemeldeten Höhe zählen, sonst Scrollbalken auf der Webseite */
.embed-inline body { display: flow-root; }
.embed-inline main { padding: 0; max-width: none; }
.embed-panel .days { grid-template-columns: 1fr 1fr; }

/* Admin: Webseiten-Box */
.widget-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.widget-side { position: sticky; top: 12px; }
.widget-preview { padding: 14px; }
.widget-preview .toolbar { margin-bottom: 8px; }
.preview-stage { background: #e9ecea; border-radius: 8px; overflow: hidden; position: relative; }
.preview-stage iframe { border: 0; background: #fff; display: block; position: absolute; top: 0; transform-origin: 0 0; box-shadow: 0 0 0 1px var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 0.85rem; border: 0; background: var(--card); padding: 6px 12px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--brand); color: var(--brand-ink); }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 46px; height: 40px; padding: 2px; flex: none; cursor: pointer; }
.code-box { position: relative; margin: 6px 0 14px; }
.code-box pre { margin: 0; background: #1f2724; color: #e6efe9; border-radius: 8px; padding: 12px 14px; padding-right: 96px; overflow-x: auto; font: 0.82rem/1.5 ui-monospace, Menlo, Consolas, monospace; white-space: pre; }
.code-box .btn { position: absolute; top: 8px; right: 8px; }
details.more { margin-top: 8px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--brand); margin-bottom: 8px; }
@media (max-width: 1100px) {
  .widget-layout { grid-template-columns: 1fr; }
  .widget-side { position: static; order: -1; }
}
.embed .week-nav .btn { white-space: nowrap; }
.embed .week-nav strong { font-size: 0.9rem; text-align: center; }
.embed-panel .steps { gap: 2px 4px; font-size: 0.72rem; }
.embed-panel .steps li + li::before { margin-right: 2px; }
.widget-form .sticky-save { flex-wrap: nowrap; }
.widget-form .sticky-save > span { flex: 1; }

/* Behandlungspfad (Buchungsseite) */
.path-text { white-space: pre-line; margin-top: -4px; }
.path-message { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.path-message .btn { text-align: center; }

/* Admin: Behandlungspfad */
.pw-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.pw-overview { position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.pw-overview ul { margin: 6px 0 6px 6px; padding-left: 16px; border-left: 2px solid var(--line); list-style: none; }
.pw-overview li { margin: 6px 0; }
.pw-overview a { color: var(--text); font-weight: 600; text-decoration: none; }
.pw-overview a:hover { text-decoration: underline; }
.pw-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.pw-head .grow { flex: 1; }
.pw-answer { display: grid; grid-template-columns: 1.2fr auto 1.6fr 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.path-answers { color: var(--muted); border-left: 3px solid var(--brand-soft); padding-left: 6px; margin-top: 4px; }
#pwWarnings .alert { margin: 8px 0 0; }
@media (max-width: 1000px) {
  .pw-layout { grid-template-columns: 1fr; }
  .pw-overview { position: static; max-height: none; }
  .pw-answer { grid-template-columns: 1fr 1fr; }
  .pw-answer > .muted { display: none; }
}
#tab-pathway .toolbar > div { flex: 0 1 340px; }

/* MEDINexo – Programmoberflächen (Admin, Einrichtung, Anleitung) in den Farben des Logos */
body.branded {
  --brand: #063461;
  --brand-ink: #ffffff;
  --brand-soft: #e4ecf5;
  --accent: #08a093;
  --bg: #f4f6f9;
  --line: #dde3ea;
}
.branded .topbar { background: #fff; color: var(--brand); border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(6, 52, 97, .04); }
.branded .topbar .inner { align-items: center; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-sub { font-weight: 600; font-size: 0.95rem; color: #4a637e; padding-left: 12px; border-left: 2px solid var(--line); }
.branded .version-btn { border-color: var(--line); color: var(--brand); }
.branded .version-btn:hover { background: var(--brand-soft); }
.branded .tabs button.active { color: var(--brand); border-bottom-color: var(--accent); }
.login-card { max-width: 440px; margin: 40px auto; text-align: left; }
.login-logo { display: block; width: min(320px, 100%); height: auto; margin: 4px auto 20px; }
footer .powered-by { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--muted); }
footer .powered-by img { height: 18px; width: auto; opacity: .9; }
@media (max-width: 600px) {
  .brand-logo { height: 34px; }
  .brand-sub { border-left: 0; padding-left: 0; }
}

/* --- Patientenportal & Anfragen (0.11) --- */
.patient-links { display: flex; gap: 8px 18px; flex-wrap: wrap; justify-content: flex-end; margin: -6px 0 12px; font-size: 0.9rem; }
.patient-links a { text-decoration: none; font-weight: 550; }
.patient-links a:hover { text-decoration: underline; }
.portal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.portal-head h1 { margin-bottom: 2px; }
.portal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 16px; }
.portal-actions a.btn { text-decoration: none; }
.portal-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); }
.portal-item:first-child { border-top: 0; padding-top: 4px; }
.portal-item .grow { flex: 1; min-width: 0; }
.portal-item .when { font-weight: 650; }
.portal-item .side { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.portal-item.off .when { text-decoration: line-through; color: var(--muted); }
.portal-msg { background: var(--brand-soft); border-radius: 8px; padding: 6px 10px; margin-top: 6px; }
details > summary { cursor: pointer; list-style: revert; }
h2.inline { display: inline; font-size: 1.15rem; }
details[open] > summary { margin-bottom: 8px; }
#reqForm h2 { margin-top: 20px; font-size: 1.05rem; }
.med-row { display: grid; grid-template-columns: 2fr 0.9fr 0.9fr 1.1fr auto; gap: 8px 10px; align-items: end; margin-bottom: 10px; }
.med-row .pzn-hint { grid-column: 1 / -1; margin-top: -4px; color: var(--muted); }
.med-row .pzn-hint:empty { display: none; }
.med-row .pzn-hint.error-text { color: var(--danger); }
.drug-name { position: relative; }
.drug-list { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 2px 0 0; padding: 4px 0; list-style: none; max-height: 280px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.drug-list li { padding: 7px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 1px; }
.drug-list li:hover, .drug-list li.active { background: var(--brand-soft); }
.med-row .remove { padding-bottom: 10px; color: var(--muted); text-decoration: none; font-size: 1.1rem; }
.choice-radios { display: grid; gap: 8px; margin-bottom: 12px; }
.choice-radios .check { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0; }
.choice-radios .check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.kind-choice { margin-top: 12px; }
@media (max-width: 600px) {
  .med-row { grid-template-columns: 1fr 1fr; }
  .med-row > div:first-child { grid-column: 1 / -1; }
  .portal-item { flex-direction: column; align-items: stretch; }
  .portal-item .side { justify-content: flex-start; }
}
/* Admin: Anfragen */
.req-items { margin: 0; padding-left: 18px; }
.req-items li { margin: 0; }
.toolbar .grow { flex: 1; min-width: 200px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 8px 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
code.fp { font-size: 0.75rem; overflow-wrap: anywhere; }
@media (max-width: 600px) { .kv { grid-template-columns: 1fr; } .kv dd { margin-bottom: 6px; } }
.pzn-copy { border: 0; cursor: pointer; font-family: inherit; }
.pzn-copy:hover { background: var(--brand-soft); }
.tab-count { display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 18px; text-align: center; }
td.actions-cell { min-width: 132px; } td.actions-cell .btn, td.actions-cell .btn-link { display: block; width: 100%; margin: 0 0 6px; white-space: nowrap; }
