/* WSR Werkstatt-App */
:root {
  --petrol: #006E81;
  --petrol-dark: #00586a;
  --petrol-tint: #e3f0f2;
  --espresso: #302A27;
  --leinen: #F9F6F4;
  --papier: #ffffff;
  --text: #1A1A18;
  --text-2: #5d5753;
  --linie: #DDD8D5;
  --signal: #E8A33D;
  --signal-tint: #fbefd9;
  --rot: #b3261e;
  --rot-tint: #f9e4e2;
  --ok: #2e7d4f;
  --radius: 10px;
  --tap: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--leinen);
  font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.45rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--petrol); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

.boot { padding: 40px 20px; text-align: center; color: var(--text-2); }

/* ---------- Grundgeruest ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: var(--espresso); color: #fff;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  min-height: 56px;
}
.top .brand { font-weight: 800; font-size: 1.05rem; letter-spacing: .01em; white-space: nowrap; }
.top .brand span { color: var(--signal); }
.top nav { display: none; gap: 4px; margin-left: 12px; }
.top nav a {
  color: #e9e4e0; text-decoration: none; padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.top nav a[aria-current="page"] { background: rgba(255,255,255,.12); color: #fff; }
.top .who {
  margin-left: auto; background: none; border: 1px solid rgba(255,255,255,.3); color: #fff;
  border-radius: 999px; padding: 6px 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  max-width: 50vw; overflow: hidden; text-overflow: ellipsis;
}
.top .countdown { font-size: .85rem; color: #cfc7c2; white-space: nowrap; }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(96px + var(--safe-b)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--papier); border-top: 1px solid var(--linie);
  padding-bottom: var(--safe-b);
}
.tabbar a {
  flex: 1; text-align: center; padding: 10px 4px 8px; text-decoration: none; color: var(--text-2);
  font-size: .78rem; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--petrol); }

@media (min-width: 900px) {
  .top nav { display: flex; }
  .tabbar { display: none; }
  main { padding-bottom: 40px; }
}

/* ---------- Bausteine ---------- */
.panel { background: var(--papier); border: 1px solid var(--linie); border-radius: var(--radius); }
.panel + .panel, .section + .section { margin-top: 16px; }
.pad { padding: 16px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.small { font-size: .88rem; }
.right { margin-left: auto; }
.stack > * + * { margin-top: 12px; }
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 20px; border-radius: var(--radius);
  border: 1px solid var(--linie); background: var(--papier); color: var(--text);
  font-weight: 650; cursor: pointer; text-decoration: none; touch-action: manipulation;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--petrol); border-color: var(--petrol); color: #fff; }
