:root {
    --ink: #171717;
    --muted: #626262;
    --line: #d0d0cc;
    --paper: #f4f5f2;
    --panel: #ffffff;
    --green: #d9f0d7;
    --green-border: #2c6a2a;
    --yellow: #fff0a3;
    --yellow-border: #806400;
    --amber: #f4ca52;
    --amber-border: #694a00;
    --red: #f2b9b4;
    --red-border: #8a1c16;
    --free: #e8e8e6;
    --free-border: #686868;
    --shadow: 0 2px 10px rgba(0, 0, 0, .07);
}

* { box-sizing: border-box; }
html {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--paper);
    -webkit-text-size-adjust: 100%;
}
body { margin: 0; min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: contain; }
a { color: inherit; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; }
button, .button, input { min-height: 50px; }
button, .button { touch-action: manipulation; -webkit-user-select: none; user-select: none; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.25rem; font-weight: 800; text-decoration: none; }
.subtitle { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.utility-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.utility-nav a { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; background: #fff; }

.page { width: min(1120px, calc(100% - 28px)); margin: 0 auto; padding: 22px 0 42px; }
.page.narrow { width: min(720px, calc(100% - 28px)); }
h1 { font-size: clamp(1.55rem, 3vw, 2.1rem); margin: 0 0 18px; letter-spacing: -.02em; }
h2 { margin: 0 0 9px; font-size: 1.18rem; }
p { line-height: 1.45; }

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}
.narrow-panel { max-width: 760px; }
.emphasis-panel { border: 2px solid var(--ink); }
.task-panel { max-width: 720px; }

.flash { border: 2px solid; border-radius: 10px; padding: 14px 16px; margin: 0 0 18px; font-weight: 700; background: #fff; }
.flash.success { border-color: var(--green-border); background: var(--green); }
.flash.error { border-color: var(--red-border); background: var(--red); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 11px 16px;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    text-decoration: none;
    font-weight: 750;
    cursor: pointer;
}
.button:active { transform: translateY(1px); }
.button.primary { background: var(--ink); color: #fff; }
.button.danger { background: var(--red-border); color: #fff; border-color: var(--red-border); }
.button.full { width: 100%; }
.large-button { min-height: 56px; font-size: 1.02rem; }
.text-link { font-weight: 750; text-underline-offset: 3px; }

label { display: grid; gap: 7px; font-weight: 700; }
input, textarea {
    width: 100%;
    border: 2px solid #555;
    background: #fff;
    padding: 12px 13px;
    border-radius: 10px;
    font-size: 16px;
}
input:focus, textarea:focus { outline: 3px solid rgba(23, 23, 23, .22); outline-offset: 1px; }
.form-grid { display: grid; gap: 16px; }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.inline-form label { flex: 1 1 260px; }
.search-form { display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: end; gap: 10px; }
.login-card { max-width: 430px; }
.login-card form { display: grid; gap: 14px; }
.hint { color: var(--muted); font-size: .9rem; margin-bottom: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.home-assign h2, .home-search h2 { font-size: 1.35rem; }
.home-assign p, .home-search p { color: var(--muted); margin-top: 0; }
.home-assign-form {
    display: grid;
    grid-template-columns: minmax(240px, 1.35fr) minmax(145px, .55fr) auto;
    align-items: end;
    gap: 12px;
}
.home-assign-form input { min-height: 56px; }
.home-assign-form .button { min-width: 150px; }
.mobile-primary-form input { min-height: 56px; }
.home-task-grid { grid-template-columns: repeat(2, 1fr); }

.task-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.task-card {
    min-height: 145px;
    display: grid;
    align-content: center;
    gap: 7px;
    padding: 18px;
    border: 2px solid var(--ink);
    border-radius: 12px;
    background: #fff;
    text-decoration: none;
    box-shadow: var(--shadow);
}
.task-card strong { font-size: 1.08rem; }
.task-card > span:last-child { color: var(--muted); font-size: .9rem; }
.task-icon, .task-count { font-size: 2rem; font-weight: 850; line-height: 1; }
.red-card { background: var(--red); border-color: var(--red-border); }

.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.summary { border: 2px solid; border-radius: 10px; padding: 13px; display: flex; align-items: baseline; justify-content: space-between; text-decoration: none; }
.summary strong { font-size: 1.9rem; }
.summary span { font-weight: 750; }
.summary.free { background: var(--free); border-color: var(--free-border); }
.summary.green { background: var(--green); border-color: var(--green-border); }
.summary.yellow { background: var(--yellow); border-color: var(--yellow-border); }
.summary.red { background: var(--red); border-color: var(--red-border); }

.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 15px; }
.range-links, .filter-links { display: flex; flex-wrap: wrap; gap: 6px; }
.range-links a, .filter-links a { border: 1px solid var(--ink); border-radius: 8px; padding: 9px 11px; text-decoration: none; background: #fff; }
.range-links a.active, .filter-links a.active { background: var(--ink); color: #fff; }

.compartment-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.compartment { min-height: 72px; padding: 8px 5px; border: 2px solid; border-radius: 8px; text-decoration: none; display: grid; align-content: center; justify-items: center; text-align: center; }
.compartment strong { font-size: 1.25rem; line-height: 1; }
.compartment span { font-size: .72rem; margin-top: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; }
.compartment em { font-style: normal; font-size: .64rem; font-weight: 900; margin-top: 3px; letter-spacing: .04em; }
.compartment.status-yellow { border-style: dashed; }
.compartment.status-amber { border-style: double; border-width: 4px; }
.compartment.status-red { border-width: 4px; }
.status-free { background: var(--free); border-color: var(--free-border); }
.status-green { background: var(--green); border-color: var(--green-border); }
.status-yellow { background: var(--yellow); border-color: var(--yellow-border); }
.status-amber { background: var(--amber); border-color: var(--amber-border); }
.status-red { background: var(--red); border-color: var(--red-border); }

.list-table { display: grid; border-top: 1px solid var(--line); }
.list-row { display: grid; grid-template-columns: 115px 1fr 95px; align-items: center; gap: 12px; min-height: 54px; padding: 12px 6px; border-bottom: 1px solid var(--line); text-decoration: none; }
.list-row:focus { outline: 3px solid var(--ink); outline-offset: 2px; }
.red-list { border: 3px solid var(--red-border); }
.red-action-row { min-height: 64px; }
.red-action-row::after { content: "›"; font-size: 1.5rem; font-weight: 700; }
.red-action-row { grid-template-columns: 115px 1fr 85px 20px; }

.patient-search-panel { border: 3px solid var(--ink); }
.patient-hit-list { display: grid; gap: 10px; }
.patient-hit { display: grid; grid-template-columns: minmax(150px, 1fr) auto 125px; align-items: center; gap: 12px; border: 3px solid; border-radius: 12px; padding: 15px 17px; text-decoration: none; }
.patient-hit:focus { outline: 3px solid var(--ink); outline-offset: 2px; }
.patient-hit-label { font-weight: 800; font-size: 1.08rem; }
.patient-hit-number { font-size: 1.4rem; font-weight: 900; white-space: nowrap; }
.patient-hit-status { text-align: right; font-weight: 700; }
.single-hit { grid-template-columns: 1fr auto; padding: 24px; min-height: 145px; }
.single-hit .patient-hit-label { font-size: 1.3rem; }
.single-hit .patient-hit-number { font-size: clamp(2.4rem, 7vw, 4rem); grid-row: span 2; }
.single-hit .patient-hit-status { text-align: left; }

.detail-card { display: grid; grid-template-columns: 140px 1fr; gap: 20px; border: 3px solid; border-radius: 14px; padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.detail-number { font-size: 3.3rem; font-weight: 900; display: grid; place-items: center; border: 2px solid currentColor; border-radius: 10px; min-height: 120px; background: rgba(255, 255, 255, .55); }
.detail-content h2 { font-size: 1.45rem; }
.status-pill { display: inline-block; border: 2px solid; border-radius: 999px; padding: 6px 11px; font-weight: 800; margin-bottom: 8px; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 12px 0 0; }
.details dt { font-weight: 700; }
.details dd { margin: 0; }
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.action-panel { display: grid; align-content: start; }
.continue-panel { border: 2px solid var(--green-border); }
.danger-panel { border: 2px solid var(--red-border); }
.confirm { display: flex; grid-template-columns: none; align-items: center; gap: 10px; margin: 13px 0; min-height: 44px; }
.confirm input { width: 27px; height: 27px; min-height: 27px; flex: 0 0 auto; }
.edit-details summary { min-height: 46px; display: flex; align-items: center; font-weight: 750; cursor: pointer; }
.details-form { margin-top: 16px; }
.back-link { margin-bottom: 0; }

.input-with-unit { display: grid; grid-template-columns: 100px 1fr; align-items: center; gap: 10px; }
.legend-list { display: grid; gap: 10px; }
.legend-list > div { display: flex; align-items: center; gap: 8px; }
.legend { width: 30px; height: 24px; border: 2px solid; border-radius: 5px; display: inline-block; flex: 0 0 auto; }
.empty { border: 1px dashed var(--line); border-radius: 10px; padding: 24px; text-align: center; }
.empty-state, .success-empty { min-height: 220px; display: grid; place-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty-state strong, .success-empty strong { color: var(--ink); font-size: 1.2rem; }
.success-empty { background: var(--green); border: 2px solid var(--green-border); border-radius: 12px; min-height: 150px; }
.footer { text-align: center; color: var(--muted); padding: 20px; font-size: .8rem; }
code { background: #eee; padding: 2px 4px; }

.mobile-tabbar { display: none; }

@media (max-width: 1180px) {
    body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
    .topbar { padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
    .brand { font-size: 1.1rem; }
    .subtitle { display: none; }
    .utility-nav a { min-height: 42px; display: inline-flex; align-items: center; padding: 8px 10px; font-size: .88rem; }
    .page { width: min(100% - 20px, 920px); padding-top: 16px; padding-bottom: 24px; }
    h1 { font-size: 1.65rem; margin-bottom: 14px; }
    .panel { padding: 16px; margin-bottom: 14px; }
    .task-grid { grid-template-columns: 1fr 1fr; }
    .task-card:first-child { grid-column: 1 / -1; min-height: 112px; }
    .task-card { min-height: 128px; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .two-column, .action-grid { grid-template-columns: 1fr; gap: 0; }
    .search-form { grid-template-columns: 1fr; }
    .mobile-primary-form .button { width: 100%; }
    .home-assign-form { grid-template-columns: minmax(220px, 1fr) 150px; }
    .home-assign-form .button { grid-column: 1 / -1; width: 100%; }
    .home-task-grid .task-card:first-child { grid-column: auto; min-height: 128px; }
    .sticky-task-panel { position: sticky; top: 8px; z-index: 5; }
    .patient-hit { grid-template-columns: 1fr auto; min-height: 82px; }
    .patient-hit-status { grid-column: 1 / -1; text-align: left; }
    .single-hit { grid-template-columns: 1fr auto; }
    .single-hit .patient-hit-status { grid-column: 1; }
    .detail-card { grid-template-columns: 110px 1fr; gap: 14px; padding: 15px; }
    .detail-number { font-size: 2.7rem; min-height: 105px; }
    .list-row { grid-template-columns: 105px 1fr 78px; }
    .red-action-row { grid-template-columns: 105px 1fr 70px 18px; }
    .grid-toolbar { display: grid; }
    .segmented-links { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; overflow-x: auto; padding-bottom: 2px; }
    .segmented-links a { white-space: nowrap; text-align: center; min-width: 72px; }
    .compartment-grid { grid-template-columns: repeat(8, 1fr); }
    .compartment { min-width: 0; }
    .mobile-tabbar {
        position: fixed;
        z-index: 20;
        left: 0;
        right: 0;
        bottom: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
        border-top: 1px solid #bbb;
        background: rgba(255, 255, 255, .97);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .1);
    }
    .mobile-tabbar a {
        min-height: 56px;
        display: grid;
        place-content: center;
        justify-items: center;
        gap: 2px;
        border-radius: 9px;
        text-decoration: none;
        color: var(--muted);
        font-size: .7rem;
    }
    .mobile-tabbar a span { font-size: 1.25rem; line-height: 1; font-weight: 800; }
    .mobile-tabbar a.active { background: var(--ink); color: #fff; }
    .footer { display: none; }
}

@media (max-width: 900px) {
    .page { width: min(100% - 20px, 760px); }
    .compartment-grid { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 560px) {
    .utility-nav a:first-child { display: none; }
    .task-grid, .home-task-grid { grid-template-columns: 1fr; }
    .task-card:first-child { grid-column: auto; }
    .home-assign-form { grid-template-columns: 1fr; }
    .home-assign-form .button { grid-column: auto; }
    .summary strong { font-size: 1.65rem; }
    .section-heading { align-items: flex-start; }
    .compartment-grid { grid-template-columns: repeat(4, 1fr); }
    .compartment { min-height: 68px; }
    .patient-hit, .single-hit { grid-template-columns: 1fr; }
    .single-hit .patient-hit-number { grid-row: auto; }
    .patient-hit-number { white-space: normal; }
    .detail-card { grid-template-columns: 1fr; }
    .detail-number { min-height: 82px; }
    .details { grid-template-columns: 1fr; gap: 2px; }
    .details dd { margin-bottom: 8px; }
    .list-row, .red-action-row { grid-template-columns: 92px 1fr 20px; }
    .list-row span:last-of-type { display: none; }
}

@media print {
    .utility-nav, .mobile-tabbar, .button, form, .footer { display: none !important; }
    body, .panel { background: #fff; }
    .page { width: 100%; }
}

/* Backup-Verwaltung */
.flash.info { border-color: #8a8a8a; background: #f2f2f2; }
.backup-manual-form { margin-top: 16px; }
#backup textarea { width: 100%; min-height: 86px; word-break: break-all; }

/* Version 1.6: getrennter Admin-Bereich */
.admin-status-bar {
    max-width: 760px;
    margin: 0 auto 16px;
    padding: 12px 14px;
    border: 2px solid #1f2937;
    border-radius: 14px;
    background: #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.admin-setup-box {
    border: 2px solid #1f2937;
    border-radius: 14px;
    padding: 16px;
    background: #f8fafc;
}
.admin-setup-box h2 { margin-top: 0; }
.backup-list { display: grid; gap: 10px; }
.backup-row {
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.backup-row div { min-width: 0; }
.backup-row strong, .backup-row span { display: block; overflow-wrap: anywhere; }
.backup-row span { margin-top: 4px; color: #475569; font-size: .9rem; }
.button.small { min-height: 42px; padding: 8px 12px; }
@media (max-width: 600px) {
    .admin-status-bar, .backup-row { align-items: stretch; flex-direction: column; }
    .backup-row .button, .admin-status-bar .button { text-align: center; width: 100%; }
}

/* PLDI Gestaltungsrahmen – angelehnt an die Praxis-Website im Ordner „neu“. */
:root {
    --ink: #182131;
    --muted: #687283;
    --line: rgba(24, 33, 49, .16);
    --paper: #f4f6f4;
    --panel: #ffffff;
    --shadow: 0 12px 40px rgba(16, 28, 48, .07);
}

html { font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif; }
body { background: radial-gradient(circle at 92% 0, rgba(141, 206, 208, .17), transparent 28rem), var(--paper); }
.topbar {
    min-height: 112px;
    padding-inline: max(1.5rem, calc((100vw - 1180px) / 2));
    background: radial-gradient(circle at 78% -45%, rgba(141, 206, 208, .34), transparent 37%), linear-gradient(110deg, #203448, #274653);
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    box-shadow: 0 8px 28px rgba(16, 28, 48, .14);
}
.brand { color: #fff; letter-spacing: -.025em; }
.subtitle { color: rgba(255, 255, 255, .58); }
.utility-nav a { color: #fff; border-color: rgba(255, 255, 255, .28); border-radius: 999px; background: transparent; }
.page { width: min(1180px, calc(100% - 3rem)); padding-top: 3rem; }
h1 { letter-spacing: -.045em; font-weight: 650; }
h2 { letter-spacing: -.025em; }
.panel, .task-card, .detail-card, .patient-hit, .admin-status-bar, .admin-setup-box, .backup-row { border-radius: 0; }
.panel { border-color: var(--line); }
.emphasis-panel, .patient-search-panel { border-color: #416f99; }
.button { border-width: 1px; border-color: #29344d; border-radius: 999px; }
.button.primary { border-color: #071222; background: #071222; }
.button.primary:hover, .button.primary:focus-visible { background: #29344d; }
.button:focus-visible, input:focus, textarea:focus, select:focus { outline-color: rgba(65, 111, 153, .28); }
input, textarea, select { border-width: 1px; border-color: rgba(24, 33, 49, .28); border-radius: 0; background: #f7faf9; }
.task-card { border-width: 1px; border-color: var(--line); }
.task-card:not(.red-card) .task-icon, .task-card:not(.red-card) .task-count { color: #416f99; }
.summary, .compartment, .status-pill { border-radius: 0; }
.text-link { color: #416f99; }

@media (max-width: 1180px) {
    .topbar { min-height: 90px; }
    .page { width: min(100% - 20px, 920px); }
    .mobile-tabbar { background: linear-gradient(110deg, #203448, #274653); border-top: 0; box-shadow: 0 -8px 28px rgba(16, 28, 48, .16); }
    .mobile-tabbar a { color: rgba(255, 255, 255, .68); }
    .mobile-tabbar a.active { color: #071222; background: #69b9c0; }
}
