/* IDL Kundenportal – no build step, no external dependencies (CSP: self only). */

:root {
    --bg: #f5f6f3;
    --surface: #ffffff;
    --surface-2: #f0f2ed;
    --border: #e1e4dc;
    --text: #1c2118;
    --muted: #646b5e;
    --accent: #4d7c0f;
    --accent-strong: #3f6212;
    --accent-soft: #ecf5dc;
    --on-accent: #ffffff;
    --ok: #15803d;
    --ok-soft: #dcfce7;
    --warn: #b45309;
    --warn-soft: #fef3c7;
    --bad: #b91c1c;
    --bad-soft: #fee2e2;
    --chart: #65a30d;
    --shadow: 0 1px 2px rgba(20, 30, 10, .06), 0 1px 3px rgba(20, 30, 10, .04);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 248px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #11140f;
        --surface: #191d16;
        --surface-2: #20251c;
        --border: #2d3328;
        --text: #e8ece3;
        --muted: #9aa392;
        --accent: #84cc16;
        --accent-strong: #a3e635;
        --accent-soft: #24301a;
        --on-accent: #10140c;
        --ok: #4ade80;
        --ok-soft: #14301f;
        --warn: #fbbf24;
        --warn-soft: #3a2c0c;
        --bad: #f87171;
        --bad-soft: #3b1515;
        --chart: #84cc16;
        --shadow: none;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #11140f;
    --surface: #191d16;
    --surface-2: #20251c;
    --border: #2d3328;
    --text: #e8ece3;
    --muted: #9aa392;
    --accent: #84cc16;
    --accent-strong: #a3e635;
    --accent-soft: #24301a;
    --on-accent: #10140c;
    --ok: #4ade80;
    --ok-soft: #14301f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0c;
    --bad: #f87171;
    --bad-soft: #3b1515;
    --chart: #84cc16;
    --shadow: none;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 650; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1rem; font-weight: 600; }
