:root{
  --brand:#8cbe3d;         /* Lind-/Blattgrün des Logos */
  --brand-600:#79a82e;
  --brand-700:#5f8a1d;
  --brand-100:#eaf3d7;
  --brand-050:#f5f9ec;
  --mint-050:#f2f8f1;
  --mint-100:#e2f0e6;
  --mint-200:#cfe6d6;
  --ink:#2b3320;
  --muted:#7c876a;
  --line:#e4e9db;
  --white:#ffffff;
  --danger:#c0492f;
  --amber:#c98a12;
  --shadow:0 8px 30px rgba(60,80,30,.10);
  --radius:16px;
}
*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
/* hidden-Attribut muss explizite display-Regeln schlagen (Modal, Spinner) */
[hidden]{ display:none !important; }
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  color:var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, var(--mint-100), transparent 60%),
    radial-gradient(1000px 500px at -10% 110%, var(--brand-050), transparent 55%),
    #f7faf2;
  min-height:100vh;
}
a{ color:var(--brand-700); }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:1px solid transparent; border-radius:12px; cursor:pointer;
  font-size:14px; font-weight:600; padding:10px 16px; line-height:1;
  transition:transform .05s ease, background .15s ease, box-shadow .15s ease;
  text-decoration:none; white-space:nowrap;
}
.btn:active{ transform:translateY(1px); }
.btn-sm{ padding:7px 12px; font-size:13px; border-radius:10px; }
.btn-block{ width:100%; }
.btn-primary{ background:var(--brand); color:#fff; box-shadow:0 4px 14px rgba(140,190,61,.35); }
.btn-primary:hover{ background:var(--brand-600); }
.btn-secondary{ background:var(--white); color:var(--brand-700); border-color:var(--mint-200); }
.btn-secondary:hover{ background:var(--mint-050); }
.btn-ghost{ background:transparent; color:var(--ink); border-color:var(--line); }
.btn-ghost:hover{ background:#fff; }
.btn-danger{ background:transparent; color:var(--danger); border-color:#e7cfc9; }
.btn-danger:hover{ background:#fbf1ef; }
.btn:disabled{ opacity:.6; cursor:default; }

/* ---------- Topbar ---------- */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 22px; background:rgba(255,255,255,.85);
  backdrop-filter:saturate(180%) blur(10px);
  border-bottom:1px solid var(--line); position:sticky; top:0; z-index:20;
}
.brand{ display:flex; align-items:center; gap:14px; }
.brand-logo{ height:42px; width:auto; }
.brand-text{ display:flex; flex-direction:column; line-height:1.25; }
.brand-text strong{ font-size:15px; }
.brand-text span{ font-size:12px; color:var(--muted); }
.topbar-right{ display:flex; align-items:center; gap:10px; }

.pill{ font-size:12px; font-weight:600; padding:5px 11px; border-radius:999px; }
.pill-ok{ background:var(--brand-100); color:var(--brand-700); }
.pill-warn{ background:#fbf1d8; color:var(--amber); }

/* ---------- Layout ---------- */
.layout{
  display:grid; grid-template-columns:320px 1fr; gap:22px;
  max-width:1280px; margin:22px auto; padding:0 22px;
  align-items:start;
}
@media (max-width:860px){ .layout{ grid-template-columns:1fr; } }

/* ---------- Sidebar / Patientenakte ---------- */
.sidebar{
  background:var(--white); border:1px solid var(--line); border-radius:var(--radius);
  padding:16px; box-shadow:var(--shadow); position:sticky; top:88px;
}
.sidebar-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.sidebar-head h2{ font-size:16px; margin:0; }
.input{
  width:100%; border:1px solid var(--line); border-radius:10px;
  padding:10px 12px; font-size:14px; background:#fcfdfa; color:var(--ink);
}
.input:focus{ outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(140,190,61,.18); }
#patient-search{ margin-bottom:12px; }

.patient-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:6px; max-height:60vh; overflow:auto; }
.patient-item{
  border:1px solid transparent; border-radius:12px; padding:11px 12px; cursor:pointer;
  transition:background .12s ease, border-color .12s ease;
}
.patient-item:hover{ background:var(--mint-050); }
.patient-item.active{ background:var(--brand-050); border-color:var(--brand-100); }
.patient-item .pi-name{ font-weight:600; font-size:14px; }
.patient-item .pi-meta{ font-size:12px; color:var(--muted); margin-top:2px; }
.patient-item .pi-count{
  float:right; font-size:11px; background:var(--mint-100); color:var(--brand-700);
  padding:2px 8px; border-radius:999px;
}
.list-empty{ color:var(--muted); font-size:13px; text-align:center; padding:24px 6px; }

/* ---------- Workspace ---------- */
.workspace{ display:flex; flex-direction:column; gap:20px; }
.empty-state{
  background:var(--white); border:1px dashed var(--mint-200); border-radius:var(--radius);
  padding:60px 24px; text-align:center; color:var(--muted); box-shadow:var(--shadow);
}
.empty-illustration{ font-size:44px; }
.empty-state h3{ margin:12px 0 6px; color:var(--ink); }

.card{
  background:var(--white); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow); overflow:hidden;
}
.card-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid var(--line);
}
.card-head h2,.card-head h3{ margin:0; font-size:16px; }
.card-body{ padding:20px; }

.patient-header{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.patient-header .ph-title{ font-size:20px; font-weight:700; }
.patient-header .ph-sub{ color:var(--muted); font-size:13px; margin-top:2px; }
.patient-actions{ display:flex; gap:8px; }

/* Formularraster */
.grid2{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.grid3{ display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; }
@media (max-width:640px){ .grid2,.grid3{ grid-template-columns:1fr; } }
.field{ display:flex; flex-direction:column; gap:6px; margin-bottom:14px; }
.field label{ font-size:12.5px; font-weight:600; color:#4f5a3c; }
.field .hint,.hint{ font-size:12px; color:var(--muted); }
textarea.input{ resize:vertical; min-height:150px; line-height:1.5; font-family:inherit; }
textarea.dictation{ min-height:220px; font-size:15px; }

.section-title{ font-size:13px; font-weight:700; color:var(--brand-700); text-transform:uppercase; letter-spacing:.4px; margin:0 0 12px; }
.divider{ height:1px; background:var(--line); margin:20px 0; border:0; }

/* Berichtsart-Auswahl */
.type-toggle{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:560px){ .type-toggle{ grid-template-columns:1fr; } }
.type-opt{
  display:flex; align-items:center; gap:10px; cursor:pointer;
  border:1px solid var(--line); border-radius:12px; padding:11px 13px; background:#fcfdfa;
  transition:border-color .12s ease, background .12s ease;
}
.type-opt.active{ border-color:var(--brand); background:var(--brand-050); }
.type-opt input{ accent-color:var(--brand); width:16px; height:16px; flex:0 0 auto; }
.type-opt span{ display:flex; flex-direction:column; line-height:1.3; }
.type-opt small{ color:var(--muted); font-size:11.5px; }

.dictation-toolbar{ display:flex; align-items:center; gap:10px; margin-bottom:8px; flex-wrap:wrap; }
.mic-hint{ font-size:12px; color:var(--muted); }

.process-row{ display:flex; align-items:center; gap:14px; margin-top:4px; }

/* ---------- Status-Badges ---------- */
.badge{ font-size:12px; font-weight:600; padding:4px 10px; border-radius:999px; display:inline-flex; align-items:center; gap:6px; }
.badge-fertig{ background:var(--brand-100); color:var(--brand-700); }
.badge-verarbeitung{ background:#e7effb; color:#2f6bb0; }
.badge-fehler{ background:#fbe9e5; color:var(--danger); }
.badge-demo{ background:#fbf1d8; color:var(--amber); }

/* ---------- Berichte-Liste ---------- */
.report-list{ display:flex; flex-direction:column; gap:10px; }
.report-item{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:#fcfdfa;
}
.report-item .ri-main{ display:flex; flex-direction:column; gap:4px; }
.report-item .ri-date{ font-weight:600; font-size:14px; }
.report-item .ri-meta{ font-size:12px; color:var(--muted); }
.report-item .ri-actions{ display:flex; gap:6px; flex-wrap:wrap; }

/* ---------- iOS-Loader ---------- */
.ios-spinner{
  width:18px; height:18px; border-radius:50%; display:inline-block;
  background:conic-gradient(from 90deg, transparent 0%, currentColor 90%);
  -webkit-mask:radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
          mask:radial-gradient(farthest-side, #0000 calc(100% - 3px), #000 0);
  animation:ios-spin .8s linear infinite;
}
.ios-spinner.lg{ width:52px; height:52px; }
.ios-spinner.lg{ background:conic-gradient(from 90deg, transparent 0%, var(--brand) 90%);
  -webkit-mask:radial-gradient(farthest-side, #0000 calc(100% - 6px), #000 0);
          mask:radial-gradient(farthest-side, #0000 calc(100% - 6px), #000 0); }
@keyframes ios-spin{ to{ transform:rotate(1turn); } }

.processing-box{
  display:flex; flex-direction:column; align-items:center; gap:16px;
  padding:36px 20px; text-align:center; color:var(--muted);
}
.processing-box .pb-title{ color:var(--ink); font-weight:600; font-size:16px; }

/* Schritt-für-Schritt-Fortschritt */
.proc-steps{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:11px; text-align:left; width:100%; max-width:340px; }
.proc-step{ display:flex; align-items:center; gap:11px; }
.proc-ic{
  width:20px; height:20px; border-radius:50%; border:2px solid var(--line);
  flex:0 0 auto; display:inline-flex; align-items:center; justify-content:center; color:#fff;
}
.proc-step.done .proc-ic{ border-color:var(--brand); background:var(--brand); }
.proc-step.done .proc-ic::after{ content:'✓'; font-size:11px; font-weight:700; }
.proc-step.active .proc-ic{ border-color:var(--brand); }
.proc-step.active .proc-ic::after{
  content:''; width:11px; height:11px; border-radius:50%;
  background:conic-gradient(from 90deg, transparent, var(--brand));
  -webkit-mask:radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
          mask:radial-gradient(farthest-side, #0000 calc(100% - 2px), #000 0);
  animation:ios-spin .8s linear infinite;
}
.proc-tx{ font-size:13.5px; color:var(--muted); transition:color .2s ease; }
.proc-step.active .proc-tx{ color:var(--ink); font-weight:600; }
.proc-step.done .proc-tx{ color:#4f5a3c; }

.proc-bar{ width:100%; max-width:340px; height:6px; background:var(--mint-100); border-radius:999px; overflow:hidden; }
.proc-bar-fill{ height:100%; width:0; background:linear-gradient(90deg, var(--brand), var(--brand-600)); border-radius:999px; transition:width .35s ease; }
.proc-meta{ font-size:12px; color:var(--muted); }

/* ---------- Ergebnis / Editor ---------- */
.result-grid{ display:flex; flex-direction:column; gap:16px; }
.check-list{ display:flex; flex-direction:column; gap:8px; }
.check-item{ display:flex; align-items:flex-start; gap:10px; font-size:14px; padding:8px 10px; border:1px solid var(--line); border-radius:10px; background:#fcfdfa; }
.check-item input{ margin-top:2px; accent-color:var(--brand); width:16px; height:16px; }
.check-item.checked{ background:var(--brand-050); border-color:var(--brand-100); }

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(30,40,15,.42);
  display:flex; align-items:flex-start; justify-content:center; padding:40px 16px;
  z-index:40; overflow:auto; backdrop-filter:blur(2px);
}
.modal{
  background:var(--white); border-radius:18px; width:100%; max-width:640px;
  box-shadow:0 24px 70px rgba(0,0,0,.28); overflow:hidden;
}
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--line); }
.modal-head h3{ margin:0; font-size:17px; }
.modal-body{ padding:22px; max-height:70vh; overflow:auto; }
.modal-foot{ display:flex; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--line); background:#fbfdf8; }
.modal-close{ background:none; border:none; font-size:22px; cursor:pointer; color:var(--muted); line-height:1; }

.toast{
  position:fixed; bottom:22px; left:50%; transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:12px 20px; border-radius:12px;
  font-size:14px; box-shadow:0 10px 30px rgba(0,0,0,.25); z-index:60; opacity:0;
  transition:opacity .2s ease, transform .2s ease;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(-4px); }
.toast.err{ background:var(--danger); }

.error-box{ background:#fbe9e5; color:var(--danger); border:1px solid #e7cfc9; border-radius:10px; padding:12px 14px; font-size:13.5px; }
.muted{ color:var(--muted); }
code{ background:var(--mint-050); padding:2px 6px; border-radius:6px; font-size:12.5px; }

/* ---------- Login ---------- */
.login-body{
  display:flex; align-items:center; justify-content:center; min-height:100vh; padding:20px;
}
.login-card{
  background:var(--white); border:1px solid var(--line); border-radius:22px;
  box-shadow:var(--shadow); padding:38px 34px; width:100%; max-width:380px; text-align:center;
}
.login-logo{ height:64px; margin-bottom:12px; }
.login-card h1{ font-size:20px; margin:6px 0 2px; }
.login-sub{ color:var(--muted); font-size:13px; margin:0 0 22px; }
.login-card form{ text-align:left; }
.login-card label{ font-size:12.5px; font-weight:600; color:#4f5a3c; }
.login-card input{ width:100%; margin:6px 0 14px; border:1px solid var(--line); border-radius:10px; padding:11px 12px; font-size:15px; }
.login-card input:focus{ outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(140,190,61,.18); }
.login-error{ background:#fbe9e5; color:var(--danger); border-radius:8px; padding:8px 10px; font-size:13px; margin-bottom:12px; }

/* ---------- Admin ---------- */
.admin-wrap{ max-width:720px; margin:26px auto; padding:0 22px; display:flex; flex-direction:column; gap:18px; }
.admin-card .card-head{ }
.admin-card{ padding:0; }
.admin-card > *:not(.card-head){ padding-left:20px; padding-right:20px; }
.admin-card .muted{ padding-top:14px; }
.admin-card form{ padding-bottom:18px; }
.admin-actions{ display:flex; gap:10px; margin-top:6px; }
.conn-msg{ margin-top:14px; font-size:13.5px; }
.msg-ok{ color:var(--brand-700); }
.msg-err{ color:var(--danger); }
.admin-info h3{ padding-top:18px; margin:0 0 8px; font-size:15px; }
.admin-info ul{ padding-left:20px; margin:0 0 18px; }
.admin-info li{ margin:6px 0; font-size:13.5px; color:#4f5a3c; }

/* Verbindungsart-Umschalter */
.mode-toggle{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width:560px){ .mode-toggle{ grid-template-columns:1fr; } }
.mode-opt{
  display:flex; align-items:center; gap:10px; cursor:pointer;
  border:1px solid var(--line); border-radius:12px; padding:12px 14px; background:#fcfdfa;
  transition:border-color .12s ease, background .12s ease;
}
.mode-opt.active{ border-color:var(--brand); background:var(--brand-050); }
.mode-opt input{ accent-color:var(--brand); width:16px; height:16px; }
.mode-opt span{ display:flex; flex-direction:column; line-height:1.3; }
.mode-opt small{ color:var(--muted); font-size:11.5px; }

.pane{ margin-top:4px; }
.status-list{ display:flex; flex-direction:column; gap:8px; margin:6px 0 12px; }
.status-row{ display:flex; align-items:center; gap:10px; font-size:14px; }
.status-dot{ width:10px; height:10px; border-radius:50%; flex:0 0 auto; }
.dot-ok{ background:var(--brand); box-shadow:0 0 0 3px rgba(140,190,61,.2); }
.dot-bad{ background:#d7b13a; box-shadow:0 0 0 3px rgba(201,138,18,.16); }

.callout{
  background:var(--mint-050); border:1px solid var(--mint-200); border-radius:12px;
  padding:14px 16px; font-size:13.5px; color:#3f4a2f; margin-bottom:6px;
}
.callout pre{
  background:#20301a; color:#eaf3d7; padding:10px 14px; border-radius:8px;
  font-size:13px; margin:8px 0; overflow:auto;
}
