:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-softer: #1c2128;
  --border: #30363d;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #2da44e;
  --accent-hover: #3fb362;
  --error: #f85149;
  --sidebar-w: 220px;
}

/* Helles Theme */
html[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f6f8fa;
  --bg-softer: #eaeef2;
  --border: #d0d7de;
  --fg: #1f2328;
  --muted: #656d76;
  --accent: #1f883d;
  --accent-hover: #1a7f37;
  --error: #cf222e;
}

/* Sepia / warm */
html[data-theme="sepia"] {
  --bg: #f4ecd8;
  --bg-soft: #efe3c5;
  --bg-softer: #e8d9b3;
  --border: #c8b88a;
  --fg: #4a3c2a;
  --muted: #8a7757;
  --accent: #a0522d;
  --accent-hover: #8b4513;
  --error: #b22222;
}

/* Ocean — dunkler Hintergrund, blauer Akzent */
html[data-theme="ocean"] {
  --bg: #0c1929;
  --bg-soft: #14253d;
  --bg-softer: #1a2f4d;
  --border: #2a4565;
  --fg: #e0e9f4;
  --muted: #88a0bb;
  --accent: #2080d8;
  --accent-hover: #2f95eb;
  --error: #e85a4f;
}

/* Midnight — fast schwarz mit Violett */
html[data-theme="midnight"] {
  --bg: #08080d;
  --bg-soft: #14141f;
  --bg-softer: #1d1d2e;
  --border: #353550;
  --fg: #e8e8f0;
  --muted: #9999b3;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --error: #ef4444;
}

/* Auto = Browser-Theme respektieren (überschreibt nicht; standard ist dark) */
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg: #ffffff;
    --bg-soft: #f6f8fa;
    --bg-softer: #eaeef2;
    --border: #d0d7de;
    --fg: #1f2328;
    --muted: #656d76;
    --accent: #1f883d;
    --accent-hover: #1a7f37;
    --error: #cf222e;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-size: 15px; }
#app, .screen, .layout { min-height: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9em; }
.error { color: var(--error); min-height: 1.2em; margin-top: 0.5em; }

/* ----- Forms / cards ----- */
.screen { display: flex; flex-direction: column; align-items: center; padding: 1.5rem; }
.card { width: 100%; max-width: 560px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 14px; padding: 1.8rem; margin-top: 3rem; }
.card.setup { max-width: 720px; }
h1 { margin-top: 0; }
label { display: block; font-size: 0.88em; margin-bottom: 0.9rem; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 0.35rem; }
input, select, textarea { width: 100%; padding: 0.6rem 0.75rem; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); color: var(--fg); font-size: 1em; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 1rem 1rem 0.5rem; margin-bottom: 1rem; }
legend { padding: 0 0.5rem; color: var(--muted); font-size: 0.85em; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > label { flex: 1 1 180px; }
.row > label.narrow { flex: 0 0 120px; }
button { padding: 0.65rem 1.1rem; background: var(--accent); color: white; border: 0; border-radius: 8px; font-size: 0.95em; font-weight: 600; cursor: pointer; }
button:hover { background: var(--accent-hover); }
button.link { background: none; color: var(--muted); padding: 0.3rem 0.6rem; font-weight: normal; }
button.link:hover { color: var(--fg); background: var(--bg-softer); }
button.primary { background: var(--accent); }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--fg); }
button.ghost:hover { border-color: var(--accent); background: var(--bg-softer); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ----- Main Layout (Sidebar + Content) ----- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-soft); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { font-weight: 800; font-size: 1.3em; color: var(--fg); padding: 4px 8px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-btn { background: transparent; color: var(--fg); text-align: left; padding: 8px 12px; border-radius: 6px; font-weight: 500; border-left: 3px solid transparent; }
.nav-btn:hover { background: var(--bg-softer); }
.nav-btn.active { background: var(--bg-softer); color: var(--fg); border-left-color: var(--muted); font-weight: 700; }

/* Klappbare Gruppen */
.nav-group-header {
  background: transparent; color: var(--muted); text-align: left;
  padding: 12px 8px 6px; margin-top: 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  border: none; cursor: pointer; display: flex; align-items: center; gap: 6px;
}
.nav-group-header:hover { color: var(--fg); }
.nav-group-chev { display: inline-block; transition: transform 0.15s ease; font-size: 10px; opacity: 0.7; }
.nav-group-header[aria-expanded="false"] .nav-group-chev { transform: rotate(-90deg); }
.nav-group { display: flex; flex-direction: column; gap: 2px; overflow: hidden; max-height: 1000px; transition: max-height 0.2s ease; }
.nav-group[data-collapsed="true"] { max-height: 0; }

.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }

.menu-toggle { display: none; position: fixed; top: 0.8rem; left: 0.8rem; z-index: 1000; background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg); font-size: 1.3em; padding: 0.4rem 0.7rem; }

.content { padding: 1.5rem 2rem; overflow-x: hidden; }
.view-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.2rem; }
.view-header h1 { margin: 0; }
.view-actions { display: flex; gap: 0.5rem; align-items: center; }
.view-actions input[type="search"] { width: 240px; padding: 0.55rem 0.8rem; }

/* ----- Table ----- */
.table-wrap { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92em; }
thead { background: var(--bg-softer); }
th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.02em; }
tbody tr { cursor: pointer; transition: background 0.1s; }
tbody tr:hover { background: var(--bg-softer); }
tbody tr:last-child td { border-bottom: none; }
.empty-row { text-align: center; color: var(--muted); padding: 2rem !important; font-style: italic; }

