/* Hausbuch – ruhiges, dichtes Arbeitslayout. Keine externen Ressourcen. */
:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --line: #e4e1d9;
  --line-strong: #cfcabd;
  --text: #1f2421;
  --muted: #69706a;
  --faint: #9aa09b;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f0eb;
  --warn: #a8620a;
  --warn-soft: #fbf0dd;
  --danger: #b3362b;
  --danger-soft: #f9e4e1;
  --ok: #2c7a3f;
  --ok-soft: #e4f2e6;
  --info-soft: #e7eef7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30, 30, 20, .05), 0 4px 16px rgba(30, 30, 20, .04);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Inter, Roboto, system-ui, sans-serif;
  /* Gewerk-Farben für die Planung */
  --c1: #2f7d6d; --c2: #b8662b; --c3: #4a62a8; --c4: #9b4a8c; --c5: #6f8a2e;
  --c6: #b0443a; --c7: #2d8aa6; --c8: #8a6d2f; --c9: #5d5aa8; --c10: #4f7a4f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141716; --surface: #1c201e; --surface-2: #222724; --line: #2e3430; --line-strong: #3c443f;
    --text: #e6e9e6; --muted: #a0a8a2; --faint: #6f7772;
    --accent: #5cbf9f; --accent-ink: #0d1f19; --accent-soft: #1d3a31;
    --warn: #e2a24a; --warn-soft: #3a2d17; --danger: #ef7b70; --danger-soft: #3d1f1c;
    --ok: #74c587; --ok-soft: #1c3322; --info-soft: #1d2836;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--sans); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 650; }
h2 { font-size: 1.08rem; font-weight: 620; }
h3 { font-size: .95rem; font-weight: 620; }
.i { flex: none; vertical-align: -3px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 680; font-size: 1.05rem; color: var(--text); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .9rem; font-weight: 750; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 520; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 2px; }
.side-foot a, .side-foot button { display: flex; align-items: center; gap: 11px; padding: 7px 10px; border-radius: 8px; color: var(--muted); font: inherit; background: none; border: 0; cursor: pointer; text-align: left; width: 100%; }
.side-foot a:hover, .side-foot button:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-user { padding: 6px 10px 0; font-size: .8rem; color: var(--faint); }

.main { padding: 28px 36px 60px; min-width: 0; max-width: 1360px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }

/* ---------- Bausteine ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head .sub { color: var(--muted); font-size: .85rem; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: .8rem; font-weight: 560; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 1.6rem; font-weight: 660; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .value small { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .hint { color: var(--muted); font-size: .82rem; margin-top: 2px; }
.kpi.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.kpi.accent .label, .kpi.accent .hint, .kpi.accent .value small { color: inherit; opacity: .82; }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap; line-height: 1.3; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.btn-sm { padding: 4px 9px; font-size: .84rem; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.icon-btn { padding: 4px 6px; border: 0; background: none; color: var(--faint); border-radius: 6px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--text); border-color: transparent; }

.notice { padding: 12px 16px; border-radius: 9px; background: var(--info-soft); font-size: .92rem; }
.notice.warn { background: var(--warn-soft); }
.notice.danger { background: var(--danger-soft); }
.notice.ok { background: var(--ok-soft); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr:hover td { background: var(--surface-2); }
.t th:first-child, .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.t .group td { background: var(--surface-2); font-weight: 620; font-size: .88rem; }
.t tfoot td { font-weight: 650; border-top: 2px solid var(--line-strong); border-bottom: 0; background: var(--surface); }
.t .row-actions { text-align: right; white-space: nowrap; width: 1%; }
.t tr.dim td { color: var(--faint); }
.t tr.highlight td { background: var(--accent-soft); }
.t td.title a { color: var(--text); font-weight: 560; }
.t td.title .sub { display: block; color: var(--muted); font-size: .82rem; font-weight: 400; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 10px; }

.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > span { background: var(--warn); }
.bar.danger > span { background: var(--danger); }

/* ---------- Formulare ---------- */
.form-card { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 580; font-size: .88rem; }
.field .help { color: var(--muted); font-size: .8rem; }
.field .err { color: var(--danger); font-size: .82rem; }
.field.check { flex-direction: row; align-items: flex-start; gap: 9px; padding-top: 24px; }
.field.check label { font-weight: 520; }
.field.check .help { display: block; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], input[type=search], input[type=file], input[type=url], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 2px 0 0; }
textarea { resize: vertical; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; padding: 6px 10px; }
.inline-form { display: inline; }

