/* heitech.stb — design language
   Source of truth: Documentation/Architecture/design-language.md.
   Sections: 1 tokens · 2 base · 3 shell · 4 controls · 5 existing screens (reworked in WP-4/5).
   Rules: no colour carries meaning alone (glyph + word), amounts are tabular, monospace is for
   codes and keyboard hints only, no external fonts (CSP self-only, DSGVO). */

/* ---------- 1. tokens ---------- */
:root {
    /* warm paper neutrals */
    --paper: #f0eee9;        /* page canvas */
    --panel: #faf9f6;        /* raised panel behind cards */
    --surface: #ffffff;      /* cards, tables, inputs */
    --ink: #222222;
    --ink-muted: #555555;
    --ink-faint: #999999;
    --rule: #d9d5cd;         /* hairlines */
    --rule-strong: #222222;  /* framing borders */

    /* semantic states and markers */
    --locked: #e6e5e1;       /* ■ abgeschlossen — handled, collapsed */
    --needs-you: #e08a1e;    /* ○ wartet auf Sie — borders and glyphs only */
    --needs-you-text: #9a5a0c; /* same meaning as text, passes AA on white */
    --why: #fff7ec;          /* "Warum Sie das sehen" band, current row */
    --advice: #2a5bd6;       /* advice from the Steuerberater, ask-advisor button */
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --danger-border: #f3b5ad;
    --ok: #067647;
    --ok-bg: #ecfdf3;
    --ok-border: #a6e1c0;

    /* type */
    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs: 0.78rem;
    --text-s: 0.875rem;
    --text: 1rem;
    --text-l: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --leading: 1.5;

    /* space, radius, widths */
    --s-1: 0.25rem;
    --s-2: 0.5rem;
    --s-3: 0.75rem;
    --s-4: 1rem;
    --s-5: 1.5rem;
    --s-6: 2rem;
    --s-7: 3rem;
    --radius-s: 4px;
    --radius: 6px;
    --radius-l: 10px;
    --radius-pill: 999px;
    --border: 1.5px;
    --border-strong: 2px;
    --content-max: 1080px;
    --measure: 64ch;
}

/* ---------- 2. base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: var(--text);
    line-height: var(--leading);
    color: var(--ink);
    background: var(--paper);
}

h1, h2, h3 { font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: var(--text-2xl); margin-bottom: var(--s-2); }
h2 { font-size: var(--text-xl); margin: var(--s-6) 0 var(--s-2); }
h3 { font-size: var(--text-l); margin: var(--s-5) 0 var(--s-2); }

p { margin: 0 0 var(--s-3); max-width: var(--measure); }
.lead { font-size: var(--text-l); color: var(--ink-muted); }
.muted, .hint { color: var(--ink-muted); font-size: var(--text-s); }

a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { color: var(--advice); }

code, kbd, .code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--ink-muted);
    background: var(--locked);
    padding: 0.05em 0.35em;
    border-radius: var(--radius-s);
}

/* amounts and any numeric column line up */
.amount, .num, td.num, th.num, table { font-variant-numeric: tabular-nums; }
.num { text-align: right; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.skip-link {
    position: absolute; left: var(--s-4); top: -3rem;
    padding: var(--s-2) var(--s-3); background: var(--surface); border: var(--border-strong) solid var(--ink);
    border-radius: var(--radius); z-index: 10;
}
.skip-link:focus { top: var(--s-2); }

/* ---------- 3. shell ---------- */
.shell-header { background: var(--surface); border-bottom: var(--border) solid var(--rule); }
.shell-bar {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-3) var(--s-4);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s-2) var(--s-4);
}
.brand {
    font-weight: 700;
    font-size: var(--text-l);
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--ink);
}
.brand:hover { color: var(--ink); }

.context { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip {
    display: inline-flex; align-items: center; gap: var(--s-1);
    padding: 0.05rem var(--s-3);
    border: var(--border) solid var(--ink);
    border-radius: var(--radius-pill);
    font-size: var(--text-s);
    line-height: 1.5;
    white-space: nowrap;
    max-width: 28ch; overflow: hidden; text-overflow: ellipsis;
}

.primary-nav { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); margin-left: auto; }
.primary-nav a { text-decoration: none; color: var(--ink-muted); padding: var(--s-1) 0; border-bottom: 2px solid transparent; }
.primary-nav a:hover { color: var(--ink); }
.primary-nav a[aria-current="page"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

.user-menu { display: flex; align-items: center; gap: var(--s-3); font-size: var(--text-s); color: var(--ink-muted); }
.user-name { font-weight: 600; color: var(--ink); }
.inline-form { display: inline; margin: 0; }

.shell-main {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: var(--s-6) var(--s-4) var(--s-7);
}

.shell-footer {
    padding: var(--s-4);
    border-top: var(--border) solid var(--rule);
    color: var(--ink-faint);
    font-size: var(--text-xs);
    text-align: center;
}

@media (max-width: 640px) {
    .shell-bar { padding: var(--s-2) var(--s-4); }
    .primary-nav { margin-left: 0; width: 100%; order: 3; }
    .user-menu { margin-left: auto; }
    .shell-main { padding: var(--s-4) var(--s-4) var(--s-6); }
    h1 { font-size: var(--text-xl); }
}

/* ---------- 4. controls ---------- */
/* Buttons have no fill. Primary = strong ink border, secondary = hairline ink border,
   tertiary = dashed, advisor = blue outline, quiet = text only. */
.btn {
    font: inherit;
    line-height: 1.3;
    display: inline-flex; align-items: center; gap: var(--s-2);
    padding: 0.5rem 1rem;
    border: var(--border) solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--locked); color: var(--ink); }
