/* ===========================================================================
   Bausteine der Oberfläche. Nur Tokens aus tokens.css (§17.11, §18).
   Aufbau folgt mockups/index.html.
   =========================================================================== */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    background: var(--bg-app);
    color: var(--text-main);
    -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4 { margin: 0; }

button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* Ein <select> ohne eigene Regeln sieht aus wie das Betriebssystem, nicht wie
   diese Anwendung - und das fiel bisher überall auf, wo eines ausserhalb von
   .field steht (Projektwahl, Auftragsfilter, Versandprotokoll). Deshalb hier
   einmal zentral, mit eigenem Pfeil statt des Systempfeils. */
select {
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 30px 7px 10px;
    background-color: var(--bg-canvas);
    color: var(--text-main);
    /* Der Pfeil als Grafik im Hintergrund: currentColor geht in einem
       data:-URI nicht, deshalb steht die Farbe zweimal - hell und dunkel. */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%236b7590' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 11px 8px;
    cursor: pointer;
    max-width: 100%;
}
select:hover { border-color: var(--accent); }
select:disabled { opacity: .6; cursor: not-allowed; }

/* Dunkel nur auf ausdrückliche Wahl - die Systemeinstellung zählt nicht
   (theme.js, Voreinstellung hell). */
[data-theme="dark"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%2393a0c4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Die aufgeklappte Liste malt der Browser selbst; einfärben lässt sie sich
   nur über color-scheme (tokens.css). Was hier geht, ist die Lesbarkeit der
   einzelnen Zeilen. */
option { background: var(--bg-panel); color: var(--text-main); }
option:disabled { color: var(--text-muted); }
input[type=checkbox], input[type=radio], input[type=range] { accent-color: var(--blue); }

a { color: var(--blue); }

/* Tastaturbedienung muss sichtbar sein (§11 Barrierefreiheit). */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* [hidden] muss staerker sein als jede Layoutregel: sonst zeigt sich ein
   ausgeblendetes .field trotzdem, weil display:flex den Vorrang hat. */
[hidden] { display: none !important; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Sprungmarke zum Inhalt – erstes fokussierbares Element der Seite. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--accent);
    color: var(--accent-contrast);
    padding: 10px 16px;
    border-radius: 0 0 8px 0;
    font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- Buttons */

.btn {
    border: 1px solid var(--border);
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 7px 12px;
    color: var(--text-main);
    font-weight: 600;
    font-size: 13px;
}
.btn:hover:not(:disabled) { filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary { background: var(--header-btn); border-color: var(--header-btn-border); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--header-btn-hover); filter: none; }

/* Orange bleibt den hervorgehobenen Vor-Ort-Aktionen vorbehalten (§18). */
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.accent:hover:not(:disabled) { filter: brightness(1.05); }

.btn.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 6px; }
.btn.block { width: 100%; justify-content: center; }

.tool-btn {
    background: var(--bg-canvas);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
}
.tool-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* ------------------------------------------------------------ Hilfsklassen */

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.spacer { flex: 1; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}
.tag.none { background: var(--status-none); }
.tag.planned { background: var(--status-planned); }
.tag.in_progress { background: var(--status-in-progress); color: var(--accent-contrast); }
.tag.done { background: var(--status-done); }
.tag.problem, .tag.blocked { background: var(--status-problem); }
.tag.cancelled { background: var(--status-none); }

.pill {
    font-size: 11px;
    background: var(--bg-canvas);
    padding: 2px 7px;
    border-radius: 999px;
    color: var(--text-muted);
}

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.banner {
    background: var(--warn-bg);
    border: 1px solid var(--warn-border);
    color: var(--warn-text);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12.5px;
}
.banner.error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.banner.ok { background: var(--success-bg); border-color: var(--status-done); color: var(--success-text); }

/* ----------------------------------------------------------------- Topbar */

.topbar {
    background: linear-gradient(180deg, var(--header-bg), var(--header-bg-2));
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 18px;
    height: 58px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.brand-badge {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--accent-contrast);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    flex: none;
}
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--header-sub); }

