@font-face { font-family: 'Poppins'; font-weight: 300; src: url(/fonts/Poppins-Light.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Poppins'; font-weight: 400; src: url(/fonts/Poppins-Regular.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Poppins'; font-weight: 500; src: url(/fonts/Poppins-Medium.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Poppins'; font-weight: 600; src: url(/fonts/Poppins-SemiBold.ttf) format('truetype'); font-display: swap; }
@font-face { font-family: 'Poppins'; font-weight: 700; src: url(/fonts/Poppins-Bold.ttf) format('truetype'); font-display: swap; }

:root {
  --accent: #A06AB2; --accent-2: #E4CAE3; --accent-ink: #7d4a90; --accent-soft: #f3ebf5;
  --bg: #f6f5f7; --panel: #ffffff; --ink: #1d1d1f; --muted: #78767d; --line: #e7e5ea; --line-2: #d8d5dc;
  --red: #c62f45; --red-soft: #fbe9ec; --green: #1f8a5b; --green-soft: #e5f4ec; --amber: #b7791f; --amber-soft: #fbf1df;
  --radius: 14px; --shadow: 0 1px 2px #0000000a, 0 6px 24px #0000000a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141316; --panel: #1d1c20; --ink: #f1eff3; --muted: #a29fa8; --line: #2c2a30; --line-2: #3a3740; --accent-soft: #2b2230;
    --accent-ink: #d7aee4; --red-soft: #3a1f25; --green-soft: #16301f; --amber-soft: #33281a; --shadow: none; color-scheme: dark; }
  .brand img, .login-logo { filter: invert(1); }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.5 'Poppins', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
h1 { font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 18px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .center { text-align: center; }
.red { color: var(--red); } .green { color: var(--green); }
.err { color: var(--red); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { width: 100%; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; outline: none; transition: border .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { resize: vertical; line-height: 1.45; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 40px; }
label { display: block; font-size: 12px; color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea, label > .picker { margin-top: 4px; color: var(--ink); font-weight: 400; font-size: 14px; }
code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
code.copy { cursor: copy; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line-2); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; color: var(--ink); transition: background .15s, transform .05s; }
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--red); }
.btn.ghost { border-style: dashed; background: transparent; color: var(--muted); }
.btn.tiny { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.big { padding: 12px 18px; width: 100%; font-size: 15px; }
.btn.pulse { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px transparent; } }
.icon { border: 0; background: transparent; cursor: pointer; color: var(--muted); font-size: 15px; padding: 6px; border-radius: 8px; }
.icon:hover { background: var(--accent-soft); }

/* Shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 22px; }
.brand img { height: 22px; }
.brand span { font-weight: 300; color: var(--muted); letter-spacing: .5px; }
.side nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; border: 0; background: none; cursor: pointer; text-align: left; }
.nav svg { width: 19px; height: 19px; fill: var(--muted); }
.nav:hover { background: var(--bg); }
.nav.on { background: var(--accent-soft); color: var(--accent-ink); }
.nav.on svg { fill: var(--accent); }
.nav.logout { color: var(--muted); font-size: 13px; }
.nav-user { padding: 0 12px; font-size: 12px; color: var(--muted); }
.main { min-width: 0; }
.tabbar { display: none; }
.page { padding: 28px 32px 60px; max-width: 1280px; margin: 0 auto; }
.page.narrow { max-width: 820px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.head-actions { display: flex; gap: 8px; align-items: center; }
.head-actions select { width: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, section.card { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.more { font-size: 12px; font-weight: 500; }
.empty { color: var(--muted); text-align: center; padding: 18px 0; margin: 0; }
.skeleton { height: 220px; border-radius: var(--radius); background: linear-gradient(90deg, var(--line) 0%, var(--bg) 50%, var(--line) 100%); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0; }
.kpi span { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi b { font-size: 22px; font-weight: 600; letter-spacing: -.3px; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { font-size: 11px; color: var(--muted); }
.kpi.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.kpi.accent span, .kpi.accent small { color: #ffffffcc; }
.kpi.warn b { color: var(--red); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid2 > .card { margin: 0; }

/* Listen */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.li:first-child { border-top: 0; }
.li-main { display: flex; flex-direction: column; min-width: 0; color: var(--ink); flex: 1; }
.li-main b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-main small, .li small { color: var(--muted); font-size: 12px; }
.li-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.li-side b { font-weight: 600; white-space: nowrap; }
.btns { display: flex; gap: 6px; }
.bar { height: 4px; background: var(--line); border-radius: 4px; margin-top: 6px; overflow: hidden; max-width: 240px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.chart { display: flex; gap: 6px; align-items: flex-end; height: 140px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart .bars { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.chart .bars i { width: 42%; border-radius: 4px 4px 0 0; min-height: 2px; }
.b1, .l1 { background: var(--accent); } .b2, .l2 { background: var(--accent-2); }
.chart small { font-size: 10px; color: var(--muted); margin-top: 4px; }
.legend { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 6px; }
.activity { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; max-height: 260px; overflow: auto; }
.activity div { display: flex; gap: 8px; align-items: baseline; }
.activity small { margin-left: auto; color: var(--muted); white-space: nowrap; font-size: 11px; }
.who { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: var(--line); color: var(--muted); flex-shrink: 0; }
.who.ki { background: var(--accent-soft); color: var(--accent-ink); }

/* Pills */
.pill { font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--line); color: var(--muted); white-space: nowrap; letter-spacing: .2px; }
.pill-versendet, .pill-offen { background: var(--amber-soft); color: var(--amber); }
.pill-angenommen, .pill-bezahlt { background: var(--green-soft); color: var(--green); }
.pill-abgelehnt, .pill-ueberfaellig { background: var(--red-soft); color: var(--red); }
.pill-storniert { text-decoration: line-through; }
.tag { font-size: 10px; background: var(--line); color: var(--muted); border-radius: 5px; padding: 0 5px; }

/* Filter + Tabellen */
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters select { width: auto; }
.chips, .seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.chips button, .seg button { border: 0; background: none; padding: 5px 11px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px; }
.chips button.on, .seg button.on { background: var(--accent); color: #fff; }
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--bg); }
.table td b { font-weight: 500; display: block; }
.table td small { display: block; color: var(--muted); font-size: 12px; }
.table tfoot td { border: 0; color: var(--muted); font-size: 12px; }
.table .r { text-align: right; white-space: nowrap; }
.table .mono { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.table tr.dim { opacity: .5; }
.clip { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cands { display: flex; flex-wrap: wrap; gap: 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card.cust { text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; margin: 0; border: 1px solid var(--line); font: inherit; color: inherit; }
.card.cust:hover { border-color: var(--accent); }
.card.cust small { font-size: 12px; color: var(--muted); }
.drop { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 28px 18px; margin-bottom: 16px; cursor: pointer; background: var(--panel); color: var(--ink); font-size: 14px; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop small { color: var(--muted); max-width: 560px; }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 4px; }
.grow { flex: 1; }
.check { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); cursor: pointer; }
.checks { display: flex; gap: 18px; flex-wrap: wrap; }
.picker { position: relative; }
.picker-list { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; right: 0; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 12px 30px #0002; max-height: 320px; overflow: auto; padding: 4px; }
.picker-item { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-item:hover { background: var(--accent-soft); }
.picker-item b { font-weight: 500; } .picker-item small { color: var(--muted); font-size: 12px; }
.picker-item.new { color: var(--accent-ink); font-weight: 500; }
.steps { padding-left: 20px; line-height: 1.8; }
.tokenbox { background: var(--amber-soft); padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.quicklinks { display: none; gap: 8px; margin-bottom: 14px; }

/* Modal + Toasts */
.modal-bg { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 50; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--panel); border-radius: 18px; padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px #0004; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13px; box-shadow: 0 8px 24px #0003; animation: tin .2s; max-width: 90vw; }
.toast.err { background: var(--red); color: #fff; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 80% 0%, var(--accent-2), transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; padding: 28px; }
.login-logo { height: 30px; align-self: flex-start; }
.login-card h1 { font-size: 28px; }
.login-card p { margin: -8px 0 4px; }

/* Editor */
.editor { padding: 20px 24px 40px; }
.ed-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }
.ed-title { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.ed-title h1 { font-size: 21px; }
.ed-title p { margin: 2px 0 0; font-size: 13px; }
.back { font-size: 20px; color: var(--muted); padding: 2px 8px; border-radius: 8px; }
.back:hover { background: var(--accent-soft); }
.ed-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 12px 30px #0002; padding: 4px; z-index: 20; min-width: 180px; display: flex; flex-direction: column; }
.menu-list button { border: 0; background: none; text-align: left; padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.menu-list button:hover { background: var(--accent-soft); }
.menu-list .danger { color: var(--red); }
.statusbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.rel { font-size: 12px; background: var(--panel); border: 1px solid var(--line); padding: 4px 10px; border-radius: 20px; color: var(--accent-ink); }
.ed-tabs { display: none; }
.ed-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.ed-form .card { margin-bottom: 14px; }
.ed-form h2 { margin-bottom: 2px; }
.addr { margin: -4px 0 0; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; }
.preview { position: sticky; top: 16px; height: calc(100vh - 32px); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #525659; }
.pdfview { height: 100%; overflow: auto; padding: 12px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pdfview canvas { background: #fff; box-shadow: 0 2px 12px #0005; border-radius: 2px; max-width: 100%; }
.pdfview .err { color: #fff; }
.preview.full { position: static; height: 80vh; }
.pad { padding: 0 0 12px; }
.ed-bottom { position: sticky; bottom: 12px; display: none; }
.ed-bottom .btn:disabled { display: none; }
.lrow { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: start; }
.llabel { font-weight: 500; text-transform: uppercase; font-size: 12px; letter-spacing: .5px; color: var(--accent-ink); }
.sections { display: flex; flex-direction: column; gap: 14px; }
.sec { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.sec-head { display: flex; gap: 8px; align-items: center; }
.sec-title { font-weight: 600; background: transparent; border-color: transparent; padding: 6px 8px; }
.sec-title:hover { border-color: var(--line-2); }
.sec-sum { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sec-note { font-size: 12px; padding: 5px 8px; background: transparent; border-color: transparent; color: var(--muted); }
.sec-note:hover, .sec-note:focus { border-color: var(--line-2); }
.item { display: grid; grid-template-columns: 82px minmax(0, 1fr) 100px 48px auto; gap: 6px; align-items: start; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.item input { padding: 6px 8px; font-size: 13px; }
.item .qty { text-align: center; padding-left: 4px; padding-right: 4px; font-size: 12px; }
.desc { display: flex; flex-direction: column; gap: 4px; }
.desc .detail { font-size: 12px; color: var(--muted); border-style: dashed; }
.price { text-align: right; font-variant-numeric: tabular-nums; }
.inkl { display: flex; align-items: center; gap: 3px; font-size: 11px; padding-top: 7px; cursor: pointer; }
.mini { display: flex; gap: 0; }
.mini button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 5px 5px; border-radius: 6px; font-size: 12px; }
.mini button:hover { background: var(--accent-soft); color: var(--ink); }
.totals { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totals .price { max-width: 160px; font-weight: 600; }
.hint { font-size: 12px; color: var(--amber); background: var(--amber-soft); padding: 6px 10px; border-radius: 8px; margin: 0; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .ed-body { grid-template-columns: 1fr; }
  .ed-tabs { display: inline-flex; background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 3px; margin-bottom: 12px; }
  .ed-tabs button { border: 0; background: none; padding: 6px 16px; border-radius: 8px; cursor: pointer; font-weight: 500; color: var(--muted); }
  .ed-tabs button.on { background: var(--accent); color: #fff; }
  .tab-edit .preview { display: none; }
  .tab-pdf .ed-form { display: none; }
  .preview { position: static; height: 78vh; }
  .ed-bottom { display: block; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 40; }
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; color: var(--muted); font-weight: 500; padding: 4px 0; }
  .tab svg { width: 22px; height: 22px; fill: var(--muted); }
  .tab.on { color: var(--accent-ink); } .tab.on svg { fill: var(--accent); }
  .page { padding: 18px 16px 40px; }
  .editor { padding: 14px 12px 40px; }
  h1 { font-size: 21px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 12px; } .kpi b { font-size: 18px; }
  .kpi.accent { grid-column: span 2; }
  .row2, .row3 { grid-template-columns: 1fr; }
  .hide-s { display: none; }
  .table td, .table th { padding: 10px; }
  .item { grid-template-columns: 56px minmax(0, 1fr) auto; }
  .item .price { grid-column: 2; }
  .item .inkl { grid-column: 3; grid-row: 2; }
  .item .mini { grid-column: 3; grid-row: 1; }
  .lrow { grid-template-columns: 1fr auto; } .lrow .llabel { grid-column: 1 / -1; }
  .quicklinks { display: flex; }
  .ed-actions { width: 100%; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .li-side .btns { flex-direction: column; }
}
