/* Mieterantwort: a printed statement on the manager's desk, annotated in royal-blue reviewer ink. */

@font-face { font-family: "Fira Sans"; font-weight: 400; font-style: normal; font-display: swap;
  src: url("/static/fonts/fira-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 400; font-style: italic; font-display: swap;
  src: url("/static/fonts/fira-sans-latin-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 500; font-style: normal; font-display: swap;
  src: url("/static/fonts/fira-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 600; font-style: normal; font-display: swap;
  src: url("/static/fonts/fira-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 700; font-style: normal; font-display: swap;
  src: url("/static/fonts/fira-sans-latin-700-normal.woff2") format("woff2"); }

:root {
  --desk: #f4f6f9;
  --sheet: #ffffff;
  --ink: #172033;
  --graphite: #4a5568;
  --rule: #d8dee8;
  --rule-soft: #e9edf3;
  --royal: #2443b8;
  --royal-dark: #1b3492;
  --royal-tint: #eef1fc;
  --err: #b42318;
  --err-tint: #fdeceb;
  --warn: #8f5100;
  --warn-tint: #fdf2df;
  --ok: #17703f;
  --ok-tint: #e7f4ec;
  --font: "Fira Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --measure: 38rem;
  --page: 76rem;
  --gutter: clamp(1rem, 4vw, 2.5rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 1.0625rem/1.55 var(--font);
  color: var(--ink);
  background: var(--desk);
  font-feature-settings: "kern", "liga";
  min-height: 100vh; display: flex; flex-direction: column;
}
body > main { flex: 1 0 auto; }
img { max-width: 100%; display: block; }
a { color: var(--royal); text-underline-offset: 0.18em; }
a:hover { color: var(--royal-dark); }
:focus-visible { outline: 3px solid var(--royal); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.012em; font-weight: 600; hyphens: manual; overflow-wrap: break-word; }
h1 { font-size: clamp(1.9rem, 1.3rem + 2.2vw, 2.65rem); }
.hero h1 { max-width: 17em; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem); }
h3 { font-size: 1.1875rem; }
p { margin: 0; }
.muted { color: var(--graphite); }
.small { font-size: 0.875rem; line-height: 1.5; }

/* Frame */
.wrap { width: min(100% - 2 * var(--gutter), var(--page)); margin-inline: auto; }
.page-wide .wrap { width: min(100% - 2 * var(--gutter), 86rem); }
.site-head { background: var(--sheet); border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 4rem; }
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 1.125rem; letter-spacing: -0.01em; }
.brand svg { flex: none; }
.site-head .tagline { color: var(--graphite); font-size: 0.9375rem; }
@media (max-width: 40rem) { .site-head .tagline { display: none; } }
main { padding-block: clamp(2rem, 5vw, 4rem) clamp(3rem, 7vw, 6rem); }
.site-foot { border-top: 1px solid var(--rule); background: var(--sheet); color: var(--graphite); font-size: 0.875rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 2rem; padding-block: 1.5rem; }
.site-foot ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.5rem; }
.site-foot a { color: var(--graphite); }

/* Buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.875rem; padding: 0.65rem 1.25rem; border-radius: 8px;
  font: 600 1rem/1.2 var(--font); text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color 120ms ease, border-color 120ms ease;
}
.btn-primary { background: var(--royal); color: #fff; }
.btn-primary:hover { background: var(--royal-dark); color: #fff; }
.btn-quiet { background: var(--sheet); color: var(--ink); border-color: var(--rule); }
.btn-quiet:hover { border-color: var(--graphite); color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { background: #0f5a31; color: #fff; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn-small { min-height: 2.25rem; padding: 0.4rem 0.85rem; font-size: 0.9375rem; }

.field { display: grid; gap: 0.35rem; }
.field label { font-weight: 500; font-size: 0.9375rem; }
.field .hint { color: var(--graphite); font-size: 0.875rem; }
.input, .textarea {
  width: 100%; padding: 0.7rem 0.85rem; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--sheet); color: var(--ink); font: inherit; font-size: 1rem;
}
.input:hover, .textarea:hover { border-color: #b9c2d0; }
.input:focus, .textarea:focus { outline: none; border-color: var(--royal); box-shadow: 0 0 0 3px var(--royal-tint); }
.textarea { resize: vertical; line-height: 1.5; }

/* Landing */
.hero { display: grid; gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
@media (min-width: 62rem) { .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.02fr); } }
.hero-copy { display: grid; gap: 1.25rem; max-width: var(--measure); }
.hero-copy .lead { font-size: 1.1875rem; line-height: 1.55; color: #2b3445; }
.for-target { padding: 0.75rem 1rem; border-left: 3px solid var(--royal); background: var(--royal-tint); border-radius: 0 6px 6px 0; }

.upload { display: grid; gap: 1rem; margin-top: 0.5rem; padding: 1.5rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.upload .row { display: grid; gap: 1rem; }
@media (min-width: 36rem) { .upload .row { grid-template-columns: 1fr 1fr; } }
.drop {
  position: relative; display: grid; gap: 0.25rem; justify-items: start;
  padding: 1.25rem 1.25rem 1.25rem 4.25rem; min-height: 5.5rem; align-content: center;
  border: 1.5px dashed #aab4c4; border-radius: 10px; background: var(--desk); cursor: pointer;
}
.drop:hover, .drop.is-over { border-color: var(--royal); background: var(--royal-tint); }
.drop:focus-within { border-color: var(--royal); outline: 3px solid var(--royal); outline-offset: 2px; }
.drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.drop svg { position: absolute; left: 1.25rem; top: 50%; transform: translateY(-50%); color: var(--royal); }
.drop-title { font-weight: 600; }
.drop-hint { color: var(--graphite); font-size: 0.875rem; }
.drop-file { font-weight: 500; color: var(--royal-dark); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; }
.consent { color: var(--graphite); font-size: 0.8125rem; line-height: 1.5; }

.facts-inline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.5rem; font-size: 0.9375rem; color: #2b3445; }
.facts-inline li { display: flex; gap: 0.6rem; align-items: baseline; }
.facts-inline svg { flex: none; color: var(--ok); transform: translateY(2px); }

/* The statement sheet: the one memorable object */
.sheet {
  position: relative; margin: 0; background: var(--sheet); border-radius: 3px;
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 var(--rule-soft), 0 18px 40px -24px rgba(23, 32, 51, 0.35);
}
.sheet-body { padding: clamp(1.25rem, 3vw, 2rem); }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding-bottom: 0.9rem; border-bottom: 2px solid var(--ink); }
.sheet-head h2, .sheet-head h3 { font-size: 1.0625rem; }
.sheet-meta { color: var(--graphite); font-size: 0.875rem; }
.sheet-rows { list-style: none; margin: 0; padding: 0; }
.sheet-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--rule-soft); font-size: 0.9375rem; }
.sheet-row .what { min-width: 0; }
.sheet-row .key { color: var(--graphite); font-size: 0.8125rem; }
.sheet-row .amt { text-align: right; font-weight: 500; }
.sheet-row.is-flagged { background: linear-gradient(90deg, var(--err-tint), transparent 70%); margin-inline: -0.75rem; padding-inline: 0.75rem; }
.sheet-total { display: grid; grid-template-columns: 1fr auto; gap: 0.3rem 0; padding-top: 0.9rem; font-size: 0.9375rem; }
.sheet-total .num, .totals .num { padding-left: 1.5rem; text-align: right; }
.sheet-total .grand { font-weight: 700; font-size: 1.0625rem; padding-top: 0.45rem; border-top: 1px solid var(--ink); }

