/* Vorbefunde-App: dark theme with the tokens of the Spiro app (same family of practice apps). */

:root {
  --bg: #0f1218;
  --bg-elev: #171b24;
  --bg-input: #10141c;
  --bg-sunk: #0c1017;
  --border: #242a35;
  --border-strong: #313947;

  --text: #e7eaee;
  --text-muted: #9aa3ae;

  --brand: #2e4e7e;
  --accent: #4fb6e0;
  --accent-ink: #0a2230;

  --warning: #eba31a;
  --critical: #e05a5a;
  --ok: #3fb984;
  --violet: #a48be8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: radial-gradient(1200px 600px at 15% -10%, #182234 0%, var(--bg) 55%) fixed;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h2, h3 { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.normal { text-transform: none; letter-spacing: 0; font-weight: 400; }
.inline { display: inline; margin: 0; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 80px; }

/* --- header --- */

.app-header { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.logo-chip {
  background: #f3f4f6; border-radius: 12px; padding: 8px 10px; display: flex; align-items: center;
  box-shadow: var(--shadow-sm); flex: 0 0 auto;
}
.logo-chip img { display: block; height: 40px; width: auto; }
.app-titles h1 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }
.app-titles p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }
.header-nav { margin-left: auto; display: flex; gap: 8px; align-self: flex-start; }
.header-nav a {
  color: var(--text-muted); text-decoration: none; font-size: 0.82rem; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); white-space: nowrap;
}
.header-nav a:hover { color: var(--text); border-color: var(--border-strong); }

/* --- cards, sections, fields --- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)), var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 18px;
}
.section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-muted); margin: 0 0 14px;
}
.grid { display: grid; gap: 14px 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hint { color: var(--text-muted); font-size: 12px; }
label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
label .req { color: var(--accent); margin-left: 2px; }

input[type="text"], input[type="password"], select {
  width: 100%; background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px; font-family: inherit; font-size: 14px;
}
input::placeholder { color: #616b78; }
input:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 182, 224, 0.22);
}

/* --- buttons --- */

