:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #667085;
    --line: #e2e5ea;
    --primary: #c8102e;
    --primary-dark: #a00d25;
    --ok: #1a7f4b;
    --ok-bg: #e5f5ec;
    --warn: #b54708;
    --warn-bg: #fdf0e3;
    --info-bg: #eaf1fb;
    --error-bg: #fdecee;
    --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 1rem; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 48px; }

/* ---- top bar ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; text-decoration: none; flex-shrink: 0; }
.brand img { display: block; height: 32px; width: auto; }
.auth-logo { display: block; height: 56px; width: auto; max-width: 100%; }
.badge-stamm { background: var(--primary); color: #fff; }
.topbar-page, .nav-toggle { display: none; }
.nav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; flex: 1; order: 1; }
.nav a, .account-menu a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
.nav a:hover, .account-menu a:hover { color: var(--text); background: var(--bg); }
.nav a.is-active, .account-menu a.is-active, .nav-group.is-current > .nav-parent { color: var(--text); background: var(--bg); font-weight: 600; }
/* Dropdowns: open on hover, on keyboard focus and with a tap (app.js). */
.nav-group { position: relative; }
.nav-parent::after { content: ""; display: inline-block; width: 5px; height: 5px; margin: 0 1px 3px 8px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); opacity: 0.6; }
.nav-sub { display: none; position: absolute; top: 100%; left: 0; z-index: 60; flex-direction: column; gap: 2px; min-width: 190px; margin-top: 6px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 28px rgba(16, 24, 40, 0.13); }
.nav-sub::before { content: ""; position: absolute; left: 0; right: 0; top: -12px; height: 12px; } /* keeps the mouse "inside" on the way down */
.nav-group:hover > .nav-sub, .nav-group.is-open > .nav-sub, .nav-group:not(.account):focus-within > .nav-sub { display: flex; }
.nav-sub a { white-space: nowrap; }
/* Account: a circle with a person, menu with Mein Konto, Einstellungen, Abmelden. */
.account { order: 3; }
.account-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--muted); cursor: pointer; }
.account-btn:hover, .account.is-open .account-btn, .account.is-current .account-btn { color: var(--primary); border-color: var(--primary); }
.account-menu { left: auto; right: 0; }
.account-name { max-width: 240px; padding: 4px 10px 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout { margin: 0; }
.logout button { width: 100%; padding: 6px 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); font: inherit; text-align: left; cursor: pointer; }
.logout button:hover { color: var(--primary); background: var(--bg); }
/* Calendar as an icon in the header (desktop: right, next to the user). */
.topbar-icon { order: 2; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.topbar-icon:hover, .topbar-icon.is-active { color: var(--primary); background: var(--bg); }


/* ---- layout blocks ---- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.actions, .row-actions, .form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions { justify-content: flex-end; }
.row-actions form { margin: 0; }
.form-actions { margin-top: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-head form { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat-warn .stat-value { color: var(--warn); }
.stat-accent .stat-value { color: var(--primary); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.warn { color: var(--warn); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.upper { text-transform: uppercase; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; }

/* ---- notices ---- */
.notice { padding: 12px 16px; border-radius: var(--radius); margin: 0 0 16px; background: var(--info-bg); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.notice ul { margin: 6px 0 0; padding-left: 20px; flex-basis: 100%; }
.notice-success { background: var(--ok-bg); color: var(--ok); }
.notice-error { background: var(--error-bg); color: #8a1020; display: block; }
.notice-import { background: var(--info-bg); border-left: 4px solid var(--primary); display: block; }
.notice-import .small { display: block; margin-top: 4px; color: var(--muted); }
.row-diff td:first-of-type { font-weight: 600; }

/* ---- tables ---- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 600; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.inactive td { color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-accent { background: var(--error-bg); color: var(--primary); margin-left: 6px; }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.tabs a.is-active { background: var(--surface); color: var(--text); font-weight: 600; border: 1px solid var(--line); }

/* ---- forms: one look for every field and every label ---- */
.form label, .auth label, .filter-bar label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #344054;
    margin-bottom: 14px;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]),
select,
textarea {
    font: inherit;
    font-size: 0.95rem;
    font-weight: 400;
    width: 100%;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background-color: #fff;
    color: var(--text);
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
/* Same arrow for every select in every browser. */
select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23667085' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
textarea { min-height: 80px; resize: vertical; }
input[type="date"], input[type="time"] { font-variant-numeric: tabular-nums; }
input::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.14); }
input:disabled, select:disabled, textarea:disabled { background-color: var(--bg); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); flex: 0 0 auto; }
input.num { text-align: right; }
.input-short { max-width: 160px; }
.form label.checkbox, label.checkbox { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; font-size: 0.9rem; color: var(--text); }
.form label.inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend { font-size: 0.85rem; font-weight: 600; color: #344054; margin-bottom: 8px; padding: 0; }
/* Compact fields inside table rows (same look, smaller). */
.input-date-small, .fields-table input:not([type="checkbox"]), .fields-table select {
    width: auto;
    min-height: 32px !important;
    padding: 4px 9px !important;
    font-size: 0.85rem !important;
}
.input-date-small { width: auto !important; }
select.input-date-small { padding-right: 30px !important; background-position: right 10px center; }
.fields-table input:not([type="checkbox"]), .fields-table select { width: 100%; }

.grid { display: grid; gap: 0 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); align-items: end; }
.grid-address { grid-template-columns: 2fr 1fr; }
.grid-address .span-2 { grid-column: span 2; }