/* Reviewer's margin notes in royal-blue ink */
.note {
  grid-column: 1 / -1; position: relative; margin-top: 0.35rem; padding-left: 0.9rem;
  color: var(--royal); font-style: italic; font-size: 0.875rem; line-height: 1.45;
  border-left: 2px solid var(--royal);
}
.note strong { font-style: normal; font-weight: 600; }
@media (min-width: 62rem) {
  .sample .sheet-row { grid-template-columns: minmax(0, 1fr) auto; }
}

.exchange { display: grid; gap: 0.75rem; padding: clamp(1.25rem, 3vw, 2rem); padding-top: 0; }
.bubble { padding: 0.85rem 1rem; border-radius: 10px; font-size: 0.9375rem; line-height: 1.5; }
.bubble .who { display: block; font-size: 0.8125rem; color: var(--graphite); margin-bottom: 0.2rem; }
.bubble-tenant { background: var(--desk); border: 1px solid var(--rule); margin-right: 2.5rem; }
.bubble-draft { background: var(--royal-tint); border: 1px solid #cfd8f6; margin-left: 2.5rem; }
.sample figcaption { padding: 0.75rem clamp(1.25rem, 3vw, 2rem); border-top: 1px solid var(--rule-soft); color: var(--graphite); font-size: 0.8125rem; }

.section { margin-top: clamp(3.5rem, 8vw, 6rem); }
.section-head { display: grid; gap: 0.6rem; max-width: var(--measure); margin-bottom: 1.75rem; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; counter-reset: step; }
@media (min-width: 52rem) { .steps { grid-template-columns: repeat(3, 1fr); gap: 2.5rem; } }
.steps li { counter-increment: step; display: grid; gap: 0.4rem; padding-top: 1rem; border-top: 2px solid var(--ink); }
.steps li::before { content: counter(step); font-weight: 700; font-size: 1.75rem; line-height: 1; color: var(--royal); font-variant-numeric: lining-nums; }

.data-facts { display: grid; gap: 0; margin: 0; border-top: 1px solid var(--rule); }
.data-facts > div { display: grid; gap: 0.25rem 2rem; padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
@media (min-width: 52rem) { .data-facts > div { grid-template-columns: 16rem minmax(0, 1fr); } }
.data-facts dt { font-weight: 600; }
.data-facts dd { margin: 0; color: #2b3445; max-width: 46rem; }

.faq { border-top: 1px solid var(--rule); max-width: 52rem; }
.faq details { border-bottom: 1px solid var(--rule); }
.faq summary { display: flex; justify-content: space-between; gap: 1rem; padding: 1.05rem 0; font-weight: 600; cursor: pointer; list-style: none; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-weight: 400; font-size: 1.4rem; line-height: 1; color: var(--royal); }
.faq details[open] summary::after { content: "–"; }
.faq details p { padding: 0 0 1.15rem; max-width: var(--measure); color: #2b3445; }

/* Progress overlay while the statement is analysed */
.progress[hidden] { display: none; }
.progress { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: var(--gutter); background: rgba(244, 246, 249, 0.94); }
.progress-card { width: min(100%, 28rem); padding: 2rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 24px 60px -30px rgba(23, 32, 51, 0.45); display: grid; gap: 1.25rem; }
.progress ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }
.progress li { display: flex; gap: 0.75rem; align-items: center; color: var(--graphite); }
.progress li::before { content: ""; flex: none; width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 2px solid var(--rule); }
.progress li.is-active { color: var(--ink); font-weight: 500; }
.progress li.is-active::before { border-color: var(--royal); border-right-color: transparent; animation: spin 0.9s linear infinite; }
.progress li.is-done { color: var(--ink); }
.progress li.is-done::before { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 3px #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Result page */
.doc-head { display: grid; gap: 1rem; margin-bottom: 2rem; }
.doc-head .top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; }
.doc-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 1.75rem; margin: 0; color: var(--graphite); font-size: 0.9375rem; }
.doc-meta div { display: flex; gap: 0.4rem; }
.doc-meta dt { color: var(--graphite); }
.doc-meta dd { margin: 0; color: var(--ink); font-weight: 500; }

.result-grid { display: grid; gap: 1.75rem; align-items: start; }
@media (min-width: 64rem) { .result-grid { grid-template-columns: minmax(0, 1fr) minmax(21rem, 25rem); } }

.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; }
.panel-body { padding: 1.25rem 1.4rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--rule-soft); }
.panel-head h2 { font-size: 1.125rem; }

