﻿/* Zimmerei-CRM â€“ frisch, warm, effizient. Eiche, Naturholz, Anthrazit. */
:root {
  --ink: #2b2724;
  --ink-2: #4a443f;
  --muted: #847a71;
  --line: #e8dfd3;
  --line-2: #f1ebe2;
  --bg: #f6f2ec;
  --card: #ffffff;
  --wood: #8b5a2b;
  --wood-2: #a86f38;
  --wood-light: #f4ebdd;
  --wood-pale: #fbf7f1;
  --cream: #fef3e3;
  --green: #3f7d4e;
  --green-bg: #e6f2e8;
  --red: #b23b2e;
  --red-bg: #fbe9e6;
  --amber: #a5670f;
  --amber-bg: #fdf0d9;
  --blue: #3a6688;
  --blue-bg: #e5eef5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(43, 39, 36, .05), 0 4px 16px rgba(43, 39, 36, .05);
  --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Consolas", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--wood); text-decoration: none; }
a:hover { color: var(--wood-2); text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 0; font-weight: 650; }
h3 { margin: 0; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
code { font-family: var(--mono); background: var(--wood-light); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.ico { flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); letter-spacing: .02em; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-line; }

/* ---------- Layout ---------- */
body.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background:
    repeating-linear-gradient(92deg, rgba(255,255,255,.012) 0 3px, rgba(0,0,0,.02) 3px 7px),
    linear-gradient(180deg, #2f2a26 0%, #26221f 100%);
  color: #e9e1d6; padding: 18px 14px;
}
.sidebar::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--wood-2), var(--wood)); opacity: .9; }
.brand { display: block; background: var(--cream); border-radius: 10px; padding: 10px 12px; margin-bottom: 22px; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.brand img { display: block; width: 100%; height: auto; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 11px; color: #d9cfc2; padding: 9px 12px; border-radius: 8px; font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: linear-gradient(90deg, rgba(168,111,56,.35), rgba(168,111,56,.12)); color: #fff; box-shadow: inset 3px 0 0 var(--wood-2); }
.nav-sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me strong { display: block; font-size: 13.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: #a99d90; font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--wood); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.me-actions { display: flex; gap: 2px; }
.me-actions a, .me-actions button { color: #cbbfb1; background: none; border: 0; padding: 7px; border-radius: 7px; cursor: pointer; display: grid; place-items: center; }
.me-actions a:hover, .me-actions button:hover { background: rgba(255,255,255,.08); color: #fff; }
.me-actions form { margin: 0; }

.main { padding: 28px 36px 120px; max-width: 1400px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .muted { margin-top: 4px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.back { font-size: 13px; color: var(--muted); display: inline-block; margin-bottom: 4px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; border: 1px solid var(--line-2); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.table-card { padding: 6px 0; overflow-x: auto; }
.table-card > .card-head { padding: 12px 22px 0; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--wood); font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-zip { display: grid; grid-template-columns: 120px 1fr 80px; gap: 14px; }
.gap-lg { gap: 20px; }
.grid-side { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.grid-doc { display: grid; grid-template-columns: minmax(340px, 1fr) 1.3fr; gap: 20px; align-items: start; }
.grid-doc-head { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; }
.form-narrow { max-width: 560px; }
.form-wide { max-width: 900px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------- Formulare ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label small { font-weight: 400; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
label.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--wood); }
input, select, textarea {
  font: inherit; font-size: 14.5px; color: var(--ink); background: #fff; border: 1px solid #ddd2c4; border-radius: 8px;
  padding: 8px 11px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--wood-2); box-shadow: 0 0 0 3px rgba(168,111,56,.18); }
input[type=checkbox], input[type=file] { width: auto; }
select[size] { padding: 4px; }
select[size] option { padding: 6px 8px; border-radius: 5px; }
.input-sm { padding: 5px 9px; font-size: 13.5px; width: auto; }
.inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0; }
form.inline { display: inline; margin: 0; }
.search { position: relative; display: flex; align-items: center; margin: 0; }
.search .ico { position: absolute; left: 11px; color: var(--muted); }
.search input { padding-left: 34px; width: 260px; background: #fff; }
.filter-input { margin-bottom: 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 14px; font-weight: 600; padding: 8px 15px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s;
  text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #3d3732; color: #fff; }
.btn-wood { background: var(--wood); color: #fff; }
.btn-wood:hover { background: var(--wood-2); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #356a42; color: #fff; }
.btn-ghost { background: #fff; color: var(--ink); border-color: #ddd2c4; }
.btn-ghost:hover { background: var(--wood-pale); border-color: var(--wood-2); color: var(--ink); }
.btn-danger-ghost { background: #fff; color: var(--red); border-color: #efc9c3; }
.btn-danger-ghost:hover { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.icon-btn { background: none; border: 0; color: var(--muted); padding: 4px; border-radius: 6px; cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--wood-light); color: var(--ink); }
.icon-btn.remove:hover { background: var(--red-bg); color: var(--red); }
.icon-btn.enter-row { color: var(--wood); background: var(--wood-light); }
.icon-btn.enter-row:hover, .icon-btn.enter-row:focus-visible { background: var(--wood); color: #fff; outline: none; }
.icon-btn:focus-visible { outline: 2px solid var(--wood-2); outline-offset: 1px; }
.saved-ok { color: var(--green) !important; }
.c-mail { width: 44px; padding-left: 4px !important; padding-right: 4px !important; }
.mail-btn { position: relative; color: var(--wood); background: var(--wood-light); padding: 6px; border-radius: 8px; }
.mail-btn:hover { background: var(--wood); color: #fff; }
.mail-btn.disabled { opacity: .35; cursor: not-allowed; background: none; color: var(--muted); }
.mail-btn.disabled:hover { background: none; color: var(--muted); }
.mail-noaddr { position: absolute; top: -4px; right: -4px; width: 14px; height: 14px; border-radius: 50%; background: var(--amber); color: #fff; font-size: 10px; font-weight: 700; line-height: 14px; text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 420px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); font-size: 14px; line-height: 1.4; }
.toast.error { background: var(--red); }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th:last-child, .table td:last-child { padding-right: 22px; }
.table th.right { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-compact td { padding: 8px 10px; }
.card > .table-compact td:first-child { padding-left: 0; }
.card > .table-compact td:last-child { padding-right: 0; }
.row-link { cursor: pointer; transition: background .1s; }
.row-link:hover { background: var(--wood-pale); }
.edit-row td { background: var(--wood-pale); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eee8e0; color: var(--ink-2); white-space: nowrap; vertical-align: middle; }
h1 .badge { font-size: 13px; }
.badge-draft { background: #eee8e0; color: var(--ink-2); }
.badge-final, .badge-sent { background: var(--amber-bg); color: var(--amber); }
.badge-paid, .badge-accepted { background: var(--green-bg); color: var(--green); }
.badge-cancelled, .badge-rejected { background: #ece9e6; color: #8b8178; text-decoration: line-through; }
.badge-overdue { background: var(--red-bg); color: var(--red); }
.badge-admin { background: var(--wood-light); color: var(--wood); }
.badge-free { background: var(--blue-bg); color: var(--blue); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 5px; background: var(--wood-light); color: var(--wood); vertical-align: middle; }
.pill-offer { background: var(--blue-bg); color: var(--blue); }
.pill-invoice { background: var(--wood-light); color: var(--wood); }
.pill-storno { background: var(--red-bg); color: var(--red); }

/* ---------- Kennzahlen ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpis-3 { grid-template-columns: 1fr 1fr 1.6fr; }
.kpis-even3 { grid-template-columns: repeat(3, 1fr); }
.search .search-spin { position: absolute; right: 10px; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--wood); border-radius: 50%; animation: spin .7s linear infinite; display: none; }
.search.loading .search-spin { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.kpi { background: var(--card); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); border: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 3px; color: var(--ink); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--wood); opacity: .85; }
a.kpi:hover { text-decoration: none; color: var(--ink); box-shadow: 0 4px 20px rgba(43,39,36,.1); }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 13px; color: var(--muted); }
.kpi-warn::before { background: var(--red); }
.kpi-warn .kpi-value { color: var(--red); }
.kpi-form form { margin: 6px 0 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: -6px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--wood); }

.empty { text-align: center; padding: 50px 20px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-inline { color: var(--muted); padding: 12px 0; }

/* ---------- Meldungen ---------- */
.flashes { display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 11px 40px 11px 16px; border-radius: 10px; font-weight: 500; position: relative; border: 1px solid; }
.flash-ok { background: var(--green-bg); color: #285c35; border-color: #c4e0ca; }
.flash-error { background: var(--red-bg); color: #8e2c21; border-color: #f0c8c1; }
.flash-x { position: absolute; right: 8px; top: 6px; background: none; border: 0; font-size: 20px; color: inherit; opacity: .6; cursor: pointer; }
.locked-note { display: flex; align-items: center; gap: 8px; background: var(--wood-light); color: var(--wood); padding: 10px 16px; border-radius: 10px; font-weight: 500; }

/* ---------- Beleg-Editor ---------- */
.rc-toggle { background: var(--wood-pale); border: 1px dashed #dcc8ad; padding: 12px; border-radius: 10px; }
.number-row { display: flex; gap: 8px; }
.number-row input { font-size: 17px; font-weight: 600; max-width: 160px; }
.number-box { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 10px; background: var(--wood-light); color: var(--wood); }
.number-box .mono { font-size: 22px; font-weight: 700; color: var(--ink); }
.chips { display: flex; gap: 6px; margin-top: -6px; }
.chip { font: inherit; font-size: 12.5px; background: var(--wood-pale); border: 1px solid var(--line); color: var(--ink-2); border-radius: 99px; padding: 3px 11px; cursor: pointer; }
.chip:hover { border-color: var(--wood-2); color: var(--wood); }
.items-card { padding: 18px 0 0; }
.items-card > .card-head { padding: 0 22px; }
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #fff; background: var(--ink); font-weight: 600; padding: 9px 8px; text-align: left; }
.items th:first-child { padding-left: 22px; }
.items td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.items td:first-child { padding-left: 22px; }
.items tr:nth-child(even) td { background: var(--wood-pale); }
.items textarea { min-height: 40px; }
.c-pos { width: 56px; } .c-qty { width: 96px; } .c-unit { width: 108px; } .c-price { width: 130px; }
.c-vat { width: 88px; } .c-total { width: 130px; text-align: right; } .c-act { width: 132px; white-space: nowrap; text-align: right; padding-right: 16px !important; }
.items th.c-total, .items th.c-price, .items th.c-qty { text-align: right; }
.items td.c-total { padding-top: 16px; font-weight: 600; }
.pos-no { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--wood-light); color: var(--wood); font-weight: 700; font-size: 13px; margin-top: 4px; }
.num-in { text-align: right; font-variant-numeric: tabular-nums; }
.doc-form.rc .c-vat { display: none; }
.items-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding: 16px 22px 20px; }
.totals { min-width: 340px; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.totals > div, #t-vat-rows > div { display: flex; justify-content: space-between; gap: 20px; }
#t-vat-rows { display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
.t-gross { background: var(--wood); color: #fff; padding: 9px 12px; border-radius: 8px; font-weight: 700; font-size: 17px; margin-top: 4px; }
.action-bar {
  position: sticky; bottom: 16px; z-index: 5; display: flex; justify-content: flex-end; align-items: center; gap: 10px;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px;
  box-shadow: 0 8px 30px rgba(43,39,36,.12);
}
.action-bar .muted { margin-right: auto; font-size: 13px; }
.pdf-card { padding: 0; overflow: hidden; }
.pdf-card .card-head { padding: 14px 20px 0; }
.pdf-card iframe { width: 100%; height: 82vh; border: 0; display: block; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 0 0 14px; }
.facts dt { color: var(--muted); font-size: 13.5px; }
.facts dd { margin: 0; font-weight: 600; }

.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(43,39,36,.15); min-width: 230px; padding: 6px; z-index: 20; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 14px; color: var(--ink); padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--wood-pale); text-decoration: none; }
.dropdown-menu .danger { color: var(--red); }
.dropdown-menu form { margin: 0; }

.backup-tile { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.backup-tile .ico { color: var(--wood); }
.backup-tile p { flex: 1; }

/* ---------- Anmeldung ---------- */
body.auth {
  min-height: 100vh; display: grid; place-items: center;
  background:
    repeating-linear-gradient(90deg, rgba(139,90,43,.035) 0 2px, transparent 2px 9px),
    radial-gradient(ellipse at top, #fbf6ee 0%, #efe5d7 100%);
}
.auth-wrap { width: 100%; max-width: 420px; padding: 20px; }
/* Karte im exakten Hintergrundton des Logos (#FEF3E3), damit das Logo ohne Kasten darin aufgeht */
.auth-card { background: var(--cream); border-radius: 16px; padding: 32px 34px; box-shadow: 0 20px 60px rgba(43,39,36,.15); border-top: 5px solid var(--wood); display: flex; flex-direction: column; gap: 16px; }
.auth-logo { width: 240px; align-self: center; display: block; }
.auth-card input { background: #fff; }
.auth-card h1 { font-size: 22px; justify-content: center; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 16px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid-doc, .grid-doc-head, .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  body.app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 18px 14px 120px; }
  .grid-2, .grid-3, .kpis, .kpis-3 { grid-template-columns: 1fr; }
}
@media print { .sidebar, .action-bar, .head-actions { display: none; } body.app { display: block; } }
