/* Werkstatt-Entwürfe – shared styles. Light by default, dark via system or toggle. */
:root {
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-2: #f8f8f6;
  --line: #e2e1dc;
  --text: #1d1d1b;
  --muted: #6b6a64;
  --accent: #ff6600;
  --accent-ink: #b84800;
  --accent-soft: #fff1e6;
  --danger: #c62828;
  --danger-soft: #fdecea;
  --warn: #b26a00;
  --warn-soft: #fff6dd;
  --ok: #2e7d32;
  --ok-soft: #e8f5e9;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141413; --surface: #1d1d1b; --surface-2: #242422; --line: #34332f;
    --text: #f1f0ea; --muted: #a3a29b; --accent: #ff7a1f; --accent-ink: #ffb07a; --accent-soft: #3a2414;
    --danger: #ff6b60; --danger-soft: #3b1714; --warn: #f0b44c; --warn-soft: #362a10;
    --ok: #6cc070; --ok-soft: #16301a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141413; --surface: #1d1d1b; --surface-2: #242422; --line: #34332f;
  --text: #f1f0ea; --muted: #a3a29b; --accent: #ff7a1f; --accent-ink: #ffb07a; --accent-soft: #3a2414;
  --danger: #ff6b60; --danger-soft: #3b1714; --warn: #f0b44c; --warn-soft: #362a10;
  --ok: #6cc070; --ok-soft: #16301a; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }

/* Banner + top bar */
.banner {
  background: repeating-linear-gradient(-45deg, var(--accent) 0 14px, #e85d00 14px 28px);
  color: #fff; text-align: center; font-weight: 600; font-size: .8rem; letter-spacing: .04em; padding: 4px 16px;
}
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; color: var(--text); }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: .8rem; }
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.search { position: relative; flex: 1 1 280px; max-width: 520px; }
.search input {
  width: 100%; padding: 10px 12px 10px 38px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: 60vh; overflow: auto; display: none;
}
.results.open { display: block; }
.result { display: block; width: 100%; text-align: left; border: 0; background: none; color: inherit; font: inherit; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: 0; }
.result:hover, .result:focus { background: var(--accent-soft); outline: none; }
.result .who { font-weight: 600; }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* Buttons, chips */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); border-radius: 8px; padding: 8px 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 38px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { padding: 14px 18px; font-size: 1.05rem; min-height: 52px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.chip.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.chip.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }

/* Layout */
.page { padding: 16px; max-width: 1600px; margin: 0 auto; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* Counters */
.counters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.counter { flex: 0 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; min-width: 110px; }
.counter b { display: block; font-size: 1.4rem; }
.counter span { font-size: .78rem; color: var(--muted); }
.counter.alert { border-color: var(--danger); }
.counter.alert b { color: var(--danger); }

/* Board */
.board-wrap { overflow-x: auto; border-radius: var(--radius); }
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; min-width: min-content; padding-bottom: 8px; }
.column { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 160px; }
.column h3 { display: flex; justify-content: space-between; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.card {
  display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--line);
  border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: 0 1px 1px rgba(0,0,0,.03);
}
.card:hover { border-color: var(--accent); border-left-color: var(--accent); }
.card.overdue { border-left-color: var(--danger); }
.card .model { font-weight: 700; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .82rem; color: var(--muted); margin-top: 4px; }
.card .due { font-size: .82rem; margin-top: 6px; }
.card.overdue .due { color: var(--danger); font-weight: 700; }
.card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.card.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: var(--surface); } }
@media (prefers-reduced-motion: reduce) { .card.flash { animation: none; } }