.originals-inline summary { cursor: pointer; font-weight: 500; color: var(--royal); }
.originals-inline .thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: 0.75rem; margin-top: 0.75rem; }


.flags { list-style: none; margin: 0; padding: 0; }
.flag { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.2rem 0.85rem; padding: 0.9rem 1.4rem; border-top: 1px solid var(--rule-soft); font-size: 0.9375rem; }
.flag:first-child { border-top: 0; }
.flag a { font-size: 0.875rem; }
.sev { display: inline-flex; align-items: center; height: 1.5rem; padding: 0 0.55rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.sev-fehler { background: var(--err-tint); color: var(--err); }
.sev-pruefen { background: var(--warn-tint); color: var(--warn); }
.sev-hinweis { background: var(--royal-tint); color: var(--royal-dark); }
.sev-ok { background: var(--ok-tint); color: var(--ok); }
.flag-empty { display: flex; gap: 0.75rem; align-items: center; padding: 1.1rem 1.4rem; color: var(--ok); font-weight: 500; }

.statement .sheet-body { padding: clamp(1rem, 2.5vw, 1.75rem); }
.positions { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.positions th { text-align: left; font-weight: 500; color: var(--graphite); font-size: 0.8125rem; padding: 0.5rem 0.5rem; border-bottom: 2px solid var(--ink); }
.positions td { padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.positions .r { text-align: right; }
.positions .pos { color: var(--graphite); width: 2.25rem; }
.positions .cat { display: block; color: var(--graphite); font-size: 0.8125rem; margin-top: 0.1rem; }
.positions tr.is-flagged > td { background: var(--err-tint); }
.positions tr.is-flagged.sev-row-pruefen > td { background: var(--warn-tint); }
.positions tr.detail > td { padding-top: 0; }
.positions details summary { cursor: pointer; color: var(--royal); font-size: 0.875rem; font-weight: 500; width: max-content; }
.positions details[open] summary { margin-bottom: 0.5rem; }
.positions details p { max-width: 44rem; line-height: 1.55; }
.positions .intern { margin-top: 0.5rem; color: var(--graphite); font-size: 0.875rem; }
.amount { font-weight: 600; }
@media (max-width: 40rem) {
  .positions .hide-sm { display: none; }
}
.totals { display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 0; max-width: 24rem; margin: 1.25rem 0 0 auto; font-size: 0.9375rem; }
.sheet-foot { margin-top: 1rem; }
.totals .grand { font-weight: 700; font-size: 1.125rem; padding-top: 0.5rem; border-top: 1px solid var(--ink); }

.qa { display: grid; gap: 1.25rem; }
@media (min-width: 64rem) { .qa { position: sticky; top: 1.5rem; } }
.qa form { display: grid; gap: 0.75rem; }
.draft { display: grid; gap: 0.75rem; padding: 1.25rem 1.4rem; border-top: 1px solid var(--rule-soft); }
.draft .question { font-size: 0.9375rem; color: #2b3445; }
.draft .question strong { color: var(--ink); }
.draft-meta { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.escalate { padding: 0.75rem 0.9rem; border-left: 3px solid var(--warn); background: var(--warn-tint); border-radius: 0 6px 6px 0; font-size: 0.875rem; }
.draft .buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.summary-text { font-size: 0.9375rem; line-height: 1.6; color: #2b3445; }

.notice-bar { margin: 0 0 1.5rem; padding: 0.9rem 1.1rem; background: var(--sheet); border: 1px solid var(--rule); border-left: 3px solid var(--royal); border-radius: 0 8px 8px 0; font-size: 0.9375rem; }
.notice-bar ul { margin: 0.5rem 0 0; padding-left: 1.2rem; color: #2b3445; }
.notice-bar summary { cursor: pointer; font-weight: 500; color: var(--royal); }
.notice-warn { border-left-color: var(--warn); background: var(--warn-tint); }

/* Plain document pages */
.doc { max-width: 46rem; display: grid; gap: 1.25rem; }
.doc h2 { font-size: 1.1875rem; margin-top: 1rem; }
.doc p { color: #2b3445; }
.notice { display: grid; gap: 1rem; max-width: 38rem; padding: 2rem; background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; }
.notice .buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.admin-table th { text-align: left; font-weight: 500; color: var(--graphite); padding: 0.5rem; border-bottom: 2px solid var(--ink); }
.admin-table td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.admin-table code { font-size: 0.8125rem; word-break: break-all; }
.table-scroll { overflow-x: auto; }
.metric { font-size: 2.5rem; font-weight: 700; color: var(--royal); line-height: 1; }
.stack { display: grid; gap: 1.5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
