/* Physiowerk Listener – Praxisfarben Rot, Anthrazit, Weiß */
:root {
  --rot: #D7262E; --rot-dunkel: #B51D24; --rot-hell: #FBE9EA;
  --anth: #2F3437; --text: #23272A; --muted: #6B7178; --line: #E3E4E6;
  --bg: #F3F3F4; --card: #FFFFFF; --soft: #F7F7F8;
  --ok: #2E7D4F; --ok-hell: #E5F4E4; --warn: #9A6200; --warn-hell: #FFF4DE;
  --radius: 18px; --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  color-scheme: light;
}
html[data-theme="dunkel"] {
  --text: #ECEDEE; --muted: #A2A7AD; --line: #3A3F43; --bg: #1C1F21; --card: #26292C; --soft: #2E3236;
  --rot-hell: #3D2224; --ok-hell: #1E3A2A; --warn-hell: #3A2F1A; --anth: #ECEDEE; color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --text: #ECEDEE; --muted: #A2A7AD; --line: #3A3F43; --bg: #1C1F21; --card: #26292C; --soft: #2E3236;
    --rot-hell: #3D2224; --ok-hell: #1E3A2A; --warn-hell: #3A2F1A; --anth: #ECEDEE; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--text);
  background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--rot); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h2.inline { display: inline; margin: 0; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.gap { gap: 10px; }
.top-gap { margin-top: 14px; }

/* Kopfzeile */
.topbar { display: grid; grid-template-columns: 240px 1fr auto; align-items: center; padding: 18px 28px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-text { font-weight: 700; line-height: 1.1; font-size: 15px; }
.brand-text small { font-weight: 500; color: var(--rot); }
.logo { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--rot);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .02em; }
.logo.big { width: 56px; height: 56px; font-size: 20px; border-radius: 16px; }
.pills { justify-self: center; display: flex; gap: 6px; background: var(--card); padding: 6px; border-radius: 999px; box-shadow: var(--shadow); }
.pill { padding: 9px 20px; border-radius: 999px; color: var(--rot); font-weight: 500; }
.pill:hover { text-decoration: none; background: var(--rot-hell); }
.pill.active { background: var(--rot); color: #fff; }
.avatar { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--card);
  color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.avatar:hover { text-decoration: none; }
.avatar.big { width: 56px; height: 56px; font-size: 18px; }

/* Layout */
.layout { display: grid; grid-template-columns: 260px 1fr; gap: 28px; padding: 0 28px 40px; max-width: 1400px; margin: 0 auto; }
.sidebar { position: sticky; top: 12px; align-self: start; display: flex; flex-direction: column; gap: 4px; }
.side-link { color: var(--text); font-weight: 600; padding: 10px 12px; border-radius: 10px; }
.side-link:hover { background: var(--card); text-decoration: none; }
.side-list { list-style: none; padding: 0 0 0 8px; margin: 0; max-height: 55vh; overflow: auto; }
.side-list a { display: flex; align-items: center; gap: 8px; color: var(--text); padding: 6px 8px; border-radius: 8px; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-list a.current, .side-list a:hover { background: var(--card); text-decoration: none; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dot.st-fertig { background: var(--ok); } .dot.st-pruefen { background: #E0A100; } .dot.st-fehler { background: var(--rot); }
.dot.st-wartet, .dot.st-verarbeitung { background: #7AA7D9; }
.content { min-width: 0; }
.content.solo { max-width: 460px; margin: 8vh auto; padding: 0 16px; }

/* Karten & Formulare */
.card { background: var(--card); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card.narrow { max-width: 440px; margin: 0 auto; }
.auth-brand { margin-bottom: 12px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
label input, label select, label textarea { margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--rot); outline-offset: 0; border-color: transparent; }
textarea.mono, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 0; }
label.check input { width: auto; margin: 0; accent-color: var(--rot); }
.consent { margin-top: 14px !important; padding: 10px 12px; background: var(--warn-hell); border-radius: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid4 { display: grid; grid-template-columns: 1.2fr 1.2fr .8fr auto; gap: 10px; margin-bottom: 14px; }
.span2 { grid-column: span 2; }
.settings-row { align-items: flex-end; }
.dossier-pick { margin: 0; min-width: 200px; }
.inline-form { margin: 0; }
.small-input { width: 230px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; color: var(--text); background: var(--soft); white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--rot); color: #fff; }
.btn.primary:hover { background: var(--rot-dunkel); }
.btn.ghost { background: var(--soft); }
.btn.danger { background: var(--rot); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 4px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.chip-select { width: auto; border-radius: 999px; background: var(--soft); border: 0; font-weight: 600; padding: 9px 16px; }
.file-btn input { display: none; }

.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; background: var(--soft); }
.flash.ok { background: var(--ok-hell); } .flash.error { background: var(--rot-hell); } .flash.info { background: var(--warn-hell); }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--soft); margin: 10px 0; }
.notice.warn { background: var(--warn-hell); }
.notice.ok { background: var(--ok-hell); }
.notice.err { background: var(--rot-hell); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--soft); }
.badge.st-fertig { background: var(--ok-hell); color: var(--ok); }
.badge.st-pruefen { background: var(--warn-hell); color: var(--warn); }
.badge.st-fehler { background: var(--rot-hell); color: var(--rot); }
.badge.st-wartet, .badge.st-verarbeitung { background: #E4EEF9; color: #2F5F93; }
.badge.vis-praxis { background: var(--rot-hell); color: var(--rot); }

/* Startseite */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 14px; }
.preset-grid form { margin: 0; }
.preset { width: 100%; height: 100%; text-align: left; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 16px; padding: 16px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; font: inherit; }
.preset:hover { border-color: var(--rot); box-shadow: var(--shadow); }
.preset-mode { align-self: flex-start; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 999px; background: var(--rot-hell); color: var(--rot); }
.preset-mode.diktat { background: var(--soft); color: var(--muted); }
.steps li { margin-bottom: 6px; }

/* Session */
.session-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.rec-row { display: grid; grid-template-columns: 1fr 260px auto; gap: 12px; align-items: center; }
.meter { height: 44px; background: var(--soft); border-radius: 12px; overflow: hidden; position: relative; }
#meter-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--rot-hell), var(--rot)); transition: width .08s; }
#rec-btn.recording { background: var(--anth); }
html[data-theme="dunkel"] #rec-btn.recording { background: #555; }
#rec-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text); }
.actions-row { margin-top: 14px; }

.report { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; margin-top: 12px; }
.report.old { opacity: .7; background: var(--soft); }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-head .title { font-weight: 700; }
.report textarea { margin-top: 10px; min-height: 260px; font-size: 14px; line-height: 1.5; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.report-actions select { width: auto; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--rot);
  border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.versions { margin-top: 8px; font-size: 13px; }
.versions summary { cursor: pointer; color: var(--muted); }
.transcript { white-space: pre-wrap; font-family: inherit; background: var(--soft); padding: 14px; border-radius: 12px; max-height: 420px; overflow: auto; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--muted); }
details[open] > summary::before { content: "▾ "; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20,22,24,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--card); border-radius: 20px; padding: 24px; width: min(560px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-card h2 { margin-top: 0; }
.check-list { list-style: none; padding: 0; margin: 12px 0; }
.check-list li { padding: 10px 12px; border-radius: 12px; background: var(--warn-hell); margin-bottom: 8px; }
.check-ok { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; background: var(--ok-hell); color: var(--ok); font-weight: 600; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.qr { display: block; margin: 12px auto; width: 220px; height: 220px; }
.linkbox { word-break: break-all; background: var(--soft); padding: 10px; border-radius: 10px; font-family: ui-monospace, monospace; font-size: 13px; }

/* Konfiguration */
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 999px; font-weight: 500; }
.tab.active { background: var(--soft); color: var(--text); }
.search input { margin: 6px 0 4px; border-radius: 999px; }
.tpl-list { list-style: none; padding: 0; margin: 0; }
.tpl-list li { border-bottom: 1px solid var(--line); }
.tpl-list a { display: block; padding: 12px 6px; color: var(--text); }
.tpl-list a:hover { background: var(--soft); text-decoration: none; }
.clamp { display: inline-block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; margin: 0; background: var(--soft); border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px; }
.tag.praxis { background: var(--rot-hell); }
.tag button { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 4px; }
.segmented { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 4px; gap: 4px; }
.seg { border: 0; background: transparent; padding: 8px 18px; border-radius: 999px; font: inherit; cursor: pointer; color: var(--text); }
.seg.active { background: var(--card); color: var(--rot); box-shadow: var(--shadow); font-weight: 600; }
.danger-zone { border: 1px solid var(--rot-hell); }

/* Tabellen & Admin */
.table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
.table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table.compact td { padding: 6px 8px; }
.table tr.inactive { opacity: .5; }
.table form { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.stat { background: var(--soft); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; }
.stat .num { font-size: 24px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat.bad { background: var(--rot-hell); }

/* Mobil */
@media (max-width: 900px) {
  .topbar { grid-template-columns: 1fr auto; padding: 12px 14px; }
  .pills { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; overflow-x: auto; }
  .brand-text { display: none; }
  .layout { grid-template-columns: 1fr; padding: 0 12px 30px; gap: 12px; }
  .sidebar { position: static; flex-direction: row; flex-wrap: wrap; }
  .sidebar form { flex: 1 1 100%; }
  .side-list { display: none; }
  .grid3, .grid4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .rec-row { grid-template-columns: 1fr; }
  .small-input { width: 100%; }
  .card { padding: 18px; }
}
body.phone-mode .sidebar { display: none; }
body.phone-mode #settings-card, body.phone-mode #reports-card { display: none; }
body.phone-mode #rec-btn { padding: 22px; font-size: 18px; }
.ok-text { color: var(--ok); font-weight: 600; }
.row > input, .row > select { width: auto; flex: 1 1 180px; }
.row > .btn { flex: none; }
