/* Moos & Malve Büro */
:root {
  --bg: #f6f5ee;
  --card: #fff;
  --ink: #22231c;
  --ink2: #5a5c50;
  --muted: #8a8c80;
  --line: #e7e5d9;
  --line2: #f0eee5;
  --moss: #a7a93e;
  --moss-d: #5f611a;
  --moss-l: #f1f2dc;
  --malve: #b68db6;
  --malve-d: #7d4a7e;
  --malve-l: #f7eef7;
  --pos: #3b7a37;
  --neg: #b23f2e;
  --r: 14px;
  --r-s: 10px;
  --shadow: 0 1px 2px rgba(40, 40, 20, .04), 0 2px 10px rgba(40, 40, 20, .03);
  --side: 236px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.45;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: var(--malve-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 620; margin: 0 0 14px; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.i { flex: none; vertical-align: middle; }
.num, .money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.right { text-align: right; }
.hidden, [hidden] { display: none !important; }

/* ---------- Rahmen ---------- */
.shell { min-height: 100vh; }
.side {
  position: fixed; inset: 0 auto 0 0; width: var(--side);
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 14px; background: #fbfaf5; border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.mark { width: 22px; height: 22px; border-radius: 7px; background: linear-gradient(135deg, var(--moss) 50%, var(--malve) 50%); flex: none; }
.brand.big { font-size: 1.2rem; justify-content: center; margin-bottom: 26px; }
.brand.big .mark { width: 30px; height: 30px; border-radius: 9px; }
.switch { display: flex; gap: 4px; background: var(--line2); border-radius: 12px; padding: 4px; }
.switch button {
  flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 7px 6px;
  font: inherit; font-size: .85rem; color: var(--ink2); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.switch button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .side-foot a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink2); font-weight: 500;
}
.nav a:hover, .side-foot a:hover { background: var(--line2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--moss-l); color: var(--moss-d); font-weight: 620; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.side-foot a.on { color: var(--moss-d); background: var(--moss-l); }
.main { margin-left: var(--side); padding: 30px 36px 60px; max-width: calc(1120px + var(--side)); }
.topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; min-height: 42px; }
.topline .acts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Karten & Raster ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid > *, .kpis > *, .main { min-width: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-l { font-size: .82rem; color: var(--ink2); }
.kpi-v { font-size: 1.5rem; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-s { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.kpi.hero { background: var(--moss-l); border-color: #e3e5bd; }
.kpi.hero .kpi-v { font-size: 1.9rem; color: var(--moss-d); }

/* ---------- Formulare ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; color: var(--ink2); font-weight: 500; }
.opt { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--ink); background: #fff;
  border: 1px solid #d9d7ca; border-radius: var(--r-s); padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--moss); box-shadow: 0 0 0 3px rgba(167, 169, 62, .22); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--moss-d); }
.check { flex-direction: row; align-items: center; gap: 10px; font-size: .95rem; color: var(--ink); font-weight: 400; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > label { flex: 1 1 160px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters label { flex: 0 1 180px; }
.filters select, .filters input { min-height: 40px; padding: 8px 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  border-radius: 11px; padding: 10px 16px; min-height: 44px; border: 1px solid #d9d7ca; background: #fff; color: var(--ink);
}
.btn:hover { text-decoration: none; background: #fbfaf5; }
.btn.primary { background: var(--moss-d); border-color: var(--moss-d); color: #fff; }
.btn.primary:hover { background: #4d4f12; }
.btn.malve { background: var(--malve-d); border-color: var(--malve-d); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink2); }
.btn.ghost:hover { background: var(--line2); }
.btn.danger { color: var(--neg); }
.btn.small { min-height: 34px; padding: 6px 11px; font-size: .85rem; border-radius: 9px; }
.btn.wide { width: 100%; }
.btn.big { min-height: 54px; font-size: 1.05rem; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.iconbtn:hover { color: var(--ink); background: var(--line2); }
.iconbtn.danger:hover { color: var(--neg); }

/* Segment-Auswahl (Radio als Knöpfe) */
.seg { display: inline-flex; background: var(--line2); border-radius: 12px; padding: 4px; gap: 4px; flex-wrap: wrap; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: block; padding: 8px 14px; border-radius: 9px; color: var(--ink2); font-size: .92rem; font-weight: 550; cursor: pointer; }
.seg input:checked + label { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg input:focus-visible + label { outline: 2px solid var(--moss); }
.field-title { font-size: .85rem; color: var(--ink2); font-weight: 500; margin-bottom: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--moss-d); border-color: var(--moss-d); }

/* ---------- Tabellen & Listen ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 10px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 10px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .r, .table th.r { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }
.table tr.strike td { color: var(--muted); text-decoration: line-through; }
.table tr.storno td { color: var(--muted); }
.tablewrap { overflow-x: auto; margin: 0 -4px; }
.scroll { max-height: 520px; overflow-y: auto; }

.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line2); }
.li:last-child { border-bottom: 0; }
.li-main { flex: 1; min-width: 0; }
.li-t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-s { font-size: .83rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-v { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.li.storno { opacity: .55; }
.li.storno .li-v { text-decoration: line-through; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 2px 6px; font-size: .85rem; color: var(--ink2); font-weight: 600; border-bottom: 1px solid var(--line); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--line2); color: var(--ink2); white-space: nowrap; }
.badge.moss { background: var(--moss-l); color: var(--moss-d); }
.badge.malve { background: var(--malve-l); color: var(--malve-d); }
.badge.warn { background: #fbefd9; color: #8a5a10; }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty div { margin-top: 14px; }

.toast { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 550; background: var(--moss-l); color: var(--moss-d); border: 1px solid #e3e5bd; }
.toast.err { background: #fbeae6; color: var(--neg); border-color: #f2cfc6; }

/* Fortschrittsbalken */
.bar { height: 10px; background: var(--line2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--moss); border-radius: 99px; }
.bar.warn > span { background: #d8a13a; }
.bar.over > span { background: var(--neg); }
.hbar { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; font-size: .88rem; padding: 4px 0; }
.hbar .bar { height: 8px; }

/* ---------- Verkauf eintragen ---------- */
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 128px 112px 96px 36px; gap: 8px; align-items: center; }
.line .sum { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.line .kat { grid-column: 1 / -1; }
.line .kat select { min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.stepper { display: flex; border: 1px solid #d9d7ca; border-radius: var(--r-s); overflow: hidden; background: #fff; }
.stepper button { border: 0; background: transparent; width: 38px; cursor: pointer; color: var(--ink2); }
.stepper button:hover { background: var(--line2); }
.stepper input { border: 0; border-radius: 0; text-align: center; padding: 8px 0; min-height: 42px; }
.stepper input:focus { box-shadow: none; }
.lines-head { display: grid; grid-template-columns: minmax(0, 1fr) 128px 112px 96px 36px; gap: 8px; font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.total-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.total { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.total small { display: block; font-size: .8rem; font-weight: 500; color: var(--muted); }
.linkbtn { border: 0; background: none; color: var(--malve-d); font: inherit; font-weight: 550; cursor: pointer; padding: 6px 0; display: inline-flex; gap: 6px; align-items: center; }
.ops { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.ops > div { display: flex; flex-direction: column; }

/* ---------- Beleg ---------- */
.drop {
  border: 2px dashed #d6d4c4; border-radius: var(--r); padding: 26px 16px; text-align: center; cursor: pointer;
  background: #fcfbf7; color: var(--ink2); display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 180px; justify-content: center; position: relative;
}
.drop:hover, .drop.over { border-color: var(--moss); background: var(--moss-l); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop img { max-width: 100%; max-height: 380px; border-radius: 8px; }
.drop.has { padding: 8px; border-style: solid; background: #fff; }
.ki-state { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--malve-d); font-weight: 550; }
.spin { width: 14px; height: 14px; border: 2px solid var(--malve-l); border-top-color: var(--malve-d); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.beleg-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--line2); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }

/* Kasse */
.kasse-calc { display: grid; grid-template-columns: 1fr auto; gap: 8px 18px; font-size: .95rem; }
.kasse-calc .r { text-align: right; font-variant-numeric: tabular-nums; }
.kasse-calc .sum { font-weight: 700; border-top: 1px solid var(--line); padding-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: .88rem; }
.chip:hover { border-color: var(--moss); text-decoration: none; }
.chip.on { background: var(--moss-l); border-color: var(--moss); color: var(--moss-d); font-weight: 600; }

/* Diagramm */
.chart-box { position: relative; height: 280px; }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--ink2); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--moss); }
.legend span.b::before { background: var(--malve); }

/* Dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .2); }
dialog::backdrop { background: rgba(30, 30, 20, .35); }
dialog .dlg { padding: 22px; }
dialog .dlg-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* Login */
.bare { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.bare-box { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 32px 28px; box-shadow: var(--shadow); }
.bare-box h1 { font-size: 1.3rem; margin-bottom: 18px; text-align: center; }

/* ---------- Handy ---------- */
@media (max-width: 900px) {
  :root { --side: 0px; }
  .side {
    position: sticky; top: 0; z-index: 20; inset: auto; width: auto; flex-direction: row; align-items: center;
    padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); gap: 10px; border-right: 0; border-bottom: 1px solid var(--line);
    background: #fbfaf5;
  }
  .brand span:last-child { display: none; }
  .brand { padding: 0; }
  .switch { flex: 1; max-width: 340px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-direction: row; justify-content: space-around;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
    padding: 6px 4px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  }
  .nav a { flex-direction: column; gap: 2px; font-size: .7rem; padding: 6px 4px; flex: 1; text-align: center; }
  .nav a.on { background: transparent; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; }
  .side-foot a { padding: 8px; }
  .side-foot a span { display: none; }
  .main { margin: 0; padding: 18px 14px 110px; }
  h1 { font-size: 1.3rem; }
  .topline { margin-bottom: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .card { padding: 16px; border-radius: 12px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-v { font-size: 1.2rem; }
  .kpi.hero { grid-column: 1 / -1; }
  .lines-head { display: none; }
  .line { grid-template-columns: 128px minmax(0, 1fr) 36px; row-gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line2); }
  .line .prod { grid-column: 1 / -1; grid-row: 1; }
  .line .qty { grid-column: 1; grid-row: 2; }
  .line .price { grid-column: 2; grid-row: 2; }
  .line .del { grid-column: 3; grid-row: 2; }
  .line .sum { display: none; }
  .line .kat { grid-row: 3; }
  .beleg-split { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .table.resp thead { display: none; }
  .table.resp tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-bottom: 1px solid var(--line2); }
  .table.resp td { border: 0; padding: 2px 4px; }
  .table.resp td.hide-m { display: none; }
  .filters label { flex: 1 1 140px; }
  .stack > div > .seg, .stack > .seg { display: flex; }
  .stack .seg label { flex: 1; text-align: center; padding: 8px 6px; }
  .topline .acts .btn { padding: 8px 12px; }
}


/* Steuerkategorie mit Suche */
.combo { position: relative; }
.combo-btn { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 12px; border: 1px solid #d9d7ca; border-radius: var(--r-s); background: #fff; font: inherit; font-size: 1rem; color: var(--ink); cursor: pointer; text-align: left; }
.combo-btn > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-btn:focus-visible { outline: 2px solid var(--moss); outline-offset: 1px; }
.combo-btn .n, .combo-i .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.combo-pop { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(30, 30, 20, .14); padding: 8px; }
.combo-list { max-height: 320px; overflow: auto; margin-top: 6px; }
.combo-g { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 10px 8px 4px; }
.combo-i { display: flex; width: 100%; gap: 10px; justify-content: space-between; border: 0; background: none; padding: 10px 8px; border-radius: 8px; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.combo-i:hover, .combo-i.on { background: var(--moss-l); }
.combo-list .empty { display: block; padding: 16px 8px; }

/* Umschalter als Links */
.seg a { display: block; padding: 8px 14px; border-radius: 9px; color: var(--ink2); font-size: .92rem; font-weight: 550; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* Analyse */
.alist { display: flex; flex-direction: column; }
.arow { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(40px, .7fr) auto 40px; gap: 12px; align-items: center; padding: 11px 6px; border-bottom: 1px solid var(--line2); color: var(--ink); border-radius: 8px; }
.arow:hover { background: var(--line2); text-decoration: none; }
.arow.on { background: var(--moss-l); }
.arow.dim { opacity: .5; }
.arow .an { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arow .bar { height: 8px; }
.arow .bar.b > span { background: var(--malve); }
.arow .av { font-weight: 600; text-align: right; }
.arow .ap { text-align: right; font-size: .85rem; }
.atotal { display: flex; justify-content: space-between; padding: 14px 6px 0; color: var(--ink2); }
.an-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
@media (max-width: 900px) {
  .arow { grid-template-columns: minmax(0, 1fr) auto 40px; row-gap: 6px; }
  .arow .bar { grid-column: 1 / -1; grid-row: 2; }
  .an-head .seg { display: flex; width: 100%; }
  .an-head .seg a { flex: 1; text-align: center; padding: 8px 6px; }
}

@media print {
  .side, .nav, .filters, .acts, .btn, .tabs { display: none !important; }
  .main { margin: 0; padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