.btn-primary { border-width: var(--border-strong); font-weight: 600; }
.btn-tertiary { border-style: dashed; color: var(--ink-muted); }
.btn-advice { border-color: var(--advice); color: var(--advice); }
.btn-quiet { border-color: transparent; background: none; padding: var(--s-1) var(--s-2); color: var(--ink-muted); text-decoration: underline; }
.btn-quiet:hover { background: none; color: var(--ink); }
.btn-link { background: none; border: none; color: var(--ink); padding: 0; text-decoration: underline; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { color: var(--danger); }
.btn kbd { background: none; padding: 0; color: var(--ink-muted); }

/* forms */
.form-field { display: flex; flex-direction: column; gap: 0.3rem; margin: var(--s-4) 0; }
.form-field label { font-weight: 600; font-size: var(--text-s); }
.form-field input, .form-field select, .form-field textarea {
    font: inherit;
    padding: 0.55rem 0.7rem;
    border: var(--border) solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
}
.form-field input:focus-visible { outline-offset: 1px; }
fieldset.form-field { border: var(--border) solid var(--rule); border-radius: var(--radius); padding: var(--s-3) var(--s-4); }
fieldset.form-field legend { font-weight: 600; font-size: var(--text-s); padding: 0 var(--s-1); }
.form-row { display: flex; gap: var(--s-4); }
.form-row .form-field { flex: 0 0 120px; }
.form-row .form-field-grow { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0.2rem 0.9rem 0.2rem 0; font-size: var(--text-s); }

.field-error { color: var(--danger); font-size: var(--text-s); }
.form-errors:not(:empty) {
    margin: var(--s-4) 0;
    padding: var(--s-3) var(--s-4);
    border: var(--border-strong) solid var(--needs-you);
    background: var(--surface);
    color: var(--ink);
    border-radius: var(--radius);
}
.form-errors ul { margin: 0; padding-left: 1.1rem; }
.form-success {
    margin: var(--s-4) 0;
    padding: var(--s-3) var(--s-4);
    border: var(--border) solid var(--ok-border);
    background: var(--ok-bg);
    color: var(--ok);
    border-radius: var(--radius);
}

/* ---------- 5. screens ---------- */
/* a centred panel for pre-context screens (login, registration, invitation, 2FA, status) */
.form-panel {
    max-width: 440px;
    margin: var(--s-6) auto;
    padding: var(--s-6);
    background: var(--surface);
    border: var(--border-strong) solid var(--ink);
    border-radius: var(--radius-l);
}
.form-panel-wide { max-width: 580px; }
.form-panel h2 { font-size: var(--text-s); margin: var(--s-5) 0 0; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.auth-switch { margin-top: var(--s-5); font-size: var(--text-s); color: var(--ink-muted); }


.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.breadcrumb { font-size: var(--text-s); margin: 0 0 var(--s-2); color: var(--ink-muted); }

.table { width: 100%; border-collapse: collapse; margin-top: var(--s-5); background: var(--surface); border: var(--border) solid var(--rule); border-radius: var(--radius); }
.table th, .table td { text-align: left; padding: 0.55rem 0.8rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th { font-size: var(--text-s); color: var(--ink-muted); font-weight: 600; }
.table tr:last-child td { border-bottom: none; }
.empty { margin-top: var(--s-5); color: var(--ink-muted); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem var(--s-5); margin-top: var(--s-5); }
.facts dt { color: var(--ink-muted); }
.facts dd { margin: 0; }

.roles-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem var(--s-2); }
.roles-form .btn { padding: 0.3rem 0.7rem; font-size: var(--text-s); }
.remove-form { margin-left: var(--s-2); }

.cards { list-style: none; padding: 0; margin: var(--s-4) 0 0; display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: var(--surface); border: var(--border) solid var(--ink); border-radius: var(--radius); padding: var(--s-4); }
.card h3 { margin: 0 0 0.4rem; font-size: var(--text); }
.card p { margin: 0 0 0.6rem; color: var(--ink-muted); font-size: var(--text-s); }
.soon { font-size: var(--text-xs); color: var(--ink-muted); border: 1px dashed var(--ink-faint); border-radius: var(--radius-pill); padding: 0.1rem 0.6rem; }


.steps li { margin: 0.6rem 0; }
.shared-key { font-size: var(--text-l); letter-spacing: 0.08em; padding: 0.4rem 0.6rem; }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.codes code { display: block; padding: 0.4rem 0.6rem; text-align: center; }

/* ---------- 6. components (design language §3, §4, §6) ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* states: glyph + word */
.state { display: inline-flex; align-items: center; gap: 0.3em; font-size: var(--text-s); white-space: nowrap; }
.state-glyph { font-family: var(--font-sans); }
.state-locked .state-glyph { color: var(--ink-muted); }
.state-waiting .state-glyph { color: var(--needs-you-text); }
.state-open { color: var(--ink-faint); }
.state-glyphs { letter-spacing: 0.15em; }

/* boxed variant for strips and lists */
.state-tile {
    display: inline-flex; flex-direction: column; align-items: center; gap: 0.1rem;
    min-width: 2.6rem; padding: 0.3rem 0.35rem;
    border: var(--border) solid var(--ink); border-radius: var(--radius-s);
    background: var(--surface); font-size: var(--text-xs); line-height: 1.2;
}
.state-tile.state-locked { background: var(--locked); }
.state-tile.state-waiting { border: var(--border-strong) solid var(--needs-you); }
.state-tile.state-open { border: var(--border) dashed var(--ink-faint); color: var(--ink-faint); }
.state-tile .month-name { font-weight: 600; }

.month-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--s-1); margin: var(--s-3) 0 var(--s-1); }
.month-strip .state-tile { min-width: 0; display: flex; }
@media (max-width: 480px) { .month-strip { grid-template-columns: repeat(6, 1fr); } }
.legend { font-size: var(--text-xs); color: var(--ink-muted); margin: 0 0 var(--s-3); }