/* Positionen (Rechnung) */
.pos-table input { padding: 6px 8px; }
.pos-table td { padding: 6px 6px; }
.pos-table td:first-child { padding-left: 20px; }

.messages { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.messages li { padding: 10px 14px; border-radius: 9px; background: var(--ok-soft); color: var(--ok); font-weight: 540; }
.messages li.error { background: var(--danger-soft); color: var(--danger); }
.messages li.warning { background: var(--warn-soft); color: var(--warn); }

/* ---------- Liste kompakt ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .date { width: 52px; flex: none; text-align: center; line-height: 1.15; }
.list .date b { display: block; font-size: 1.05rem; }
.list .date span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.list .grow { flex: 1; min-width: 0; }
.list .grow .sub { color: var(--muted); font-size: .82rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; display: inline-block; }

/* ---------- Diagramm ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-rect { fill: color-mix(in srgb, var(--accent) 28%, transparent); }
.chart .bar-rect:hover { fill: color-mix(in srgb, var(--accent) 50%, transparent); }
.chart .bar-rect.peak { fill: color-mix(in srgb, var(--warn) 55%, transparent); }
.chart .saldo { fill: none; stroke: var(--accent); stroke-width: 2.2; }
.chart .polster { stroke: var(--danger); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }

/* ---------- Planung (Gantt) ---------- */
.gantt-wrap { overflow-x: auto; }
.gantt { display: grid; min-width: 980px; font-size: .82rem; }
.gantt .gh, .gantt .gl, .gantt .gc { border-bottom: 1px solid var(--line); }
.gantt .gh { background: var(--surface-2); text-align: center; padding: 6px 0 5px; color: var(--muted); font-weight: 600; font-size: .72rem; line-height: 1.2; border-left: 1px solid var(--line); }
.gantt .gh.we, .gantt .gc.we { background: color-mix(in srgb, var(--line) 45%, var(--surface)); }
.gantt .gh.today { color: var(--accent); }
.gantt .gh.today b { background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 0 4px; }
.gantt .gl { padding: 8px 12px 8px 20px; position: sticky; left: 0; background: var(--surface); z-index: 2; border-right: 1px solid var(--line); min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.gantt .gl b { font-weight: 600; font-size: .86rem; }
.gantt .gl span { color: var(--muted); font-size: .76rem; }
.gantt .gc { border-left: 1px solid var(--line); min-height: 44px; position: relative; }
.gantt a.gc { display: block; }
.gantt a.gc:hover { background: var(--accent-soft); }
.gantt .lane { display: contents; }
.gbar { margin: 7px 2px; border-radius: 6px; padding: 4px 8px; color: #fff; font-weight: 600; font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 1; align-self: start; line-height: 1.35; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.gbar:hover { text-decoration: none; filter: brightness(1.08); }
.gbar.tentativ { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.gbar small { font-weight: 500; opacity: .85; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav strong { min-width: 150px; text-align: center; font-size: 1.05rem; }

/* ---------- Dokumente ---------- */
.doc-ico { width: 34px; height: 40px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .62rem; font-weight: 700; color: var(--muted); flex: none; }
.doc-ico.pdf { color: var(--danger); }
.doc-ico.img { color: var(--accent); }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login .brand { padding: 0 0 20px; justify-content: center; }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: 8px 12px; z-index: 10; overflow-x: auto; gap: 2px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 0; }
  .brand span:last-child { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { padding: 7px 9px; }
  .nav a span { display: none; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; }
  .side-foot .lbl, .side-user { display: none; }
  .main { padding: 20px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .field.check { padding-top: 0; }
  .t th:first-child, .t td:first-child { padding-left: 14px; }
  .t th:last-child, .t td:last-child { padding-right: 14px; }
  .hide-sm { display: none; }
}

/* ---------- Druck (Bankbudget etc.) ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f4f4f4; --shadow: none; color-scheme: light; }
  .side, .no-print, .actions, .messages { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  body { font-size: 10.5pt; }
  a { color: inherit; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: -6px 0 22px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 560; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-row > div { padding: 16px 18px; border-left: 1px solid var(--line); }
.stat-row > div:first-child { border-left: 0; }
.stat-row .label { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-row .value { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat-row .hint { color: var(--muted); font-size: .8rem; }
@media (max-width: 1100px) { .stat-row { grid-template-columns: repeat(2, 1fr); } .stat-row > div { border-left: 0; border-top: 1px solid var(--line); } }
.warn-t { color: var(--warn); }