.btn.primary:hover { background: var(--petrol-dark); }
.btn.danger { color: var(--rot); border-color: #e7c1bd; }
.btn.ghost { background: none; border-color: transparent; color: var(--petrol); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .92rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn svg { width: 22px; height: 22px; flex: none; }
.iconbtn {
  width: var(--tap); height: var(--tap); flex: none; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); border: 1px solid var(--linie); background: var(--papier); cursor: pointer; color: var(--text);
}
.iconbtn svg { width: 24px; height: 24px; }

label.field { display: block; }
label.field > span { display: block; font-size: .9rem; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--radius);
  border: 1px solid #c9c2be; background: var(--papier); font-size: 1rem;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--petrol); box-shadow: 0 0 0 3px var(--petrol-tint); }
.hint { font-size: .85rem; color: var(--text-2); margin-top: 6px; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 600px) { .grid2 { grid-template-columns: 1fr 1fr; } }

.badge {
  display: inline-block; font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--petrol-tint); color: var(--petrol-dark); white-space: nowrap;
}
.badge.vorlaeufig { background: var(--signal-tint); color: #8a5a0f; }
.badge.abgeschlossen, .badge.archiviert { background: #ece8e5; color: var(--text-2); }
.badge.freigegeben { background: #e2efe6; color: var(--ok); }

.seg { display: inline-flex; background: #ece8e5; border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 8px 16px; border-radius: 8px; font-weight: 650; color: var(--text-2);
  min-height: 42px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--papier); color: var(--text); box-shadow: 0 1px 2px rgba(48,42,39,.15); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 8px 16px; border-radius: 999px; border: 1px solid #c9c2be; background: var(--papier);
  font-weight: 600; cursor: pointer; text-align: left;
}
.chip[aria-pressed="true"] { background: var(--petrol); border-color: var(--petrol); color: #fff; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-top: 1px solid var(--linie); }
.list > li:first-child { border-top: 0; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; min-height: 64px;
  background: none; border: 0; text-align: left; cursor: pointer; color: inherit; text-decoration: none;
}
.item:hover { background: #fbfaf9; }
.item .t { font-weight: 650; }
.item .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.item .tags:empty { display: none; }
.item .s { font-size: .88rem; color: var(--text-2); }
.item .dur { font-weight: 750; font-size: 1.1rem; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--text-2); }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  background: var(--espresso); color: #fff; padding: 12px 18px; border-radius: var(--radius);
  z-index: 60; max-width: calc(100vw - 32px); font-weight: 600; box-shadow: 0 6px 20px rgba(48,42,39,.25);
}
.toast.err { background: var(--rot); }

/* ---------- Sheet (Dialog von unten) ---------- */
.sheet-bg {
  position: fixed; inset: 0; background: rgba(48,42,39,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--leinen); width: 100%; max-width: 640px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px 16px calc(20px + var(--safe-b));
  animation: up .18s ease-out;
}
@media (min-width: 700px) {
  .sheet-bg { align-items: center; }
  .sheet { border-radius: 16px; max-height: 86vh; }
}
@keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
.sheet .sheet-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet .sheet-foot {
  display: flex; gap: 10px; margin: 20px -16px calc(-20px - var(--safe-b)); padding: 12px 16px calc(14px + var(--safe-b));
  position: sticky; bottom: calc(-20px - var(--safe-b)); background: var(--leinen); border-top: 1px solid var(--linie);
}
.sheet .sheet-foot .btn { flex: 1; }

/* ---------- Freischaltung und Anmeldung ---------- */
.gate { max-width: 460px; margin: 6vh auto 0; }
.gate h1 { margin-bottom: 8px; }
.gate .lead { color: var(--text-2); margin-bottom: 20px; }
.code-input { font-size: 1.6rem; letter-spacing: .12em; text-align: center; text-transform: uppercase; font-weight: 700; }
.people { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 18px; }
.person {
  min-height: 96px; border-radius: var(--radius); border: 1px solid var(--linie); background: var(--papier);
  font-size: 1.15rem; font-weight: 700; cursor: pointer; padding: 12px; display: flex; flex-direction: column;
  align-items: flex-start; justify-content: space-between; text-align: left;
}
.person .ini {
  width: 40px; height: 40px; border-radius: 50%; background: var(--petrol); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1rem;
}
.pin-dots { display: flex; gap: 14px; justify-content: center; margin: 22px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--espresso); }
.pin-dots i.on { background: var(--espresso); }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 340px; margin: 0 auto; }
.pad-grid button {
  height: 68px; border-radius: var(--radius); border: 1px solid var(--linie); background: var(--papier);
  font-size: 1.6rem; font-weight: 700; cursor: pointer; touch-action: manipulation;
}
.pad-grid button.fn { font-size: 1rem; font-weight: 650; color: var(--text-2); }
.pad-grid button:active { background: var(--petrol-tint); }