/* markers */
.marker { margin: var(--s-3) 0; border-radius: var(--radius); }
.marker-body > :last-child { margin-bottom: 0; }
.marker-needs-you { padding: var(--s-3) var(--s-4); border: var(--border-strong) solid var(--needs-you); background: var(--surface); }
.marker-needs-you .fact-line { margin-bottom: var(--s-1); }
.marker-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.marker-handled { background: var(--locked); font-size: var(--text-s); }
p.marker-handled { padding: var(--s-2) var(--s-3); max-width: none; }
details.marker-handled > summary { padding: var(--s-2) var(--s-3); cursor: pointer; list-style: none; }
details.marker-handled > summary::-webkit-details-marker { display: none; }
details.marker-handled[open] > summary { border-bottom: 1px solid var(--rule); }
details.marker-handled .marker-body { padding: var(--s-2) var(--s-3) var(--s-3); }
.marker-glyph { color: var(--ink-muted); margin-right: 0.3em; }
.marker-info { padding: var(--s-3) var(--s-4); border: var(--border) dashed var(--ink); background: var(--surface); }
.marker-label {
    display: inline-block; margin-bottom: var(--s-1);
    font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.04em;
    background: var(--locked); color: var(--ink-muted); padding: 0.05em 0.4em; border-radius: var(--radius-s);
}
blockquote.marker-advice { margin: var(--s-3) 0; padding: var(--s-2) var(--s-4); border-left: 5px double var(--advice); border-radius: 0; }
.marker-advice .marker-meta { font-size: var(--text-s); color: var(--ink-muted); margin-bottom: var(--s-1); }
.marker-advice p { margin: 0; }

/* why band */
.why { padding: var(--s-3) var(--s-4); background: var(--why); border-radius: var(--radius); margin: 0 0 var(--s-4); }

/* kpis */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s-3); margin: var(--s-4) 0; }
.kpi { padding: var(--s-3) var(--s-4); border: var(--border) solid var(--ink); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; }
.kpi-label { font-size: var(--text-s); color: var(--ink-muted); }
.kpi-value { font-size: var(--text-xl); font-weight: 600; margin: 0.1rem 0; }
.kpi-note { font-size: var(--text-xs); color: var(--ink-muted); }

/* section heads with a count */
.section-head { display: flex; align-items: baseline; gap: var(--s-2); margin: var(--s-6) 0 var(--s-2); }
.section-head h2, .section-head h3 { margin: 0; }
.count { color: var(--ink-muted); font-weight: 400; }

