/* Werkstatt · Maschinenzeit – mobil zuerst, hell/dunkel automatisch */
:root {
  --navy: #172d40; --navy-2: #23465f; --wood: #8a5a2b; --wood-2: #a8733e;
  --bg: #f3f1ec; --surface: #ffffff; --surface-2: #f7f5f0; --line: #e2ddd3;
  --text: #1d2a35; --muted: #6b7680; --ok: #2f7d4f; --ok-bg: #e5f3ea; --warn: #9a5b00; --warn-bg: #fdf1dc;
  --bad: #a23a33; --bad-bg: #fbe9e7; --focus: rgba(138, 90, 43, .35);
  --radius: 14px; --shadow: 0 6px 22px rgba(23, 45, 64, .08);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a23; --surface: #172530; --surface-2: #1d2e3b; --line: #2b3f4e; --text: #e8eef2; --muted: #9aabb8;
    --ok: #7bd29e; --ok-bg: #173627; --warn: #f2c06d; --warn-bg: #3a2c12; --bad: #ff9c92; --bad-bg: #3b1d1a;
    --shadow: 0 6px 22px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--wood-2); }
.boot { min-height: 80vh; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); }
.boot img { width: 72px; height: 72px; border-radius: 18px; }

/* Kopf */
.top { position: sticky; top: 0; z-index: 5; background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; gap: 12px; }
.top img { width: 36px; height: 36px; border-radius: 9px; background: #fff; }
.top .t { flex: 1; min-width: 0; }
.top strong { display: block; font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top span { font-size: 12px; opacity: .78; }
.top button { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: 10px; padding: 7px 10px; font-size: 13px; }

main { max-width: 980px; margin: 0 auto; padding: 16px 16px 96px; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; box-shadow: 0 -4px 18px rgba(0,0,0,.06); }
.tabs button { flex: 1; border: 0; background: none; padding: 8px 4px; border-radius: 12px; font-size: 13px; font-weight: 650; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button .i { font-size: 20px; line-height: 1; }
.tabs button.on { background: var(--surface-2); color: var(--wood); }
@media (min-width: 760px) {
  .tabs { position: static; max-width: 980px; margin: 16px auto 0; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; padding: 6px; }
  .tabs button { flex-direction: row; justify-content: center; gap: 8px; font-size: 14px; }
  main { padding-bottom: 32px; }
}

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { margin: 0 0 10px; font-size: 18px; }
.card h3 { margin: 16px 0 8px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.btn { appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 15px; cursor: pointer; min-height: 46px; }
.btn.primary { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border: 0; }
.btn.wood { background: linear-gradient(135deg, var(--wood), var(--wood-2)); color: #fff; border: 0; }
.btn.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.btn.big { width: 100%; font-size: 18px; min-height: 60px; border-radius: 16px; }
.btn.link { background: none; border: 0; padding: 6px 0; min-height: 0; color: var(--wood-2); font-weight: 650; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 12px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 11px; padding: 11px 12px; font-size: 16px; min-height: 46px; }
textarea { min-height: 70px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.msg { padding: 10px 12px; border-radius: 11px; font-size: 14px; margin: 8px 0; }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 99px; padding: 2px 8px; font-size: 11px; font-weight: 750; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge.lock { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.run { background: var(--ok-bg); color: var(--ok); border-color: transparent; }

/* Anmeldung */
.auth { max-width: 420px; margin: 6vh auto 0; }
.auth .logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.auth .logo img { width: 52px; height: 52px; border-radius: 14px; }
.auth h1 { margin: 0; font-size: 22px; }

/* Erfassen */
.running { border: 2px solid var(--ok); }
.running .clock { font-size: 44px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; margin: 2px 0 4px; }
.running .machine { font-size: 20px; font-weight: 800; }
.machines { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 10px; }
.machines button { overflow-wrap: anywhere; hyphens: auto; -webkit-hyphens: auto; text-align: left; border: 1px solid var(--line); background: var(--surface-2); border-radius: 12px; padding: 12px; min-height: 64px; font-weight: 700; cursor: pointer; }
.machines button small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; margin-top: 2px; }
.monthbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.monthbar strong { flex: 1; text-align: center; font-size: 16px; }
.monthbar button { min-width: 46px; }
.day { margin: 14px 0 6px; font-size: 13px; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.entry { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 8px; cursor: pointer; width: 100%; text-align: left; }
.entry .grow strong { display: block; }
.entry .h { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry.del { opacity: .55; text-decoration: line-through; }
.sum { display: flex; justify-content: space-between; font-weight: 800; padding: 10px 2px 0; border-top: 1px solid var(--line); margin-top: 6px; }

/* Übersicht */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); font-weight: 650; }
.kpi strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { font-size: 12px; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
td small { display: block; color: var(--muted); font-size: 11px; }
tr.tot td { font-weight: 800; background: var(--surface-2); }
td.name { position: sticky; left: 0; background: var(--surface); font-weight: 700; }
tr.tot td.name { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

/* Dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog::backdrop { background: rgba(10, 20, 30, .55); }
dialog .in { padding: 18px; overflow: auto; max-height: calc(100vh - 40px); }
dialog h2 { margin: 0 0 12px; font-size: 19px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.actions .sp { flex: 1; }
.video { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 3 / 4; max-height: 60vh; margin: 0 auto 12px; }
.video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.video .frame { position: absolute; inset: 18%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 650; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }
.list-admin .item { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-admin .item:last-child { border-bottom: 0; }
.chip-on { color: var(--ok); font-weight: 700; }
.chip-off { color: var(--bad); font-weight: 700; }
pre.invite { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font: 14px/1.45 inherit; }
