@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(fonts/barlow-400-latin.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(fonts/barlow-500-latin.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(fonts/barlow-600-latin.woff2) format('woff2'); }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --ink: #010205; --ink-2: #2a2b2e; --grey: #6b6d70; --grey-2: #9a9b9e; --line: #e1e1e4;
  --surface: #eeeff2; --bg: #f6f6f7; --white: #fff; --dark: #0e0e12; --red: #ab1e11;
  --ok: #18794e; --ok-bg: #e6f4ec; --warn: #a15c00; --warn-bg: #fdf1dc; --bad: #c0261a; --bad-bg: #fbe9e7;
  --r: 10px; --side: 248px;
  --font: 'Barlow', 'Helvetica Neue', Arial, sans-serif;
}
html, body { height: 100%; }
body { font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ── Grundgerüst ───────────────────────────────────── */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--dark); color: #fff; padding: 1.4rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.side .logo { background: #fff; border-radius: 8px; padding: 0.6rem 0.8rem; margin-bottom: 1.4rem; }
.side .logo img { height: 34px; width: auto; }
.side a { display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.8rem; border-radius: 8px; color: rgba(255,255,255,0.72); transition: background 0.15s, color 0.15s; }
.side a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side a.on { background: rgba(255,255,255,0.14); color: #fff; }
.side a svg, .tabs a svg { width: 20px; height: 20px; flex-shrink: 0; }
.side .badge { margin-left: auto; }
.side .bottom { margin-top: auto; font-size: 0.85rem; color: rgba(255,255,255,0.5); padding: 0 0.8rem; }
.side .bottom button { background: none; border: 0; color: rgba(255,255,255,0.7); cursor: pointer; padding: 0.4rem 0; }
.main { min-width: 0; padding: 2rem clamp(1rem, 3vw, 2.6rem) 4rem; max-width: 1280px; }
.tabs { display: none; }

/* ── Kopf eines Bereichs ───────────────────────────── */
.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.top h1 { font-size: clamp(1.7rem, 1.3rem + 1.4vw, 2.4rem); font-weight: 400; line-height: 1.1; }
.top p { color: var(--grey); margin-top: 0.3rem; }
.back { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--grey); margin-bottom: 0.6rem; min-height: 32px; }
.back:hover { color: var(--ink); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.muted { color: var(--grey); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Buttons ───────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-height: 44px; padding: 0 1.1rem; border-radius: 6px; border: 1.5px solid var(--ink); background: var(--ink); color: #fff; cursor: pointer; white-space: nowrap; transition: background 0.15s, opacity 0.15s; }
.btn:hover { background: var(--ink-2); }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); background: #fff; }
.btn.red { background: var(--red); border-color: var(--red); }
.btn.sm { min-height: 36px; padding: 0 0.8rem; font-size: 0.9rem; }
.btn.danger { background: #fff; color: var(--bad); border-color: var(--line); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }

/* ── Karten & Kennzahlen ───────────────────────────── */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1.2rem 1.3rem; }
.card + .card { margin-top: 1rem; }
.card h2 { font-size: 1.15rem; font-weight: 500; margin-bottom: 0.8rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.4rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem 1.2rem; display: block; transition: border-color 0.15s, transform 0.15s; }
a.kpi:hover { border-color: var(--ink); transform: translateY(-2px); }
.kpi small { display: block; color: var(--grey); font-size: 0.875rem; margin-bottom: 0.4rem; }
.kpi b { display: block; font-size: 1.9rem; font-weight: 400; line-height: 1.1; }
.kpi span { display: block; font-size: 0.85rem; color: var(--grey); margin-top: 0.3rem; }
.kpi.alert { border-color: var(--red); background: linear-gradient(#fff, #fff7f6); }
.kpi.alert b { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1rem; align-items: start; }

/* ── Listen ────────────────────────────────────────── */
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 1.1rem; border-top: 1px solid var(--line); min-height: 60px; }
.item:first-child { border-top: 0; }
a.item:hover, .item.click:hover { background: var(--bg); cursor: pointer; }
.item .t { font-weight: 500; }
.item .s { color: var(--grey); font-size: 0.875rem; }
.item .amt { margin-left: auto; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.thumb { width: 48px; height: 48px; border-radius: 6px; background: var(--surface); object-fit: cover; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--grey); font-size: 0.7rem; }
.empty { padding: 1.6rem 1.1rem; color: var(--grey); text-align: center; }
.pill { display: inline-block; font-size: 0.78rem; padding: 0.12rem 0.55rem; border-radius: 999px; background: var(--surface); color: var(--ink-2); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--red); color: #fff; font-size: 0.75rem; font-weight: 600; }
.chips { display: flex; gap: 0.4rem; overflow-x: auto; scrollbar-width: none; margin-bottom: 1rem; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex-shrink: 0; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 0.45rem 0.95rem; cursor: pointer; min-height: 40px; }
.chips button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.search { width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 0.75rem 1rem 0.75rem 2.6rem; margin-bottom: 1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b6d70' stroke-width='1.8'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 0.8rem center; background-size: 20px; }
.search:focus { outline: 2px solid var(--ink); outline-offset: 1px; }

/* ── Formulare ─────────────────────────────────────── */
.form { display: grid; gap: 0.9rem; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.9rem; }
label.fl { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--ink-2); }
.in, select.in, textarea.in { width: 100%; border: 1.5px solid #c9cacd; border-radius: 6px; background: #fff; padding: 0.65rem 0.8rem; font-size: 1rem; min-height: 44px; }
textarea.in { min-height: 110px; resize: vertical; line-height: 1.5; }
.in:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(1,2,5,0.08); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; cursor: pointer; padding: 0.7rem 0.8rem; border: 1.5px solid #c9cacd; border-radius: 6px; background: #fff; }
.check input { width: 20px; height: 20px; accent-color: var(--red); margin-top: 1px; flex-shrink: 0; }
.check.on { border-color: var(--red); background: #fff7f6; }
.drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.4rem; min-height: 140px; border: 2px dashed #c9cacd; border-radius: var(--r); background: #fff; cursor: pointer; text-align: center; padding: 1rem; color: var(--grey); position: relative; overflow: hidden; }
.drop:hover, .drop.over { border-color: var(--ink); color: var(--ink); }
.drop svg { width: 34px; height: 34px; }
.drop img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── Dialog ────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(1,2,5,0.45); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade 0.15s; }
.modal { background: var(--bg); border-radius: 14px; width: min(620px, 100%); max-height: calc(100vh - 2rem); overflow: auto; padding: 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,0.3); animation: rise 0.2s; }
.modal h2 { font-size: 1.4rem; font-weight: 400; margin-bottom: 1rem; display: flex; justify-content: space-between; align-items: center; }
.modal .x { background: var(--surface); border: 0; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; }
.modal .actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.2rem; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

/* ── Abgleich ──────────────────────────────────────── */
.match { display: grid; grid-template-columns: 1fr 30px 1fr auto; gap: 0.8rem; align-items: center; padding: 0.9rem 1.1rem; border-top: 1px solid var(--line); }
.match:first-child { border-top: 0; }
.match .arrow { color: var(--grey-2); text-align: center; font-size: 1.2rem; }
.match .box { min-width: 0; }
.match .box .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .pp { display: inline-flex; gap: 0.3rem; align-items: center; font-size: 0.8rem; color: #0a58ca; background: #e8f0fe; padding: 0.1rem 0.5rem; border-radius: 999px; margin-top: 0.2rem; }
.upl { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 1.4rem; }
.upl .drop { min-height: 110px; }

/* ── Rechnungseditor ───────────────────────────────── */
.pos { width: 100%; border-collapse: collapse; }
.pos th { text-align: left; font-weight: 500; font-size: 0.85rem; color: var(--grey); padding: 0.4rem; border-bottom: 1px solid var(--line); }
.pos td { padding: 0.35rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.pos td .in { min-height: 40px; padding: 0.45rem 0.6rem; }
.pos .num { width: 90px; } .pos .unit { width: 80px; } .pos .sum { width: 110px; text-align: right; padding-top: 0.9rem; font-variant-numeric: tabular-nums; }
.pos .del { width: 40px; }
.pos .del button { background: none; border: 0; color: var(--grey); cursor: pointer; font-size: 1.2rem; width: 36px; height: 40px; }
.pos tr.src td:first-child .in { border-left: 3px solid var(--red); }
.totals { margin-left: auto; width: min(320px, 100%); margin-top: 1rem; }
.totals div { display: flex; justify-content: space-between; padding: 0.35rem 0; font-variant-numeric: tabular-nums; }
.totals .tot { border-top: 2px solid var(--ink); font-size: 1.2rem; font-weight: 500; margin-top: 0.3rem; padding-top: 0.6rem; }

/* ── Projekt ───────────────────────────────────────── */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.gallery a { aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface); display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--grey); text-align: center; padding: 0.3rem; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.alertbox { border: 1px solid var(--red); background: #fff7f6; border-radius: var(--r); padding: 0.9rem 1.1rem; display: flex; gap: 0.8rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.alertbox b { color: var(--red); }
.notes { white-space: pre-wrap; }
mark { background: #ffe58a; border-radius: 2px; padding: 0 1px; }

/* ── Anmeldung ─────────────────────────────────────── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--dark); }
.login form { background: #fff; border-radius: 14px; padding: 2rem; width: min(380px, 100%); display: grid; gap: 1rem; }
.login img { height: 54px; width: auto; margin: 0 auto 0.5rem; }
.login .err { color: var(--bad); font-size: 0.9rem; min-height: 1.2em; }

/* ── Meldung ───────────────────────────────────────── */
#toast { opacity: 0; pointer-events: none; position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 140%); background: var(--ink); color: #fff; padding: 0.8rem 1.2rem; border-radius: 8px; z-index: 200; transition: transform 0.25s, opacity 0.25s; max-width: calc(100% - 2rem); box-shadow: 0 8px 24px rgba(0,0,0,0.25); }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast.err { background: var(--bad); }

/* ── Handy ─────────────────────────────────────────── */
.fab { display: none; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 1.1rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
  .tabs { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; z-index: 50; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.97); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabs a { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; padding: 0.55rem 0 0.5rem; font-size: 0.72rem; color: var(--grey); position: relative; min-height: 58px; }
  .tabs a.on { color: var(--ink); }
  .tabs a .badge { position: absolute; top: 4px; left: 54%; min-width: 18px; height: 18px; font-size: 0.65rem; }
  .fab { display: flex; position: fixed; z-index: 60; right: 1rem; bottom: calc(72px + env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 50%; background: var(--red); color: #fff; border: 0; align-items: center; justify-content: center; box-shadow: 0 8px 24px rgba(171,30,17,0.45); cursor: pointer; }
  .fab svg { width: 28px; height: 28px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi b { font-size: 1.5rem; }
  .grid2, .f2, .f3, .upl { grid-template-columns: 1fr; }
  .top { align-items: flex-start; flex-direction: column; }
  .match { grid-template-columns: 1fr; gap: 0.4rem; }
  .match .arrow { text-align: left; transform: rotate(90deg); width: 20px; }
  .pos thead { display: none; }
  .pos tr { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; gap: 6px; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
  .pos td { border: 0; padding: 0; }
  .pos td:first-child { grid-column: 1 / -1; }
  .pos .num, .pos .unit, .pos .sum { width: auto; }
  .pos .sum { padding-top: 0.6rem; }
  .modal { padding: 1.1rem; border-radius: 14px 14px 0 0; align-self: flex-end; max-height: 92vh; }
  .modal-bg { padding: 0; align-items: flex-end; }
}
@media print { .side, .tabs, .fab { display: none !important; } .shell { display: block; } }
@media (max-width: 900px) {
  .card { padding: 1rem; }
  .card .list { margin: 0 -0.4rem; }
  .item { padding: 0.8rem 0.9rem; gap: 0.7rem; }
  .item .s { font-size: 0.82rem; }
  .thumb { width: 42px; height: 42px; }
}

html, body { touch-action: manipulation; }
a, button, input, select, textarea, label { -webkit-tap-highlight-color: transparent; }