/* ---- item editor ---- */
.items { margin-top: 8px; }
.items-table td { padding: 6px 4px; }
.items-table .col-qty { width: 90px; }
.items-table .col-price { width: 130px; }
.items-table .col-total { width: 120px; }
.items-table .col-remove { width: 100px; }
.totals { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-top: 16px; flex-wrap: wrap; }
.totals dl { display: grid; grid-template-columns: auto 140px; gap: 4px 16px; margin: 0; }
.totals dt { color: var(--muted); text-align: right; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .total { font-weight: 700; color: var(--text); font-size: 1.1rem; }

/* ---- buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid #c9ced6;
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    min-height: 40px;
    border-radius: 8px;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-danger { color: #8a1020; border-color: #f0b8c0; }
.btn-danger:hover { background: var(--error-bg); }
.btn-small { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
button.link:hover { color: var(--text); text-decoration: underline; }

.danger-zone { margin-top: -4px; text-align: right; }

.preview { display: grid; grid-template-columns: 1fr minmax(260px, 440px); gap: 24px; align-items: start; }
.preview p { margin: 0 0 10px; }
.preview-label { font-size: 0.8rem; font-weight: 700; margin-bottom: 2px !important; }
.preview-qr svg { display: block; width: 100%; height: auto; }
@media (max-width: 760px) { .preview { grid-template-columns: 1fr; } }

.step {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    margin-right: 6px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.9rem;
}
.pick-table .input-qty { width: 80px; }
.pick-table .input-amount { width: 110px; }
.pick-total { text-align: right; margin: 12px 0 0; font-size: 1.1rem; }
.product-form { padding: 10px 0; border-bottom: 1px solid var(--line); }
.product-form:last-of-type { border-bottom: 0; }
.product-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 4px 0; }
.pick-desc { display: block; color: var(--muted); font-size: 0.85rem; }
.product-row label { margin-bottom: 0 !important; }
.product-row .grow { flex: 1 1 260px; }
.inline-cancel { display: flex; gap: 6px; align-items: center; }
.grid-3 .span-2 { grid-column: span 2; }
.grid-3 .span-3 { grid-column: span 3; }
.grid-4 { grid-template-columns: repeat(4, 1fr); align-items: end; }
.mt { margin-top: 24px; }
.spacer { flex: 1; }
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--primary); }

/* ---- CRM: customer record ---- */
.customer-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.customer-grid > .card { margin-bottom: 20px; }
/* Internal note: full width on top, pale yellow, unobtrusive. */
.form .note-bar { display: flex; flex-direction: row; align-items: flex-start; gap: 12px; margin: 0 0 16px; padding: 8px 12px; background: #fffdf0; border: 1px solid #f3ecc4; border-radius: var(--radius); font-weight: 400; }
.note-label { flex: 0 0 auto; padding-top: 5px; font-size: 0.8rem; font-weight: 600; color: #8a7a2e; text-transform: uppercase; letter-spacing: 0.03em; }
.note-input { flex: 1; min-height: 34px !important; padding: 5px 8px !important; background: transparent !important; border: 0 !important; box-shadow: none !important; color: #5c5326 !important; line-height: 1.45; }
.note-input:focus { background: #fffbe0 !important; box-shadow: none !important; }
.note-form { margin: 0; }
.note-form .note-bar { align-items: center; }
.note-form .note-label { padding-top: 0; }
.tabs-card { border-bottom: 1px solid var(--line); gap: 2px; margin: 0 0 20px; flex-wrap: wrap; }
.tabs-card a { padding: 10px 16px; border-radius: 8px 8px 0 0; border: 1px solid transparent; border-bottom: 0; margin-bottom: -1px; font-weight: 500; }
.tabs-card a:hover { color: var(--text); background: var(--surface); }
.tabs-card a.is-active { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 600; }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 0.75rem; text-align: center; }
.tabs-card a.is-active .tab-count { background: var(--error-bg); color: var(--primary); }
.panel-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.panel-grid > .card { margin-bottom: 20px; }
.edit-entry { margin-top: 10px; padding: 12px; background: var(--bg); border-radius: 8px; }
.edit-entry .form-actions { margin-top: 4px; }
.grid-addr-row { grid-template-columns: 1.2fr 1.6fr 1.6fr 0.6fr 0.7fr 1.2fr 0.5fr; }
.field-check { align-self: center; margin-top: 18px; }
@media (max-width: 1000px) { .grid-addr-row { grid-template-columns: repeat(3, 1fr); } }
.event-table td { vertical-align: top; }
.master-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 28px; }
.sub-head { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.radios-inline { display: flex; gap: 16px; margin: 0; }
.radios-inline .checkbox { margin: 0 !important; }
.account-row { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.account-row:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.account-row .sub-head { margin-bottom: 12px; }
.address-row { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.address-new { opacity: 0.85; }
.address-flags { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.activity-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.activity-row label { margin-bottom: 8px !important; }
.activity-form { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { padding: 10px 0 10px 14px; border-left: 3px solid var(--line); margin-left: 4px; }
.timeline-item + .timeline-item { margin-top: 2px; }
.timeline-item.is-invoice { border-left-color: #c9ced6; }
.timeline-item.is-done .timeline-text { color: var(--muted); text-decoration: line-through; }
.timeline-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline-head form { margin: 0; }
.timeline-text { margin-top: 4px; white-space: normal; overflow-wrap: anywhere; }
input.mono { font-family: ui-monospace, Consolas, monospace; letter-spacing: 0.02em; }
.device-list { list-style: none; margin: 0; padding: 0; }
.device-item { padding: 12px 0 12px 14px; border-left: 3px solid var(--primary); margin-left: 4px; }
.device-item + .device-item { margin-top: 6px; }
.device-item.is-inactive { border-left-color: var(--line); }
.device-item.is-inactive > .timeline-head strong, .device-item.is-inactive > .device-data { color: var(--muted); }
.device-data { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 8px 0 0; font-size: 0.92rem; }
.device-data dt { color: var(--muted); }
.device-data dd { margin: 0; overflow-wrap: anywhere; }
.device-data .btn-small { min-height: 0; padding: 1px 8px; margin-left: 4px; font-size: 0.75rem; }
.device-code { background: var(--bg); padding: 1px 6px; border-radius: 4px; user-select: all; }
.inv-no { font-weight: 700; color: var(--primary); text-decoration: none; letter-spacing: 0.02em; }
.inv-no:hover { text-decoration: underline; }
.card-subhead { margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 1rem; }

/* Invoice page, credit notes, customer account */
.page-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 0; }
.inline-form { margin: 0; display: inline-flex; }
.inline-fields { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-fields label.inline { margin: 0; }
.mt-small { margin-top: 12px; }
.refund-found { border-left: 4px solid var(--warn); }
.credit-badge { color: var(--ok); }
.account-table td { vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* Settings → E-Mail: test mails with live preview */
.mailtest-subject { margin: 18px 0 6px; overflow-wrap: anywhere; }
.mailtest-frame { display: block; width: 100%; height: 480px; min-height: 320px; border: 1px solid var(--line); border-radius: var(--radius); background: #f3f3f3; }
.mailtest-ok { color: var(--ok); }
.mailtest-error { color: var(--primary-dark); }
.device-place { margin: 0 0 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.event-list { list-style: none; margin: 0 0 8px; padding: 0; }
.event-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.event-list li:last-child { border-bottom: 0; }
.event-when { display: inline-block; min-width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); }
.task-row { display: flex; gap: 10px; align-items: flex-start; }
.task-row .grow { flex: 1; }
.task-row form { margin: 0; }
.danger-zone { margin: 0 0 20px; text-align: right; }
.input-order { width: 70px !important; }
.row-new td { background: var(--bg); }
.calendar-choice { list-style: none; padding: 0; margin: 0 0 16px; }
.calendar-choice li { padding: 6px 0; }
.calendar-choice form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }

/* ---- CRM: month calendar ---- */
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; margin-bottom: 8px; }
.month-head { background: var(--surface); padding: 6px 8px; font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.month-day { background: var(--surface); min-height: 108px; padding: 4px 5px 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.month-day.is-weekend { background: #fafbfc; }
.month-day.is-other { background: var(--bg); }
.month-day.is-other .day-number { color: #b0b6c0; }
.day-number { align-self: flex-end; font-size: 0.85rem; color: var(--muted); text-decoration: none; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.day-number:hover { background: var(--bg); color: var(--text); }
.is-today .day-number { background: var(--primary); color: #fff; font-weight: 700; }
.event { display: block; font-size: 0.78rem; line-height: 1.3; padding: 2px 5px; border-radius: 4px; background: var(--info-bg); color: #1d3f72; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event.has-customer { background: var(--ok-bg); color: var(--ok); }
.event.is-allday { font-weight: 600; }
.event.is-birthday { background: #fff3b0; color: #6b5900; }
.event:hover { filter: brightness(0.95); }
/* Month as a list of days (small screens only, see below). */
.agenda { display: none; }
.agenda-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; overflow: hidden; }
.agenda-day.is-today { border-color: var(--primary); }
.agenda-day.is-past { opacity: 0.7; }
.agenda-date { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.agenda-weekday { font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; }
.agenda-daynum { font-weight: 700; font-size: 1.05rem; }
.is-today .agenda-daynum { color: var(--primary); }
.agenda-add { margin-left: auto; }
.agenda-empty { margin: 0; padding: 10px 14px; }
.agenda-event { display: flex; gap: 12px; padding: 11px 14px; color: var(--text); text-decoration: none; border-left: 4px solid #8fb0e0; }
.agenda-event + .agenda-event { border-top: 1px solid var(--line); }
.agenda-event.has-customer { border-left-color: var(--ok); }
.agenda-event.is-birthday { border-left-color: #e0c341; }
.agenda-event:active { background: var(--bg); }
.agenda-time { flex: 0 0 64px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; padding-top: 1px; }
.agenda-title { flex: 1; min-width: 0; font-weight: 500; overflow-wrap: anywhere; }
.agenda-meta { display: block; font-weight: 400; font-size: 0.85rem; color: var(--muted); }
.nowrap { white-space: nowrap; }
.pick-table tr.no-price td { color: #b0b6c0; }
/* Products: compact list, the form opens on a click on the title. */
.product-list { list-style: none; margin: 0; padding: 0; }
.product-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.product-item:last-child { border-bottom: 0; }
.product-item.is-inactive .product-title { color: var(--muted); }
.product-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.product-title { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; text-align: left; }
.product-title:hover { color: var(--primary); text-decoration: underline; }
.product-price { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }
.product-meta { margin-top: 2px; }
.product-item .product-form { border-bottom: 0; padding-bottom: 0; }

.product-group { margin: 18px 0 4px; font-size: 0.95rem; padding-bottom: 6px; border-bottom: 2px solid var(--line); }
.product-group:first-of-type { margin-top: 4px; }
.pick-table tr.pick-group th { padding-top: 16px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); background: transparent; }
.pick-table tbody:first-of-type tr.pick-group th { padding-top: 6px; }
@media (max-width: 760px) { .pick-table tr.pick-group { display: block; cursor: default; padding-bottom: 0; } }

/* Searchable select (customers, app.js [data-search]). */
.combo { position: relative; }
.combo-select { display: none !important; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; max-height: 300px; overflow-y: auto; margin: 4px 0 0; padding: 4px 0; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); font-weight: 400; }
.combo-list li { padding: 9px 12px; cursor: pointer; overflow-wrap: anywhere; }
.combo-list li:hover, .combo-list li.is-active { background: var(--bg); }
.combo-list li.is-selected { font-weight: 600; }
.combo-list li.combo-empty { color: var(--muted); cursor: default; }
.filter-bar .combo { min-width: 220px; }

/* Offer process: offer -> order confirmation -> invoice. */
.process { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.process li { position: relative; padding: 4px 0 14px 34px; border-left: 2px solid var(--line); margin-left: 11px; }
.process li:last-child { border-left-color: transparent; padding-bottom: 0; }
.process li::before { counter-increment: step; content: counter(step); position: absolute; left: -12px; top: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 700; display: grid; place-items: center; }
.process li.is-done::before { background: var(--primary); border-color: var(--primary); color: #fff; }
.process li.is-off::before { background: var(--bg); }
.process form { margin: 4px 0; flex-wrap: wrap; }
.chat { list-style: none; margin: 0 0 14px; padding: 0; }
.chat li { max-width: 80%; margin-bottom: 8px; padding: 8px 12px; border-radius: 8px; background: var(--bg); overflow-wrap: anywhere; }
.chat li.is-customer { background: #fff8e1; }
.chat li.is-team { margin-left: auto; }
.offer-text { white-space: normal; }
.module-row { padding: 12px 0; border-top: 1px solid var(--line); }
.module-row:first-of-type { border-top: 0; }
.module-row p { margin: 4px 0 0 28px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filter-bar label { margin-bottom: 0; }
.filter-bar .grow { flex: 1 1 220px; }
.open-sum .spacer { flex: 1; }
.open-sum { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.open-sum strong { font-size: 1.05rem; }
.pay-link { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }

.sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(16, 24, 40, 0.06);
}
.sticky-actions .spacer { flex: 1; }
.form .input-template { width: 220px; max-width: 100%; }
[data-qr-iban-hint] { margin-top: -6px; color: var(--primary); }
[hidden] { display: none !important; }

/* ---- login ---- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.auth h1 { margin-bottom: 12px; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.code-input { font-size: 1.4em; letter-spacing: .25em; text-align: center; font-variant-numeric: tabular-nums; }
.tfa-qr { width: 200px; max-width: 100%; height: auto; display: block; margin: 8px 0; }
.plain { list-style: none; padding: 0; margin: 4px 0 10px; }
.plain li { padding: 2px 0; }
.input-suffix { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.input-suffix input { flex: 1; min-width: 0; }

/* ---- small screens (phone) ---- */
@media (max-width: 760px) {
    body { font-size: 15px; }
    h1 { font-size: 1.35rem; }
    main.wrap { padding-top: 16px; padding-bottom: calc(32px + env(safe-area-inset-bottom)); }
    .wrap { padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }

    /* Top bar: sticky, menu behind a button. */
    .topbar { position: sticky; top: 0; z-index: 50; padding-top: env(safe-area-inset-top); }
    .topbar-inner { gap: 10px; min-height: 52px; }
    .topbar-page { display: block; flex: 1; min-width: 0; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar-page::before { content: "· "; }
    .nav-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
    .nav-toggle-icon, .nav-toggle-icon::before, .nav-toggle-icon::after { display: block; width: 16px; height: 2px; background: currentColor; border-radius: 1px; position: relative; transition: transform 0.15s; }
    .nav-toggle-icon::before, .nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
    .nav-toggle-icon::before { top: -5px; }
    .nav-toggle-icon::after { top: 5px; }
    .topbar.is-open .nav-toggle-icon { background: transparent; }
    .topbar.is-open .nav-toggle-icon::before { transform: translateY(5px) rotate(45deg); }
    .topbar.is-open .nav-toggle-icon::after { transform: translateY(-5px) rotate(-45deg); }
    .nav, .account { display: none; }
    .topbar-icon { order: 0; width: 40px; height: 40px; border: 1px solid var(--line); }
    .topbar.is-open .nav { display: flex; flex-direction: column; flex-basis: 100%; gap: 2px; padding: 4px 0 6px; border-top: 1px solid var(--line); }
    .topbar.is-open .nav { align-items: stretch; }
    .topbar.is-open .nav a, .topbar.is-open .account-menu a, .topbar.is-open .logout button { padding: 12px; font-size: 1.05rem; }
    /* Phone: the dropdowns open in place, indented under their item. */
    .nav-group { display: flex; flex-direction: column; }
    .nav-parent::after, .nav-sub::before, .account-btn { display: none; }
    .nav-sub, .topbar.is-open .nav-sub { display: flex; position: static; min-width: 0; margin: 0; padding: 0 0 0 18px; background: none; border: 0; box-shadow: none; }
    .topbar.is-open .account { display: block; flex-basis: 100%; padding: 2px 0 10px; border-top: 1px solid var(--line); }
    .account-menu, .topbar.is-open .account-menu { padding-left: 0; }
    .account-name { max-width: none; padding: 12px 12px 2px; border: 0; color: var(--muted); font-size: 0.9rem; font-weight: 500; }

    /* Fields: 16px stops iOS from zooming in on every tap. */
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]):not([type="submit"]):not([type="button"]),
    select, textarea,
    .input-date-small, .fields-table input:not([type="checkbox"]), .fields-table select { font-size: 16px !important; min-height: 44px !important; }
    input::-webkit-date-and-time-value { text-align: left; }
    input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
    label.checkbox, .form label.checkbox { min-height: 32px; }
    .btn { min-height: 44px; }
    .btn-small { min-height: 38px; padding: 6px 12px; }
    .device-data .btn-small { min-height: 30px; padding: 3px 10px; font-size: 0.8rem; }

    /* Layout: one column, tighter cards. */
    .grid-2, .grid-3, .grid-address { grid-template-columns: 1fr; }
    .grid-address .span-2, .grid-3 .span-2, .grid-3 .span-3 { grid-column: auto; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
    .customer-grid, .master-grid, .panel-grid, .grid-addr-row { grid-template-columns: 1fr; }
    .card { padding: 14px; margin-bottom: 14px; }
    .card-head { flex-wrap: wrap; }
    .page-head { margin-bottom: 14px; gap: 10px; }
    .page-head .actions { width: 100%; }
    .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat { padding: 10px 12px; }
    .stat-value { font-size: 1.2rem; }
    .form .note-bar { flex-direction: column; gap: 2px; }
    .filter-bar { display: grid; grid-template-columns: 1fr 1fr; }
    .filter-bar .grow { grid-column: 1 / -1; }
    .filter-bar .btn { width: 100%; }
    .sticky-actions { margin: 0 -14px; border-radius: 0; border-left: 0; border-right: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
    .sticky-actions .btn-primary { flex: 1; }
    .danger-zone { text-align: left; }

    /* Customer tabs: one row that scrolls sideways. */
    .tabs-card { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -14px 14px; padding: 0 14px; border-bottom: 1px solid var(--line); }
    .tabs-card::-webkit-scrollbar { display: none; }
    .tabs-card a { flex: 0 0 auto; white-space: nowrap; padding: 12px 12px 10px; margin: 0; border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent !important; }
    .tabs-card a.is-active { border-bottom-color: var(--primary); }

    /* Calendar: list instead of the month grid. */
    .month-grid, .month-legend { display: none; }
    .agenda { display: block; margin-bottom: 14px; }

    /* Tables become cards; labels come from the column heads (app.js). */
    .table thead { display: none; }
    .table, .table tbody { display: block; }
    .table tr { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); }
    .table tbody tr:last-child { border-bottom: 0; }
    .table td, .table tbody th { display: block; border: 0; padding: 3px 0; text-align: left; }
    .table td.num { text-align: left; }
    .table td:first-child, .table tbody th:first-child { font-size: 1.02rem; font-weight: 600; }
    .table td[data-label] { position: relative; padding-left: 38%; min-height: 24px; }
    .table td[data-label]::before { content: attr(data-label); position: absolute; left: 0; top: 4px; width: 35%; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--muted); overflow-wrap: anywhere; }
    .table td.row-actions { display: flex; padding-left: 0; justify-content: flex-start; margin-top: 8px; }
    .table td.row-actions::before { content: none; }
    .inline-cancel { flex-wrap: wrap; }
    .pay-link { max-width: 100%; }
    .items-table td { display: block; }
    .items-table .col-qty, .items-table .col-price, .items-table .col-total, .items-table .col-remove { width: auto; }
    .fields-table td[data-label] { padding-left: 0; padding-top: 20px; }
    .fields-table td[data-label]::before { top: 2px; width: 100%; }
    /* New invoice: product = checkbox + title, below unit / price / quantity side by side. */
    .pick-table tr { display: grid; grid-template-columns: 28px repeat(3, minmax(0, 1fr)); column-gap: 10px; align-items: start; cursor: pointer; }
    .pick-table td:nth-child(1) { grid-column: 1; grid-row: 1; padding-top: 2px; }
    .pick-table td:nth-child(2) { grid-column: 2 / -1; grid-row: 1; padding-left: 0; }
    .pick-table td:nth-child(2)::before { content: none; }
    .pick-table td:nth-child(n+3) { grid-row: 2; padding-left: 0; padding-top: 20px; text-align: left; }
    .pick-table td:nth-child(3) { grid-column: 2; }
    .pick-table td:nth-child(n+3)::before { top: 2px; width: 100%; }
    .pick-table .input-qty { width: 100%; }
    .totals dl { grid-template-columns: auto 1fr; }
    .event-list li { padding: 9px 0; }
    .event-when { min-width: 84px; }
}

/* ---- Auswertungen ---- */
.report-filter { margin: 0; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.report-grid > .card { margin-bottom: 20px; }
.bar-chart { display: block; width: 100%; height: auto; margin: 4px 0 8px; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; }
.chart-bar.is-current { fill: #c8102e; }
.chart-bar.is-prev { fill: #2f6fd0; }
.chart-hit { fill: transparent; }
.chart-month:hover .chart-hit { fill: var(--bg); }
.chart-legend { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.legend-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: 6px; }
.legend-swatch.is-current { background: #c8102e; }
.legend-swatch.is-prev { background: #2f6fd0; }
.ok { color: var(--ok); font-weight: 600; }
.class-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 6px; font-size: 0.8rem; font-weight: 700; background: var(--bg); color: var(--muted); }
.class-badge.class-a { background: var(--ok-bg); color: var(--ok); }
.class-badge.class-b { background: var(--info-bg); color: #1f4f99; }
.class-badge.class-c { background: var(--bg); color: var(--text); }
.class-badge.class-d { background: var(--bg); color: var(--muted); }
.report-classes { font-size: 1.1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.class-list { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px 22px; }
.class-list a { text-decoration: none; color: var(--text); }
.stats.aging { margin-bottom: 14px; }
/* ---- Mahnwesen ---- */
.dunning-letters li { margin-bottom: 10px; }
.dunning-letters li.is-muted { opacity: 0.55; }
.dunning-card .inline-form { flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.dunning-badge { margin-top: 3px; }
@media (max-width: 760px) { .report-grid { grid-template-columns: 1fr; } }
.notice-info { background: var(--info-bg); color: var(--text); }
/* ---- Dokumente ---- */
.doc-drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 14px 16px; transition: border-color 0.15s, background 0.15s; }
.doc-drop.is-over { border-color: var(--primary); background: var(--error-bg); }
.doc-drop-hint { margin: 0 0 10px; }
/* ---- Ratenzahlung ---- */
.installments-box { margin: 4px 0 14px; padding: 12px 14px; border-left: 3px solid var(--primary); background: var(--bg); border-radius: 0 var(--radius) var(--radius) 0; }
/* ---- Zahlungsmoral ---- */
.pay-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.pay-sehr_gut { background: var(--ok-bg); color: var(--ok); }
.pay-gut { background: var(--info-bg); color: #1f4f99; }
.pay-schlecht { background: var(--warn-bg); color: var(--warn); }
.pay-sehr_schlecht { background: var(--error-bg); color: var(--primary); }
.pay-line { margin: 0 0 12px; }
/* ---- Schlagworte, Kontaktpersonen ---- */
.tag { display: inline-block; margin: 2px 4px 2px 0; padding: 1px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 0.78rem; font-weight: 500; text-decoration: none; white-space: nowrap; }
a.tag:hover { color: var(--text); border-color: var(--muted); }
.tag-pick { cursor: pointer; font: inherit; font-size: 0.78rem; }
.tag-suggest { display: block; margin-top: 4px; }

/* Handelsregister (Zefix) lookup in the customer / supplier form */
.zefix { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.zefix-hits { flex-basis: 100%; display: grid; gap: 4px; max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: var(--surface); }
.zefix-hit { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; font: inherit; padding: 6px 8px; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.zefix-hit:hover, .zefix-hit:focus-visible { background: var(--bg); outline: none; }
.zefix-hit:focus-visible { box-shadow: 0 0 0 2px var(--primary); }
.person-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.person-row:last-child { border-bottom: 0; }
.grid-person { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 760px) { .grid-person { grid-template-columns: 1fr; } }
/* ---- Suche ---- */
.search-mask { margin-bottom: 6px; }
.search-kinds { margin-bottom: 14px; }
.search-hits { list-style: none; padding: 0; margin: 0; }
.search-hits li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.search-hits li:last-child { border-bottom: 0; }
.search-snippet { color: var(--muted); }
mark { background: #fff3a8; color: inherit; padding: 0 1px; border-radius: 2px; }
