:root {
  --brand: #f2a900; --brand-d: #c98a00; --brand-l: #fff4d6;
  --ink: #2b2b2b; --muted: #6f6f6f; --line: #e6e6e6; --bg: #f6f6f4; --card: #fff;
  --ok: #2e8b57; --ok-l: #e5f4ec; --warn: #c77700; --warn-l: #fff2dc; --bad: #c0392b; --bad-l: #fbe7e5;
  --info: #2f6fb0; --info-l: #e6f0fa;
  --r: 10px; --sh: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--info); }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.side { width: 230px; background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side .logo { padding: 18px 16px 10px; }
.side .logo img { width: 100%; max-width: 190px; }
.side .logo div { font-weight: 700; color: var(--brand-d); margin-top: 4px; font-size: 13px; letter-spacing: .3px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 8px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; margin: 1px 0; }
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-l); color: #7a5200; font-weight: 600; }
.nav .ic { width: 20px; text-align: center; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.side .foot { border-top: 1px solid var(--line); padding: 10px 12px; font-size: 13px; }
.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }
.top { display: none; }
.langs { display: flex; gap: 4px; }
.langs button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 3px 8px; cursor: pointer; font-size: 12px; }
.langs button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

@media (max-width: 900px) {
  .side { position: fixed; z-index: 30; left: -260px; transition: left .2s; box-shadow: 0 0 30px rgba(0,0,0,.15); }
  .side.open { left: 0; }
  .top { display: flex; align-items: center; gap: 10px; background: #fff; border-bottom: 1px solid var(--line); padding: 10px 14px; position: sticky; top: 0; z-index: 20; }
  .top img { height: 26px; }
  .top .burger { font-size: 22px; background: none; border: 0; cursor: pointer; }
  .main { padding: 16px 14px 60px; }
  .layout { display: block; }
}

/* Karten, Raster */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 16px; margin-bottom: 16px; border: 1px solid #eee; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: #fff; border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); border: 1px solid #eee; border-left: 4px solid var(--brand); }
.kpi .v { font-size: 24px; font-weight: 700; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi.ok { border-left-color: var(--ok); } .kpi.bad { border-left-color: var(--bad); } .kpi.info { border-left-color: var(--info); }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .two { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.head h1 { margin: 0; }

/* Buttons & Formulare */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 13px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #ccc; background: #fafafa; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.danger { color: var(--bad); border-color: #efc4bf; }
.danger:hover { background: var(--bad-l); }
.small { padding: 4px 9px; font-size: 13px; }
.link { border: 0; background: none; color: var(--info); padding: 0; }
button:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #d6d6d6; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-l); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin: 10px 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 14px; }
.search { max-width: 280px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border-radius: 20px; padding: 5px 12px; font-size: 13px; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 9px 14px; }
.tabs button.on { border-bottom-color: var(--brand); font-weight: 600; }

/* Tabellen */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); background: #fafafa; position: sticky; top: 0; }
td.n, th.n { text-align: right; white-space: nowrap; }
tr.arch td { color: #999; }
tfoot td { font-weight: 700; background: #fafafa; }
.pill { display: inline-block; border-radius: 12px; padding: 2px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.p-ok { background: var(--ok-l); color: var(--ok); } .p-warn { background: var(--warn-l); color: var(--warn); }
.p-bad { background: var(--bad-l); color: var(--bad); } .p-info { background: var(--info-l); color: var(--info); }
.p-mute { background: #eee; color: #666; }

/* Shop */
.shop { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .shop { grid-template-columns: 1fr; } .cart { position: static; order: -1; } }
@media (max-width: 600px) { .products { grid-template-columns: repeat(2, 1fr); gap: 8px; } .prod { padding: 8px; } .prod .img { height: 100px; } .prod .img img { max-height: 100px; } .prod .add { flex-wrap: wrap; } .prod .add input { width: 100%; } .prod .add button { width: 100%; justify-content: center; } }
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.prod { background: #fff; border-radius: var(--r); border: 1px solid #eee; box-shadow: var(--sh); padding: 12px; display: flex; flex-direction: column; position: relative; }
.prod .img { height: 130px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.prod .img img { max-height: 130px; max-width: 100%; object-fit: contain; }
.prod .noimg { font-size: 44px; opacity: .3; }
.prod .nm { font-weight: 600; font-size: 14px; min-height: 40px; }
.prod .meta { font-size: 12px; color: var(--muted); }
.prod .pr { font-size: 17px; font-weight: 700; margin: 6px 0; }
.prod .add { display: flex; gap: 6px; margin-top: auto; }
.prod .add input { width: 70px; }
.prod .edit { position: absolute; top: 8px; right: 8px; }
.prod.inCart { border-color: var(--brand); }
.cart { position: sticky; top: 16px; }
.cart .it { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.cart .it input { width: 64px; padding: 4px 6px; }
.cart .it .nm { flex: 1; }
.cart .tot { font-size: 18px; font-weight: 700; text-align: right; margin: 10px 0; }
.qty { display: inline-flex; align-items: center; gap: 4px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 900px; }
.modal .mh { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mh h2 { margin: 0; flex: 1; }
.modal .mh .x { border: 0; font-size: 22px; line-height: 1; padding: 2px 8px; }
.modal .mb { padding: 6px 18px 16px; }
.modal .mf { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }

/* Unterschrift */
.sig { border: 2px dashed #ccc; border-radius: 10px; background: #fff; position: relative; touch-action: none; }
.sig canvas { display: block; width: 100%; height: 180px; cursor: crosshair; }
.sig .hint { position: absolute; left: 0; right: 0; bottom: 34px; text-align: center; color: #bbb; pointer-events: none; font-size: 13px; }
.sig .base { position: absolute; left: 20px; right: 20px; bottom: 30px; border-bottom: 1px solid #ddd; pointer-events: none; }

/* Liste / Alarme */
.alerts .al { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; margin-bottom: 6px; font-size: 14px; }
.al.bad { background: var(--bad-l); } .al.warn { background: var(--warn-l); } .al.info { background: var(--info-l); } .al.ok { background: var(--ok-l); }
.al a { margin-left: auto; white-space: nowrap; }
.bar { height: 12px; background: #eee; border-radius: 8px; overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--brand), #f7c64d); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.picklist { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.picklist div { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.picklist div:hover { background: var(--bg); }
.picklist div.on { background: var(--brand-l); font-weight: 600; }

/* Login */
.login { max-width: 400px; margin: 8vh auto; padding: 0 14px; }
.login .card { padding: 26px; }
.login img { width: 230px; display: block; margin: 0 auto 6px; }
.login .ttl { text-align: center; font-weight: 700; color: var(--brand-d); margin-bottom: 18px; }
.err { color: var(--bad); font-size: 14px; margin-top: 10px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 99; }
#toast div { background: #333; color: #fff; padding: 10px 18px; border-radius: 8px; margin-top: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#toast div.e { background: var(--bad); }

/* Druck */
#print { display: none; }
@media print {
  body { background: #fff; }
  #app, #toast, .modal-bg { display: none !important; }
  #print { display: block; padding: 0; font-size: 12px; }
  #print table { font-size: 12px; }
  #print th { position: static; }
  #print img.lg { width: 200px; }
}

tr.click, td.click { cursor: pointer; }
tr.click:hover td { background: var(--brand-l); }
td.click:hover { background: var(--brand-l); }