.btn {
  appearance: none; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 10px 18px;
  font-size: 14.5px; font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: filter 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:not(:disabled):hover { filter: brightness(1.08); }
.btn-secondary { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn-secondary:not(:disabled):hover { border-color: var(--accent); }
.btn-danger { background: transparent; color: #ff9aa2; border-color: rgba(192, 32, 46, 0.55); }
.btn-danger:not(:disabled):hover { background: rgba(192, 32, 46, 0.16); border-color: rgba(192, 32, 46, 0.85); }
.btn-small { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; margin-top: 18px; }
.btn.copied { border-color: var(--ok); color: var(--ok); }
.btn-link {
  background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12.5px;
  padding: 2px 4px; white-space: nowrap;
}
.btn-link:hover { text-decoration: underline; }
.btn-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

/* --- messages --- */

.flash {
  background: rgba(79, 182, 224, 0.1); border: 1px solid rgba(79, 182, 224, 0.35); border-radius: var(--radius-sm);
  padding: 10px 14px; margin-bottom: 14px; font-size: 14px;
}
.alert { border-radius: var(--radius-sm); padding: 10px 14px; margin: 12px 0; font-size: 14px; border: 1px solid; }
.alert-error { background: rgba(224, 90, 90, 0.12); border-color: rgba(224, 90, 90, 0.45); color: #f4c4c4; }
.alert-ok { background: rgba(63, 185, 132, 0.1); border-color: rgba(63, 185, 132, 0.4); color: #bfe8d4; }
.alert-warn { background: rgba(235, 163, 26, 0.1); border-color: rgba(235, 163, 26, 0.4); color: #f2d9a6; }

.tag {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px;
  border: 1px solid var(--border-strong); color: var(--text-muted); margin-left: 4px; vertical-align: 1px;
}
.tag-red { color: #ffb0b0; border-color: rgba(224, 90, 90, 0.55); }
.tag-blue { color: var(--accent); border-color: rgba(79, 182, 224, 0.5); }

/* --- upload and case list --- */

.upload-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.file-drop {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-input);
  padding: 18px; display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 92px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: rgba(79, 182, 224, 0.06); }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .icon { font-size: 22px; }
.file-name { color: var(--text); font-size: 14px; font-weight: 600; }
.file-hint { color: var(--text-muted); font-size: 12px; }

.case-list { display: flex; flex-direction: column; }
.case-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.case-row:last-child { border-bottom: none; }
.case-main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-decoration: none; color: var(--text); }
.case-main:hover .case-name { color: var(--accent); }
.case-name { font-weight: 600; }

.badge {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border-strong); color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px;
}
.badge-fertig { color: var(--ok); border-color: rgba(63, 185, 132, 0.5); }
.badge-bestaetigen, .badge-pruefen { color: var(--warning); border-color: rgba(235, 163, 26, 0.5); }
.badge-fehler { color: #ffb0b0; border-color: rgba(224, 90, 90, 0.55); }
.badge-lesen, .badge-pseudonymisieren, .badge-analyse { color: var(--accent); border-color: rgba(79, 182, 224, 0.5); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

/* --- case page --- */

.case-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.case-head h2 { font-size: 22px; }

.stepper { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 0 0 18px; }
.step {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted);
  padding: 5px 11px 5px 6px; border: 1px solid var(--border); border-radius: 999px;
}
.step-no {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--border); font-size: 11px; font-weight: 700;
}
.step-done { color: var(--text); }
.step-done .step-no { background: rgba(63, 185, 132, 0.25); color: var(--ok); }
.step-current { color: var(--text); border-color: var(--accent); }
.step-current .step-no { background: var(--accent); color: var(--accent-ink); }

.wait { display: flex; align-items: center; gap: 18px; }
.wait-title { font-weight: 600; font-size: 16px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite; flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.doc-chips, .ph-counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 16px; }
.chip {
  font-size: 12.5px; padding: 3px 10px; border-radius: 999px; background: var(--bg-input);
  border: 1px solid var(--border-strong); color: var(--text-muted);
}

/* --- review --- */

.review-patient { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hit-list { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-direction: column; gap: 6px; }
.hit-list li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mask-form { margin-top: 18px; }
.mask-row { display: flex; gap: 8px; margin-top: 6px; }
.mask-row input { flex: 1; }
.mask-row select { width: auto; }

.page { margin-bottom: 18px; }
.page-head { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.page-head strong { color: var(--text); }
.page-text {
  white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: var(--bg-sunk); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
  max-height: 560px; overflow-y: auto;
}
.ph {
  color: var(--violet); background: rgba(164, 139, 232, 0.12); border-radius: 4px; padding: 0 2px;
  font-family: var(--mono); font-size: 0.95em;
}
.ph-name { border-bottom: 1px dotted var(--violet); }
.ph-count { white-space: nowrap; }
.hit { background: rgba(224, 90, 90, 0.35); color: #fff; border-radius: 3px; outline: 1px solid var(--critical); }
.quote { background: rgba(235, 163, 26, 0.28); color: #fff; border-radius: 3px; }

/* --- overview --- */

.ov-toolbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; margin-bottom: 8px; background: linear-gradient(var(--bg) 70%, transparent);
}
.block-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.block-head h3 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.6px; }
.block-no {
  width: 26px; height: 26px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 14px;
}
.block-no.flag { background: rgba(235, 163, 26, 0.2); color: var(--warning); }
.push { margin-left: auto; }

.timeline, .plain-list, .group-items, .hint-list, .doc-list { list-style: none; padding: 0; margin: 0; }
.tl-item {
  display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px solid var(--border);
}
.tl-item:last-child { border-bottom: none; }
.tl-when { font-family: var(--mono); font-size: 13px; color: var(--text-muted); }
.tl-off { opacity: 0.6; }
.tl-off strong { text-decoration: line-through; text-decoration-color: rgba(224, 90, 90, 0.7); }
.tl-actions { display: inline-flex; align-items: baseline; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.src-links { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.src-link {
  background: rgba(79, 182, 224, 0.08); border: 1px solid rgba(79, 182, 224, 0.3); color: var(--accent);
  border-radius: 6px; font: inherit; font-size: 12px; padding: 0 7px; cursor: pointer; white-space: nowrap;
}
.src-link:hover { background: rgba(79, 182, 224, 0.18); }
.src-unbelegt { color: #ffb0b0; border-color: rgba(224, 90, 90, 0.45); background: rgba(224, 90, 90, 0.08); }

.copy-box { margin-top: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg-sunk); }
.copy-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px 12px;
  border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted);
}
.copy-text { white-space: pre-wrap; padding: 12px 14px; font-size: 14.5px; line-height: 1.6; }
.copy-line { font-weight: 500; }
.plain-list li { padding: 5px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

.groups { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 4px 14px; }
.group-label { color: var(--text-muted); font-size: 13px; padding: 5px 0; }
.group-items li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; align-items: baseline; }
.not-used { margin-top: 12px; font-size: 13.5px; }
.not-used summary { cursor: pointer; color: var(--text-muted); }

.hint-list li {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--border); align-items: baseline;
}
.hint-list li:last-child { border-bottom: none; }
.hint-icon { text-align: center; color: var(--warning); }
.hint-faellig .hint-icon, .hint-widerspruch .hint-icon { color: var(--warning); }
.hint-unbelegt .hint-icon { color: var(--critical); }
.doc-list li { padding: 5px 0; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.footer-note { margin-top: 10px; }

/* --- source drawer --- */

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(660px, 100%); z-index: 20;
  background: var(--bg-elev); border-left: 1px solid var(--border-strong); box-shadow: -20px 0 40px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
}
.drawer[hidden] { display: none; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-weight: 600; font-size: 14px; }
.drawer-nav { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.drawer-body { padding: 14px 16px; overflow-y: auto; flex: 1; }
.drawer-body .page-text { max-height: none; }

/* --- login --- */

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
}
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.login-head h1 { font-size: 1.15rem; margin: 0; }
.login-head p { margin: 2px 0 0; font-size: 0.82rem; color: var(--text-muted); }
.login-card label { display: block; margin-bottom: 8px; }

/* --- narrow screens --- */

@media (max-width: 760px) {
  .container { padding: 18px 16px 60px; }
  .app-header { flex-wrap: wrap; }
  .app-titles p { display: none; }
  .upload-grid, .grid.cols-3, .groups { grid-template-columns: minmax(0, 1fr); }
  .tl-item { grid-template-columns: 64px minmax(0, 1fr); }
  .tl-actions { grid-column: 2; justify-content: flex-start; }
  .mask-row { flex-wrap: wrap; }
}