.topbar nav { display: flex; gap: 6px; }
.topbar nav a,
.topbar .hbtn {
    background: var(--header-btn);
    border: 1px solid var(--header-btn-border);
    color: #fff;
    padding: 7px 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.topbar nav a:hover, .topbar .hbtn:hover { background: var(--header-btn-hover); }
.topbar nav a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.topbar nav a.active .pill { background: rgba(0, 0, 0, .12); color: var(--accent-contrast); }
.topbar .pill { background: rgba(255, 255, 255, .18); color: #fff; }

.topbar .presence { display: flex; margin-left: auto; align-items: center; gap: 10px; }
.hdivider { width: 1px; height: 22px; background: var(--header-btn-border); }

.avatars { display: flex; }
.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid var(--header-bg);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    color: #fff;
    margin-left: -6px;
    flex: none;
}
.avatar.me {
    background: var(--accent);
    color: var(--accent-contrast);
    width: 32px; height: 32px;
    margin-left: 6px;
    border: 0;
}

/* --------------------------------------------------------------- Struktur */

.app { display: flex; flex-direction: column; height: 100vh; }

/* Der Bereichsinhalt bekommt den Rest der Höhe; min-height:0 ist nötig, damit
   ein scrollender oder zoomender Kindbereich (der Plan) nicht die Seite
   auseinanderdrückt. */
#viewRoot { flex: 1; display: flex; min-height: 0; }
#viewRoot:focus { outline: none; }

.subnav {
    display: flex; gap: 6px; flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.subnav button {
    background: var(--bg-canvas);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    font-weight: 600;
    font-size: 13px;
}
.subnav button.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.toolbar {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    padding: 10px 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
}
.toolbar .sep { width: 1px; height: 24px; background: var(--border); }

.sidebar {
    width: 360px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border);
    overflow: auto;
    display: flex;
    flex-direction: column;
    flex: none;
}
.sidebar .sec { padding: 14px 16px; border-bottom: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.content { flex: 1; overflow: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }

/* --------------------------------------------------------------- Formular */

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.field input, .field textarea {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    width: 100%;
    background: var(--bg-canvas);
    color: var(--text-main);
}
/* select bringt seine Gestaltung schon mit (siehe oben); im Formular
   braucht es nur die volle Breite. */
.field select { width: 100%; }
.field textarea { min-height: 80px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--text-muted); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger-border); }
.field .error { font-size: 11.5px; color: var(--danger-text); }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- Tabellen */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr.click { cursor: pointer; }
tr.click:hover td, tr.click:focus-within td { background: var(--bg-canvas); }

.table-wrap { overflow-x: auto; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 10px; font-size: 13px; margin: 0; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-muted);
}

/* ----------------------------------------------------------------- Anmeldung */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-canvas);
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 20px 20px;
}
.login-card {
    width: min(420px, 100%);
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.login-head {
    background: linear-gradient(180deg, var(--header-bg), var(--header-bg-2));
    color: #fff;
    padding: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}
.login-body { padding: 20px; }
.login-foot {
    padding: 12px 20px 20px;
    font-size: 12px;
    color: var(--text-muted);
}
.dev-accounts {
    margin-top: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
}
.dev-accounts button {
    background: none;
    border: 0;
    color: var(--blue);
    padding: 0;
    font-size: 12px;
    text-decoration: underline;
}

/* ------------------------------------------------------------------ Dialog */

.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 25, .45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 16px;
}
.modal-bg.open { display: flex; }
.modal {
    background: var(--bg-panel);
    color: var(--text-main);
    border-radius: 14px;
    width: min(920px, 100%);
    max-height: 92vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal .mb { padding: 18px; }
.modal .mf { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

/* ----------------------------------------------------------------- Hinweise */

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 32px));
}
.toast {
    background: #111a2e;
    color: #fff;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: var(--shadow);
}
.toast.error { background: var(--status-problem); }
.toast.ok { background: var(--status-done); }

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

@media (max-width: 900px) {
    .sidebar { width: 300px; }
    .brand-sub { display: none; }
}

/* ------------------------------------------------------------- Standplan */

/* Arbeitsfläche mit Punktraster, 20 px (§18). */
.plan-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    background: var(--bg-canvas);
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: 20px 20px;
    cursor: grab;
    touch-action: none;   /* Pinch und Ziehen gehören dem Plan, nicht der Seite */
}

.plan-svg {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
    outline: none;
}

.plan-svg:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.plan-search { min-width: 240px; }

.zoom-controls {
    position: absolute;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: stretch;
}

.zoom-controls .zoom-label {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 11.5px;
    color: var(--text-muted);
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.zoom-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    color: var(--text-main);
    font-size: 17px;
    line-height: 1;
}
.zoom-btn:hover { background: var(--bg-canvas); }

.layer-panel {
    position: absolute;
    left: 12px;
    bottom: 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 12.5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow);
}
.layer-panel label { display: flex; gap: 8px; align-items: center; cursor: pointer; }

.legend { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); align-items: center; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-dot.status-none { background: var(--status-none); }
.legend-dot.status-planned { background: var(--status-planned); }
.legend-dot.status-in_progress { background: var(--status-in-progress); }
.legend-dot.status-done { background: var(--status-done); }
.legend-dot.status-problem { background: var(--status-problem); }
/* Stand ohne Platz (aus dem Import): gestrichelter Rahmen statt Farbe - er hat noch keinen Status im Plan. */
.legend-dot.unplaced-dot { background: transparent; border: 2px dashed var(--text-muted); width: 8px; height: 8px; }

/* Ebenen aus- und einblenden (US-15). */
.plan-wrap.hide-labels .booth-label,
.plan-wrap.hide-labels .booth-sub { display: none; }
.plan-wrap.hide-status .booth { fill: rgba(150, 160, 180, .12) !important; stroke: var(--status-none) !important; }
.plan-wrap.hide-cursors .cursor-remote { display: none; }
/* US-15: Auch die Staende selbst lassen sich ausblenden - manchmal geht es
   nur um die Halle. */
