/* Praxis-Web-App – Farben wie in den Entwürfen (Salbeigrün, Sand, Creme) */
:root {
  --bg: #f8f7f1; --card: #ffffff; --ink: #2c2e2d; --muted: #6f726d; --line: #e4e1d6; --line2: #efede6;
  --green: #2f4a3a; --green2: #8a9a7b; --pale: #dfe6d8; --chip: #ecebe3; --sand: #efe6d2; --brown: #6b5530; --warn: #9a5b2b; --bad: #a3402f; --badbg: #f6e1dc;
  --r: 18px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
h1 { font-weight: 600; font-size: 30px; letter-spacing: -.3px; margin: 0; }
h2 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin: 22px 4px 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid #b7c7a8; outline-offset: 2px; }

/* Startbild, Anmeldung */
.splash { min-height: 100dvh; display: flex; align-items: center; justify-content: center; }
.logo { width: 76px; height: 76px; border-radius: 22px; background: var(--green); color: #f3efe4; display: flex; align-items: center; justify-content: center; font-size: 38px; font-weight: 300; letter-spacing: -1px; }
.lock { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(32px + var(--safe-t)) 24px calc(32px + var(--safe-b)); text-align: center; gap: 12px; }
.lock h1 { font-size: 26px; margin-top: 8px; }
.lock p { margin: 0; max-width: 360px; color: var(--muted); }
.lock form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.lock input { width: 100%; min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); padding: 0 16px; font-size: 17px; }
.lock .err { color: var(--bad); min-height: 20px; font-size: 14px; }
.btn { min-height: 50px; border-radius: 26px; border: 0; background: var(--green); color: #fff; font-weight: 700; font-size: 16px; padding: 0 22px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.soft { background: var(--chip); color: var(--ink); }
.btn.line { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.small { min-height: 38px; font-size: 14px; padding: 0 14px; }
.btn:disabled { opacity: .6; }
.linkbtn { background: none; border: 0; color: var(--green); font-size: 15px; padding: 8px; }

/* Grundgerüst */
.shell { min-height: 100dvh; }
.main { padding: calc(14px + var(--safe-t)) 16px calc(100px + var(--safe-b)); max-width: 760px; margin: 0 auto; }
.top { padding: 8px 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.top .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.round { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--chip); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--green); background: none; border: 0; font-size: 16px; min-height: 44px; padding: 0 6px 0 0; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + var(--safe-b)); z-index: 5; }
nav.tabs button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); min-height: 50px; justify-content: center; }
nav.tabs button.on { color: var(--green); font-weight: 700; }
nav.tabs .brand { display: none; }

/* Karten, Listen */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 6px 0 4px; }
.tile.wide-only { display: none; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px; text-align: left; }
.tile b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.tile span { font-size: 12px; color: var(--muted); }
.tile.dark { background: var(--green); border-color: var(--green); color: #f3efe4; }
.tile.dark span { color: #f3efe4; opacity: .85; }
.tile.alert b { color: var(--warn); }
button.tile { font: inherit; color: inherit; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.card.pad { padding: 14px 16px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; gap: 12px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line2); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; min-height: 56px; }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .r { text-align: right; flex: none; font-size: 15px; }
.item .chev { color: #a3a59f; flex: none; }
.when { width: 56px; text-align: center; flex: none; }
.when b { display: block; font-size: 16px; }
.when span { font-size: 12px; color: var(--muted); }
.sep { width: 1px; align-self: stretch; background: var(--line); flex: none; }
.av { width: 40px; height: 40px; border-radius: 20px; background: var(--pale); color: var(--green); display: flex; align-items: center; justify-content: center; font-weight: 600; flex: none; }
.av.co { background: var(--sand); color: var(--brown); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 3px 8px; background: var(--chip); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--pale); color: var(--green); }
.pill.sand { background: var(--sand); color: var(--brown); }
.pill.bad { background: var(--badbg); color: var(--bad); }
.note { background: var(--sand); color: var(--brown); border-radius: 16px; padding: 12px 14px; font-size: 14px; display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.note.plain { background: var(--chip); color: var(--muted); }
.empty { padding: 26px 16px; text-align: center; color: var(--muted); font-size: 15px; }
.kv { padding: 2px 16px; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line2); font-size: 15px; }
.kv > div:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); flex: none; }
.kv span:last-child { text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.text { white-space: pre-wrap; font-size: 15px; line-height: 1.5; padding: 14px 16px; overflow-wrap: anywhere; }

/* Suche, Filter */
.search { position: relative; margin: 4px 0 10px; }
.search input { width: 100%; min-height: 44px; border-radius: 12px; border: 0; background: var(--chip); padding: 0 14px 0 40px; font-size: 16px; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--chip); border-radius: 20px; padding: 8px 14px; font-size: 14px; min-height: 36px; }
.chip.on { background: var(--green); color: #f3efe4; font-weight: 700; }

/* Klientenakte */
.head { display: flex; gap: 14px; align-items: center; padding: 4px 6px 14px; }
.head .av { width: 56px; height: 56px; border-radius: 28px; font-size: 22px; }
.head h1 { font-size: 26px; }
.hero { background: var(--green); color: #f3efe4; border-radius: var(--r); padding: 16px 18px; }
.hero .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .8px; opacity: .8; }
.hero .big { font-size: 20px; font-weight: 700; margin: 4px 0 2px; }
.hero .sub { font-size: 14px; opacity: .9; }
.acts { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 0; }

/* Ansicht für Dokumente (Vollbild) */
.sheet { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet header { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 10px 8px; border-bottom: 1px solid var(--line); background: rgba(248,247,241,.96); }
.sheet header .ttl { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.sheet .body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(16px + var(--safe-b)); }
.sheet .body.inv { max-width: 760px; width: 100%; margin: 0 auto; }
.pdfpage { margin: 0 auto 12px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,.12); }
.pdfpage canvas { width: 100%; height: 100%; display: block; }
.viewer-img { max-width: 100%; display: block; margin: 0 auto; border-radius: 8px; }
.viewer-text { white-space: pre-wrap; background: #fff; border-radius: 12px; padding: 16px; font: 14px/1.5 ui-monospace, Menlo, monospace; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(90px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 40; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 16px; font-size: 14px; max-width: 480px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.toast.err { background: var(--bad); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }
.spinner.dark { border-color: var(--line); border-top-color: var(--green); }
@keyframes spin { to { transform: rotate(360deg); } }

/* iPad / großer Bildschirm: Navigation links, Klientenliste und Akte nebeneinander */
@media (min-width: 900px) {
  nav.tabs { top: 0; right: auto; width: 230px; grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: 4px; border-top: 0; border-right: 1px solid var(--line); padding: calc(20px + var(--safe-t)) 12px 20px; background: #f1f0e8; }
  nav.tabs .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 700; }
  nav.tabs .brand .logo { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
  nav.tabs button { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 15px; min-height: 44px; padding: 0 12px; border-radius: 12px; }
  nav.tabs button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.06); }
  .main { margin-left: 230px; max-width: none; padding: calc(24px + var(--safe-t)) 32px 40px; }
  .main > .inner { max-width: 820px; }
  .split { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 24px; align-items: start; }
  .split > .pane { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow: auto; }
  .split .back { display: none; }
  #toasts { bottom: 24px; }
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tile.wide-only { display: block; }
}
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
