/* TMS Monteur-App – Tablet zuerst (Querformat), funktioniert auch auf dem Handy */
:root {
  --blue: #0B4F8A; --blue-dark: #073763; --blue-soft: #E3EDF7;
  --ink: #14202B; --ink-2: #3A4754; --muted: #5B6875; --line: #DDE3E8; --line-2: #D4DCE3;
  --bg: #F3F5F7; --card: #FFFFFF;
  --orange: #C2410C; --orange-dark: #9A3412; --orange-soft: #FDE7DA;
  --green: #1F7A3E; --green-dark: #17602F; --green-soft: #E6F2EA;
  --purple: #5B3E9E; --purple-soft: #ECE7F7;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 32, 43, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--bg); display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; }
h1 { font-size: 24px; margin: 2px 0 4px; line-height: 1.2; }
h2 { font-size: 19px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 6px 0; }
a { color: var(--blue); }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.pre { white-space: pre-line; }
.eyebrow { font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .03em; }
.row { display: flex; align-items: center; } .row.gap { gap: 10px; } .row.gap-sm { gap: 6px; } .row.wrap { flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* ---------- Kopfleiste ---------- */
.topbar { background: var(--ink); color: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.work-pane > *, .page > * { flex-shrink: 0; }
.table td.num { white-space: nowrap; }
.order-head .row { flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 19px; display: flex; align-items: baseline; gap: 10px; }
.brand span { font-weight: 400; font-size: 14px; color: #B9C6D2; }
.active-pill { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 14px; border-radius: 999px; background: var(--blue); font-size: 14px; }
.active-pill a { color: #fff; text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.active-pill .live-clock { font-family: var(--mono); font-size: 18px; }
.active-pill.s-onsite { background: var(--green); } .active-pill.s-pause { background: #6B7785; } .active-pill.s-return { background: var(--purple); }
.active-pill.idle { background: transparent; border: 1px solid #3A4754; color: #B9C6D2; padding: 6px 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.nav-btn { color: #DCE3EA; text-decoration: none; background: none; border: 0; font: inherit; font-size: 14px; display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border-radius: 10px; cursor: pointer; }
@media (max-width: 1240px) { .nav-btn span { display: none; } .nav-btn { padding: 0 12px; } }
.nav-btn.on { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.sync-pill { display: flex; align-items: center; gap: 6px; font: inherit; font-size: 13px; color: #B9E4C6; background: rgba(31, 122, 62, .25); border: 0; border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; }
.sync-pill.offline { color: #FFD9C2; background: rgba(194, 65, 12, .35); }

/* ---------- Grundbausteine ---------- */
.main { flex: 1; min-height: 0; overflow: auto; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; } .btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-secondary { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-success { background: var(--green); color: #fff; } .btn-success:hover:not(:disabled) { background: var(--green-dark); }
.btn-danger { background: #fff; color: var(--orange-dark); border-color: var(--orange); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-light { background: #fff; color: var(--ink); min-height: 36px; border-radius: 999px; }
.btn-icon { padding: 0; width: 44px; }
.btn-lg { min-height: 54px; font-size: 16px; padding: 0 20px; }
.btn-xl { min-height: 64px; font-size: 18px; width: 100%; border-radius: 14px; }
.btn-record { background: var(--orange); color: #fff; width: 100%; }
.btn-record.recording { background: var(--ink); }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chip-blue { background: var(--blue-soft); color: var(--blue); } .chip-warn { background: var(--orange-soft); color: var(--orange-dark); }
.chip-ok { background: var(--green-soft); color: var(--green-dark); } .chip-grey { background: #EDF1F4; color: var(--ink-2); }
.notice { padding: 10px 14px; border-radius: 10px; display: flex; gap: 8px; align-items: center; }
.notice-warn { background: var(--orange-soft); color: var(--orange-dark); } .notice-ok { background: var(--green-soft); color: var(--green-dark); }
.input { font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; min-height: 46px; width: 100%; }
.input:focus { outline: 2px solid var(--blue); outline-offset: 1px; border-color: var(--blue); }
.input:disabled { background: #F6F8FA; color: var(--ink-2); }
textarea.input { resize: vertical; min-height: 64px; }
.input-lg { font-size: 22px; min-height: 56px; letter-spacing: .06em; } .input-sm { min-height: 38px; padding: 6px 10px; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field.grow { flex: 1; } .w-sm { width: 100px; flex: none; } .w-md { width: 180px; flex: none; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; font-size: 15px; }
.check input { width: 22px; height: 22px; accent-color: var(--green); }
.seg { display: flex; background: #E4E9EE; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); border-radius: 8px; min-height: 38px; padding: 0 14px; cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px 8px; border-bottom: 1px solid #EDF1F4; vertical-align: middle; }
.table td.num { font-family: var(--mono); text-align: right; }
.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 15px; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 12px; } ul.plain li { padding: 6px 0; border-bottom: 1px solid #EDF1F4; }
.status-dot { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status-dot::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.s-travel.status-dot { color: var(--blue); } .s-onsite.status-dot { color: var(--green); } .s-pause.status-dot { color: #6B7785; } .s-return.status-dot { color: var(--purple); }

/* ---------- Start: Koppeln & Anmelden ---------- */
.start { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.start-card { width: min(560px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.brand-lg { font-weight: 800; font-size: 28px; color: var(--blue); display: flex; align-items: baseline; gap: 10px; }
.brand-lg span { font-weight: 500; font-size: 16px; color: var(--muted); }
.user-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.user-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border-radius: 14px; border: 2px solid var(--line-2); background: #fff; font: inherit; font-weight: 600; cursor: pointer; min-height: 110px; }
.user-tile small { color: var(--muted); font-weight: 400; }
.user-tile.on { border-color: var(--blue); background: var(--blue-soft); }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 15px; }
.pin-area { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pin-dots { display: flex; gap: 12px; height: 20px; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--ink-2); }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.pin-pad { display: grid; grid-template-columns: repeat(3, 84px); gap: 10px; }
.pin-key { height: 64px; border-radius: 14px; border: 1px solid var(--line-2); background: #fff; font: inherit; font-size: 24px; font-weight: 600; cursor: pointer; color: var(--ink); }
.pin-key:active { background: var(--blue-soft); }
.pin-ok { background: var(--blue); color: #fff; border-color: var(--blue); font-size: 18px; }
.pin-ok:disabled { opacity: .4; }

/* ---------- Hauptansicht ---------- */
.home { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.list-pane { border-right: 1px solid var(--line); background: #EEF1F4; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.pane-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.pane-head h2 { margin: 0; font-size: 22px; }
.order-list { display: flex; flex-direction: column; gap: 8px; }
.order-item { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; background: #fff; border-radius: 12px; border: 2px solid transparent; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.order-item.on { border-color: var(--blue); }
.order-item.running { box-shadow: inset 4px 0 0 var(--green), var(--shadow); }
.work-pane { overflow: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.placeholder { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); gap: 6px; text-align: center; padding: 24px; }
.back-link { display: none; text-decoration: none; font-weight: 600; min-height: 36px; align-items: center; }
.order-head { display: flex; flex-direction: column; gap: 12px; }
.order-head h1 { font-size: 22px; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.status-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; min-height: 108px; border-radius: 14px; border: 2px solid var(--line-2); background: #fff; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.status-btn .status-label { font-size: 17px; font-weight: 700; line-height: 1.2; }
.status-btn .status-sub { font-size: 13px; color: var(--muted); }
.status-btn:disabled:not(.on) { opacity: .45; cursor: not-allowed; }
.status-btn.on { color: #fff; cursor: default; }
.status-btn.on .status-sub { color: rgba(255, 255, 255, .9); font-family: var(--mono); font-size: 20px; }
.status-btn.s-travel.on { background: var(--blue); border-color: var(--blue); }
.status-btn.s-onsite.on { background: var(--green); border-color: var(--green); }
.status-btn.s-pause.on { background: #6B7785; border-color: #6B7785; }
.status-btn.s-return.on { background: var(--purple); border-color: var(--purple); }
.status-btn.s-travel .icon { color: var(--blue); } .status-btn.s-onsite .icon { color: var(--green); } .status-btn.s-return .icon { color: var(--purple); }
.status-btn.on .icon { color: #fff; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); padding: 0 14px; min-height: 46px; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); }
.tab-body { min-height: 200px; }
.tab-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.report-form { display: flex; flex-direction: column; gap: 10px; }
.notes .note, .note { padding: 10px 0; border-bottom: 1px solid #EDF1F4; }
.note:last-child { border-bottom: 0; }
.note audio { width: 100%; margin-top: 4px; }
.photo-btn { margin-bottom: 14px; cursor: pointer; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.photo { margin: 0; background: #fff; border-radius: 12px; padding: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #DCE3EA; }
.material-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.kpi strong { font-family: var(--mono); font-size: 22px; font-weight: 500; }
.kpi.s-travel { box-shadow: inset 4px 0 0 var(--blue), var(--shadow); } .kpi.s-onsite { box-shadow: inset 4px 0 0 var(--green), var(--shadow); }
.kpi.s-pause { box-shadow: inset 4px 0 0 #6B7785, var(--shadow); } .kpi.s-return { box-shadow: inset 4px 0 0 var(--purple), var(--shadow); }
.work-foot { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding-top: 18px; }

/* ---------- Abschluss ---------- */
.complete { padding: 18px 22px 28px; max-width: 1280px; margin: 0 auto; }
.complete .back-link { display: inline-flex; }
.complete-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.sign-card { display: flex; flex-direction: column; gap: 10px; }
.signature { width: 100%; height: 220px; border: 2px dashed #9AA8B5; border-radius: 12px; background: #FAFBFC; touch-action: none; }
.photo-mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.photo-mini { display: flex; flex-direction: column; gap: 4px; }
.photo-mini img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #DCE3EA; }

/* ---------- Tickets & Verwaltung ---------- */
.page { padding: 18px 22px 28px; display: flex; flex-direction: column; gap: 14px; }
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.ticket { display: flex; flex-direction: column; gap: 8px; }
.ticket h3 { text-transform: none; letter-spacing: 0; color: var(--ink); font-size: 17px; margin: 4px 0 0; }
.ticket.prio-high { box-shadow: inset 4px 0 0 var(--orange), var(--shadow); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.span-2 { grid-column: span 2; }
.code-big { font-size: 40px; text-align: center; letter-spacing: .12em; margin: 10px 0; }

/* ---------- Dialoge & Meldungen ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 32, 43, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); max-height: 90vh; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(520px, calc(100% - 32px)); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 15px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); transition: opacity .4s; }
.toast-ok { background: var(--green-dark); } .toast-error { background: var(--orange-dark); }
.toast.out { opacity: 0; }

/* ---------- Handy / Hochformat ---------- */
@media (max-width: 900px) {
  .home { grid-template-columns: 1fr; }
  .home.has-selection .list-pane { display: none; }
  .home:not(.has-selection) .work-pane { display: none; }
  .back-link { display: inline-flex; }
  .list-pane { border-right: 0; }
  .status-grid, .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tab-grid, .complete-grid, .admin-grid, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .brand span, .nav-btn span, .pill-number { display: none; }
  .topbar { gap: 8px; padding: 8px 12px; }
  .active-pill { order: 3; width: 100%; justify-content: space-between; }
  .top-right { gap: 0; }
  .order-head > .row-between { flex-direction: column; align-items: flex-start; }
  .work-pane, .page, .complete { padding: 12px 16px 20px; }
  .ticket-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; }
}
details { margin-top: 8px; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary { margin-bottom: 10px; color: var(--blue); }

.packlist { margin-bottom: 14px; border-left: 4px solid var(--blue); }
