:root {
  --bg: #f4f6f5; --card: #ffffff; --ink: #1d2421; --muted: #6b7570; --line: #e2e7e4;
  --accent: #2f5d50; --accent-ink: #ffffff; --accent-soft: #e6efeb; --warn: #b3261e; --warn-soft: #fbeae8;
  --gold: #c08a2d; --radius: 12px; --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615; --card: #1b201e; --ink: #e8ecea; --muted: #94a09a; --line: #2b3330;
    --accent: #6fb49c; --accent-ink: #0f1a16; --accent-soft: #1f2e29; --warn: #f2867b; --warn-soft: #3a1f1c;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
code { font-size: .85rem; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--card); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; padding: 0 6px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.logo { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: .9rem; }
.logo.big { width: 56px; height: 56px; font-size: 1.3rem; border-radius: 14px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink); font-weight: 500; }
.side nav a:hover { background: var(--bg); text-decoration: none; }
.side nav a.active { background: var(--accent-soft); color: var(--accent); }
.icon { width: 19px; height: 19px; flex: none; }
.logout { margin-top: auto; padding: 0 10px; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; font: inherit; }

main { padding: 28px 36px 60px; max-width: 1200px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.accent { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { background: var(--card); color: var(--warn); border-color: var(--line); }
.btn.danger:hover { background: var(--warn-soft); }
.icon-btn { border: 0; background: none; color: var(--muted); font-size: 1.2rem; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--warn-soft); color: var(--warn); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }
.empty { color: var(--muted); }
.card.empty { text-align: center; padding: 40px; }
.flash { background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 8px; margin-bottom: 18px; }
.flash.error { background: var(--warn-soft); border-color: var(--warn); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 18px; }
.grid2 .wide { grid-column: 1 / -1; }
.grid3, .grid4 { display: grid; gap: 14px; margin-bottom: 18px; }
.grid3 { grid-template-columns: repeat(3, 1fr); }
.grid4 { grid-template-columns: repeat(4, 1fr); }
.grid3 .card, .grid4 .card { margin: 0; }
.meta { padding: 14px 16px; }
.meta > span:first-child { display: block; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.meta select { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.address { line-height: 1.6; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--ink); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi:hover { text-decoration: none; border-color: var(--accent); }
.kpi span { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi small { color: var(--muted); }
.kpi.warn strong { color: var(--warn); }

ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
ul.rows li:first-child { border-top: 0; padding-top: 0; }
ul.rows a { display: flex; flex-direction: column; color: var(--ink); min-width: 0; }
ul.rows a span { font-size: .85rem; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.s-gesendet, .s-in_arbeit, .s-offen { background: #e7eefb; color: #2b5cb8; }
.s-angenommen, .s-bezahlt, .s-erledigt { background: #e3f3ea; color: #23784a; }
.s-abgelehnt, .s-storniert { background: var(--warn-soft); color: var(--warn); }
.s-verrechnet { background: #f6efe1; color: #8a6118; }
@media (prefers-color-scheme: dark) {
  .s-gesendet, .s-in_arbeit, .s-offen { background: #1e2a40; color: #8fb0ee; }
  .s-angenommen, .s-bezahlt, .s-erledigt { background: #19301f; color: #7fd19f; }
  .s-verrechnet { background: #33291a; color: #e0b866; }
}

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; background: var(--card); }
.table-wrap > table.list.clickable { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tfoot td { border-top: 1px solid var(--line); border-bottom: 0; }
table.clickable tbody tr { cursor: pointer; }
table.clickable tbody tr:hover { background: var(--bg); }
.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.billed td { color: var(--muted); }
td.overdue { color: var(--warn); font-weight: 600; }
table.totals { margin: 16px 0 16px auto; min-width: 280px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.totals td { padding: 5px 0; }
table.totals td:last-child { text-align: right; padding-left: 24px; }
table.totals .grand td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--ink); padding-top: 8px; }

.filters { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.filters a { padding: 5px 12px; border-radius: 99px; color: var(--muted); border: 1px solid var(--line); background: var(--card); font-size: .85rem; }
.filters a.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filters a:hover { text-decoration: none; }
.search { margin-bottom: 14px; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=color] { padding: 2px; height: 40px; }
textarea { resize: vertical; }
.form h2 { margin-top: 10px; }
.fields { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; margin-bottom: 18px; }
.fields label { display: flex; flex-direction: column; gap: 4px; }
.fields label > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.fields .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }

.items-editor { margin-bottom: 18px; }
table.edit td { padding: 6px 4px; border-bottom: 0; }
table.edit th { padding: 6px 4px; }
table.edit textarea { min-height: 40px; }
.w-qty { width: 80px; } .w-unit { width: 90px; } .w-price { width: 110px; } .w-total { width: 110px; }
td.line-total { padding-top: 14px !important; font-variant-numeric: tabular-nums; }
.editor-actions { display: flex; gap: 8px; margin-top: 8px; }
.editor-actions select { width: auto; }

.time-form { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.time-form input { width: auto; }
.time-form .grow { flex: 1; min-width: 200px; }
.time-form .short { width: 90px; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 40px 32px; max-width: 380px; width: 100%; text-align: center; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.login-card h1 { font-size: 1.3rem; }
.login-card p { margin: 0 0 8px; }
.btn.google { background: var(--card); color: var(--ink); border-color: var(--line); padding: 11px 20px; width: 100%; justify-content: center; }
.login-card form { width: 100%; }
.login-card .btn.ghost { width: 100%; justify-content: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; z-index: 5; height: auto; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand span:last-child { display: none; }
  .side nav { flex-direction: row; }
  .side nav a span { display: none; }
  .logout { margin: 0 0 0 auto; padding: 0; white-space: nowrap; }
  main { padding: 20px 16px 50px; }
  .kpis, .grid4 { grid-template-columns: 1fr 1fr; }
  .grid2, .grid3, .fields { grid-template-columns: 1fr; }
}