p { margin: .25rem 0 .75rem; }
small, .small { font-size: .82rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .9em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 20px; height: 20px; flex: none; }
.icon.sm { width: 16px; height: 16px; }
.icon.lg { width: 32px; height: 32px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh;
    width: var(--sidebar-w); flex: none;
    display: flex; flex-direction: column; gap: 4px;
    padding: 18px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.brand { display: block; padding: 6px 8px 18px; }
.brand img { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 6px; padding: 4px 6px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: var(--radius-sm);
    color: var(--text); font-weight: 500;
}
.nav-link:hover { background: var(--surface-2); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-strong); }
.nav-link.subtle { color: var(--muted); font-weight: 400; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 12px;
    height: 60px; padding: 0 24px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.customer { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions form { margin: 0; }
.who { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }
.icon-btn.menu-btn { display: none; }
.content { padding: 28px 24px 48px; max-width: 1280px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.scrim { display: none; }

/* ---------- building blocks ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: .2rem 0 0; }
.back { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; margin-bottom: -8px; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; color: var(--text); box-shadow: var(--shadow);
}
a.stat:hover { border-color: var(--accent); text-decoration: none; }
.stat-alert { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.stat-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .85rem; font-weight: 500; }
.stat-value { font-size: 1.85rem; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-value.sm { font-size: 1.4rem; display: block; }
.stat-sub { font-size: .85rem; color: var(--muted); }
.mini-stats { display: flex; gap: 28px; margin-bottom: 12px; }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 2px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap; line-height: 1.6;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.chip { display: inline-block; padding: 1px 8px; margin: 1px 4px 1px 0; border-radius: 6px; background: var(--surface-2); font-size: .8rem; }

/* ---------- buttons & forms ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 38px; padding: 0 16px;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    text-decoration: none !important;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: .88rem; }
.btn-block { width: 100%; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.input {
    width: 100%; min-height: 38px; padding: 7px 11px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit;
}
.input:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 25%, transparent); outline-offset: 0; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: .9rem; font-weight: 500; }
.field.inline { flex-direction: column; }
.field.has-error .input { border-color: var(--bad); }
.field-error { color: var(--bad); font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; white-space: nowrap; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.toolbar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px;
}
.toolbar > label:not(.check) { min-width: 160px; }
.toolbar .grow { flex: 1; }
.search { position: relative; flex: 1; min-width: 220px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { padding-left: 34px; }
.quick { display: flex; gap: 12px; margin-left: auto; font-size: .88rem; align-self: center; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.segmented a { padding: 6px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: -6px -20px 0; padding: 0 12px; flex-wrap: wrap; }
.tabs a { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tabs .tab-filter { margin-left: auto; font-weight: 500; color: var(--accent); }
.tabs + .table-wrap, .tabs + .empty { margin: 0 -20px -18px; }

/* ---------- tables & lists ---------- */
.table-wrap { overflow-x: auto; position: relative; }   /* keeps absolutely placed .sr-only labels inside the scroll box */
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); white-space: nowrap; }
.table th a { color: inherit; }
.table tr:target td { background: var(--accent-soft); }
mark { background: var(--warn-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
[data-live-results].is-loading { opacity: .6; transition: opacity .15s; }
.table th.right, .table td.right { text-align: right; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { background: var(--surface-2); color: var(--text); font-size: .9rem; text-transform: none; letter-spacing: 0; border-top: 1px solid var(--border); border-bottom: 0; }
.row-link { cursor: pointer; }
.card > .table-wrap:only-child .table th:first-child, .card > .table-wrap .table td:first-child { padding-left: 20px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--border); color: var(--text); }
.list li:last-child .list-row, .list li.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); text-decoration: none; border-radius: 6px; }
.list.compact .list-row { padding: 6px 2px; font-size: .92rem; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv-title { font-size: .92rem; font-weight: 600; margin: 0 0 6px; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.timeline li { position: relative; }
.timeline li::before { content: ""; position: absolute; left: -20px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.timeline del { color: var(--muted); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; padding: 32px 16px; }
.empty.big { padding: 80px 16px; }
.empty-code { font-size: 3.5rem; font-weight: 700; color: var(--accent); line-height: 1; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.alert-error { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.alert-info { background: var(--accent-soft); color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.alert.impersonation { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; }

/* ---------- machines ---------- */
.machine-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.machine { color: var(--text); display: flex; flex-direction: column; gap: 12px; transition: border-color .15s; }
.machine:hover { border-color: var(--accent); text-decoration: none; }
.machine-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.machine-name { font-size: 1.02rem; }

/* ---------- chart ---------- */
.chart { display: block; width: 100%; height: 180px; }
.chart-bar { fill: var(--chart); }
.chart-bar:hover { fill: var(--accent-strong); }
.chart-base { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; margin-top: 6px; }

/* ---------- login ---------- */
body.guest { min-height: 100vh; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%), var(--bg); }
.guest-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 16px; }
.guest-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 10px 30px rgba(20, 30, 10, .08); display: flex; flex-direction: column; gap: 14px; }
.guest-logo { display: block; background: #fff; border-radius: 8px; padding: 6px 8px; max-width: 100%; height: auto; align-self: flex-start; }
.guest-title { font-size: 1.4rem; margin-top: 8px; }
.guest-foot { color: var(--muted); font-size: .8rem; text-align: center; max-width: 400px; }

/* ---------- responsive ---------- */
/* Tenant overview: one row per transponder, tenant cells span the group (like the legacy overview) */
.tenant-table tbody.tenant-group tr:last-child td { border-bottom: 1px solid var(--border); }
.tenant-table tbody.tenant-group:last-of-type tr:last-child td { border-bottom: 0; }
.tenant-table tbody.tenant-group tr:not(:last-child) td:not([rowspan]) { border-bottom-style: dashed; }
.tenant-table tbody tr:hover { background: transparent; }
.tenant-table tbody.tenant-group:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.tenant-table td { vertical-align: middle; }
.tenant-table tbody.row-reserve { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 2px; flex-wrap: nowrap; }
.actions form { display: inline; margin: 0; }
.actions .slot { display: inline-flex; min-width: 32px; }
.card > .table-wrap .tenant-table tbody.tenant-group tr + tr td:first-child { padding-left: 14px; }
.icon-btn.act { width: 32px; height: 32px; color: var(--muted); }
.icon-btn.act:hover { color: var(--text); text-decoration: none; }
.icon-btn.act-bad:hover { color: var(--bad); background: var(--bad-soft); }
.icon-btn.act-ok:hover { color: var(--ok); background: var(--ok-soft); }
.legend { margin-top: -6px; }
.legend summary { cursor: pointer; width: max-content; }
.legend ul { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 8px; }
.tp-list { list-style: none; padding: 0; margin: 0; }
.tp-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.tp-item:last-child { border-bottom: 0; }
.tp-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tp-head .grow { flex: 1; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.input-sm { min-height: 32px; padding: 4px 9px; font-size: .9rem; }
.card.narrow { max-width: 560px; }
.choice-list { border: 0; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.choice-list legend { font-weight: 600; margin-bottom: 8px; }
.choice { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.choice input { accent-color: var(--accent); }

@media (max-width: 1100px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 40;
        transform: translateX(-100%); transition: transform .2s ease;
        box-shadow: 0 0 40px rgba(0, 0, 0, .2);
    }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0, 0, 0, .35); }
    .icon-btn.menu-btn { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 40px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .who, .hide-sm { display: none; }
    .quick { margin-left: 0; width: 100%; }
}
@media (max-width: 560px) {
    .form-grid { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .toolbar > label:not(.check), .toolbar .btn { width: 100%; }
    .stat-value { font-size: 1.5rem; }
    h1 { font-size: 1.35rem; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
@media print {
    .sidebar, .topbar, .site-foot, .toolbar, .btn, .tabs .tab-filter, .actions, .legend { display: none !important; }
    .content { padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
}

/* Machine cards: the name link covers the card, buttons stay clickable on top */
.machine { position: relative; }
.machine:focus-within { border-color: var(--accent); }
.machine .stretched { color: inherit; }
.machine .stretched::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.machine-actions { position: relative; z-index: 1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }

/* Verwiegungen */
.report-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 24px; align-items: start; }
.report-form fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.report-form legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.report-form .form-actions { grid-column: 1 / -1; }
.row-fields { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row-fields .field { flex: 1 1 130px; min-width: 0; }
.row-buttons { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-buttons[hidden], .btn[hidden] { display: none; }
.filter-chip { margin: 16px 0 0; }
.filter-chip a { margin-left: 8px; }
.card-head.pad { padding: 14px 16px 0; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-info { background: var(--accent-soft); color: var(--accent-strong); }
.weighing-table td .badge { margin-left: 4px; vertical-align: middle; }
.weighing-table tr.row-storno td { color: var(--warn); }
.weighing-table tfoot th { color: var(--text); font-size: .9rem; text-transform: none; letter-spacing: 0; }
.stats + .alert, .stats + .card, .alert + .card, .filter-chip + .stats { margin-top: 16px; }
@media print {
    .report-form, .head-actions, .back { display: none !important; }
}
.auto-pdf { flex-wrap: wrap; margin-top: 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.auto-pdf-text { display: flex; flex-direction: column; margin-right: auto; }
.auto-pdf .input { width: 240px; max-width: 100%; }
@media print { .auto-pdf { display: none !important; } }
.auto-pdf + .stats { margin-top: 16px; }
.weighing-pager { margin-top: 16px; flex-wrap: wrap; gap: 8px 12px; }
.rename-form { margin-top: 14px; flex-wrap: wrap; } .rename-form .input { flex: 1 1 160px; min-width: 0; }

/* Kontaktdaten-Hinweis */
.reminder { margin: 0 0 20px; font-weight: 400; }
.reminder p { margin: 4px 0 8px; }
.reminder-list { margin: 0; padding-left: 20px; }
.reminder-list a { font-weight: 600; }
.confirm-box { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; font-weight: 400; margin-bottom: 20px; }
.confirm-box > span { flex: 1 1 260px; }
#stammdaten-aendern fieldset { border: 0; padding: 0; margin: 0; }
.plain-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.plain-fieldset .field .check { white-space: normal; }
.plain-fieldset input[type=color] { width: 44px; height: 28px; padding: 0 2px; border: 1px solid var(--border, #ccc); border-radius: 6px; background: none; }
#stammdaten-aendern legend { font-weight: 600; margin-bottom: 4px; }
.link-row { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; }
.compact-grid { gap: 0 24px; } .card.span-2 { grid-column: 1 / -1; }
.fill-form { margin-top: 12px; flex-wrap: wrap; align-items: flex-end; } .fill-form .field { flex: 1 1 90px; }
.section-title { margin: 28px 0 12px; font-size: 1.1rem; }
.logo-preview { padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: #fff; margin-bottom: 8px; } .logo-preview img { display: block; max-width: 100%; max-height: 90px; width: auto; height: auto; }
.row-actions { display: flex; flex-wrap: wrap; gap: 4px; } .row-actions form { margin: 0; }
.inline-form { display: flex; gap: 6px; margin-top: 6px; align-items: center; } .inline-form .input { max-width: 190px; }
.stat { font-size: 2rem; font-weight: 600; line-height: 1.2; margin: 4px 0; }

/* Language switcher (DE | EN | FR) */
.lang-switch { display: inline-flex; gap: 2px; font-size: .8rem; font-weight: 600; }
.lang-switch a { padding: 3px 7px; border-radius: 6px; color: var(--muted); text-decoration: none; }
.lang-switch a:hover { color: var(--text); }
.lang-switch a.active { background: var(--border); color: var(--text); }
.guest-card > .lang-switch { align-self: flex-end; margin-bottom: 4px; }

/* Legal footer (Impressum / Datenschutz) */
.legal-foot { color: var(--muted); font-size: .8rem; }
.legal-foot a { color: inherit; text-decoration: underline; }
.site-foot { padding: 16px 24px 24px; text-align: center; border-top: 1px solid var(--border); }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Montagebericht (admin print sheet): same grid as IDL's Excel template montagebericht.xlsx, A1:H51.
   8 columns of 80 px, 51 rows of 20 px (15 pt); the tick boxes sit where the template's form controls are. */
.report-sheet { --col: 80px; --row: 20px; position: relative; display: grid; grid-template-columns: repeat(8, var(--col)); grid-template-rows: repeat(51, var(--row));
    width: calc(var(--col) * 8); height: calc(var(--row) * 51); margin: 0 auto; background: #fff; color: #000; font: 11pt/20px Calibri, Carlito, Arial, sans-serif; }
.report-sheet > div { box-sizing: border-box; border: 1px solid #000; margin: 0 -1px -1px 0; padding: 0 3px; white-space: pre-line; overflow: hidden; }
.report-sheet .rs-title { grid-area: 1 / 1 / 4 / 9; text-align: center; font-weight: 700; font-size: 16pt; line-height: 21px; }
.report-sheet .rs-customer { grid-area: 7 / 1 / 13 / 5; }
.report-sheet .rs-device { grid-area: 7 / 5 / 13 / 9; }
.report-sheet .rs-placement { grid-area: 13 / 1 / 14 / 9; }
.report-sheet .rs-date { grid-area: 14 / 1 / 16 / 9; display: flex; align-items: center; }
.report-sheet .rs-technician { grid-area: 16 / 1 / 18 / 9; display: flex; align-items: center; }
.report-sheet .rs-test-report { grid-area: 18 / 1 / 40 / 5; }
.report-sheet .rs-material { grid-area: 18 / 5 / 40 / 9; }
.report-sheet .rs-arrival { grid-area: 42 / 1 / 44 / 5; display: flex; align-items: center; }
.report-sheet .rs-departure { grid-area: 42 / 5 / 44 / 9; display: flex; align-items: center; }
.report-sheet .rs-sign-technician { grid-area: 44 / 1 / 51 / 5; }
.report-sheet .rs-sign-customer { grid-area: 44 / 5 / 51 / 9; }
.report-sheet > .rs-footer { grid-area: 51 / 1 / 52 / 9; border-width: 1px 0 0; margin: 0; text-align: center; }
.report-sheet .rs-sign-line { position: absolute; border-top: 1px solid #000; }
.report-sheet .rs-sign-caption { position: absolute; display: flex; justify-content: space-between; padding: 0 3px; }
.report-sheet .rs-sign-line-left { left: 10px; top: 952px; width: 305px; }
.report-sheet .rs-sign-caption-left { left: 31px; top: 956px; width: 280px; }
.report-sheet .rs-sign-line-right { left: 334px; top: 950px; width: 305px; }
.report-sheet .rs-sign-caption-right { left: 342px; top: 954px; width: 298px; }
.rs-check { position: absolute; display: flex; align-items: center; gap: 4px; font: 8pt/11px "Segoe UI", Arial, sans-serif; }
.rs-check i { flex: none; width: 11px; height: 11px; border: 1px solid #333; background: #fff; }
.rs-check-repair { left: 16px; top: 72px; width: 125px; height: 29px; }
.rs-check-remote { left: 492px; top: 71px; width: 119px; height: 29px; }
.rs-check-recal { left: 130px; top: 72px; width: 113px; height: 29px; }
.rs-check-found { left: 7px; top: 787px; width: 128px; height: 29px; }
.rs-check-fixed { left: 132px; top: 786px; width: 119px; height: 29px; }
.rs-check-unfixable { left: 254px; top: 784px; width: 166px; height: 29px; }
.rs-check-service { left: 257px; top: 76px; width: 113px; height: 22px; }
.rs-check-other { left: 374px; top: 74px; width: 96px; height: 25px; }
.rs-check-nosign { left: 367px; top: 972px; width: 197px; height: 29px; }
.rs-check-recal-ok { left: 399px; top: 786px; width: 122px; height: 29px; }
.rs-check-recal-nok { left: 511px; top: 786px; width: 128px; height: 29px; }
/* Margin 0 makes the browser drop its own print header and footer (date, page title, URL). The whole document uses the page
   type, so there is no forced page break; the space around the sheet comes from the padding. */
@page report { size: A4; margin: 0; }
html:has(.report-sheet) { page: report; }
@media print { .report-actions, .scrim { display: none !important; } .shell { display: block; min-height: 0; } .main-col { display: block; } .content { display: block; padding: 12mm 0 0; max-width: none; } .report-sheet { break-inside: avoid; } }
.rs-check.is-ticked i::after { content: "\2715"; display: block; font: 700 11px/11px Arial, sans-serif; text-align: center; }
/* Configurator: choices on the left, the sheet in the middle (shown smaller, the print page shows it at full size), open
   service / Nacheichung and open cases on the right; narrower: the right column moves under the choices */
.report-config { display: grid; grid-template-columns: minmax(260px, 320px) auto minmax(240px, 1fr); grid-template-areas: "form sheet side"; gap: 24px; align-items: start; }
.report-config > .report-form { grid-area: form; }
.report-config > .report-preview { grid-area: sheet; }
.report-side { grid-area: side; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.report-side .card { display: flex; flex-direction: column; gap: 10px; }
.report-side-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0; font-size: 1rem; }
.report-side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.report-side-list li { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.report-side-list li:first-child { border-top: 0; padding-top: 0; }
.report-side-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.job-pick { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: .85rem; cursor: pointer; }
.job-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.job-pick.is-on-report { cursor: default; border-color: transparent; background: var(--ok-soft); color: var(--ok); }
.report-side .btn { align-self: flex-start; white-space: normal; text-align: left; height: auto; }
.report-side p { margin: 0; }
@media (max-width: 1160px) { .report-config { grid-template-columns: minmax(260px, 340px) 1fr; grid-template-areas: "form sheet" "side sheet"; } }
.report-form { display: flex; flex-direction: column; gap: 14px; }
.report-form fieldset { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 0; padding: 0; margin: 0; }
.report-form legend { width: 100%; padding: 0; margin-bottom: 2px; font-weight: 600; }
.report-form .field-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.report-form .field .input { width: 100%; min-width: 0; box-sizing: border-box; }
.report-form textarea { resize: vertical; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; }
.report-preview { position: sticky; top: 12px; overflow-x: auto; }
.report-preview .report-sheet { zoom: 0.85; margin: 0; }
@media (max-width: 1100px) { .report-config { grid-template-columns: 1fr; grid-template-areas: "form" "side" "sheet"; } .report-preview { position: static; } }
@media print { .report-form, .report-side { display: none !important; } .report-config { display: block; } .report-preview .report-sheet { zoom: 1; margin: 0 auto; } }
/* Montagebericht, Nacheichung: attachment page per machine with the latest weighings */
.report-appendix { width: 640px; margin: 24px auto 0; background: #fff; color: #000; font: 11pt/1.4 Calibri, Carlito, Arial, sans-serif; break-before: page; padding: 8px 0; }
.report-appendix h2 { font-size: 14pt; margin: 0 0 6px; }
.report-appendix table { width: 100%; border-collapse: collapse; }
.report-appendix th, .report-appendix td { border: 1px solid #000; padding: 1px 6px; text-align: left; }
.report-appendix .num { text-align: right; }
.report-preview .report-appendix { zoom: 0.85; margin-left: 0; }
@media print { .report-preview .report-appendix { zoom: 1; margin: 0 auto; } }

/* ---------------------------------------------------------------- Serviceplanung (admin) */
.tabs.service-nav { margin: 0 0 16px; padding: 0; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.service-table td { vertical-align: top; }
.service-table .group-row td { background: var(--surface-2); }
.service-table .group-row-office td { font-weight: 700; background: var(--accent-soft); color: var(--accent-strong); }
/* Serviceplanung: each customer is its own tbody; a page-coloured gap and an accent bar set the customers clearly apart */
.service-table tbody.customer-block > tr.group-row > td { font-size: .95rem; }
.service-table tbody.customer-block > tr > td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
.service-table tbody + tbody > tr:first-child > td { border-top: 18px solid var(--bg); }
.service-table tbody.office-block + tbody.customer-block > tr:first-child > td { border-top: 0; }
.job-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; align-items: center; }
.job-actions form { margin: 0; }
.job-actions:empty { display: none; }
.tour-stop { break-inside: avoid; }
.tour-stop + .tour-stop { margin-top: 16px; }
/* all sheets of a tour in one print: every sheet after the first starts on a new page */
.report-batch .report-sheet { margin: 0 auto; }
.report-batch .report-sheet ~ .report-sheet { break-before: page; margin-top: 24px; }
/* service contract: must stand out in every list (kein Vertrag = ask the customer first) */
.contract-badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 700;
    border: 1px solid; vertical-align: middle; white-space: nowrap; }
.contract-service { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.contract-fullService { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent); }
.contract-none { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.contract-excluded { background: var(--surface-2, transparent); color: var(--muted, inherit); border-color: var(--border, currentColor); }

/* Support und Reparaturen (admin) */
.pre-line { white-space: pre-line; }
details.card > summary { cursor: pointer; }
details.card[open] > summary { margin-bottom: 14px; }
.support-badge { margin-left: 6px; }
a.tile-link { color: inherit; text-decoration: none; display: block; }
.follow-up { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.follow-up details > summary, #rueckmeldungen > details > summary { list-style: none; width: fit-content; margin-top: 6px; }
.follow-up details > summary::-webkit-details-marker, #rueckmeldungen > details > summary::-webkit-details-marker { display: none; }
.follow-up details[open] > summary, #rueckmeldungen > details[open] > summary { margin-bottom: 10px; }
.follow-ups-done { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
a.tile-link:hover .card { border-color: var(--accent); }

/* ---------- Admin-App (/admin/app, phone first) ---------- */
body.admin-app { padding-bottom: calc(64px + env(safe-area-inset-bottom)); font-size: 16px; }   /* 16px: no zoom on input focus (iOS) */
.app-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 6px; min-height: 52px;
    padding: env(safe-area-inset-top) 8px 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); }
.app-title { flex: 1; min-width: 0; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.app-offline-banner { margin: 0; border-radius: 0; border-width: 0 0 1px; font-size: .9rem; }
.app-content { max-width: 720px; margin: 0 auto; padding: 14px 14px 24px; display: flex; flex-direction: column; gap: 10px; }
.app-content > p { margin: 0; }
.app-section { margin-top: 12px; font-size: 1.05rem; display: flex; align-items: center; gap: 6px; }
.app-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
    box-shadow: var(--shadow); color: inherit; }
.app-card .kv { margin-top: 8px; }
a.app-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
a.app-link:hover, a.app-link:active { border-color: var(--accent); }
a.app-link > .icon { color: var(--muted); }
.app-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.app-clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.app-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.app-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--muted); text-decoration: none !important; }
.app-tile-value { font-size: 1.6rem; font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }
.app-tile-bad { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.app-tile-bad .app-tile-value { color: var(--bad); }
.app-segments { display: flex; gap: 4px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); overflow-x: auto; }
.app-segments a { flex: 1; text-align: center; padding: 7px 8px; border-radius: 6px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; }
.app-segments a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); text-decoration: none; }
.app-search { display: flex; gap: 8px; }
.app-search .input { flex: 1; }
.app-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.app-row p { margin: 0; }
.app-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.app-stop-title { font-size: 1.05rem; }
.app-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.app-actions .btn { flex: 1 1 auto; min-height: 44px; }
.app-machine { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 4px; }
.app-job { padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.app-job-name { font-weight: 600; margin-right: 6px; }
.app-job .job-actions { gap: 6px; margin-top: 8px; }
.app-job .job-actions .btn { min-height: 44px; padding: 0 14px; font-size: .95rem; }
.app-note { background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px; }
.app-label { margin: 0 0 2px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.app-card .app-label + p { margin: 0 0 10px; }
.app-gap { margin-top: 14px; }
.btn.app-wide { width: 100%; min-height: 46px; }
.admin-app .form-grid { grid-template-columns: 1fr; }
.admin-app .input { min-height: 44px; }
.app-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 16px;
    padding-top: 12px; border-top: 1px solid var(--border); }
.app-foot form { margin: 0; }
.app-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--surface);
    border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.app-tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px;
    color: var(--muted); font-size: .72rem; font-weight: 600; text-decoration: none; }
.app-tabs a.active { color: var(--accent-strong); }
.app-tabs a.active .icon { stroke-width: 2.4; }
button[data-offline-disabled] { opacity: .45; cursor: not-allowed; }
.admin-app [hidden] { display: none !important; }   /* .badge / .alert set display, which would override the attribute */
.app-job .btn-ghost { border-color: var(--border); }
.app-offline-banner .btn { margin-left: 6px; }