/* Side sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; display: none; }
.sheet-backdrop.open { display: block; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); z-index: 41;
  box-shadow: var(--shadow); transform: translateX(100%); transition: transform .2s ease; display: flex; flex-direction: column;
}
.sheet.open { transform: none; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
.sheet header { display: flex; align-items: flex-start; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.sheet header h2 { margin: 0; }
.sheet .body { overflow: auto; padding: 16px; flex: 1; }
.sheet section + section { margin-top: 18px; }
.sheet h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
.status-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.status-buttons .btn.current { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.history { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--line); }
.history li { position: relative; padding: 0 0 10px 14px; }
.history li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.history .when { font-size: .8rem; color: var(--muted); }
.notice { border-radius: 8px; padding: 10px 12px; background: var(--warn-soft); color: var(--text); border: 1px solid transparent; }
.notice.danger { background: var(--danger-soft); }
.notice.ok { background: var(--ok-soft); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check.done span { text-decoration: line-through; color: var(--muted); }
.std-jobs { display: flex; flex-wrap: wrap; gap: 6px; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabpanel[hidden] { display: none; }

/* Start page cards */
.choice { display: block; text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.choice:hover { border-color: var(--accent); }
.choice .tag { display: inline-block; font-weight: 800; color: #fff; background: var(--accent); border-radius: 8px; padding: 2px 10px; margin-bottom: 10px; }
.choice ul { margin: 10px 0 0; padding-left: 18px; }

/* Plan board (B) */
.plan { display: grid; grid-template-columns: 110px repeat(6, minmax(150px, 1fr)); gap: 6px; min-width: 1000px; }
.plan .head { font-size: .8rem; font-weight: 700; color: var(--muted); padding: 6px; }
.plan .head.today { color: var(--accent-ink); }
.plan .who { font-weight: 700; padding: 8px 6px; }
.plan .cell { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px; min-height: 96px; }
.plan .cell.away { background: repeating-linear-gradient(45deg, var(--surface-2) 0 8px, var(--line) 8px 9px); color: var(--muted); display: grid; place-items: center; text-align: center; font-size: .8rem; }
.plan .block { display: block; width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 6px; padding: 4px 6px; margin-bottom: 4px; font-size: .8rem; }
.load { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-bottom: 6px; }
.load i { display: block; height: 100%; background: var(--ok); }
.load.mid i { background: var(--warn); }
.load.high i { background: var(--danger); }
.load-label { font-size: .72rem; color: var(--muted); margin-bottom: 4px; }

/* Signature */
.signature { width: 100%; height: 160px; border: 2px dashed var(--line); border-radius: 8px; background: var(--surface-2); touch-action: none; display: block; }

/* Work card (tablet) */
.workcard { max-width: 760px; }
.timer { font-size: 2rem; font-variant-numeric: tabular-nums; font-weight: 700; }

/* Questions page */
.qa { counter-reset: q; list-style: none; padding: 0; margin: 0; }
.qa li { counter-increment: q; padding: 12px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.qa li::before { content: counter(q) ". "; font-weight: 700; }
.qa .lines { margin-top: 8px; height: 54px; background: repeating-linear-gradient(transparent 0 26px, var(--line) 26px 27px); }
.boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 6px 16px; margin-top: 8px; }
.box::before { content: "☐ "; font-size: 1.1rem; }

@media (max-width: 640px) {
  .page { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .brand small { display: none; }
  dl.facts { grid-template-columns: 1fr; gap: 0 0; }
  dl.facts dt { margin-top: 8px; }
  .hide-sm { display: none !important; }
  .board-wrap { scroll-snap-type: x mandatory; }
  .board { grid-auto-columns: 82vw; }
  .column { scroll-snap-align: start; }
}

@media print {
  .banner { background: none; color: #000; border-bottom: 1px solid #000; }
  .topbar, .no-print, .tabs { display: none !important; }
  body { background: #fff; color: #000; }
  .panel { border: 0; padding: 0; }
  .sheet, .sheet-backdrop { display: none !important; }
}

/* Dialogs */
.dlg { max-width: 600px; width: calc(100% - 32px); max-height: calc(100dvh - 32px); overflow: auto; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.dlg::backdrop { background: rgba(0, 0, 0, .45); }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