/* ---------- Tagesansicht ---------- */
.daynav { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.daynav .date {
  flex: 1; min-height: var(--tap); border: 1px solid var(--linie); background: var(--papier);
  border-radius: var(--radius); font-weight: 700; font-size: 1.05rem; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 0 8px; text-align: center;
}
.daynav .date input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.daynav .today-tag { color: var(--petrol); font-weight: 650; font-size: .9rem; margin-left: 6px; }

.times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Der Tagesbalken: Anwesenheit als Strecke, gebuchte Zeit als Segmente, Zielmarke bei der Schwelle */
.daybar { margin-top: 16px; }
.daybar .nums { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; margin-bottom: 10px; }
.daybar .big { font-size: 2rem; font-weight: 800; line-height: 1; }
.daybar .big small { font-size: 1rem; font-weight: 650; color: var(--text-2); margin-left: 4px; }
.daybar .nums .lbl { font-size: .85rem; color: var(--text-2); }
.track {
  position: relative; height: 26px; border-radius: 6px; background: repeating-linear-gradient(135deg, #efebe8 0 8px, #e7e2df 8px 16px);
  overflow: hidden; display: flex;
}
.track .seg { height: 100%; border-right: 2px solid var(--papier); background: var(--petrol); }
.track .seg.neben { background: #7d9fa6; }
.track.low .seg { background: var(--signal); }
.track.low .seg.neben { background: #efc27d; }
.track .goal { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--espresso); }
.daybar .legend { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-2); margin-top: 6px; }
.status-line { margin-top: 10px; padding: 10px 12px; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.status-line.low { background: var(--signal-tint); color: #7a4f0c; }
.status-line.ok { background: var(--petrol-tint); color: var(--petrol-dark); }
.status-line.info { background: #efebe8; color: var(--text-2); }

.fab-wrap { position: sticky; bottom: calc(76px + var(--safe-b)); margin-top: 16px; z-index: 10; }
@media (min-width: 900px) { .fab-wrap { bottom: 16px; } }
.btn.fab { width: 100%; min-height: 60px; font-size: 1.1rem; box-shadow: 0 6px 18px rgba(0,88,106,.28); }

.lock { color: var(--ok); display: inline-flex; vertical-align: -3px; }
.lock svg { width: 16px; height: 16px; }

/* Dauer-Auswahl */
.duration { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 6px 0 14px; }
.duration .val { font-size: 2.4rem; font-weight: 800; min-width: 140px; text-align: center; }
.duration .iconbtn { width: 64px; height: 64px; font-size: 1.8rem; font-weight: 700; }

.step-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.step-title h3 { flex: 1; }
.picked {
  display: flex; align-items: center; gap: 12px; background: var(--papier); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 10px 12px;
}

/* ---------- Auftraege ---------- */
.searchbar { display: flex; gap: 8px; }
.searchbar .input { flex: 1; }
.order-kz {
  display: inline-block; border: 2px solid var(--espresso); border-radius: 5px; padding: 0 6px;
  font-weight: 750; font-size: .85rem; letter-spacing: .03em; background: #fff; white-space: nowrap;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
.kv dt { color: var(--text-2); font-size: .92rem; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.bars .barrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin-top: 10px; }
.bars .bar { grid-column: 1 / -1; height: 8px; background: #efebe8; border-radius: 4px; overflow: hidden; }
.bars .bar i { display: block; height: 100%; background: var(--petrol); }

.photos { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.photos button { padding: 0; border: 0; background: #e7e2df; border-radius: 8px; overflow: hidden; aspect-ratio: 1; cursor: pointer; position: relative; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .cat { position: absolute; left: 4px; bottom: 4px; font-size: .7rem; font-weight: 700; background: rgba(48,42,39,.75); color: #fff; padding: 1px 6px; border-radius: 4px; }
.lightbox { position: fixed; inset: 0; background: rgba(20,17,16,.94); z-index: 70; display: flex; flex-direction: column; }
.lightbox img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.lightbox .bar { display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); color: #fff; align-items: center; }
.upload-progress { height: 6px; background: #e7e2df; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.upload-progress i { display: block; height: 100%; background: var(--petrol); width: 0; transition: width .2s; }

/* ---------- Freigabe und Auswertung ---------- */
.grp-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: #f3efec; border-bottom: 1px solid var(--linie); }
.grp-head:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.check { width: 26px; height: 26px; accent-color: var(--petrol); flex: none; }
.share { font-weight: 750; }
.share.low { color: #9a6410; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--linie); vertical-align: top; }
table.data th { font-size: .85rem; color: var(--text-2); font-weight: 650; border-top: 0; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
.tablewrap { overflow-x: auto; }
.sticky-actions {
  position: sticky; bottom: calc(76px + var(--safe-b)); margin-top: 14px; z-index: 10;
  background: var(--espresso); color: #fff; border-radius: var(--radius); padding: 10px 12px; display: flex; align-items: center; gap: 12px;
}
@media (min-width: 900px) { .sticky-actions { bottom: 16px; } }
.sticky-actions .btn { min-height: 46px; }

.code-show { font-size: 2rem; font-weight: 800; letter-spacing: .14em; text-align: center; padding: 18px; background: var(--papier); border: 2px dashed var(--petrol); border-radius: var(--radius); margin: 12px 0; }

.ocr-status { display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--petrol-tint); border-radius: var(--radius); margin-top: 10px; font-weight: 600; }
.spinner { width: 20px; height: 20px; border: 3px solid var(--petrol); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
