/* Schlicht & hell – Lucida-Logo + Gold als Akzent, Systemschrift. */
:root {
  --bg: #ffffff;
  --text: #1c1b18;
  --muted: #6f6c64;
  --line: #e9e6dc;
  --line-strong: #d6d2c4;
  --soft: #f8f7f2;
  --gold: #efedaf;
  --gold-soft: #f8f6d8;
  --gold-dark: #8a7a3c;
  --danger: #b4532a;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Seitenleiste ---------- */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 14px 18px; border-right: 1px solid var(--line); background: var(--soft); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 2px 10px 6px; }
.brand img { height: 20px; width: auto; }
.brand span { font-size: 13px; color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line-strong); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.side-nav a svg { width: 17px; height: 17px; flex: none; }
.side-nav a:hover { color: var(--text); background: #efede4; }
.side-nav a.active { color: var(--text); background: var(--gold); }
.side-group { margin: 16px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #a19d92; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.side-foot .btn { justify-content: center; }
.side-user { border-top: 1px solid var(--line); padding-top: 12px; font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.side-user b { font-weight: 600; }
.side-user div { display: flex; gap: 12px; }
.side-user a { color: var(--muted); text-decoration: none; font-size: 12px; }
.side-user a:hover { color: var(--text); text-decoration: underline; }
.save-state { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: center; }
.save-state.error { color: var(--danger); }

/* ---------- Übersicht ---------- */
h2.first { margin-top: 8px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; min-width: 0; }
.kpi span { display: block; font-size: 12px; color: var(--muted); }
.kpi b { display: block; font-size: 24px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.kpi b.neg { color: var(--danger); }
.kpi b.pos { color: var(--text); }
.kpi small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; background: #fff; margin-top: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head a { font-size: 12px; color: var(--gold-dark); }
.legend { display: flex; align-items: center; gap: 6px 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.legend i.vertraege, .seg.vertraege { background: #7a6200; }
.legend i.einmal, .seg.einmal { background: #b09628; }
.legend i.linie { width: 16px; height: 0; border-top: 2px dashed var(--text); border-radius: 0; }
.chart { position: relative; height: 220px; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.bar-col { display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-wert { height: 18px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-stack { flex: 1; width: 62%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.seg { width: 100%; }
.seg:first-child { border-radius: 4px 4px 0 0; }
.bar-label { height: 24px; line-height: 24px; font-size: 12px; color: var(--muted); }
.bar-col.zukunft .seg { opacity: .45; }
.bar-col.aktuell .bar-label { color: var(--text); font-weight: 600; }
.kostenlinie { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--text); opacity: .55; pointer-events: none; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.mini-kpis span { display: block; font-size: 11px; color: var(--muted); }
.mini-kpis b { font-size: 16px; font-weight: 650; font-variant-numeric: tabular-nums; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.liste em { font-style: normal; color: var(--muted); text-align: right; white-space: nowrap; }
.menge-alle { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--gold-soft); align-self: center; }
.menge-alle input { width: 80px; height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 8px; text-align: right; outline: none; font-variant-numeric: tabular-nums; background: #fff; }
.menge-alle input:focus { border-color: var(--gold-dark); }

/* ---------- Seite ---------- */
.view { max-width: 1320px; width: 100%; padding: 32px 36px 80px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.sub { color: var(--muted); margin: 6px 0 0; }
h2 { font-size: 17px; font-weight: 650; margin: 36px 0 12px; }
.status { font-size: 12px; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.s-run { background: var(--gold-soft); color: var(--gold-dark); }
.s-plan { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.s-end { color: var(--muted); }
tr.ended .cell, tr.ended td.calc { color: var(--muted); }

/* Zahlungsstatus */
select.cell.st-offen { color: var(--danger); }
select.cell.st-teilbezahlt { color: #9a6a1c; }
select.cell.st-bezahlt { color: var(--gold-dark); font-weight: 550; }

/* Pipeline-Phasen */
.phases { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.phase { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; min-width: 0; }
.phase span { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase b { display: block; font-size: 20px; font-weight: 650; margin-top: 2px; }
.phase small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.phase.ph-2, .phase.ph-3 { background: var(--soft); }
.phase.ph-4 { background: var(--gold-soft); border-color: #e3dfa2; }
.phase.ph-5 { opacity: .7; }
select.cell.phase-sel.ph-2, select.cell.phase-sel.ph-3 { font-weight: 550; }
select.cell.phase-sel.ph-4 { color: var(--gold-dark); font-weight: 600; }
select.cell.phase-sel.ph-5 { color: var(--muted); }
td .plus { font-size: 12px; color: var(--gold-dark); background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; font-weight: 550; }
td .plus:hover { background: var(--gold-soft); }
@media (max-width: 900px) { .phases { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.totals { display: flex; gap: 28px; }
.totals div { text-align: right; font-size: 12px; color: var(--muted); }
.totals b { display: block; font-size: 20px; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: 13px; margin: 14px 2px 0; }
.note b { color: var(--text); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  background: var(--gold); border: 1px solid #dcd88f; color: var(--text); text-decoration: none; font-weight: 550; font-size: 13px; white-space: nowrap;
}
.btn:hover { background: #e8e59c; }
.btn.ghost { background: #fff; border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--soft); }
.add { margin-top: 12px; }
.x {
  width: 26px; height: 26px; border: none; background: none; border-radius: 6px; cursor: pointer;
  color: var(--muted); font-size: 16px; line-height: 1; opacity: 0; transition: opacity .1s;
}
tr:hover .x, .x:focus-visible { opacity: 1; }
.x:hover { background: #fbeee8; color: var(--danger); }
@media (hover: none) { .x { opacity: .6; } }

/* ---------- Tabelle (Excel-artig) ---------- */
.sheet { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: #fff; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--soft);
  padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
td { border-bottom: 1px solid var(--line); padding: 0; height: 38px; vertical-align: middle; }
th.r, td.r { text-align: right; }
td.calc { padding: 0 10px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
td.calc.strong { font-weight: 600; }
td.muted { color: var(--muted); padding: 0 10px; }
tbody tr:hover td { background: #fcfcf8; }
tr.group td { background: var(--soft); font-weight: 600; padding: 0 10px; height: 36px; }
tr.group .plus { font-weight: 500; font-size: 12px; color: var(--gold-dark); background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; margin-left: 8px; }
tr.group .plus:hover { background: var(--gold-soft); }
tr.sum td { background: var(--gold-soft); font-weight: 650; padding: 0 10px; height: 44px; border-bottom: none; }

.cell {
  width: 100%; height: 38px; border: 1px solid transparent; background: transparent; padding: 0 10px; outline: none; border-radius: 0;
}
.cell:hover { background: var(--soft); }
.cell:focus { background: #fff; border-color: var(--gold-dark); box-shadow: inset 0 0 0 1px var(--gold-dark); }
.cell.r { text-align: right; font-variant-numeric: tabular-nums; }
select.cell { appearance: none; cursor: pointer; padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%236f6c64' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; }
.cell.warn { color: var(--danger); }

/* ---------- Einstellungen-Zeile ---------- */
.basis { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--soft); margin-bottom: 16px; }
.basis label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.basis input { width: 72px; height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; padding: 0 8px; text-align: right; outline: none; font-variant-numeric: tabular-nums; }
.basis input:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 2px var(--gold-soft); }

/* ---------- Blatt-Tabs (Kalkulationen) ---------- */
.sheets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.sheets a, .sheets button {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; text-decoration: none; cursor: pointer; font-size: 13px; color: var(--muted);
}
.sheets a:hover, .sheets button:hover { color: var(--text); background: var(--soft); }
.sheets a.active { background: var(--gold); border-color: #dcd88f; color: var(--text); font-weight: 550; }
.sheet-name { font-size: 22px; font-weight: 650; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; margin-left: -9px; outline: none; background: none; width: 420px; max-width: 100%; }
.sheet-name:hover { border-color: var(--line-strong); }
.sheet-name:focus { border-color: var(--gold-dark); }
.link-danger { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 12px; text-decoration: underline; padding: 0; }
.link-danger:hover { color: var(--danger); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-radius: 10px;
  background: var(--text); color: #fff; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); transition: opacity .15s, transform .15s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: var(--gold); border: none; border-radius: 6px; padding: 5px 10px; cursor: pointer; font-weight: 550; color: var(--text); }

@media (max-width: 1100px) {
  .kpis, .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; padding: 12px 16px; gap: 10px; border-right: none; border-bottom: 1px solid var(--line); }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-nav a { white-space: nowrap; }
  .side-group { display: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 0; }
  .side-user { border-top: none; padding-top: 0; flex-direction: row; align-items: center; gap: 12px; }
  .view { padding: 20px 16px 60px; }
  .totals { gap: 18px; }
  .chart { gap: 4px; }
  .bar-wert { display: none; }
}

/* Angebot hochladen */
.upload {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin: 0 0 16px; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); background: #fff; transition: background .15s, border-color .15s;
}
.upload b { flex: none; padding: 7px 12px; border-radius: 8px; background: var(--gold); border: 1px solid #dcd88f; font-weight: 550; font-size: 13px; }
.upload span { color: var(--muted); font-size: 13px; }
.upload:hover { background: var(--soft); }
.upload.drag { background: var(--gold-soft); border-color: var(--gold-dark); }
a.doc { display: inline-block; margin: 0 10px; font-size: 12px; color: var(--gold-dark); text-decoration: none; border-bottom: 1px solid #d9d0a6; white-space: nowrap; }
a.doc:hover { border-color: var(--gold-dark); }
.unit-cell { display: flex; align-items: center; }
.unit-cell .cell { padding-right: 4px; }
.unit-cell span { color: var(--muted); font-size: 12px; padding-right: 10px; }

/* Anmeldung (Webspace-Version) */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 20px; }
.login-logo { height: 28px; margin-bottom: 28px; }
.login form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login input { height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 12px; font-size: 14px; outline: none; }
.login input:focus { border-color: var(--gold-dark); box-shadow: 0 0 0 3px var(--gold-soft); }
.login .btn { justify-content: center; height: 42px; margin-top: 6px; font-size: 14px; }
.login-fehler, .login-ok { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin: 16px 0 0; }
.login-fehler { background: #fdf4ef; color: var(--danger); border: 1px solid #efd3c4; }
.login-ok { background: var(--gold-soft); color: var(--gold-dark); border: 1px solid #e3dfa2; }
