/* Luong Signatur – Farben & Schrift nach den Luong-Consulting-Brand-Guidelines */
@font-face { font-family: "Jost"; font-weight: 300; font-display: swap; src: url(/fonts/Jost-300-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jost"; font-weight: 300; font-display: swap; src: url(/fonts/Jost-300-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Jost"; font-weight: 400; font-display: swap; src: url(/fonts/Jost-400-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jost"; font-weight: 400; font-display: swap; src: url(/fonts/Jost-400-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Jost"; font-weight: 500; font-display: swap; src: url(/fonts/Jost-500-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jost"; font-weight: 500; font-display: swap; src: url(/fonts/Jost-500-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-display: swap; src: url(/fonts/PlayfairDisplay-600-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-weight: 600; font-display: swap; src: url(/fonts/PlayfairDisplay-600-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Playfair Display"; font-weight: 400; font-style: italic; font-display: swap; src: url(/fonts/PlayfairDisplay-400i-latin.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Playfair Display"; font-weight: 400; font-style: italic; font-display: swap; src: url(/fonts/PlayfairDisplay-400i-latin-ext.woff2) format("woff2"); unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --paper: #FBFAF7; --paper-deep: #F3F0E9; --paper-raised: #FFFFFF;
  --ink: #16150F; --pencil: #57544C; --gold: #B99A3C; --gold-dark: #9A7F2F;
  --line: rgba(22, 21, 15, .10); --line-soft: rgba(22, 21, 15, .06);
  --gold-wash: rgba(185, 154, 60, .09); --gold-line: rgba(185, 154, 60, .35);
  --ok: #2F6B3F; --ok-wash: rgba(47, 107, 63, .09);
  --warn: #8A5A12; --warn-wash: rgba(176, 116, 20, .10);
  --bad: #9B2C2C; --bad-wash: rgba(155, 44, 44, .08);
  --radius: 10px; --shadow: 0 1px 2px rgba(22,21,15,.05), 0 8px 28px rgba(22,21,15,.07);
  --font: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Playfair Display", Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-weight: 300; font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--paper); min-height: 100vh; min-height: 100dvh; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.005em; }
h1 { font-size: clamp(1.6rem, 3.6vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; }
h1 em, h2 em { font-weight: 400; font-style: italic; color: var(--gold-dark); }
p { margin: 0 0 .8em; }
a { color: var(--gold-dark); }
small, .muted { color: var(--pencil); }
.muted { font-size: .92rem; }
.kicker { font-weight: 500; font-size: .72rem; letter-spacing: .32em; text-transform: uppercase; color: var(--gold-dark); margin-bottom: .6rem; display: block; }
.hidden { display: none !important; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .82rem; word-break: break-all; }

/* Kopf */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(251,250,247,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; padding: .65rem 1.1rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.brand img { width: 34px; height: 34px; }
.brand b { font-weight: 500; letter-spacing: .2em; font-size: .86rem; display: block; line-height: 1.1; }
.brand span { font-size: .6rem; letter-spacing: .4em; color: var(--pencil); text-transform: uppercase; display: block; }
.tabs { display: flex; gap: .2rem; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { border: 0; background: none; font: inherit; font-weight: 400; color: var(--pencil); padding: .45rem .8rem; border-radius: 999px; cursor: pointer; white-space: nowrap; font-size: .95rem; }
.tab:hover { color: var(--ink); background: var(--line-soft); }
.tab.active { color: var(--ink); background: var(--gold-wash); box-shadow: inset 0 0 0 1px var(--gold-line); }
.tab .badge-count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .3em; border-radius: 999px; background: var(--gold); color: #fff; font-size: .72rem; font-weight: 500; line-height: 1.45em; text-align: center; }

@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; padding: .5rem .8rem .2rem; gap: .2rem; }
  .tabs { order: 3; width: 100%; margin: 0; padding-bottom: .35rem; }
  .brand b { font-size: .8rem; }
  .user-menu { margin-left: auto; }
}

main { max-width: 1240px; margin: 0 auto; padding: 1.4rem 1.1rem 4rem; }
.view-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .8rem; margin-bottom: 1.2rem; }
.view-head p { max-width: 640px; margin: 0; }

/* Bausteine */
.card { background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; font: inherit; font-weight: 400; font-size: .95rem; padding: .62rem 1.05rem; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s, opacity .15s; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
.btn:hover { background: #2b2a22; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.gold:hover { background: var(--gold-dark); border-color: var(--gold-dark); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); border-color: rgba(155,44,44,.35); }
.btn.danger:hover { background: var(--bad-wash); }
.btn.small { padding: .4rem .75rem; font-size: .86rem; }
.btn.big { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn svg { width: 1.05em; height: 1.05em; flex-shrink: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label { display: block; font-weight: 400; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .9rem; }
.field .hint { font-size: .8rem; color: var(--pencil); margin-top: .2rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], select, textarea {
  width: 100%; font: inherit; font-weight: 300; color: var(--ink); background: var(--paper); border: 1px solid rgba(22,21,15,.18); border-radius: 8px; padding: .6rem .75rem; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-wash); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 300; font-size: .95rem; cursor: pointer; margin-bottom: .7rem; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--gold-dark); flex-shrink: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }

.notice { border-radius: 8px; padding: .75rem .9rem; font-size: .92rem; margin-bottom: .9rem; background: var(--gold-wash); border: 1px solid var(--gold-line); }
.notice.ok { background: var(--ok-wash); border-color: rgba(47,107,63,.3); }
.notice.warn { background: var(--warn-wash); border-color: rgba(176,116,20,.3); }
.notice.bad { background: var(--bad-wash); border-color: rgba(155,44,44,.3); }
.notice b { font-weight: 500; }

.badge { display: inline-block; font-size: .74rem; font-weight: 500; letter-spacing: .04em; padding: .12rem .55rem; border-radius: 999px; background: var(--line-soft); color: var(--pencil); white-space: nowrap; }
.badge.sent, .badge.opened { background: var(--gold-wash); color: var(--gold-dark); }
.badge.signed { background: var(--ok-wash); color: var(--ok); }
.badge.withdrawn { background: var(--bad-wash); color: var(--bad); }

/* Datei wählen */
.drop { border: 1.5px dashed var(--gold-line); border-radius: var(--radius); background: var(--paper-raised); padding: 2.6rem 1rem; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { background: var(--gold-wash); border-color: var(--gold); }
.drop svg { width: 42px; height: 42px; color: var(--gold); margin-bottom: .4rem; }
.drop b { font-weight: 400; display: block; font-size: 1.05rem; }
.drop input { display: none; }

/* Arbeitsbereich: PDF links, Bedienung rechts */
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.2rem; align-items: start; }
.side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 1rem; }
@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .side { position: static; order: -1; }
}
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 .4rem; }
.steps li { counter-increment: step; display: flex; gap: .6rem; align-items: baseline; padding: .3rem 0; color: var(--pencil); font-size: .93rem; }
.steps li::before { content: counter(step); flex-shrink: 0; width: 1.45rem; height: 1.45rem; border-radius: 50%; border: 1px solid var(--gold-line); color: var(--gold-dark); font-size: .78rem; display: inline-flex; align-items: center; justify-content: center; font-weight: 500; }
.steps li.done { color: var(--ink); }
.steps li.done::before { content: "✓"; background: var(--gold); border-color: var(--gold); color: #fff; }

/* PDF-Ansicht */
.pdf-view { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px; background: var(--paper-deep); border-radius: var(--radius); border: 1px solid var(--line); min-height: 200px; }
.pdf-page { position: relative; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 6px 18px rgba(0,0,0,.06); max-width: 100%; }
.pdf-page canvas { display: block; width: 100%; height: 100%; }
.pdf-page .overlay { position: absolute; inset: 0; }
.pdf-page .pnum { position: absolute; right: 6px; bottom: -20px; font-size: .72rem; color: var(--pencil); }
.pdf-view.adding .overlay { cursor: crosshair; touch-action: none; }
.pdf-view.adding .pdf-page { outline: 2px dashed var(--gold-line); outline-offset: 3px; }

.frame { position: absolute; border: 2px solid var(--gold); background: rgba(185,154,60,.13); border-radius: 4px; display: flex; align-items: flex-end; justify-content: flex-start; touch-action: none; }
.frame .flabel { position: absolute; left: 0; top: -1.45em; font-size: .72rem; font-weight: 500; background: var(--gold); color: #fff; padding: .05em .5em; border-radius: 4px 4px 0 0; white-space: nowrap; pointer-events: none; letter-spacing: .02em; }
.frame.editable { cursor: move; }
.frame .fdel { position: absolute; right: -11px; top: -11px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--ink); color: #fff; font-size: 15px; line-height: 24px; text-align: center; cursor: pointer; padding: 0; }
.frame .fres { position: absolute; right: -8px; bottom: -8px; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--gold); cursor: nwse-resize; }
.frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.frame.signed { background: transparent; border-style: dashed; border-color: var(--gold-line); }
.frame.target { cursor: pointer; animation: pulse 2s infinite; }
.frame.target .flabel { pointer-events: auto; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(185,154,60,.45); } 50% { box-shadow: 0 0 0 7px rgba(185,154,60,0); } }
@media (max-width: 600px) { .pdf-view { padding: 8px; gap: 22px; border-radius: 0; margin: 0 -1.1rem; border-left: 0; border-right: 0; } }

/* Dialoge */
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(22,21,15,.5); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .15s; }
.modal { background: var(--paper); border-radius: 14px; width: min(540px, 100%); max-height: calc(100dvh - 2rem); overflow: auto; padding: 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); position: relative; }
.modal .close { position: absolute; right: .7rem; top: .6rem; border: 0; background: none; font-size: 1.5rem; cursor: pointer; color: var(--pencil); line-height: 1; padding: .2rem .4rem; }
@keyframes fade { from { opacity: 0; } }
.qr { display: flex; justify-content: center; margin: .6rem 0 .8rem; }
.qr img, .qr svg { width: 220px; height: 220px; image-rendering: pixelated; background: #fff; padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
.choice { display: grid; gap: .6rem; }
.choice button { text-align: left; display: flex; gap: .9rem; align-items: center; padding: .9rem 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper-raised); font: inherit; cursor: pointer; color: var(--ink); }
.choice button:hover { border-color: var(--gold); background: var(--gold-wash); }
.choice button svg { width: 30px; height: 30px; color: var(--gold-dark); flex-shrink: 0; }
.choice button b { font-weight: 400; display: block; }
.choice button small { display: block; font-size: .84rem; }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--gold-line); border-top-color: var(--gold-dark); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Unterschriftsfeld (Vollbild) */
.pad-screen { position: fixed; inset: 0; z-index: 100; background: var(--paper); display: flex; flex-direction: column; padding: max(.7rem, env(safe-area-inset-top)) max(.8rem, env(safe-area-inset-right)) max(.7rem, env(safe-area-inset-bottom)) max(.8rem, env(safe-area-inset-left)); }
.pad-head { display: flex; align-items: center; gap: .8rem; justify-content: space-between; margin-bottom: .5rem; }
.pad-head h2 { margin: 0; font-size: 1.15rem; }
.pad-head p { margin: 0; font-size: .85rem; color: var(--pencil); }
.pad-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.pad-box { position: relative; background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line), var(--shadow); touch-action: none; }
.pad-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-box .baseline { position: absolute; left: 6%; right: 6%; bottom: 24%; border-bottom: 1.5px solid var(--gold-line); pointer-events: none; }
.pad-box .baseline::before { content: "✕"; position: absolute; left: -2px; bottom: 2px; color: var(--gold); font-size: 1rem; }
.pad-box .ph { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(87,84,76,.35); font-family: var(--serif); font-style: italic; font-size: clamp(1.1rem, 4vw, 1.8rem); pointer-events: none; }
.pad-foot { display: flex; gap: .5rem; align-items: center; justify-content: space-between; margin-top: .6rem; flex-wrap: wrap; }
.pad-foot .colors { display: flex; gap: .4rem; }
.pad-foot .colors button { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.pad-foot .colors button.on { border-color: var(--gold); box-shadow: 0 0 0 2px #fff inset; }
.rotate-hint { display: none; font-size: .85rem; color: var(--gold-dark); text-align: center; margin-bottom: .4rem; }
@media (orientation: portrait) and (max-width: 600px) { .rotate-hint { display: block; } }

/* Dokumentliste */
.doclist { display: flex; flex-direction: column; gap: .55rem; }
.docrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem 1rem; align-items: center; padding: .85rem 1rem; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; transition: border-color .15s; }
.docrow:hover { border-color: var(--gold-line); }
.docrow .t { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docrow .m { font-size: .84rem; color: var(--pencil); grid-column: 1; }
.docrow .badge { grid-row: 1 / span 2; grid-column: 2; }
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.timeline { list-style: none; padding: 0; margin: .4rem 0 0; font-size: .88rem; }
.timeline li { padding: .35rem 0 .35rem 1.1rem; border-left: 2px solid var(--gold-line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: .75rem; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.timeline time { color: var(--pencil); font-size: .8rem; display: block; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: .2rem 0 1rem; font-size: .92rem; }
dl.kv dt { color: var(--pencil); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Toasts */
.toasts { position: fixed; z-index: 120; left: 50%; bottom: 1.2rem; transform: translateX(-50%); display: flex; flex-direction: column; gap: .4rem; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: var(--ink); color: var(--paper); padding: .65rem 1rem; border-radius: 10px; font-size: .92rem; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: fade .2s; pointer-events: auto; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Login & öffentliche Seiten */
.center-page { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.login-card { width: min(400px, 100%); }
.login-card .brand { margin-bottom: 1.4rem; }
.public-head { border-bottom: 1px solid var(--line); background: var(--paper-raised); }
.public-head .in { max-width: 980px; margin: 0 auto; padding: .9rem 1.1rem; display: flex; align-items: center; gap: .8rem; }
.public-head .sender { font-weight: 400; }
.public-main { max-width: 980px; margin: 0 auto; padding: 1.3rem 1.1rem 7rem; }
.sticky-cta { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; background: rgba(251,250,247,.96); backdrop-filter: blur(8px); border-top: 1px solid var(--line); padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); }
.sticky-cta .in { max-width: 980px; margin: 0 auto; display: flex; gap: .8rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.sticky-cta .in p { margin: 0; font-size: .9rem; color: var(--pencil); }
.big-icon { width: 64px; height: 64px; color: var(--gold); margin-bottom: .6rem; }
.footer-note { text-align: center; font-size: .78rem; color: var(--pencil); margin-top: 2rem; }
.footer-note a { color: inherit; }
.widerruf-box { border: 1px solid var(--line); border-left: 4px solid var(--gold); background: var(--paper-raised); border-radius: 8px; padding: 1rem 1.1rem; margin: 1rem 0; }