.plan-wrap.hide-booths .booth-layer { display: none; }

/* ------------------------------------------------------------ Stände (SVG) */

.booth-group { cursor: pointer; outline: none; }
.booth-group .booth { transition: fill-opacity .12s; }
.booth-group:hover .booth { fill-opacity: .3; }
.booth-group:focus-visible .booth { stroke-dasharray: 6 3; }
.booth-group.dimmed { opacity: .25; }

.booth-label {
    font-size: 12px;
    font-weight: 700;
    fill: var(--text-main);
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, .75);
    stroke-width: 3px;
}
.booth-sub {
    font-size: 10px;
    fill: var(--text-muted);
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, .7);
    stroke-width: 3px;
}
[data-theme="dark"] .booth-label { stroke: rgba(10, 18, 38, .8); }
[data-theme="dark"] .booth-sub { stroke: rgba(10, 18, 38, .8); }

/* Automatisch zum Untergrund des Plans gewählt (plan/contrast.js). Hängt nicht
   am Hell/Dunkel der Oberfläche: Der Plan darunter ist in beiden gleich. Die
   doppelte Klasse schlägt die Themenregeln darüber. */
.booth-label.on-light { fill: #1b2440; stroke: rgba(255, 255, 255, .85); }
.booth-sub.on-light { fill: #3d4866; stroke: rgba(255, 255, 255, .85); }
.booth-label.on-dark { fill: #ffffff; stroke: rgba(10, 18, 38, .85); }
.booth-sub.on-dark { fill: #e4e8f2; stroke: rgba(10, 18, 38, .85); }

.booth-highlight { pointer-events: none; }
.highlight-pulse { animation: booth-pulse 1.4s ease-in-out infinite; }
.highlight-badge-text { font-size: 11px; font-weight: 600; fill: var(--accent-contrast); }

@keyframes booth-pulse {
    0%, 100% { opacity: .3; }
    50% { opacity: 1; }
}

/* Wer Bewegung nicht mag, bekommt sie nicht (§11 Barrierefreiheit). */
@media (prefers-reduced-motion: reduce) {
    .highlight-pulse { animation: none; opacity: .9; }
}

/* Teilen (views/share.js) */
.share-dialog { min-width: min(760px, 86vw); }
.share-heading { margin: 14px 0 8px; font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.share-links { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.share-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.share-top { display: flex; align-items: center; gap: 8px; }
.share-url { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.share-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12.5px; }
.share-controls select, .share-controls input[type="date"] { padding: 4px 6px; font-size: 12.5px; }
.share-badge { padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.share-badge.ok { background: var(--success-bg); color: var(--success-text); }
.share-badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.qr-dialog { display: flex; flex-direction: column; align-items: center; gap: 12px; }
/* Immer schwarz auf weiß, auch im dunklen Thema - sonst scannt die Kamera nicht. */
.qr-box { width: min(280px, 70vw); background: #ffffff; padding: 8px; border-radius: 8px; }
.qr-box img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-url { font-size: 11.5px; word-break: break-all; text-align: center; color: var(--text-muted); }

/* Strichcodes scannen (js/scan.js, ADR-0013) */
.banner.warn { background: var(--warn-bg); border-color: var(--status-planned); color: var(--warn-text); }
.scan-hbtn { font-weight: 600; }
.scan-dialog { display: flex; flex-direction: column; gap: 10px; min-width: min(480px, 86vw); }
.scan-form { display: flex; gap: 8px; }
.scan-input { flex: 1; font-size: 18px; letter-spacing: .04em; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.scan-camera { position: relative; border-radius: 10px; overflow: hidden; background: #000; }
.scan-video { display: block; width: 100%; max-height: 50vh; object-fit: cover; }
/* Zielrahmen: wo der Code hingehoert, damit niemand die Kiste suchend schwenkt. */
.scan-aim { position: absolute; inset: 30% 10%; border: 3px solid rgba(255,255,255,.85); border-radius: 8px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
.scan-learn { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.scan-learn-pair { display: flex; flex-direction: column; gap: 6px; }
/* Im Plan: der gescannte Zielstand und der Platz darin (plan/booths.js). */
.scan-pulse { animation: booth-pulse 1.1s ease-in-out infinite; }
.scan-spot { animation: scan-spot 1.1s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes scan-spot { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.6); opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
    .scan-pulse, .scan-spot { animation: none; }
}
.scan-panel { border: 2px solid var(--accent); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.scan-panel .scan-target { display: flex; gap: 8px; align-items: center; }
.scan-panel .scan-target.mine { font-weight: 600; }
.plan-svg.picking, .plan-svg.picking * { cursor: crosshair !important; }

/* Aufbaureihenfolge: Streifenleiste und Fälligkeit (ADR-0015) */
.strips-dialog { min-width: min(820px, 92vw); }
.strips { display: flex; flex-direction: column; gap: 14px; max-height: 60vh; overflow: auto; }
.strip-board { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.strip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.strip {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--border); border-left: 4px solid var(--accent);
    border-radius: 8px; padding: 8px 10px; background: var(--surface); cursor: grab;
}
.strip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.strip.zieht { opacity: .45; }
.strip.ziel { border-top: 3px solid var(--accent); }
.strip.spaet { border-left-color: var(--status-problem); }
.strip.fertig { opacity: .6; border-left-color: var(--status-done); }
.strip-pos { font-size: 18px; font-weight: 700; min-width: 1.6rem; text-align: center; color: var(--text-muted); }
.strip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.strip-zeiten { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.strip-griff { display: flex; flex-direction: column; gap: 3px; }
.danger-pill { background: var(--danger-bg); color: var(--danger-text); }
.pill.faellig.bald { background: var(--warn-bg); color: var(--warn-text); font-weight: 600; }
.pill.faellig.ueberfaellig { background: var(--danger-bg); color: var(--danger-text); font-weight: 600; }
.due-pulse { animation: booth-pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
    .due-pulse { animation: none; }
}

/* Aufbauzeiten: Slots, Wunschzeiten, Ausstellerseite (ADR-0015) */
.slot-liste { display: flex; flex-direction: column; gap: 10px; }
.slot-tag { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.slot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.slot-chip {
    display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
    padding: 4px 9px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; font: inherit; font-size: 12.5px; line-height: 1.25;
}
.slot-chip .slot-last { font-size: 10.5px; color: var(--text-muted); }
.slot-chip.frei { border-color: var(--status-done); }
.slot-chip.teil { border-color: var(--status-in-progress); }
.slot-chip.voll { border-color: var(--status-problem); background: var(--danger-bg); }
.slot-chip.gesperrt { opacity: .55; text-decoration: line-through; }
.import-vorschau { margin: 10px 0; max-height: 40vh; overflow: auto; }
.warn-text { color: var(--warn-text); }

/* Seite des Ausstellers (aufbauzeit.html) */
.zeit-card { max-width: 34rem; }
.zeit-kopf { font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.zeit-slots { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.zeit-slot {
    padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--surface); cursor: pointer; font: inherit;
}
.zeit-slot:hover { border-color: var(--accent); }
.zeit-slot.gewaehlt { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); font-weight: 600; }

/* Markierungen und Kistenzettel (views/orders.js, ADR-0014) */
.flag-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.flag-chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
    background: color-mix(in srgb, var(--flag, #6b7590) 16%, transparent);
    border: 1px solid var(--flag, #6b7590);
    color: var(--text);
}
button.flag-chip { cursor: pointer; font: inherit; font-size: 12.5px; padding: 4px 11px; }
.flag-chip.system { border-style: dashed; }
.flag-remove { background: none; border: 0; padding: 0 2px; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; }
.flag-row { margin: 6px 0; align-items: center; }
.flag-manager { display: flex; flex-direction: column; gap: 6px; }
.flag-manager-row input[type="text"] { flex: 1; }
.flag-picker { display: flex; flex-direction: column; gap: 10px; }
.crate-row { align-items: center; margin: 6px 0; }
.hall-color { width: 36px; height: 32px; padding: 2px; border-radius: 6px; cursor: pointer; }
.plain-fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin: 10px 0; }
.plain-fieldset legend { font-size: 12.5px; font-weight: 600; padding: 0 4px; }
.plain-fieldset .check { display: flex; align-items: center; gap: 6px; margin: 4px 0; }

/* Externe Techniker (views/techniker.js, anmeldung.html) */
.techniker-liste { margin-top: 4px; }
.techniker-liste table { width: 100%; }
.techniker-liste .share-badge { margin-left: 6px; }
.techniker-liste tr.muted td { opacity: .6; }
.anmeldung-projekt { margin: 0 0 4px; font-size: 16px; font-weight: 600; }

/* Beim Drucken des Anmelde-QR bleibt nur der Code auf dem Papier - ein
   Aushang mit Knöpfen und Dialograhmen darum sieht nach Versehen aus. */
@media print {
    body > *:not(.modal-bg) { display: none !important; }
    .modal-bg, .modal { position: static !important; background: none !important; box-shadow: none !important; border: 0 !important; max-height: none !important; }
    .modal .mh button, .modal .mf, .qr-dialog p { display: none !important; }
    .qr-box { width: 70mm; }
}

/* Kontextmenü (ui.js: contextMenu) - Rechtsklick auf einen Stand */
.ctx-menu {
    position: fixed;
    z-index: 70;
    min-width: 210px;
    padding: 6px;
    background: var(--bg-panel);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, .18);
}
.ctx-title {
    padding: 6px 10px 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.ctx-item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.ctx-item:hover,
.ctx-item:focus-visible { background: var(--bg-canvas); outline: none; }
.ctx-item.danger { color: var(--danger-text); }
.ctx-sep { height: 1px; margin: 4px 2px; background: var(--border); }

/* Fortschrittsbalken (ui.js: progressIndicator) - Plan-Export */
.progress-box { margin-top: 14px; }
.progress-box[hidden] { display: none; }
.progress-track {
    position: relative;
    height: 8px;
    background: var(--bg-canvas);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}
.progress-fill {
    width: 0;
    height: 100%;
    background: var(--accent);
    transition: width .25s ease-out;
}
/* Phase ohne messbaren Fortschritt: der Balken steht, eine Welle laeuft drueber. */
.progress-track.busy::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    animation: progress-sweep 1.2s linear infinite;
}
@keyframes progress-sweep {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}
.progress-text { margin-top: 6px; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) {
    .progress-fill { transition: none; }
    .progress-track.busy::after { animation: none; background: rgba(255, 255, 255, .25); }
}

.booth-preview { pointer-events: none; }

/* Standliste in der Seitenleiste */
.booth-list { display: flex; flex-direction: column; gap: 2px; }
.booth-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-main);
    text-align: left;
    font-size: 13px;
}
.booth-list-item:hover { background: var(--bg-canvas); }

/* --------------------------------------------------------------- Produkte */

.product-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    background: var(--bg-canvas);
    object-fit: contain;
    flex: none;
}
.product-thumb.placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

code {
    font-family: Consolas, 'Courier New', monospace;
    font-size: 11.5px;
    background: var(--accent-soft);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--text-main);
}

/* --------------------------------------------------------------- Aufträge */

.orders { flex: 1; display: flex; min-width: 0; min-height: 0; }

.order-list {
    width: 340px;
    flex: none;
    border-right: 1px solid var(--border);
    background: var(--bg-panel);
    overflow: auto;
}

.order-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: 0;
    border-bottom: 1px solid var(--border);
    background: none;
    color: var(--text-main);
    font: inherit;
}
.order-item:hover { background: var(--bg-canvas); }
.order-item.selected { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.order-item-title { font-weight: 600; margin: 2px 0; }

.order-detail {
    flex: 1;
    overflow: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.tasks { display: flex; flex-direction: column; }
.task {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px 6px;
    border-bottom: 1px dashed var(--border);
    cursor: pointer;
}
.task input { width: 18px; height: 18px; flex: none; }
.task.done span { text-decoration: line-through; color: var(--text-muted); }
.task input:disabled { cursor: not-allowed; }

.site-addition {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 4px;
}
.accent-pill { background: var(--accent-soft); color: var(--warn-text); font-weight: 600; }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }

/* US-28: abgelehnte Positionen werden durchgestrichen dargestellt. */
.item-rejected td { text-decoration: line-through; opacity: .6; }
.item-rejected .site-addition { text-decoration: none; }

.product-picker, .item-picker, .assignee-picker {
    max-height: 220px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.product-option {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text-main);
    text-align: left;
    font: inherit;
}
.product-option:hover { background: var(--bg-canvas); }
.product-option.selected { background: var(--accent-soft); font-weight: 600; }

.comments { display: flex; flex-direction: column; gap: 10px; }
.comment {
    padding: 8px 10px;
    border-left: 3px solid var(--border);
    background: var(--bg-canvas);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
}

@media (max-width: 900px) {
    .order-list { width: 260px; }
}

.booth-items { display: flex; flex-direction: column; gap: 8px; }
.booth-item {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}
.booth-item.rejected { text-decoration: line-through; opacity: .6; }

/* Präsenz: wer arbeitet gerade woran (US-51). */
.presence-marker { pointer-events: none; }
.presence-initials { font-size: 10px; font-weight: 700; fill: #fff; }

/* -------------------------------------------------------------------------
   Abnahme: Schaden markieren, unterschreiben, Dokument versenden
   (US-40 bis US-44, US-82). Mockup 06_unterschrift_canvas.
   ------------------------------------------------------------------------- */

.field-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }

.row-actions { white-space: nowrap; text-align: right; }

/* Schrittanzeige des Unterschrifts-Dialogs. */
.steps { display: flex; gap: 8px; align-items: center; }
.steps span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-canvas);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
}
.steps span.on { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }

/* --- Schadensmarkierung ------------------------------------------------- */

.damage-marker { display: flex; flex-direction: column; }

.damage-image {
    position: relative;
    width: 100%;
    max-width: 420px;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-canvas);
    touch-action: manipulation;
    cursor: crosshair;
}
.damage-image.readonly { cursor: default; max-width: 260px; margin-top: 8px; }

.damage-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* US-32: ohne Produktbild ein Umriss mit dem Kategorie-Symbol. */
.damage-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 12px;
    border: 2px dashed var(--border);
    border-radius: 8px;
}
.damage-symbol { font-size: 44px; line-height: 1; }

.damage-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.damage-mark {
    fill: rgba(217, 58, 63, .18);
    stroke: var(--status-problem);
    stroke-width: 1.2;
    vector-effect: non-scaling-stroke;
}
.damage-point circle { fill: var(--status-problem); stroke: none; }
.damage-point line { stroke: var(--status-problem); stroke-width: 1.4; vector-effect: non-scaling-stroke; }

/* --- Schadensliste ------------------------------------------------------ */

.damage-list { display: flex; flex-direction: column; gap: 12px; }
.damage-entry {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}
.damage-entry.open { border-left: 3px solid var(--status-problem); }

.photo-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photo-thumb {
    width: 88px;
    height: 88px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
}

.damage-summary {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--danger-border);
    background: var(--danger-bg);
    border-radius: 8px;
}
.danger-text { color: var(--danger-text); }

/* --- Unterschrift ------------------------------------------------------- */

.signature-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
    margin-top: 12px;
}

.signature-summary {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
    max-height: 60vh;
    overflow: auto;
}
.signature-summary ul { margin: 0; padding-left: 18px; }
.signature-summary li { margin: 2px 0; }

.signature-canvas {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--accent);
    border-radius: 8px;
    background: var(--bg-panel);
    /* Ohne das scrollt das Tablet beim Unterschreiben die Seite. */
    touch-action: none;
    cursor: crosshair;
}

/* --- Auswahl der Bestätigungspunkte ------------------------------------- */

.confirm { display: flex; flex-direction: column; gap: 6px; }
.confirm-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    cursor: pointer;
    font-size: 13px;
}
.confirm-option input { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.confirm-option.warn { border-color: var(--warn-border); background: var(--warn-bg); }
.confirm-option.disabled { opacity: .55; cursor: not-allowed; }

.confirm-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
}

/* --- Dokumente ---------------------------------------------------------- */

.document-list { display: flex; flex-direction: column; gap: 10px; }
.document-entry {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}

.mail-status {
    font-size: 11.5px;
    font-weight: 600;
    border-radius: 999px;
    padding: 2px 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-muted);
}
.mail-status.sent { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.mail-status.queued, .mail-status.sending { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.mail-status.failed, .mail-status.bounced { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }

@media (max-width: 820px) {
    .signature-layout { grid-template-columns: minmax(0, 1fr); }
    .signature-summary { max-height: none; }
    .row-actions { text-align: left; }
}

/* -------------------------------------------------------------------------
   Administration: Dokumenten-Designer, E-Mail, Firmendaten (P4b).
   Mockups 11_admin_dokumenten_designer und 12_admin_email.
   ------------------------------------------------------------------------- */

.tool-btn.sm { padding: 3px 8px; font-size: 12px; }

/* Zwei Spalten: links das Formular, rechts das Protokoll bzw. das Logo. */
.admin-split {
    display: grid;
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

/* Vorlagen | Blöcke | Vorschau */
.designer {
    display: grid;
    grid-template-columns: minmax(220px, 260px) minmax(320px, 1fr) minmax(0, 1.1fr);
    gap: 16px;
    align-items: start;
}

.template-picker { display: flex; flex-direction: column; gap: 6px; }
.template-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    color: var(--text-main);
    font: inherit;
    font-size: 13px;
}
.template-option:hover { border-color: var(--accent); }
.template-option.selected { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.version-list { display: flex; flex-direction: column; gap: 4px; }
.version-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    padding: 6px 8px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 12.5px;
    cursor: pointer;
}
.version-row:hover { background: var(--bg-canvas); }
.version-row.selected { border-color: var(--accent); background: var(--accent-soft); }

.block-list { display: flex; flex-direction: column; gap: 6px; }
.block-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}
.block-row.off { opacity: .55; }
.block-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.block-move { display: flex; flex-direction: column; gap: 2px; flex: none; }
.block-move .tool-btn { padding: 0 6px; line-height: 1.4; }

.block-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-panel);
    font-size: 11.5px;
    cursor: pointer;
}
.chip input { width: 14px !important; height: 14px !important; margin: 0 !important; }

.preview-card { position: sticky; top: 12px; }
.preview-frame {
    width: 100%;
    height: 70vh;
    min-height: 420px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}

.hints { margin-top: 12px; font-size: 12.5px; }
.hints summary { cursor: pointer; color: var(--text-muted); font-weight: 600; }
.hints ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-muted); }
.placeholder-list { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.template-list { display: flex; flex-direction: column; gap: 8px; }
.template-entry {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}
.template-entry.inactive { opacity: .7; }

.logo-box {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
}
.logo-preview { max-height: 120px; max-width: 100%; object-fit: contain; }

@media (max-width: 1200px) {
    .designer { grid-template-columns: minmax(0, 1fr); }
    .preview-card { position: static; }
}
@media (max-width: 900px) {
    .admin-split { grid-template-columns: minmax(0, 1fr); }
}

/* -------------------------------------------------------------------------
   Aenderungshistorie (US-53): aufklappbar, laedt erst beim Oeffnen.
   ------------------------------------------------------------------------- */

.history-card summary {
    cursor: pointer;
    display: flex;
    gap: 6px;
    align-items: baseline;
}
.history-body { margin-top: 10px; }

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.history-entry:last-child { border-bottom: 0; padding-bottom: 0; }

.avatar.sm {
    width: 22px; height: 22px;
    font-size: 9px;
    flex: none;
    /* .avatar ist fuer die Reihe in der Topbar gebaut: negativer
       Rand zum Ueberlappen, Rahmen in der Kopfzeilenfarbe. */
    margin-left: 0;
    border-color: var(--bg-panel);
}

.history-changes {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
}
.history-changes li { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.history-field { color: var(--text-muted); min-width: 110px; }
.history-from { text-decoration: line-through; color: var(--text-muted); }
.history-to { font-weight: 600; }

/* -------------------------------------------------------------------------
   Fotos am Auftrag (US-25) und @-Erwaehnungen im Kommentar (US-26).
   ------------------------------------------------------------------------- */

.photo-upload {
    padding: 10px 12px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
    margin-bottom: 12px;
}

.photo-gallery { min-height: 40px; }
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.photo-tile {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-panel);
}
.photo-tile img {
    display: block;
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: var(--bg-canvas);
}
.photo-tile figcaption {
    padding: 6px 8px;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mention-picker { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.mention-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.mention {
    font-size: 11.5px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--warn-text);
}
.comment.mentions-me { border-left-color: var(--accent); background: var(--accent-soft); }
.mention.me { background: var(--accent); color: var(--accent-contrast); }

/* -------------------------------------------------------------------------
   Offline (US-45): Verbindungszustand und Ausgangskorb.
   ------------------------------------------------------------------------- */

.offline-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid var(--header-btn-border);
    background: var(--header-btn);
    color: #fff;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    margin-right: 8px;
}
.offline-status:hover { background: var(--header-btn-hover); }
.offline-status.offline { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.offline-status.conflict { background: var(--status-problem); border-color: var(--status-problem); color: #fff; }

.outbox-list { display: flex; flex-direction: column; gap: 8px; }
.outbox-entry {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    background: var(--bg-canvas);
    font-size: 13px;
}
.outbox-entry.conflict { border-left-color: var(--status-problem); background: var(--danger-bg); }

/* PDF-Import: Seitenwahl und Vorschau (Erweiterung zu US-10, ADR-0007). */
.pdf-import {
    margin: 4px 0 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-canvas);
}
/* Die Drehknoepfe stehen in einer Reihe mit dem, was sie bewirkt haben. */
.rotate-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.rotate-row .btn.turn {
    /* Ein Pfeil braucht keine Wortbreite, aber eine gleiche Breite wie sein
       Gegenstueck - sonst huepft die Reihe beim Umschalten. */
    min-width: 38px;
    font-size: 16px;
    line-height: 1;
    padding: 6px 10px;
}

.pdf-preview {
    display: block;
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 6px;
    /* Ein Plan auf durchsichtigem Grund waere auf der dunklen Flaeche
       unlesbar - gerendert wird ohnehin auf Weiss. */
    background: #fff;
}

/* ----------------------------------------------------------------- Import (ADR-0018) */

.modal.import-wizard { width: min(1240px, 100%); }
.wizard-steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 14px; counter-reset: schritt; flex-wrap: wrap; }
.wizard-steps li { counter-increment: schritt; padding: 4px 10px; border-radius: 999px; font-size: 12px; color: var(--text-muted); border: 1px solid var(--border); }
.wizard-steps li::before { content: counter(schritt) ". "; }
.wizard-steps li.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }
.wizard-steps li.done { color: var(--text-main); }
.wizard-foot { margin-top: 16px; gap: 8px; align-items: center; }
.import-wizard .check { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.import-raw tr.import-header-row td { font-weight: 600; background: var(--bg-canvas); }
.import-summary { gap: 6px; margin-bottom: 8px; }
.import-summary .import-error { background: var(--status-problem); color: #fff; }
.import-summary .import-new { background: var(--status-planned); color: #fff; }
.import-preview td { vertical-align: top; }
.import-preview tr.import-row-error td { background: var(--warn-bg); }
.import-preview tr.import-row-unchanged td { color: var(--text-muted); }
.import-changes { margin: 4px 0 0; padding-left: 16px; }
.import-conflict { font-weight: 600; }
.import-material .row { margin-bottom: 4px; }

/* -------------------------------------------------------------------------
   Handy (12.11.2026): Bedienung vor Ort, auch in der PM Suite Mobile App.
   Die Grenze 760 px muss zu ui.js istSchmal() passen. Breite Bildschirme
   bleiben unverändert.
   ------------------------------------------------------------------------- */

.nur-schmal { display: none !important; }

@media (max-width: 760px) {
    .nur-schmal { display: inline-flex !important; }
    .nur-breit { display: none !important; }

    /* Höhe der Leiste unten, plus Gestenleiste des Geräts. */
    :root { --unten: calc(60px + env(safe-area-inset-bottom, 0px)); }

    .app { height: 100dvh; padding-bottom: var(--unten); }

    /* Kopfzeile: nur Name und das Nötigste. */
    .topbar { height: 52px; padding: 0 10px; gap: 8px; padding-top: env(safe-area-inset-top, 0px); }
    .brand { min-width: 0; flex: 1; }
    .brand-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar .avatars, .topbar .hdivider, .topbar #themeButton, .topbar .avatar.me { display: none; }
    .topbar .presence { gap: 6px; margin-left: 0; }
    .topbar #accountButton { max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; min-height: 40px; }

    /* Hauptbereiche als Leiste unten - mit dem Daumen erreichbar. */
    .topbar nav {
        position: fixed;
        left: 0; right: 0; bottom: 0;
        z-index: 30;
        height: var(--unten);
        padding: 6px 6px env(safe-area-inset-bottom, 0px);
        gap: 4px;
        background: var(--header-bg);
        border-top: 1px solid var(--header-btn-border);
    }
    .topbar nav a {
        /* block statt inline-flex: Text in einem Flex-Element schrumpft
           nicht unter seine Breite, die Leiste wuerde zu breit. */
        display: block;
        text-align: center;
        line-height: 34px;
        flex: 1 1 0;
        min-width: 0;
        padding: 6px 2px;
        font-size: 12px;
        min-height: 46px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-radius: 10px;
        background: transparent;
        border-color: transparent;
    }

    /* Scannen als großer runder Knopf über der Leiste. */
    .topbar .scan-hbtn {
        position: fixed;
        right: 14px;
        bottom: calc(var(--unten) + 14px);
        z-index: 31;
        min-height: 56px;
        padding: 0 20px;
        border-radius: 28px;
        font-size: 15px;
        background: var(--accent);
        border-color: var(--accent);
        color: var(--accent-contrast);
        box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
    }

    /* Fingergerechte Ziele (mind. 44 px). */
    .btn, .tool-btn, select, .field input, .field textarea, input[type=search], input[type=text] { min-height: 44px; font-size: 16px; }
    .btn.sm { min-height: 40px; }

    /* Werkzeugleisten: eine Zeile, seitlich wischen statt umbrechen. */
    .toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .toolbar::-webkit-scrollbar { display: none; }
    .toolbar > * { flex: none; }
    .toolbar .grow { display: none; }
    .plan-search { min-width: 180px; }

    .content { padding: 12px; }
    .grid2 { grid-template-columns: 1fr; }
    .kv { grid-template-columns: 1fr; gap: 0 10px; }
    .kv dt { margin-top: 6px; }
    table { display: block; overflow-x: auto; }

    /* Dialoge füllen den Bildschirm. */
    .modal-bg { padding: 0; align-items: stretch; }
    .modal { width: 100%; max-height: none; height: 100%; border-radius: 0; }
    .modal .mf { position: sticky; bottom: 0; background: var(--bg-panel); flex-wrap: wrap; }
    .modal .mf .btn { flex: 1 1 auto; }

    /* Aufträge: erst die Liste, nach dem Antippen das Detail. */
    .orders { position: relative; }
    .order-list { width: 100%; border-right: 0; }
    .order-detail { display: none; padding: 12px; }
    .orders.zeige-detail .order-list { display: none; }
    .orders.zeige-detail .order-detail { display: flex; }
    .order-item { padding: 14px; }
    .zurueck-liste { align-self: flex-start; }

    /* Unterschrift: groß genug für einen Finger. */
    .signature-canvas { height: 45vh; min-height: 220px; }

    /* Standplan: Plan über die ganze Breite, Details als Blatt von unten. */
    #viewRoot:has(> .plan-main) { position: relative; }
    .plan-main .plan-wrap { border-left: 0; }
    #viewRoot > .sidebar {
        position: fixed;
        left: 0; right: 0;
        bottom: var(--unten);
        width: auto;
        max-height: 0;
        z-index: 25;
        border-left: 0;
        border-top: 1px solid var(--border);
        border-radius: 14px 14px 0 0;
        box-shadow: 0 -8px 24px rgba(0, 0, 0, .18);
        transition: max-height .2s ease;
    }
    #viewRoot > .sidebar.offen { max-height: 62dvh; }
    .blatt-griff {
        position: fixed;
        left: 14px;
        bottom: calc(var(--unten) + 14px);
        z-index: 31;
        min-height: 48px;
        padding: 0 16px;
        border-radius: 24px;
        border: 1px solid var(--border);
        background: var(--bg-panel);
        color: var(--text-main);
        font-weight: 600;
        align-items: center;
        box-shadow: 0 6px 18px rgba(0, 0, 0, .2);
    }
    #viewRoot:has(> .sidebar.offen) .blatt-griff { bottom: calc(var(--unten) + 62dvh + 10px); }
    .zoom-controls { bottom: calc(14px + 70px); }
    /* Ebenen oben links, damit unten Platz fuer Griff und Scannen bleibt. */
    .layer-panel { top: 10px; bottom: auto; left: 10px; flex-direction: row; flex-wrap: wrap; gap: 4px 10px; max-width: calc(100% - 20px); padding: 6px 8px; }
}

@media (max-width: 760px) and (prefers-reduced-motion: reduce) {
    #viewRoot > .sidebar { transition: none; }
}

/* In der PM Suite Mobile App steht der Name schon in der App-Leiste. */
.in-pm-app .topbar .brand { display: none; }
.in-pm-app .topbar .presence { margin-left: auto; }