/* dense office tables */
.table-dense th, .table-dense td { padding: 0.35rem 0.6rem; font-size: var(--text-s); }
.table .row-urgent td:first-child { box-shadow: inset 4px 0 0 var(--needs-you); }
.table .row-current td { background: var(--why); }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }

/* uploads */
.form-field input[type="file"] { padding: 0.45rem 0.7rem; border-style: dashed; cursor: pointer; }
.form-field input[type="file"]::file-selector-button { font: inherit; margin-right: var(--s-3); padding: 0.3rem 0.7rem; border: var(--border) solid var(--ink); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); cursor: pointer; }
.form-field .hint { font-size: var(--text-xs); color: var(--ink-muted); }
.filter-form { align-items: center; }
.filter-form select { font: inherit; font-size: var(--text-s); padding: 0.35rem 0.6rem; border: var(--border) solid var(--ink); border-radius: var(--radius); background: var(--surface); color: var(--ink); }

/* bank lines */
.table td.purpose { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* matching */
.table td.actions { white-space: nowrap; }
.table td.actions .inline-form { display: inline-block; margin-right: var(--s-1); }
.table td.actions .btn { padding: 0.25rem 0.6rem; font-size: var(--text-s); }
.card-matching { margin-top: var(--s-5); }
.card-matching .section-head { margin-top: 0; }
.link-form { margin-top: var(--s-4); }
.link-form select { max-width: 100%; }

/* document card */
.document-card .page-head { align-items: baseline; }
.document-card .card-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s-5); align-items: start; margin-top: var(--s-4); }
@media (max-width: 760px) { .document-card .card-grid { grid-template-columns: 1fr; } }
.document-card .facts { margin-top: var(--s-3); }
.provenance { font-size: var(--text-xs); color: var(--ink-muted); font-family: var(--font-mono); margin-top: var(--s-4); }
.badge { display: inline-block; font-size: var(--text-xs); padding: 0 var(--s-2, 0.4rem); border: 1px solid var(--needs-you); color: var(--needs-you-text); border-radius: var(--radius-s); }
.preview { border: var(--border) solid var(--rule); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.preview img { display: block; max-width: 100%; height: auto; }
.preview iframe { display: block; width: 100%; height: 70vh; border: 0; }
.preview-note { padding: var(--s-3) var(--s-4); color: var(--ink-muted); font-size: var(--text-s); }

/* filter chips */
.filters { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0; }
button.chip { font: inherit; font-size: var(--text-s); background: var(--surface); cursor: pointer; }
button.chip:hover { background: var(--locked); }
.chip[aria-pressed="true"] { border-width: var(--border-strong); font-weight: 600; }

/* keyboard legend */
.keys { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-muted); border-top: var(--border) solid var(--rule); padding-top: var(--s-2); margin-top: var(--s-4); }

/* question card */
.panel { background: var(--panel); border: var(--border) solid var(--rule); border-radius: var(--radius-l); padding: var(--s-4); }
.question { max-width: 440px; }
.question-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s-3); }
.progress-dots { display: inline-flex; gap: var(--s-1); }
.progress-dots span { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); }
.progress-dots .done { background: var(--ink); }
.fact { padding: var(--s-3); border: var(--border) solid var(--ink); border-radius: var(--radius); background: var(--surface); margin-bottom: var(--s-3); }
.fact-meta { font-size: var(--text-s); color: var(--ink-muted); }
.answers { display: grid; gap: var(--s-2); margin: var(--s-3) 0; }
.answers .btn { justify-content: center; }

/* two-column home: tasks first on phones */
.two-col { display: grid; grid-template-columns: 1.25fr 1fr; gap: var(--s-5); align-items: start; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } .two-col > .col-tasks { order: -1; } }

/* style guide only */
.swatches { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--s-2); }
.swatches li { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-s); }
.swatch { width: 1.6rem; height: 1.6rem; border-radius: var(--radius-s); border: 1px solid var(--rule); }
.swatch-paper { background: var(--paper); } .swatch-panel { background: var(--panel); } .swatch-surface { background: var(--surface); }
.swatch-ink { background: var(--ink); } .swatch-locked { background: var(--locked); } .swatch-needs-you { background: var(--needs-you); }
.swatch-why { background: var(--why); } .swatch-advice { background: var(--advice); }
.sample-buttons, .sample-states { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; max-width: none; }

a.kpi { text-decoration: none; color: inherit; }
a.kpi:hover { background: var(--panel); }
a.kpi .kpi-note { text-decoration: underline; }
.status-page h1 { font-size: var(--text-xl); }

/* owner home */
.home-context { margin-bottom: var(--s-4); }
.owner-home .lead { margin-bottom: var(--s-5); }
.col-tasks .section-head { margin-top: 0; }
