/* Kundenportal – Basis-Styles (Mobile first). Farben kommen aus /branding.css */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px; line-height: 1.45;
  color: var(--c-ink); background: var(--c-grey-pale); min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--c-primary-strong); }
h1 { font-size: 1.45rem; margin: 0 0 .6rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 1.2rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: .4rem 0 .8rem; }
.muted { color: var(--c-ink-muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; word-break: break-all; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar {
  background: var(--c-header-bg); color: var(--c-header-text); display: flex; align-items: center; gap: .8rem;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
}
.topbar-logo { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex: none; }
.topbar-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-text strong { font-size: 1.05rem; letter-spacing: .01em; }
.topbar-text span { font-size: .8rem; opacity: .75; }

.container { width: 100%; max-width: 680px; margin: 0 auto; padding: 1rem; flex: 1; }
body.admin .container { max-width: 1100px; }
.footer { text-align: center; font-size: .8rem; color: var(--c-ink-muted); padding: 1rem; }
.footer a { color: inherit; }

.card { background: var(--c-surface); border-radius: 16px; padding: 1.1rem 1.1rem 1.2rem; box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.05); margin-bottom: 1rem; }
.card.compact { padding: .8rem .9rem; }

/* Fortschritt */
.progress { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; }
.progress-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--c-grey-light); overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--c-primary-soft), var(--c-primary)); transition: width .3s; }
.progress-label { font-size: .8rem; color: var(--c-ink-muted); white-space: nowrap; }

