:root {
  --blue: #1a9be8; --blue-d: #0f7cc0; --red: #e5262a; --green: #16a34a; --amber: #d97706;
  --bg: #f4f6f9; --card: #fff; --text: #1f242b; --muted: #6b7380; --line: #e3e7ed; --soft: #eef6fd;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-d); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: #0f1720; color: #cdd5df; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 1.1rem; }
.brand img { width: 26px; height: 34px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.brand small { display: block; font-weight: 500; color: #8a96a6; font-size: .72rem; }
.side a { color: #cdd5df; padding: 9px 12px; border-radius: 8px; display: flex; gap: 10px; align-items: center; font-weight: 500; }
.side a:hover { background: #1b2530; text-decoration: none; color: #fff; }
.side a.active { background: var(--blue); color: #fff; }
.side .sp { flex: 1; }
.side .ico { width: 18px; text-align: center; opacity: .9; }
.main { padding: 26px 30px 90px; max-width: 1180px; width: 100%; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bottomnav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 96px; }
  .bottomnav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 50; padding-bottom: env(safe-area-inset-bottom); }
  .bottomnav a { text-align: center; padding: 8px 2px 7px; color: var(--muted); font-size: .7rem; font-weight: 600; }
  .bottomnav a .ico { display: block; font-size: 1.25rem; line-height: 1.2; }
  .bottomnav a.active { color: var(--blue); }
  .hide-m { display: none !important; }
}

/* Cards & grids */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .v { font-size: 1.5rem; font-weight: 700; margin-top: 2px; }
.stat .l { color: var(--muted); font-size: .82rem; font-weight: 600; }
.stat.blue { background: var(--blue); color: #fff; } .stat.blue .l { color: #e1f1fc; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--soft); }
.tablewrap { overflow-x: auto; }

/* Forms */
label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 9px; background: #fff; color: var(--text); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(26,155,232,.35); border-color: var(--blue); }
input[readonly] { background: #f6f7f9; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); font-size: .92rem; }
.check input { width: auto; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; padding: 9px 15px; border-radius: 9px; border: 1px solid #cfd6df; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f5f8; text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); }
.btn.danger { color: var(--red); border-color: #f1c4c5; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.small { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .76rem; font-weight: 700; background: #eef1f5; color: #4b5563; white-space: nowrap; }
.b-angenommen { background: #e8f3fd; color: #0f6aa8; }
.b-diagnose { background: #f1ecff; color: #6b3fd1; }
.b-warten_freigabe, .b-warten_teil { background: #fff4e0; color: #a15c00; }
.b-in_reparatur { background: #e6f7f5; color: #0f766e; }
.b-fertig { background: #dcfce7; color: #15803d; }
.b-nicht_reparierbar { background: #fde8e8; color: #b42318; }
.b-abgeholt { background: #eef1f5; color: #4b5563; }
.b-storniert { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.b-entwurf { background: #fff4e0; color: #a15c00; }
.b-final { background: #e8f3fd; color: #0f6aa8; }
.b-bezahlt { background: #dcfce7; color: #15803d; }
.b-offen { background: #fde8e8; color: #b42318; }
.b-teilweise { background: #fff4e0; color: #a15c00; }

.statusbar { display: flex; gap: 6px; flex-wrap: wrap; }
.statusbar button { font: inherit; font-size: .82rem; font-weight: 600; border: 1px solid var(--line); background: #fff; padding: 6px 10px; border-radius: 99px; cursor: pointer; color: var(--muted); }
.statusbar button.on { background: var(--blue); color: #fff; border-color: var(--blue); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { padding: 7px 13px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: .88rem; }
.tabs a.on { background: var(--text); color: #fff; border-color: var(--text); }
.tabs a:hover { text-decoration: none; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--blue); position: absolute; left: -6px; top: 13px; }
.timeline li.notiz::before { background: #9ca3af; }
.timeline li.nachricht::before { background: var(--green); }

/* Items editor */
.items td { padding: 6px 4px; }
.items input, .items select { padding: 7px 8px; }
.items .desc { min-width: 220px; }
.items .num { width: 80px; }
.items .money { width: 105px; text-align: right; }
.totals { margin-left: auto; max-width: 340px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .big { font-size: 1.2rem; font-weight: 800; border-top: 2px solid var(--text); margin-top: 6px; padding-top: 8px; }
@media (max-width: 860px) {
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td { border: 0; padding: 0; }
  .items td.dcell { grid-column: 1 / -1; }
  .items .num, .items .money { width: 100%; }
}

.picker { position: relative; }
.picker .list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 300px; overflow: auto; margin-top: 4px; }
.picker .list div { padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f1f3f6; }
.picker .list div:hover { background: var(--soft); }
.chosen { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; background: var(--soft); border: 1px solid #cfe6f8; padding: 10px 12px; border-radius: 10px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 90px; background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px; z-index: 100; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 92vw; }
.toast.err { background: var(--red); }
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,32,.45); z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 480px; box-shadow: 0 20px 50px rgba(0,0,0,.25); max-height: 92vh; overflow: auto; }
.notice { background: #fff8e6; border: 1px solid #f6dc9c; color: #6b4a00; padding: 10px 13px; border-radius: 10px; font-size: .9rem; margin-bottom: 14px; }
.notice.blue { background: var(--soft); border-color: #cfe6f8; color: #0f4f7c; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* Login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0f1720, #13314a); }
.login .card { width: 100%; max-width: 400px; padding: 28px; }
.login .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login .logo img { width: 36px; height: 48px; object-fit: contain; }
.login .logo b { font-size: 1.35rem; }
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; }
code.secret { display: block; text-align: center; background: #f3f5f8; padding: 8px; border-radius: 8px; word-break: break-all; font-size: .85rem; }