/* ----- Stats grid ----- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 1.2rem; }
.stat-card .label { color: var(--muted); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.02em; }
.stat-card .value { font-size: 2em; font-weight: 700; margin-top: 0.3rem; }

/* ----- Status badges ----- */
.badge { display: inline-block; padding: 0.2em 0.6em; border-radius: 999px; font-size: 0.8em; font-weight: 600; }
.badge.draft { background: #373e47; color: var(--muted); }
.badge.sent, .badge.new { background: #1f6feb; color: white; }
.badge.accepted, .badge.paid { background: var(--accent); color: white; }
.badge.overdue, .badge.rejected { background: var(--error); color: white; }

/* ----- Chat ----- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 3rem); }
.chat-log { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.8rem; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; }
.chat-log .user-msg, .chat-log .bot-msg { max-width: 80%; padding: 0.7rem 1rem; border-radius: 12px; line-height: 1.4; }
.chat-log .user-msg { background: var(--accent); color: white; align-self: flex-end; }
.chat-log .bot-msg { background: var(--bg-softer); border: 1px solid var(--border); align-self: flex-start; }
.chat-input { display: flex; gap: 0.5rem; padding: 0.75rem 0 0; }
#mic-btn, #file-btn { background: var(--bg-soft); border: 1px solid var(--border); font-size: 1.1em; padding: 0.55rem 0.9rem; }

/* ----- Modal ----- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 14px; padding: 0; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; }
.modal-card.wide { max-width: 1200px; }
.cust-tab { padding: 0.5rem 1rem; border-radius: 6px 6px 0 0; border: 1px solid transparent; border-bottom: none; }
.cust-tab.active { background: var(--bg-soft); border-color: var(--border); color: var(--accent); font-weight: 600; }
.cust-tab-pane { min-height: 200px; }
.cust-tab-pane table { table-layout: fixed; width: 100%; }
.cust-tab-pane table th, .cust-tab-pane table td {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  padding: 0.5rem; font-size: 0.92em;
}
.cust-tab-pane table td:nth-child(2) { white-space: normal; word-break: break-word; }
.cust-tab-pane table th:nth-child(1), .cust-tab-pane table td:nth-child(1) { width: 110px; }
.cust-tab-pane table th:nth-child(3), .cust-tab-pane table td:nth-child(3) { width: 110px; }
.cust-tab-pane table th:nth-child(4), .cust-tab-pane table td:nth-child(4) { width: 100px; text-align: right; }
.cust-tab-pane table th:nth-child(5), .cust-tab-pane table td:nth-child(5) { width: 100px; }
.cust-tab-pane table th:nth-child(6), .cust-tab-pane table td:nth-child(6) { width: 50px; }
.cust-tab-pane h4 { margin: 1rem 0 0.4rem 0; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 1.1em; }
#modal-body { padding: 1.2rem 1.5rem; overflow-y: auto; }
#modal-body .row > label { flex: 1 1 180px; }
#modal-body .form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

/* ----- Mobile ----- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -100%; top: 0; width: 260px; transition: left 0.25s; z-index: 900; }
  .sidebar.open { left: 0; box-shadow: 2px 0 18px rgba(0,0,0,0.5); }
  .menu-toggle { display: block; }
  .content { padding: 4rem 1rem 1.5rem; }
  .view-actions input[type="search"] { width: 160px; }
  th, td { padding: 0.5rem 0.7rem; font-size: 0.88em; }
  .row > label.narrow { flex: 1 1 auto; }
  .card.auth, .card.setup { margin-top: 1rem; padding: 1.2rem; }
}

/* ====================== Quotation Editor ====================== */
.qe-grid { display: flex; flex-direction: column; gap: 1.2rem; }
.qe-header { background: var(--bg-soft); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); }
.qe-header label { display: block; margin: 0.4rem 0; }
.qe-header input, .qe-header select, .qe-header textarea {
  width: 100%; padding: 0.5rem; background: var(--bg-softer); color: inherit;
  border: 1px solid var(--border); border-radius: 4px; font-family: inherit; font-size: 0.95rem;
}
.qe-header textarea { min-height: 4em; }

.customer-picker { position: relative; }
.autocomplete {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 10;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 4px;
  max-height: 240px; overflow-y: auto; margin-top: 2px;
}
.ac-item { padding: 0.4rem 0.6rem; cursor: pointer; }
.ac-item:hover { background: var(--bg-softer); }
.ac-empty { padding: 0.6rem; color: #888; }

.qe-group { background: var(--bg-soft); padding: 0.8rem 1rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1rem; }
.qe-group legend { font-size: 1rem; padding: 0 0.4rem; }
.qe-group .g-pos { color: #888; margin-right: 0.4rem; }

table.qe-items { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
table.qe-items th { text-align: left; font-weight: normal; color: #888; font-size: 0.85rem;
  padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
table.qe-items td { padding: 0.5rem; vertical-align: top; border-bottom: 1px solid var(--border); }
table.qe-items .ta-right { text-align: right; }
table.qe-items tr.row-head td, table.qe-items tr.row-note td { background: rgba(255,255,255,0.03); }
table.qe-items tr.row-alt td { background: rgba(160,160,160,0.10); font-style: italic; }
table.qe-items tr.row-event td { background: rgba(255,200,0,0.08); }
table.qe-items select.i-type-sel { font-size: 0.75rem; padding: 0.1rem 0.2rem; margin: 0 0.3rem;
  background: var(--bg-soft); color: var(--fg); border: 1px solid var(--border); border-radius: 3px; }

.qe-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.qe-add { display: flex; justify-content: center; padding: 0.5rem 0; }

.qe-totals { background: var(--bg-soft); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); }
.totals-grid { display: flex; gap: 2rem; flex-wrap: wrap; }
.totals-grid > div { display: flex; flex-direction: column; }
.totals-grid .label { color: #888; font-size: 0.85rem; }
.totals-grid b { font-size: 1.2rem; }

/* Inline-editierbare Tabellenzellen */
table.qe-items input.cell-edit, table.qe-items select.cell-edit {
  background: transparent; border: 1px solid transparent; color: inherit;
  padding: 0.2rem 0.3rem; font: inherit; width: 100%; min-width: 0;
}
table.qe-items input.cell-edit:hover, table.qe-items select.cell-edit:hover { border-color: #444; }
table.qe-items input.cell-edit:focus, table.qe-items select.cell-edit:focus {
  border-color: #58a6ff; outline: none; background: var(--bg-softer);
}
table.qe-items input.qty, table.qe-items input.price,
table.qe-items input.disc, table.qe-items input.vat { text-align: right; max-width: 8em; }
table.qe-items input.hl { font-weight: bold; font-size: 1rem; }
table.qe-items input.desc { color: #999; font-size: 0.9rem; margin-top: 0.2rem; }
table.qe-items col.col-name, table.qe-items th:nth-child(4) { min-width: 18em; }

/* responsiv: schmaler bei Handy */
@media (max-width: 760px) {
  table.qe-items input.cell-edit, table.qe-items select.cell-edit { font-size: 0.85rem; }
  table.qe-items th, table.qe-items td { padding: 0.3rem; }
}

/* Tab-Buttons (z.B. Rechnungen Aus/Eingang) */
.tab-btn { padding: 0.4rem 0.9rem; }
.tab-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Auswertung */
.ana-grid { display: flex; flex-direction: column; gap: 1rem; }
table.ana-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.ana-table th, table.ana-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
table.ana-table th { text-align: left; color: #aaa; font-weight: 600; background: rgba(255,255,255,0.02); }
table.ana-table th.r, table.ana-table td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.ana-table tfoot td { font-weight: bold; background: rgba(255,255,255,0.05); border-top: 2px solid var(--border); }
table.ana-table .neg { color: #ff7f7f; }
table.ana-table .pos { color: #a3d9a5; }
table.ana-table tr.zero td { color: #555; }

/* Invoice-Editor: Items-Tabelle (flach, ohne Gruppen) */
table.qe-items input.cell-edit-inv, table.qe-items textarea.cell-edit-inv {
  background: transparent; border: 1px solid transparent; color: inherit;
  padding: 0.2rem 0.3rem; font: inherit; width: 100%; min-width: 0;
  resize: vertical;
}
table.qe-items input.cell-edit-inv:hover, table.qe-items textarea.cell-edit-inv:hover { border-color: #444; }
table.qe-items input.cell-edit-inv:focus, table.qe-items textarea.cell-edit-inv:focus {
  border-color: #58a6ff; outline: none; background: var(--bg-softer);
}
table.qe-items .cell-edit-inv.num { text-align: right; max-width: 8em; }
table.qe-items .cell-edit-inv.unit { max-width: 7em; }
table.qe-items .cell-edit-inv.tiny { color: #999; font-size: 0.85rem; min-height: 1.2em; }
table.qe-items tr.is-heading td { background: rgba(255,255,255,0.05); font-weight: bold; }
.inv-toolbar { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }

/* Read-only items table fuer Auftrags-Detail */
table.items-readonly { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
table.items-readonly th { text-align: left; color: #888; font-size: 0.85rem;
  padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
table.items-readonly td { padding: 0.5rem; vertical-align: top; border-bottom: 1px solid var(--border); }
table.items-readonly tr.is-heading td { background: rgba(255,255,255,0.05); font-weight: bold; }

/* Service-Picker (auch im Invoice-Editor) */
.svc-picker { margin-top: 0.6rem; padding: 0.6rem; background: var(--bg-softer);
  border-radius: 6px; border: 1px solid var(--border); }
.svc-picker .svc-q { width: 60%; padding: 0.4rem; font: inherit; background: var(--bg);
  color: inherit; border: 1px solid var(--border); border-radius: 4px; }
.svc-picker .svc-cat-filter { padding: 0.4rem; font: inherit; background: var(--bg);
  color: inherit; border: 1px solid var(--border); border-radius: 4px; margin-left: 0.4rem; }
.svc-picker .svc-results { margin-top: 0.5rem; max-height: 320px; overflow-y: auto; }
.svc-row { display: grid; grid-template-columns: 100px 1fr 80px 80px auto;
  align-items: center; gap: 0.6rem; padding: 0.4rem; border-bottom: 1px dashed var(--border); font-size: 0.9rem; }
.svc-row .svc-code { color: #888; font-family: monospace; font-size: 0.85rem; }
.svc-row .svc-price { color: #a3d9a5; text-align: right; }

/* Katalog-Suche pro Gruppe */
.cat-search { margin-top: 0.6rem; padding: 0.6rem; background: var(--bg-softer); border-radius: 6px; border: 1px solid var(--border); }
.cat-search .cat-q { width: 100%; padding: 0.5rem; font: inherit; background: var(--bg); color: inherit;
  border: 1px solid var(--border); border-radius: 4px; }
.cat-search .cat-results { margin-top: 0.5rem; max-height: 320px; overflow-y: auto; }
.cat-row { display: grid; grid-template-columns: 50px 100px 1fr 50px 100px auto;
  align-items: center; gap: 0.6rem; padding: 0.4rem; border-bottom: 1px dashed var(--border); font-size: 0.9rem; }
.cat-row .cat-sup { color: #888; text-transform: uppercase; font-size: 0.8rem; }
.cat-row .cat-sku { color: #888; font-family: monospace; font-size: 0.85rem; }
.cat-row .cat-price { color: #a3d9a5; text-align: right; font-size: 0.85rem; }
.cat-row .cat-add { padding: 0.3rem 0.6rem; }
@media (max-width: 760px) {
  .cat-row { grid-template-columns: 1fr auto; }
  .cat-row .cat-sup, .cat-row .cat-sku, .cat-row .cat-unit { display: none; }
}

/* Katalog-Pflege View */
.cat-stats-grid { display: flex; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.cat-stat-tile { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem 1.2rem; min-width: 120px; }
.cat-stat-tile .label { color: #888; font-size: 0.85rem; display: block; }
.cat-stat-tile b { font-size: 1.4rem; display: block; margin: 0.2rem 0; }
.cat-stat-tile .muted { font-size: 0.8rem; }

table.cat-suppliers { width: 100%; border-collapse: collapse; background: var(--bg-soft); border-radius: 6px; overflow: hidden; margin-bottom: 1rem; }
table.cat-suppliers th, table.cat-suppliers td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); }
table.cat-suppliers thead { background: var(--bg-softer); }
table.cat-suppliers .ta-right { text-align: right; }
.cat-sku { font-family: monospace; font-size: 0.85rem; color: #888; }

fieldset.catalog-import { background: var(--bg-soft); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1rem; }
fieldset.catalog-import label { display: block; margin: 0.5rem 0; }
fieldset.catalog-import input[type="text"] { width: 100%; padding: 0.5rem; background: var(--bg-softer); color: inherit; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
fieldset.catalog-import input[type="file"] { margin-top: 0.3rem; }
#dn-status { margin-top: 0.7rem; }

/* Leistungs-Picker im Editor */
.svc-picker { margin-top: 0.6rem; padding: 0.6rem; background: var(--bg-softer); border-radius: 6px; border: 1px solid var(--border); }
.svc-picker-bar { display: flex; gap: 0.5rem; }
.svc-picker .svc-q { flex: 1; padding: 0.5rem; font: inherit; background: var(--bg); color: inherit; border: 1px solid var(--border); border-radius: 4px; }
.svc-picker .svc-cat-filter { padding: 0.5rem; font: inherit; background: var(--bg); color: inherit; border: 1px solid var(--border); border-radius: 4px; }
.svc-picker .svc-results { margin-top: 0.5rem; max-height: 360px; overflow-y: auto; }
.svc-row { display: grid; grid-template-columns: 100px 90px 1fr 80px 80px auto;
  align-items: center; gap: 0.6rem; padding: 0.4rem; border-bottom: 1px dashed var(--border); font-size: 0.9rem; }
.svc-row .svc-cat { color: #888; font-size: 0.75rem; text-transform: uppercase; }
.svc-row .svc-code { color: #888; font-family: monospace; font-size: 0.8rem; }
.svc-row .svc-price { color: #a3d9a5; text-align: right; }
.svc-row .svc-add { padding: 0.3rem 0.6rem; }
@media (max-width: 760px) {
  .svc-row { grid-template-columns: 1fr auto auto; }
  .svc-row .svc-cat, .svc-row .svc-code, .svc-row .svc-unit { display: none; }
}

/* Leistungen-View Übersicht */
h3.svc-cat { color: #888; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 0.05em; margin: 1rem 0 0.4rem 0; }

/* Arbeitsdokumente */
.wr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.wr-card { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 1.5rem 1rem; cursor: pointer; text-align: left; color: inherit; }
.wr-card:hover { background: var(--bg-softer); border-color: #58a6ff; }
.wr-card .wr-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.wr-card h3 { margin: 0.3rem 0; font-size: 1.05rem; }
.wr-card p { margin: 0; color: #888; font-size: 0.9rem; }

#wr-list-section h2 { font-size: 0.85rem; letter-spacing: 0.05em; text-transform: uppercase; }

/* Checkliste im Work-Report-Editor */
.cl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; align-items: center;
  padding: 0.4rem 0; border-bottom: 1px dashed var(--border); }
.cl-check { display: flex; align-items: center; gap: 0.5rem; }
.cl-note { padding: 0.4rem; background: var(--bg-softer); color: inherit; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
@media (max-width: 760px) {
  .cl-row { grid-template-columns: 1fr; gap: 0.3rem; }
}

/* Checklist Section-Header */
.cl-section { color: #58a6ff; font-weight: bold; font-size: 0.85rem;
  letter-spacing: 0.05em; text-transform: uppercase;
  margin: 0.8rem 0 0.3rem 0; padding-bottom: 0.2rem;
  border-bottom: 1px solid var(--border); }
.cl-section:first-child { margin-top: 0; }

/* Section-Headings auf Arbeitsdokumente-View */
h2.wr-section { color: #58a6ff; font-size: 0.9rem; letter-spacing: 0.05em;
  text-transform: uppercase; margin: 1.4rem 0 0.6rem 0;
  padding-bottom: 0.3rem; border-bottom: 1px solid var(--border); }
h2.wr-section:first-child { margin-top: 0; }
.wr-cards { margin-bottom: 1rem; }

/* Entwickler-Assistent */
.dev-chat { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; min-height: 300px; max-height: 60vh; overflow-y: auto; margin-bottom: 0.6rem; }
.dev-chat .user-msg, .dev-chat .bot-msg { margin: 0.5rem 0; padding: 0.6rem 0.8rem; border-radius: 6px; }
.dev-chat .user-msg { background: var(--bg-softer); border-left: 3px solid #58a6ff; }
.dev-chat .bot-msg { background: var(--bg); border-left: 3px solid #a3d9a5; }
.dev-chat p { margin: 0; white-space: pre-line; }
.dev-chat code { background: var(--bg-softer); padding: 0.1em 0.3em; border-radius: 3px; font-family: monospace; font-size: 0.9em; }
.dev-chat pre { background: var(--bg-softer); padding: 0.6rem; border-radius: 4px; overflow-x: auto; font-family: monospace; font-size: 0.85rem; }

.dev-terminal { margin-top: 1.2rem; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 0.8rem; }
.dev-terminal summary { cursor: pointer; font-weight: bold; padding: 0.3rem 0; }
.dev-terminal form { display: flex; gap: 0.5rem; margin: 0.6rem 0; }
.dev-terminal input { flex: 1; padding: 0.5rem; font-family: monospace; background: var(--bg); color: inherit; border: 1px solid var(--border); border-radius: 4px; }
.dev-terminal button { padding: 0.5rem 1rem; }
.dev-out { background: #000; color: #b8e6b8; padding: 0.7rem; border-radius: 4px;
  font-family: "Courier New", monospace; font-size: 0.85rem; max-height: 400px; overflow: auto; white-space: pre-wrap; }

/* Foto-Upload im Chat */
.photo-btn {
  cursor: pointer; padding: 0.5rem 0.7rem; background: var(--bg-softer);
  border: 1px solid var(--border); border-radius: 4px;
  font-size: 1.1rem; user-select: none;
}
.photo-btn:hover { background: var(--bg-soft); }
#chat-photo-preview {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem; background: var(--bg-soft); border-radius: 6px;
  margin-top: 0.4rem;
}
#chat-photo-img { max-height: 60px; border-radius: 4px; }
.chat-thumb { max-width: 220px; max-height: 200px; border-radius: 6px;
  display: block; margin-bottom: 0.4rem; }

/* Foto-Grid im Arbeitsdokument-Editor */
.wre-photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem; margin-top: 0.6rem; }
.wre-photo-tile { position: relative; background: var(--bg-softer); border-radius: 6px; overflow: hidden;
  aspect-ratio: 1; }
.wre-photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wre-photo-del { position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff; border-radius: 50%;
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border: none; cursor: pointer; }
.wre-photo-del:hover { background: rgba(220,50,50,0.85); }

/* ===== iPhone-Hochformat-Optimierung ===== */
@media (max-width: 480px) {
  body { font-size: 15px; }
  .content { padding: 3.5rem 0.7rem calc(1rem + env(safe-area-inset-bottom, 0)) 0.7rem; }
  .view-header { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .view-header h1 { font-size: 1.3rem; margin: 0; }
  .view-header .view-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
  .view-header .view-actions input[type="search"] { flex: 1 1 100%; min-width: 0; }
  .view-header .view-actions button, .view-header .view-actions select { flex: 1 1 auto; }

  /* Tabellen scrollen horizontal statt zerquetscht */
  .table-wrap, table.cat-suppliers, table.qe-items {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  table.qe-items { min-width: 640px; }   /* breite Editor-Tabelle scrollt */

  /* Quotation-Editor Header: Felder voll breit, einzeln untereinander */
  .qe-header label { display: block; }
  .qe-header input, .qe-header select, .qe-header textarea { width: 100%; box-sizing: border-box; }

  /* WR-Karten 1-spaltig statt 2 */
  .wr-cards { grid-template-columns: 1fr; }

  /* Auth-/Setup-Karten Padding kleiner */
  .card.auth, .card.setup { padding: 1rem; margin: 0.5rem; }

  /* Sidebar: voller Bildschirm wenn offen, mit safe-area */
  .sidebar { width: 86vw; max-width: 320px; padding-top: calc(0.5rem + env(safe-area-inset-top, 0)); }
  .menu-toggle { top: calc(0.6rem + env(safe-area-inset-top, 0)); }

  /* Modal nicht ueber den Bildschirmrand */
  .modal { padding: 0.5rem; }
  .modal-card { width: 100%; max-height: 90vh; overflow-y: auto; }

  /* Chat-Eingabefeld breit, Buttons darunter */
  .chat-input { flex-wrap: wrap; }
  .chat-input input[type="text"] { flex: 1 1 100%; }

  /* Foto-Grid kleiner */
  .wre-photos-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}

/* ===== Hamburger-Menue-Knopf garantiert dunkel + nicht ueber Inhalt ===== */
.menu-toggle {
  background: #1c2128 !important;
  color: #c9d1d9 !important;
  border: 1px solid #30363d !important;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
@media (max-width: 480px) {
  .menu-toggle { padding: 0.4rem 0.6rem; font-size: 1.2em; }
  /* Inhalt etwas weiter runter, damit Knopf nicht ueber H1 */
  #view-dashboard { padding-top: 1rem; }
  .view-header h1 { padding-left: 2.5rem; }   /* Platz neben dem Hamburger */
}

/* ===== Hamburger-Knopf richtig fix + sichtbar abgegrenzt ===== */
.menu-toggle {
  position: fixed !important;
  top: calc(0.7rem + env(safe-area-inset-top, 0)) !important;
  left: 0.7rem !important;
  z-index: 1500;
  background: #161b22 !important;
  color: #c9d1d9 !important;
  border: 1px solid #444c56 !important;
  border-radius: 10px;
  padding: 0.5rem 0.85rem !important;
  font-size: 1.4em !important;
  line-height: 1;
  box-shadow: 0 4px 14px rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.menu-toggle:active { background: #1c2128 !important; transform: scale(0.96); }

@media (max-width: 480px) {
  /* Genug Luft, damit Inhalt NIE unter den Knopf rutscht */
  .content { padding-top: 4.2rem !important; }
  .view-header { padding-left: 0; }
  .view-header h1 { padding-left: 0; }
}

/* ===== Sicherheitsabstand: Inhalt darf NIE unter dem Hamburger sitzen ===== */
@media (max-width: 860px) {
  /* Hamburger-Bereich oben links reserviert */
  .content { padding-top: 5rem; padding-left: 0.8rem; padding-right: 0.8rem; }
  .view-header { padding-left: 0; }
  /* H1 immer mit Mindestabstand zum Hamburger */
  .view-header h1 { margin-left: 3rem; line-height: 1.2; }
  /* Bei sehr kleinen Screens: View-Header in 2 Zeilen */
  .view-actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .content { padding-top: 4.5rem; }
  .view-header h1 { font-size: 1.25rem; margin-left: 2.5rem; }
}

/* ===== Hamburger compact + Inhalt schiebt nach rechts ===== */
@media (max-width: 860px) {
  .menu-toggle {
    width: 44px; height: 44px;
    padding: 0 !important;
    font-size: 1.5em !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }
  /* Content komplett RECHTS vom Hamburger - keine Ueberlappung mehr moeglich */
  .content { padding-left: 3.6rem; padding-right: 0.8rem; }
  .view-header h1 { margin-left: 0; padding-left: 0; }
  .view-header { padding-left: 0; }
}
@media (max-width: 480px) {
  .menu-toggle { width: 40px; height: 40px; }
  .content { padding-left: 3.2rem; padding-top: 0.8rem; }
  .view-header h1 { font-size: 1.2rem; }
}

/* ===== Mehr Abstand: Inhalt weiter weg vom Hamburger, Knopf bleibt gleich ===== */
@media (max-width: 860px) {
  .content { padding-left: 5rem; }   /* war 3.6rem -> jetzt mehr Luft */
  .view-header { gap: 1rem; margin-bottom: 1.5rem; padding-top: 0.5rem; }
  .view-header h1 { margin-bottom: 0.3rem; }
}
@media (max-width: 480px) {
  .content { padding-left: 4.5rem; }   /* war 3.2rem -> jetzt mehr Luft */
}

/* ===== "Büro"-Branding aus Sidebar ausblenden, Hoehe aber halten ===== */
.sidebar .brand {
  visibility: hidden;
  height: 1.3em;   /* gleiche Hoehe wie das alte Label */
  padding: 0.3rem 0.5rem 1rem;
}

/* ===== Spalten-Offset zuruecknehmen - urspruengliche Werte ===== */
@media (max-width: 860px) {
  .content { padding: 4rem 1rem 1.5rem !important; }
  .view-header h1 { margin-left: 0; }
}
@media (max-width: 480px) {
  .content { padding: 3.5rem 0.7rem calc(1rem + env(safe-area-inset-bottom, 0)) 0.7rem !important; }
}

/* Kalender */
.cal-day { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.8rem; margin-bottom: 0.7rem; }
.cal-day-h { font-weight: bold; font-size: 0.95rem; color: #58a6ff; margin-bottom: 0.4rem; }
.cal-event { background: var(--bg-softer); border-left: 4px solid #2da44e;
  padding: 0.5rem 0.7rem; margin: 0.3rem 0; border-radius: 4px; cursor: pointer; }
.cal-event:hover { background: #1c2128; }
.cal-time { font-size: 0.85rem; color: #888; }
.cal-title { font-weight: bold; }
.cal-loc { font-size: 0.85rem; color: #aaa; margin-top: 0.2rem; }
#cal-range { margin: 0 0.6rem; }

/* Termin-Modal Outlook-style */
.appt-form label { display: block; margin: 0.5rem 0; }
.appt-form input[type="text"], .appt-form input[type="date"],
.appt-form input[type="datetime-local"], .appt-form textarea {
  width: 100%; padding: 0.55rem; background: var(--bg-softer); color: inherit;
  border: 1px solid var(--border); border-radius: 4px; font: inherit; box-sizing: border-box;
}
.appt-form .appt-row { display: flex; gap: 0.6rem; }
.appt-form .appt-row > label { flex: 1; }
.appt-form .appt-allday { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.appt-form .form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: center; }
.appt-form #appt-cust-meta { padding-top: 0.3rem; font-size: 0.85rem; }
@media (max-width: 480px) { .appt-form .appt-row { flex-direction: column; gap: 0; } }

/* Sub-Menue-Buttons im Termin-Modal (Wartung / Vor-Ort / Prüfung Auswahl) */
.appt-sub-menu {
  margin: 0.4rem 0; padding: 0.5rem;
  background: var(--bg-softer); border-radius: 6px;
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  border: 1px solid var(--border);
}
.appt-sub-menu button { padding: 0.4rem 0.7rem; font-size: 0.9rem; }

/* PDF-Vorlagen-Upload-Sektion */
fieldset.forms-upload { margin-top: 1.5rem; background: var(--bg-soft); padding: 1rem; border-radius: 8px; border: 1px solid var(--border); }
fieldset.forms-upload legend { padding: 0 0.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-top: 0.6rem; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.form-card { background: var(--bg-softer); padding: 0.8rem; border-radius: 6px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 0.3rem; cursor: pointer; }
.form-card:hover { border-color: #58a6ff; }
.form-name { font-weight: bold; }
.form-card input[type="file"] { margin-top: 0.4rem; font-size: 0.85rem; }

/* Theme-Picker im Einstellungen-Tab */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.theme-pick { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 0.8rem; background: var(--bg-soft); border: 2px solid var(--border); border-radius: 10px; color: var(--fg); cursor: pointer; font-weight: 500; }
.theme-pick:hover { border-color: var(--accent); }
.theme-pick.active { border-color: var(--accent); background: var(--bg-softer); }

/* Kalender-View-Toggle */
.cal-view-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* Kalender-Monatsansicht */
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-month .cal-mday { background: var(--bg-soft); min-height: 100px; padding: 0.4rem; display: flex; flex-direction: column; gap: 0.2rem; cursor: pointer; }
.cal-month .cal-mday.other { opacity: 0.4; }
.cal-month .cal-mday.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-month .cal-mday-num { font-weight: bold; font-size: 0.85rem; }
.cal-month .cal-mday-events { display: flex; flex-direction: column; gap: 1px; }
.cal-month .cal-mday-ev { font-size: 0.7rem; padding: 1px 4px; border-radius: 3px; background: var(--accent); color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-month .cal-mhdr { background: var(--bg-softer); padding: 0.4rem; text-align: center; font-weight: bold; font-size: 0.85rem; }

/* Tagesansicht */
.cal-day-view { display: grid; grid-template-columns: 60px 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; }
.cal-day-view .cal-hour-label { padding: 0.4rem; background: var(--bg-soft); font-size: 0.85rem; text-align: right; color: var(--muted); }
.cal-day-view .cal-hour-slot { padding: 0.4rem; background: var(--bg-soft); min-height: 40px; }
.cal-day-view .cal-event-slot { background: var(--accent); color: white; padding: 0.3rem 0.6rem; border-radius: 4px; margin-bottom: 2px; cursor: pointer; }

/* Listenansicht */
.cal-list-view .cal-list-item { padding: 0.6rem; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 6px; margin-bottom: 0.4rem; cursor: pointer; display: grid; grid-template-columns: 90px 1fr; gap: 0.6rem; }
.cal-list-view .cal-list-item:hover { background: var(--bg-softer); }
.cal-list-view .cal-list-date { color: var(--muted); font-size: 0.85rem; }
.cal-list-view .cal-list-date .day-num { font-size: 1.4rem; font-weight: bold; color: var(--fg); display: block; }

/* Resizable Tabellen-Spalten in Listen-Übersichten */
.table-wrap table { table-layout: fixed; }
.table-wrap table th { position: relative; user-select: none; }
.table-wrap table th .col-resize {
  position: absolute; right: 0; top: 0; bottom: 0; width: 6px;
  cursor: col-resize; user-select: none; z-index: 5;
}
.table-wrap table th .col-resize:hover,
.table-wrap table th .col-resize.dragging { background: var(--accent); }
.theme-swatch { width: 56px; height: 56px; border-radius: 50%; border: 2px solid; position: relative; overflow: hidden; }
.theme-swatch > span { position: absolute; right: 6px; bottom: 6px; width: 18px; height: 18px; border-radius: 50%; }

/* Drag & Drop für Angebot-Positionen */
table.qe-items tr[draggable="true"] { transition: box-shadow 0.1s; }
table.qe-items tr.drag-over td { box-shadow: inset 0 3px 0 #1a4; }
fieldset.qe-group.drag-over { box-shadow: inset 0 0 0 2px #1a4; }
.drag-handle { display: inline-block; cursor: grab; }
.drag-handle:active { cursor: grabbing; }

/* === Sanfte Defensiv-Fixes (2026-04-27 v2) === */
*, *::before, *::after { box-sizing: border-box; }

/* Inputs: nicht ueberfluten */
input, textarea, select { max-width: 100%; min-width: 0; }

/* Lange Worte/URLs in Tabellen brechen */
td, th { overflow-wrap: anywhere; }

/* Inputs in Tabellen-Zellen koennen schrumpfen */
table input, table textarea, table select { min-width: 0; }

/* Tabellen-Wrapper scrollbar */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Modals nie ueber Viewport */
.modal-card { max-height: 92vh; }

/* === Mobile: nur richtig kleine Phones === */
@media (max-width: 600px) {
  .content { padding: 0.7rem 0.6rem; }
  .view-header h1 { font-size: 1.15rem; }

  /* Item-Tabellen seitlich scrollen */
  table.qe-items, table.items, table.tehours,
  #wre-items table, #wre-te-list table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  table.qe-items tbody, table.items tbody, table.tehours tbody { white-space: normal; }

  /* Modals fast Vollbild */
  .modal-card { max-width: 100vw; max-height: 100vh; border-radius: 0; }
  #modal-body { padding: 0.8rem 0.9rem; }

  /* Form-Rows stapeln */
  .row { flex-direction: column; gap: 0.4rem; }

  /* iOS: Inputs ohne Auto-Zoom */
  input, textarea, select { font-size: 16px; }
}


/* Listen-Tabellen: Titel-Spalte umbrechen, nicht abschneiden */
.table-wrap table td { vertical-align: middle; }
.table-wrap table td:nth-child(2) {
  white-space: normal;
  word-break: break-word;
  max-width: 32rem;
  line-height: 1.35;
}
.table-wrap table { table-layout: auto; }


/* Mobile (<= 600px): Listen-Tabellen kompakt — Titel auf 2 Zeilen, sonst scrollbar */
@media (max-width: 600px) {
  .table-wrap { overflow-x: auto; }
  .table-wrap table { font-size: 0.82em; }
  .table-wrap table td, .table-wrap table th { padding: 0.5rem 0.4rem; }
  .table-wrap table td:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 11rem;
    line-height: 1.2;
  }
  .table-wrap table td, .table-wrap table th {
    padding: 0.35rem 0.3rem;
  }
  .table-wrap table { font-size: 0.78em; }
  /* Status-Dropdowns kompakter */
  .table-wrap table select { font-size: 0.85em; padding: 0.2rem 0.3rem; min-width: 6rem; }
  /* Geld-Spalten kleiner */
  .table-wrap table td.ta-right, .table-wrap table th.ta-right { white-space: nowrap; }
}


/* Externe-Portale-Karten */
.portal-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  text-decoration: none;
  color: var(--fg, inherit);
  background: var(--bg-soft);
  transition: all 0.15s;
  font-size: 0.95em;
}
.portal-link:hover {
  background: var(--bg-softer);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}


/* Sortierbare Tabellen-Header */
table.sortable th[data-sort-key] {
  cursor: pointer;
  user-select: none;
  position: relative;
}
table.sortable th[data-sort-key]:hover {
  background: var(--bg-soft);
}
table.sortable th[data-sort-key].sort-asc::after {
  content: " ▲";
  font-size: 0.75em;
  opacity: 0.7;
}
table.sortable th[data-sort-key].sort-desc::after {
  content: " ▼";
  font-size: 0.75em;
  opacity: 0.7;
}


/* Dashboard Marlon-Tile */
.dash-marlon-btn {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: .45rem .8rem;
  border-radius: .4rem;
  font-size: .9em;
  cursor: pointer;
  font-weight: 500;
}
.dash-marlon-btn:hover {
  background: rgba(255,255,255,0.28);
}


/* Dokument-erstellen Hub */
.create-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.create-card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: 1.2rem 1rem;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: all .15s;
  color: var(--fg);
}
.create-card:hover {
  border-color: var(--accent, #4a6fdc);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,.08);
}
.create-icon { font-size: 2rem; line-height: 1; }
.create-title { font-weight: 600; font-size: 1rem; }
.create-desc { font-size: .8em; opacity: .7; }


/* (alte details/summary nav-group entfernt) */


/* Dokument erstellen — Listen-Layout */
.create-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.8rem;
  max-width: 700px;
}
.create-list .create-card {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  text-align: left;
  width: 100%;
  border-radius: 0.4rem;
}
.create-list .create-icon {
  font-size: 1.6rem;
  width: 2.5rem;
  flex-shrink: 0;
}
.create-list .create-title {
  font-weight: 600;
  font-size: 1rem;
  flex: 0 0 auto;
}
.create-list .create-desc {
  flex: 1;
  font-size: 0.85em;
  opacity: 0.7;
  text-align: left;
  margin-left: 0.4rem;
}



/* <a> als Button (fuer tel: und mailto: Links) */
.btn-anchor {
  display: inline-block; padding: 0.65rem 1.1rem; border-radius: 8px;
  background: var(--accent); color: white; font-size: 0.95em; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn-anchor.ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-anchor.ghost:hover { border-color: var(--accent); background: var(--bg-softer); }

/* Kunden-Modal: Action-Bar oben (kompakt, sichtbar ohne Scrollen) */
.cust-action-bar {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 16px 0; padding: 10px 12px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
}
.cust-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 6px;
  background: var(--bg-softer); color: var(--fg);
  border: 1px solid var(--border); cursor: pointer; text-decoration: none;
  font-size: 0.95em; font-weight: 600; font-family: inherit;
}
.cust-action:hover { background: var(--bg); border-color: var(--accent); }
@media (max-width: 480px) {
  .cust-action-bar { gap: 6px; padding: 8px; }
  .cust-action { flex: 1 1 calc(50% - 3px); justify-content: center; padding: 10px 8px; font-size: 0.9em; }
}

/* Icon-only Mode am Handy */
.cust-icon { font-size: 1.1em; }
.cust-label { margin-left: 6px; }
@media (max-width: 480px) {
  .cust-action-bar { gap: 4px; padding: 6px; }
  .cust-action {
    flex: 1 1 0; min-width: 0; justify-content: center;
    padding: 12px 4px; font-size: 1.3em;
  }
  .cust-label { display: none; }
  .cust-icon { font-size: 1.4em; }
}

/* Kunden-Modal Tabs */
.cust-tabs {
  display: flex; gap: 4px; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.cust-tab { border-radius: 6px 6px 0 0; padding: 8px 12px; }
.cust-tab .t-icon { display: inline; }
.cust-tab .t-label { display: inline; margin-left: 6px; }
@media (max-width: 480px) {
  .cust-tabs { gap: 2px; }
  .cust-tab {
    flex: 1 1 0; min-width: 0; padding: 10px 4px;
    font-size: 1.2em; text-align: center;
  }
  .cust-tab .t-label { display: none; }
  .cust-tab .t-icon { font-size: 1.3em; }
}

/* === iOS Hochformat-Fixes === */

/* Sidebar: dynamische Viewport-Hoehe + scrollbar (auch wenn iOS-Adressleiste eingeblendet) */
.sidebar {
  height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Modal: dynamische Viewport-Hoehe + Header oben fixiert sodass X immer erreichbar */
@media (max-width: 600px) {
  .modal-card {
    max-width: 100vw; max-height: 100vh; max-height: 100dvh;
    border-radius: 0; height: 100dvh;
  }
  .modal-header {
    position: sticky; top: 0; z-index: 5;
    background: var(--bg-soft);
    padding: 0.7rem 1rem;
  }
  #modal-body { -webkit-overflow-scrolling: touch; }
  /* Schliessen-Button am Handy groesser tappbar */
  #modal-close { font-size: 1.4em; padding: 6px 12px; }
}

/* Sidebar nav-Texte umbrechen statt ueberlaufen */
.nav-btn {
  white-space: normal;
  word-break: keep-all;
  line-height: 1.25;
}
.nav-group-header {
  white-space: nowrap;
}

/* @-Symbol gross + zentriert wie ein Icon */
.cust-at {
  font-weight: 800; font-size: 1.3em;
  line-height: 1; display: inline-block; transform: translateY(-1px);
}
/* Inline-SVG (WhatsApp-Logo) vertikal mittig */
.cust-icon svg { vertical-align: middle; display: inline-block; }

/* iOS Safe-Area: Modal-Header rutscht hinter Statusleiste — padding-top mit env() */
@media (max-width: 600px) {
  .modal-header {
    padding-top: calc(0.7rem + env(safe-area-inset-top, 0)) !important;
  }
  /* Sidebar Top auch mit safe-area */
  .sidebar {
    padding-top: calc(16px + env(safe-area-inset-top, 0));
  }
}

/* === WhatsApp Messenger-Style === */
#wa-mic-btn.wa-mic-recording {
  background: #e74c3c !important; color: #fff !important;
  border-color: #e74c3c !important;
  animation: waMicPulse 1s infinite;
}
@keyframes waMicPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.5); } 50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); } }

/* Bubbles weicher + Messenger-Look */
#wa-thread #wa-msgs > div {
  border-radius: 16px !important;
  padding: 8px 12px !important;
  margin-bottom: 4px !important;
  box-shadow: 0 1px 1px rgba(0,0,0,0.06);
  position: relative;
}
/* Eingehend: rund mit Spitze links */
#wa-thread #wa-msgs > div[style*=bg-softer],
#wa-thread #wa-msgs > div[style*=align-self:flex-start] {
  border-bottom-left-radius: 4px !important;
}
/* Ausgehend: WA-grün, Spitze rechts */
#wa-thread #wa-msgs > div[style*=dcf8c6] {
  border-bottom-right-radius: 4px !important;
}
html[data-theme=dark] #wa-thread #wa-msgs > div[style*=dcf8c6],
html:not([data-theme]) #wa-thread #wa-msgs > div[style*=dcf8c6] {
  background: #056162 !important; color: #fff !important;
}

/* Datums-Trenner (wird per JS eingefuegt) */
.wa-date-sep {
  align-self: center; background: rgba(0,0,0,0.05);
  padding: 3px 12px; border-radius: 999px;
  font-size: 0.75em; color: var(--muted);
  margin: 8px 0; box-shadow: none !important;
}

/* WA Thread-Header kompakter */
#wa-thread-header {
  background: var(--bg-soft);
  padding: 0.6rem 0.8rem !important;
  border-bottom: 1px solid var(--border);
}

/* Mehr Luft im Msg-Container, schoenes Wallpaper-Feeling */
#wa-msgs {
  background: var(--bg);
  background-image: linear-gradient(180deg, transparent, rgba(0,0,0,0.02));
  padding: 12px !important; gap: 2px !important;
}

/* Composer 2-zeilig: Buttons oben, Text+Senden unten */
#wa-send-form {
  flex-wrap: wrap;
}
#wa-send-form > label[for="wa-attach-file"],
#wa-send-form > #wa-template-btn,
#wa-send-form > #wa-send-location-btn,
#wa-send-form > #wa-mic-btn {
  flex: 0 0 auto;
}
#wa-send-form > #wa-send-text {
  flex: 1 1 100%;
  min-width: 0;
  order: 10;
  padding: 0.7rem 0.9rem !important;
  font-size: 1em;
}
#wa-send-form > #wa-send-btn {
  order: 11;
  flex: 0 0 auto;
  padding: 0.7rem 1.2rem !important;
}

/* Composer 2-zeilig — !important damit's gegen inline-style gewinnt */
#wa-send-form { flex-wrap: wrap !important; gap: 6px !important; padding: 8px !important; }
#wa-send-form > #wa-send-text {
  flex: 1 1 100% !important;
  width: 100% !important;
  order: 10 !important;
  padding: 0.7rem 0.9rem !important;
  font-size: 1em !important;
}
#wa-send-form > #wa-send-btn {
  order: 11 !important;
  flex: 1 1 100% !important;
  padding: 0.7rem 1.2rem !important;
  font-size: 1em !important;
}
@media (min-width: 720px) {
  /* Am Desktop: Senden-Button rechts neben Text */
  #wa-send-form > #wa-send-btn { flex: 0 0 auto !important; }
  #wa-send-form > #wa-send-text { flex: 1 1 calc(100% - 120px) !important; width: auto !important; }
}

/* Rot-Theme — fuer Ebner Haustechnik */
html[data-theme="rot"] {
  --bg: #ffffff;
  --bg-soft: #fef4f4;
  --bg-softer: #fce5e5;
  --border: #e8c8c8;
  --fg: #1a0808;
  --muted: #7a4a4a;
  --accent: #c8202c;
  --accent-hover: #a91824;
  --error: #8b0000;
}
