:root { --bg: #f4f6f9; --card: #fff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --accent: #2563eb; --danger: #b91c1c; --nav: #0f172a; --radius: 10px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
h1 { font-size: 21px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
h2.sec { margin: 20px 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 12px 0 4px; }
code { word-break: break-all; font-size: 12px; }
.muted { color: var(--muted); }
.pre { white-space: pre-wrap; }

#shell { display: flex; min-height: 100vh; }
#nav { position: fixed; top: 0; bottom: 0; left: 0; width: 210px; background: var(--nav); color: #cbd5e1; display: flex; flex-direction: column; padding: env(safe-area-inset-top) 0 12px; z-index: 5; }
#nav .brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: #fff; font-weight: 600; }
#nav .brand img { width: 32px; height: 32px; }
#nav a { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 11px 18px; }
#nav a i { font-style: normal; width: 20px; text-align: center; }
#nav a.on { background: #1e293b; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
#nav a b { margin-left: auto; background: var(--danger); color: #fff; border-radius: 9px; padding: 0 7px; font-size: 12px; }
#nav .grow { flex: 1; }
#nav .who { padding: 0 18px; font-size: 13px; }
#nav .chiprow { padding: 6px 18px; }
.syncchip { display: inline-block; border-radius: 12px; padding: 2px 10px; font-size: 12px; background: #334155; color: #fff; white-space: nowrap; }
.syncchip.ok { background: #166534; } .syncchip.off { background: #92400e; } .syncchip.warn { background: var(--danger); } .syncchip.sync { background: #1d4ed8; }

#main { flex: 1; margin-left: 210px; padding: 18px 22px 60px; min-width: 0; }
#aufnahmeWrap { position: fixed; top: 0; right: 0; bottom: 0; left: 210px; display: flex; flex-direction: column; background: #fff; }
#aufnahmeBar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); padding-top: calc(8px + env(safe-area-inset-top)); }
#aufnahmeFrame { flex: 1; min-height: 0; }
#aufnahmeFrame iframe { width: 100%; height: 100%; border: 0; display: block; }

.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.head > div:not(.tools) { min-width: 0; }
.head p { margin: 2px 0 0; }
.head .tools { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { text-decoration: none; font-size: 28px; line-height: 1; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 7px 14px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: #94a3b8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: 13px; }
.btn.block { width: 100%; margin-top: 10px; }
.icon { border: 0; background: none; font: inherit; font-size: 18px; min-width: 40px; min-height: 40px; cursor: pointer; color: var(--muted); }

input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; padding: 8px 10px; min-height: 40px; max-width: 100%; }
input[type=checkbox] { min-height: 0; width: 20px; height: 20px; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field > span { font-size: 13px; color: var(--muted); }
.field small { color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.check { display: flex; gap: 10px; align-items: center; padding: 5px 0; }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label { display: flex; align-items: center; gap: 3px; }
.grid2 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 0 14px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: var(--ink); }
.tile b { display: block; font-size: 32px; font-weight: 600; line-height: 1.2; }
.tile span { display: block; color: var(--muted); font-size: 13px; }
.tile small { display: block; color: var(--muted); font-size: 12px; min-height: 1.2em; }
.tile:hover { border-color: #94a3b8; }
.tile.green b { color: #166534; } .tile.blue b { color: #1e40af; } .tile.orange b { color: #b45309; } .tile.red b { color: #b91c1c; } .tile.violet b { color: #5b21b6; }
.dash { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.sechead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; min-height: 32px; }
.sechead h2 { margin: 0 auto 0 0; }
.tasks { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.row.task { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 8px 8px 14px; gap: 12px; }
.row.task:last-child { border-bottom: 1px solid var(--line); }
.tmid { flex: 1; min-width: 0; }
.tmid .main { width: 100%; padding: 0; }
.tmeta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tmeta:empty { display: none; }
.tcust { font-size: 13px; text-decoration: none; }
.due { text-align: right; font-size: 13px; min-width: 96px; }
.due b { display: block; font-weight: 600; }
.due span { display: block; font-size: 12px; }
.due.late, .due.late span { color: var(--danger); } .due.today, .due.today span { color: #b45309; } .due.muted { color: var(--muted); }
.badge.blue { background: #dbeafe; color: #1e40af; }
#main .main span.gap, .gap { color: var(--danger); font-size: 12px; }
.chip.on { border-color: var(--accent); background: #eff6ff; max-width: none; }
.sugg { border-color: #c4b5fd; } .sugg h2 { color: #5b21b6; } .sugg .actions { margin: 6px 0; }
dl { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 4px 10px; margin: 0; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; overflow-wrap: anywhere; }

.list, .plainlist, .timeline { list-style: none; margin: 0; padding: 0; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card .list { border: 0; }
.row { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: left; background: none; border: 0; font: inherit; color: inherit; text-decoration: none; padding: 4px 0; cursor: pointer; }
#main .main span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.main span.late { color: var(--danger) !important; }
.task.done b { text-decoration: line-through; color: var(--muted); }
.frozen { opacity: .65; }
.plainlist li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.badge { display: inline-block; border-radius: 10px; background: #e2e8f0; padding: 1px 9px; font-size: 12px; white-space: nowrap; }
.badge.green { background: #dcfce7; color: #166534; } .badge.orange { background: #ffedd5; color: #9a3412; }
.chip { display: inline-block; border: 1px solid var(--line); background: #f8fafc; border-radius: 12px; padding: 3px 10px; font: inherit; font-size: 12px; text-decoration: none; color: var(--ink); max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.timeline li { background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.timeline .meta { font-size: 13px; color: var(--muted); }
.timeline .main { width: 100%; }
.empty { color: var(--muted); padding: 18px; text-align: center; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.filters input { flex: 1 1 260px; }
.filters select.on { border-color: var(--accent); background: #eff6ff; }
.count { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: 12px; color: var(--muted); }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: #f1f5f9; }
.phone { display: none; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.conflict span { color: var(--muted); }
.msg { overflow-wrap: anywhere; }
.err { color: var(--danger); min-height: 1.2em; }

#dialog .scrim { position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(15, 23, 42, .45); z-index: 20; }
#dialog .sheet { position: fixed; z-index: 21; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(460px, 94vw); max-height: 90vh; overflow: auto; background: #fff; border-radius: 14px; padding: 18px 20px 0; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
#dialog .sheet.wide { width: min(640px, 94vw); }
#dialog .acts { position: sticky; bottom: 0; background: #fff; display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 10px 0 16px; }
#dialog .acts .danger { margin-right: auto; }
.preview { max-width: 100%; max-height: 55vh; display: block; margin: 0 auto 8px; }
#toast { position: fixed; left: 50%; bottom: calc(76px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 92vw; }
#toast.show { opacity: .96; }

#gate { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 40px; }
.gatebox { width: min(520px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.gatebox > img { width: 56px; height: 56px; display: block; margin: 0 auto 8px; }
.gatebox h1 { text-align: center; margin-bottom: 16px; }

/* Angebote und Belege */
.offers { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.offer { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.offer .btn { align-self: flex-start; }
.offermain { color: inherit; text-decoration: none; display: block; flex: 1; }
.offerhead { display: flex; align-items: center; gap: 8px; }
.offerhead b { margin-right: auto; min-width: 0; overflow-wrap: anywhere; }
.badge.st-offen { background: #dbeafe; color: #1e40af; } .badge.st-auftrag { background: #ffedd5; color: #9a3412; } .badge.st-geliefert { background: #ede9fe; color: #5b21b6; }
.badge.st-berechnet { background: #fef3c7; color: #92400e; } .badge.st-bezahlt { background: #dcfce7; color: #166534; } .badge.st-abgelehnt { background: #fee2e2; color: #b91c1c; }
.steps { display: flex; list-style: none; margin: 10px 0 6px; padding: 0; counter-reset: s; }
.steps li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); min-width: 0; }
.steps li::before { content: ''; position: absolute; top: 11px; right: 50%; width: 100%; height: 3px; background: #e2e8f0; }
.steps li:first-child::before { display: none; }
.steps li.done::before { background: #16a34a; }
.steps i { position: relative; z-index: 1; width: 25px; height: 25px; border-radius: 50%; background: #fff; border: 2px solid #cbd5e1; font-style: normal; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.steps li.done i { background: #16a34a; border-color: #16a34a; color: #fff; }
.steps li.done span { color: var(--ink); font-weight: 600; }
.steps.off { opacity: .45; }
.head + .steps { max-width: 640px; margin-bottom: 16px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 12px; }
.bpos { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; }
.bpos.aus .bbody { opacity: .5; }
.bbody { flex: 1; min-width: 0; }
.bbody textarea { width: 100%; resize: vertical; }
.bnums { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: flex-end; margin-top: 6px; }
.bnums label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); }
.bnums input { width: 110px; }
.bgp { margin-left: auto; font-size: 13px; }
.bsum { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 3px 24px; margin-top: 12px; text-align: right; }
.bsum .big { font-size: 17px; font-weight: 600; }

@media (max-width: 800px) {
  #nav { top: auto; right: 0; width: auto; flex-direction: row; padding: 0 0 env(safe-area-inset-bottom); }
  #nav .brand, #nav .grow, #nav .who { display: none; }
  #nav a { flex: 1; flex-direction: column; gap: 0; padding: 7px 2px; font-size: 11px; position: relative; }
  #nav a.on { box-shadow: inset 0 3px 0 var(--accent); }
  #nav a b { position: absolute; top: 3px; right: 12%; }
  #nav .chiprow { position: fixed; top: calc(6px + env(safe-area-inset-top)); right: 8px; padding: 0; flex: none; z-index: 6; }
  #main { margin-left: 0; padding: calc(34px + env(safe-area-inset-top)) 12px calc(90px + env(safe-area-inset-bottom)); }
  #aufnahmeWrap { left: 0; bottom: calc(54px + env(safe-area-inset-bottom)); padding-top: calc(30px + env(safe-area-inset-top)); }
  #aufnahmeBar { padding-top: 6px; }
  .two, .dash, .offers { grid-template-columns: 1fr; }
  #nav a { font-size: 10px; }
  .row.task { flex-wrap: wrap; gap: 6px 10px; }
  .tmid { flex: 1 1 calc(100% - 40px); }
  .due { text-align: left; margin-left: 30px; margin-right: auto; }
  .due b, .due span { display: inline; margin-right: 6px; }
  .desk { display: none; }
  .phone { display: block; }
  .filters select { flex: 1 1 140px; }
  .grid2 { grid-template-columns: 1fr 1fr; }
}