/* Formulare */
.field { margin-bottom: 1rem; }
.field > label, .field-legend { display: block; font-weight: 600; margin-bottom: .35rem; }
.help { font-size: .85rem; color: var(--c-ink-muted); margin: .25rem 0 0; }
.error-text { color: var(--c-danger); font-size: .875rem; margin-top: .3rem; font-weight: 500; }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="month"], input[type="number"], input[type="password"], input[type="search"], textarea, select {
  width: 100%; font: inherit; font-size: 16px; padding: .75rem .8rem; border: 1.5px solid var(--c-grey-light); border-radius: 12px; background: #fff; color: var(--c-ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-primary) 25%, transparent); }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--c-danger); }
textarea { min-height: 6rem; resize: vertical; }
.input-row { display: flex; gap: .5rem; }
.input-row > * { flex: 1; min-width: 0; }
.input-row .narrow { flex: 0 0 34%; }
.suffix { display: flex; align-items: center; gap: .5rem; }
.suffix span { white-space: nowrap; color: var(--c-ink-muted); font-size: .9rem; }

.options { display: grid; gap: .5rem; }
.option { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border: 1.5px solid var(--c-grey-light); border-radius: 12px; background: #fff; cursor: pointer; }
.option input { width: 22px; height: 22px; margin: 0; accent-color: var(--c-primary); flex: none; }
.option.selected { border-color: var(--c-primary); background: color-mix(in srgb, var(--c-primary) 8%, #fff); }

.check { display: flex; align-items: flex-start; gap: .7rem; padding: .6rem 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: .1rem 0 0; accent-color: var(--c-primary); flex: none; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem .9rem; border: 1.5px solid var(--c-grey-light); border-radius: 12px; background: #fff; cursor: pointer; margin-bottom: 1rem; }
.switch input { width: 44px; height: 26px; appearance: none; background: var(--c-grey-light); border-radius: 13px; position: relative; flex: none; margin: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--c-primary); }
.switch input:checked::after { transform: translateX(18px); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font: inherit; font-weight: 600; padding: .85rem 1.2rem; border-radius: 12px; border: 0; cursor: pointer; background: var(--c-primary); color: #1a1408; text-decoration: none; min-height: 48px; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-secondary { background: #fff; color: var(--c-ink); border: 1.5px solid var(--c-grey-light); }
.btn-ghost { background: transparent; color: var(--c-primary-strong); }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: .5rem .8rem; min-height: 38px; font-size: .9rem; border-radius: 10px; }
.actions { display: flex; gap: .6rem; margin-top: 1.2rem; }
.actions .btn { flex: 1; }
.actions .btn-ghost { flex: 0 0 auto; }

/* Uploads */
.upload-slot { border: 1.5px dashed var(--c-grey-light); border-radius: 12px; padding: .8rem; margin-bottom: .8rem; background: #fff; }
.upload-slot.filled { border-style: solid; border-color: var(--c-ok); }
.upload-slot .slot-title { font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.upload-buttons { display: flex; gap: .5rem; margin-top: .6rem; }
.upload-buttons .btn { flex: 1; }
.upload-preview { display: flex; align-items: center; gap: .8rem; margin-top: .6rem; }
.upload-preview img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--c-grey-light); background: var(--c-grey-pale); }
.upload-preview .file-meta { flex: 1; font-size: .875rem; min-width: 0; overflow-wrap: anywhere; }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: var(--c-grey-pale); color: var(--c-ink-muted); }
.badge-ok { background: color-mix(in srgb, var(--c-ok) 18%, #fff); color: #1d6b42; }
.badge-new { background: color-mix(in srgb, var(--c-accent) 20%, #fff); color: #8a4506; }
.badge-warn { background: color-mix(in srgb, var(--c-danger) 15%, #fff); color: #8f2a2a; }
.badge-primary { background: color-mix(in srgb, var(--c-primary) 22%, #fff); color: var(--c-primary-strong); }

/* Unterschrift */
.signature-wrap { position: relative; border: 1.5px solid var(--c-grey-light); border-radius: 12px; background: #fff; overflow: hidden; touch-action: none; }
.signature-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; }
.signature-wrap .sig-line { position: absolute; left: 8%; right: 8%; bottom: 40px; border-top: 1px dashed var(--c-grey-light); pointer-events: none; }
.signature-wrap .sig-hint { position: absolute; left: 0; right: 0; bottom: 12px; text-align: center; color: var(--c-grey); font-size: .85rem; pointer-events: none; }
.statement { background: var(--c-grey-pale); border-radius: 12px; padding: .8rem 1rem; font-size: .95rem; max-height: 40vh; overflow: auto; }
.statement h1, .statement h2, .statement h3 { font-size: 1rem; margin: .4rem 0; }
.statement blockquote { margin: .4rem 0; padding: .4rem .8rem; border-left: 3px solid var(--c-primary); background: #fff; font-size: .875rem; }

/* Zusammenfassung / Detail */
.kv { display: grid; grid-template-columns: 1fr; gap: .15rem .8rem; margin: .4rem 0 .8rem; }
.kv dt { font-size: .8rem; color: var(--c-ink-muted); margin-top: .5rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 560px) { .kv { grid-template-columns: 220px 1fr; } .kv dt { margin-top: 0; padding-top: .35rem; } .kv dd { padding: .3rem 0; border-bottom: 1px solid var(--c-grey-pale); } }
.masked { letter-spacing: .1em; }
.progress-upload { margin-top: 1rem; }
.notice { border-radius: 12px; padding: .8rem 1rem; margin: .8rem 0; font-size: .95rem; }
.notice-info { background: color-mix(in srgb, var(--c-primary) 12%, #fff); }
.notice-ok { background: color-mix(in srgb, var(--c-ok) 15%, #fff); }
.notice-error { background: color-mix(in srgb, var(--c-danger) 12%, #fff); color: #7a1f1f; }
.notice-warn { background: color-mix(in srgb, var(--c-accent) 15%, #fff); }
.big-check { font-size: 3rem; text-align: center; color: var(--c-ok); line-height: 1; margin: .5rem 0; }
.fingerprint { font-family: ui-monospace, monospace; font-size: .8rem; color: var(--c-ink-muted); }

/* Admin */
.admin-nav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 1rem; }
.admin-nav a { padding: .55rem .9rem; border-radius: 999px; text-decoration: none; color: var(--c-ink); background: #fff; border: 1.5px solid var(--c-grey-light); font-size: .95rem; font-weight: 500; }
.admin-nav a.active { background: var(--c-primary); border-color: var(--c-primary); color: #1a1408; }
.admin-nav .spacer { flex: 1; }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: .8rem; }
.toolbar input[type="search"] { flex: 1; min-width: 200px; }
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; }
.tabs button { font: inherit; font-size: .9rem; padding: .4rem .8rem; border-radius: 999px; border: 1.5px solid var(--c-grey-light); background: #fff; cursor: pointer; }
.tabs button.active { background: var(--c-ink); color: #fff; border-color: var(--c-ink); }
.list { display: flex; flex-direction: column; gap: .5rem; }
.row { display: flex; gap: .8rem; align-items: center; background: #fff; border-radius: 12px; padding: .8rem 1rem; text-decoration: none; color: inherit; border: 1.5px solid transparent; }
.row:hover { border-color: var(--c-grey-light); }
.row.unread { border-left: 4px solid var(--c-accent); }
.row .row-main { flex: 1; min-width: 0; }
.row .row-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .row-sub { font-size: .85rem; color: var(--c-ink-muted); }
.row .row-side { text-align: right; font-size: .8rem; color: var(--c-ink-muted); white-space: nowrap; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.file-card { border: 1px solid var(--c-grey-light); border-radius: 12px; padding: .7rem; margin-bottom: .7rem; background: #fff; }
.file-card img { max-width: 100%; border-radius: 8px; display: block; margin-top: .5rem; }
.file-card canvas { max-width: 100%; display: block; margin-top: .5rem; border: 1px solid var(--c-grey-pale); }
.sig-img { max-width: 320px; width: 100%; border: 1px solid var(--c-grey-light); border-radius: 8px; background: #fff; }
.copy-box { display: flex; gap: .5rem; align-items: stretch; }
.copy-box input { flex: 1; min-width: 0; }
.words { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .8rem 0; }
.words li { list-style: none; background: var(--c-grey-pale); border-radius: 8px; padding: .5rem .6rem; font-family: ui-monospace, monospace; font-size: .95rem; }
.words li b { color: var(--c-ink-muted); font-weight: 500; margin-right: .4rem; font-size: .8rem; }
.words-input { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.words-input input { padding: .5rem; font-size: 15px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.tbl th, table.tbl td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--c-grey-pale); vertical-align: top; }
table.tbl th { color: var(--c-ink-muted); font-weight: 600; }
.stat { display: inline-flex; flex-direction: column; background: #fff; border-radius: 12px; padding: .7rem 1rem; min-width: 120px; margin: 0 .5rem .5rem 0; border: 1.5px solid var(--c-grey-light); }
.stat b { font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--c-ink-muted); }
.lock-screen { max-width: 420px; margin: 2rem auto; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--c-grey-light); border-top-color: var(--c-primary); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.honeypot { position: absolute; left: -9999px; top: -9999px; opacity: 0; height: 0; width: 0; }

@media print {
  body { background: #fff; }
  .topbar, .footer, .admin-nav, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #999; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
