/* === RESET & BASE === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --brand: #FFB800; --brand-hover: #ffce4d; --brand-light: #fff2c2; --brand-50: #fff8dc; --brand-fg: #141414; --ink: #141414; --ink-2: #2a2a2a; --ink-3: #4a4a4a; --blue: var(--brand); --blue-hover: var(--brand-hover); --blue-light: var(--brand-light); --blue-50: var(--brand-50);
  --green: #16a34a; --green-light: #f0fdf4;
  --amber: #d97706; --amber-light: #fffbeb;
  --red: #dc2626; --red-light: #fef2f2;
  --gray-50: #F4F1EA; --gray-100: #E4E0D6; --gray-200: #d4d0c6; --gray-300: #b4b0a6;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-700: #374151; --gray-900: #111827;
  --white: #ffffff;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
html { font-size: 15px; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-900); min-height: 100vh; }

/* === TOPBAR === */
.logo { width: 32px; height: 32px; background: var(--blue); color: white; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; }
.topbar h1 { font-size: 18px; font-weight: 700; }
.quote-nr { font-size: 13px; color: var(--gray-400); font-weight: 500; }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; transition: all .15s; font-family: var(--font); }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-secondary { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-700); }
.btn-lg { padding: 12px 28px; font-size: 16px; border-radius: var(--radius); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: var(--red); color: white; }

/* === MAIN === */
.main { max-width: 900px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }

/* === SECTIONS === */
.section { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.section-header { margin-bottom: 20px; }
.section-header h2 { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.section-hint { font-size: 13px; color: var(--gray-500); }

/* === INPUT SECTION === */
.input-area { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.mic-btn { width: 72px; height: 72px; border-radius: 50%; border: 3px solid var(--blue); background: var(--blue-light); color: var(--blue); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all .2s; flex-shrink: 0; }
.mic-btn:hover { background: var(--blue); color: white; }
.mic-btn.recording { background: var(--red); border-color: var(--red); color: white; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.input-text-wrap { flex: 1; position: relative; }
.input-text-wrap textarea { width: 100%; padding: 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); font-size: 15px; font-family: var(--font); resize: vertical; min-height: 90px; transition: border-color .15s; }
.input-text-wrap textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50); }
.transcript-live { position: absolute; bottom: 8px; left: 12px; right: 12px; font-size: 13px; color: var(--gray-400); font-style: italic; pointer-events: none; }
.input-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.extended-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-500); cursor: pointer; padding: 4px 10px; border-radius: 99px; transition: all .15s; user-select: none; }
.extended-toggle:hover { background: var(--blue-light); color: var(--blue); }
.extended-toggle input { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.extended-toggle input:checked + span { color: var(--blue); font-weight: 600; }

/* Status bar */
.status-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--radius-sm); margin-top: 12px; font-size: 13px; font-weight: 500; }
.status-bar.info { background: var(--blue-light); color: var(--blue); }
.status-bar.success { background: var(--green-light); color: var(--green); }
.status-bar.warning { background: var(--amber-light); color: var(--amber); }
.status-bar.error { background: var(--red-light); color: var(--red); }

/* === POSITIONS SECTION === */
.positions-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.position-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); transition: border-color .15s; }
.position-card:hover { border-color: var(--blue); }
.position-card.ki-added { border-left: 3px solid var(--blue); }
.position-num { width: 28px; height: 28px; background: var(--gray-100); color: var(--gray-700); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; margin-top: 2px; }
.position-body { flex: 1; }
.position-title { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.position-title input { border: none; font: inherit; font-weight: 600; width: 100%; padding: 0; background: transparent; }
.position-title input:focus { outline: none; border-bottom: 1px solid var(--blue); }
.position-meta { font-size: 12px; color: var(--gray-500); display: flex; gap: 12px; flex-wrap: wrap; }
.position-badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-user { background: var(--gray-100); color: var(--gray-700); }
.badge-ki { background: var(--blue-light); color: var(--blue); }
.position-actions { display: flex; gap: 4px; flex-shrink: 0; }
.positions-actions { display: flex; gap: 12px; justify-content: space-between; }

/* Position details row (chips for stunden, badge, teile count, avg price) */
.position-details { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.detail-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; background: var(--gray-100); border-radius: 99px; font-size: 12px; color: var(--gray-700); }
.detail-chip strong { font-weight: 700; }
.price-chip { background: var(--green-light); color: var(--green); font-weight: 600; }

/* Click-to-edit */
.editable { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .15s; }
.editable:hover { border-bottom-color: var(--blue); color: var(--blue); }
.editable-num { cursor: pointer; transition: background .15s; }
.editable-num:hover { background: var(--blue-light); }
.inline-edit { border: 1px solid var(--blue) !important; border-radius: 4px !important; padding: 2px 6px !important; font-size: inherit; font-family: var(--font); background: var(--white); box-shadow: 0 0 0 3px var(--blue-50); }

/* Teil tags (parts shown inside position card) */
.position-teile { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.teil-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 6px; font-size: 12px; cursor: pointer; transition: all .15s; }
.teil-tag:hover { border-color: var(--blue); background: var(--blue-light); }
.teil-selected { border-color: var(--blue); background: var(--blue-light); box-shadow: 0 0 0 2px var(--blue-50); }
.teil-name { font-weight: 500; color: var(--gray-900); }
.teil-hersteller { color: var(--gray-500); font-size: 11px; }
.teil-preis { font-weight: 700; color: var(--green); white-space: nowrap; }
.teil-link { color: var(--blue); text-decoration: none; font-size: 12px; line-height: 1; flex-shrink: 0; display: inline-flex; align-items: center; gap: 3px; }
.teil-link:hover { color: var(--blue-hover); }
.teil-domain { font-size: 11px; color: var(--gray-400); }
.teil-link:hover .teil-domain { color: var(--blue-hover); }
.teil-delete { background: none; border: none; color: var(--gray-300); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; flex-shrink: 0; margin-left: auto; }
.teil-delete:hover { color: var(--red); }

/* Position hint */
.position-hint { font-size: 12px; color: var(--gray-500); margin-top: 4px; font-style: italic; }

/* === PARTS SECTION === */
.parts-list { display: flex; flex-direction: column; gap: 16px; }
.part-group { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); overflow: hidden; }
.part-collapsed .part-group-body { padding: 14px; }
.part-name { font-weight: 500; }
.part-manufacturer { color: var(--gray-500); font-size: 12px; }
.part-price { font-weight: 600; text-align: right; }
.part-select { cursor: pointer; }
.labor-row label { font-size: 13px; color: var(--gray-500); }
.labor-input { display: flex; align-items: center; gap: 6px; }
.labor-input span { font-size: 13px; color: var(--gray-500); }
.labor-cost { font-weight: 600; font-size: 14px; min-width: 80px; text-align: right; }

/* === QUOTE SECTION === */
.customer-card { padding: 16px; background: var(--gray-50); border-radius: var(--radius-sm); margin-bottom: 20px; }
.customer-card h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--gray-700); }
.customer-fields { display: flex; flex-direction: column; gap: 8px; }
.field { padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 14px; font-family: var(--font); width: 100%; }
.field:focus { outline: none; border-color: var(--blue); }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* Quote table */

/* Totals */

/* === EXPORT SECTION === */
.export-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* === OVERLAY === */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 80px; }
.overlay-content { background: var(--white); border-radius: var(--radius); width: 500px; max-height: 60vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.overlay-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--gray-200); }
.overlay-header h2 { font-size: 16px; font-weight: 700; }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-500); padding: 4px; }
.btn-close:hover { color: var(--gray-700); }
.overlay-body { padding: 16px 20px; }
.quote-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--gray-100); cursor: pointer; transition: background .15s; }
.quote-list-item:hover { background: var(--gray-50); }
.ql-info { font-weight: 600; font-size: 14px; }
.ql-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* === UTILITIES === */
.hidden { display: none !important; }
.empty { text-align: center; color: var(--gray-400); padding: 20px; font-size: 14px; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: white; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Message history */
.msg-history { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.msg-history:empty { display: none; }
.msg-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; background: var(--gray-100); border-radius: 99px; font-size: 12px; }
.msg-time { color: var(--gray-400); font-weight: 500; }
.msg-preview { color: var(--gray-700); }

/* Diff proposals */
.diff-proposal { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 10px; background: var(--amber-light); border-radius: 99px; }
.diff-old { text-decoration: line-through; color: var(--gray-400); }
.diff-new { font-weight: 700; color: var(--amber); }
.diff-arrow { color: var(--gray-400); }
.diff-accept, .diff-reject { background: none; border: none; cursor: pointer; font-size: 14px; padding: 0 2px; line-height: 1; }
.diff-accept { color: var(--green); }
.diff-reject { color: var(--red); }

/* Position select checkbox */
.pos-check { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; margin-top: 6px; flex-shrink: 0; }
.pos-summary { font-size: 12px; color: var(--gray-400); margin-left: 8px; font-weight: 400; }
.pos-toolbar { display: flex; align-items: center; gap: 8px; }
.pos-toolbar-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--gray-500); cursor: pointer; }
.pos-toolbar-check input { accent-color: var(--blue); cursor: pointer; }
.pos-collapsed .position-body { }

/* Add position form */
.add-pos-form { display: flex; gap: 8px; align-items: center; padding: 12px; background: var(--blue-light); border-radius: var(--radius-sm); }

/* Copy buttons in section headers */
.copy-section-btn { flex-shrink: 0; }

/* === SETTINGS PANEL (web app addition) === */
.settings-panel { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-lg); position: fixed; top: 60px; right: 24px; z-index: 150; width: 340px; }
.settings-panel h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.settings-panel label { display: block; font-size: 13px; color: var(--gray-500); margin-bottom: 4px; margin-top: 12px; }
.settings-panel input { width: 100%; padding: 8px 12px; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 14px; font-family: var(--font); }
.settings-panel input:focus { outline: none; border-color: var(--blue); }
.settings-panel .settings-actions { margin-top: 16px; display: flex; gap: 8px; }

/* === API STATUS BADGE === */
.api-badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--green-light); color: var(--green); font-weight: 600; }
.api-badge.error { background: var(--red-light); color: var(--red); }


/* EMAIL GATE OVERLAY */
.email-gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
}
.email-gate-overlay.hidden { display: none; }
.email-gate-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 1rem;
  padding: 2.5rem 2rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.email-gate-logo {
  width: 56px;
  height: 56px;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 1.5rem;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
}
.email-gate-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--gray-900);
}
.email-gate-card p {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin: 0 0 1.25rem;
  line-height: 1.5;
}
.email-gate-card form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.email-gate-card .field {
  text-align: center;
  font-size: 1rem;
}
.email-gate-error {
  color: #ef4444;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}
.email-gate-error.hidden { display: none; }

/* ============================================================
   v0.3.0 — Quote-Tabelle, Teile-Toggles, Settings, Print
   ============================================================ */

.section-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- ANGEBOT: Tabelle ---------- */

.quote-table-wrap { overflow-x: auto; margin-bottom: 20px; }
.quote-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }

.quote-table th {
  text-align: left; padding: 10px 12px;
  background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
  font-weight: 600; color: var(--gray-500);
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
}
.quote-table td {
  padding: 6px 12px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.quote-table tr:last-child td { border-bottom: none; }

.quote-table .col-pos   { width: 56px; color: var(--gray-500); }
.quote-table .col-qty   { width: 110px; text-align: right; }
.quote-table .col-unit  { width: 130px; text-align: right; }
.quote-table .col-total { width: 130px; text-align: right; }
.quote-table td.col-unit, .quote-table td.col-total { font-variant-numeric: tabular-nums; }
.quote-table td.col-total { font-weight: 600; }

/* Inputs in der Tabelle sehen aus wie Text — Rahmen erst bei Hover/Focus. */
.quote-table input {
  width: 100%; box-sizing: border-box;
  font: inherit; color: inherit; font-family: var(--font);
  padding: 5px 8px; margin: 0;
  border: 1px solid transparent; border-radius: 5px;
  background: transparent;
  transition: border-color .12s, background .12s;
}
.quote-table input:hover { border-color: var(--gray-200); background: var(--white); }
.quote-table input:focus {
  outline: none; border-color: var(--blue); background: var(--white);
  box-shadow: 0 0 0 3px var(--blue-50);
}
.quote-table input.cell-qty {
  text-align: right; width: 72px; margin-left: auto; display: block;
  font-variant-numeric: tabular-nums;
}
.quote-table .qty-static { color: var(--gray-500); font-variant-numeric: tabular-nums; padding-right: 8px; }

/* Arbeitszeile vs. Teil-Unterzeile */
.quote-table .row-labor td.col-desc input { font-weight: 500; }
.quote-table .row-sub td { border-bottom-color: var(--gray-50); }
.quote-table .row-sub td.col-pos { border-left: 2px solid var(--gray-100); }
.quote-table .row-sub td.col-desc input,
.quote-table .row-sub td.col-unit,
.quote-table .row-sub td.col-total { color: var(--gray-500); }
.quote-table .row-sub td.col-desc { padding-left: 24px; position: relative; }
.quote-table .row-sub td.col-desc::before {
  content: "↳"; position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  color: var(--gray-300); font-size: 12px;
}
.cell-sub { display: block; font-size: 11px; color: var(--gray-400); padding: 0 9px 2px; }
.quote-empty { text-align: center; color: var(--gray-400); padding: 24px 0; font-size: 14px; }

/* ---------- ANGEBOT: Summen ---------- */

.quote-totals { max-width: 380px; margin-left: auto; }
.total-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 6px 0; font-size: 14px; color: var(--gray-700);
  font-variant-numeric: tabular-nums;
}
.total-label { display: flex; flex-direction: column; }
.total-note { font-size: 11px; color: var(--gray-400); font-weight: 400; margin-top: 1px; }
.total-net {
  border-top: 1px solid var(--gray-200); margin-top: 6px; padding-top: 10px;
  font-weight: 600; color: var(--gray-900);
}
.total-final {
  border-top: 2px solid var(--gray-900); margin-top: 8px; padding-top: 12px;
  font-weight: 700; font-size: 18px; color: var(--gray-900);
}

/* ---------- TEILE & KALKULATION ---------- */

.part-group {
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  overflow: hidden; transition: border-color .15s;
}
.part-group:hover { border-color: var(--gray-300); }
.part-group-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer; user-select: none;
}
.part-group-header:hover { background: var(--gray-100); }
.part-collapsed .part-group-header { border-bottom: none; }
.part-group-title { font-weight: 600; font-size: 14px; flex: 1; }
.part-group-summary {
  font-size: 12px; color: var(--gray-500); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.part-toggle {
  border: none; background: transparent; cursor: pointer;
  font-size: 10px; color: var(--gray-400);
  padding: 0; width: 18px; flex-shrink: 0; line-height: 1;
}
.part-toggle:hover { color: var(--blue); }
.part-group-body { padding: 14px; }

.part-row {
  display: grid; grid-template-columns: 28px 1fr 110px 100px;
  gap: 10px; align-items: center;
  padding: 9px 10px; margin: 0 -10px;
  border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer;
  transition: background .12s;
}
.part-row:hover { background: var(--gray-50); }
.part-row.selected { background: var(--blue-light); }
.part-row .part-select { display: flex; align-items: center; justify-content: center; }
.part-row input[type="radio"] { width: 16px; height: 16px; cursor: pointer; margin: 0; }
.part-info { min-width: 0; }
.part-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-manufacturer { color: var(--gray-500); font-size: 12px; }
.part-source { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-source a { color: var(--blue); text-decoration: none; }
.part-source a:hover { text-decoration: underline; }
.part-price { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

.manual-teil { padding: 4px 0 8px; }
.manual-label { display: block; font-size: 12px; color: var(--gray-500); margin-bottom: 6px; }
.manual-teil-row { display: flex; gap: 8px; }
.manual-teil-row .manual-teil-name { flex: 1; }
.manual-teil-row .manual-teil-price { width: 130px; }

.labor-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0 2px; margin-top: 10px;
  border-top: 1px solid var(--gray-200);
}
.labor-row label { font-size: 13px; color: var(--gray-500); font-weight: 500; }
.labor-input { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.labor-input input {
  width: 68px; padding: 6px 8px; text-align: right;
  border: 1px solid var(--gray-200); border-radius: 5px;
  font-size: 13px; font-family: var(--font);
  font-variant-numeric: tabular-nums;
}
.labor-input input:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-50);
}
.labor-formula { color: var(--gray-400); }
.labor-cost { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }

/* ---------- POSITION HINZUFÜGEN ---------- */

.add-pos-form {
  border: 1px solid var(--blue); border-radius: var(--radius-sm);
  background: var(--blue-light);
  padding: 16px; margin-top: 4px;
}
.add-pos-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.add-pos-head h4 { margin: 0; font-size: 14px; font-weight: 700; color: var(--gray-900); }
.add-pos-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--gray-400); padding: 0 2px;
}
.add-pos-close:hover { color: var(--red); }

.add-pos-fields { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.add-pos-field { display: flex; flex-direction: column; gap: 5px; }
.add-pos-field-grow { flex: 1; min-width: 240px; }
.add-pos-field label { font-size: 12px; font-weight: 500; color: var(--gray-700); }
.add-pos-field .field { background: var(--white); }
.add-pos-field .input-suffix .field { width: 92px; }

.add-pos-actions { display: flex; gap: 8px; margin-top: 14px; }
.add-pos-help {
  font-size: 12px; color: var(--gray-500); line-height: 1.6;
  margin: 12px 0 0; padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,.06);
}
.add-pos-help strong { color: var(--gray-700); font-weight: 600; }

/* Input mit Einheit dahinter (h, %, €/h) */
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix span { font-size: 13px; color: var(--gray-500); white-space: nowrap; }

/* ---------- TEIL-TAGS (Positionen) ---------- */

.teil-artnr { font-size: 11px; color: var(--gray-400); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.teil-edit { cursor: text; border-bottom: 1px dashed transparent; }
.teil-edit:hover { border-bottom-color: var(--blue); }
.teil-add {
  display: inline-flex; align-items: center; padding: 4px 10px;
  background: transparent; border: 1px dashed var(--gray-300); border-radius: 6px;
  font-size: 12px; color: var(--gray-500); cursor: pointer; transition: all .15s;
}
.teil-add:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.hint-add {
  background: none; border: none; padding: 2px 0; margin-top: 4px;
  font-size: 12px; color: var(--gray-400); cursor: pointer;
}
.hint-add:hover { color: var(--blue); }

/* ---------- EINSTELLUNGEN ---------- */

.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px; align-items: start;
}
.settings-group {
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 20px; background: var(--white);
}
.settings-group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--gray-500); margin: 0 0 16px;
  padding-bottom: 10px; border-bottom: 1px solid var(--gray-100);
}
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin: 14px 0 5px; }
.settings-group .field-label:first-of-type { margin-top: 0; }
.settings-group .field { width: 100%; }
.settings-group .input-suffix .field { width: 110px; }
.field-sm { max-width: 140px; }
.field-help { font-size: 12px; color: var(--gray-400); margin: 16px 0 0; line-height: 1.6; }
.field-help code { background: var(--gray-100); padding: 1px 5px; border-radius: 3px; font-size: 11px; }

.source-add { display: flex; gap: 8px; align-items: center; }
.source-add .field { flex: 1; }
.source-add .btn { white-space: nowrap; }
.sources-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; min-height: 22px; }
.source-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  background: var(--gray-100); border-radius: 6px; font-size: 12px; color: var(--gray-700);
}
.source-remove {
  background: none; border: none; color: var(--gray-400); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 2px;
}
.source-remove:hover { color: var(--red); }
.empty-sm { font-size: 12px; color: var(--gray-400); margin: 0; }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--gray-900); color: var(--white);
  padding: 11px 22px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 200;
}

/* ---------- DRUCK ---------- */

@media print {
  .topbar, .input-actions, .msg-history, .input-area, .status-bar,
  .pos-toolbar, .positions-actions, .export-actions, .copy-section-btn,
  .overlay, .email-gate-overlay, .add-pos-form, .toast,
  #sectionInput, #sectionParts, #sectionExport,
  .pos-check, .pos-toggle, .pos-delete, .teil-delete, .teil-add, .hint-add {
    display: none !important;
  }
  body { background: var(--white); }
  .main { max-width: none; padding: 0; margin: 0; }
  .section { border: none; box-shadow: none; padding: 0; margin: 0; page-break-inside: avoid; }
  .quote-table input {
    border: none !important; background: transparent !important;
    padding: 0 !important; box-shadow: none !important;
  }
  .customer-card { border: 1px solid #ddd; }
  a[href]:after { content: ""; }
}

/* ============================================================
   v0.4.0 — gemeinsame Topbar + Onboarding-Tour
   ============================================================ */

/* ---------- TOPBAR (identisch auf allen Seiten) ---------- */

.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px;
  background: var(--white); border-bottom: 1px solid var(--gray-200);
  position: sticky; top: 0; z-index: 100;
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: inherit; flex-shrink: 0;
}
.topbar-brand h1 { font-size: 17px; font-weight: 700; margin: 0; }
.topbar .quote-nr {
  font-size: 12px; color: var(--gray-400); font-weight: 600;
  background: var(--gray-100); padding: 3px 9px; border-radius: 99px;
  flex-shrink: 0;
}

.topbar-nav { display: flex; align-items: center; gap: 2px; margin-left: 8px; }
.nav-link {
  display: inline-flex; align-items: center;
  padding: 7px 13px; border-radius: 7px;
  font-size: 14px; font-weight: 500; font-family: var(--font);
  color: var(--gray-500); text-decoration: none;
  background: none; border: none; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-link.active { background: var(--blue-light); color: var(--blue); font-weight: 600; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.help-btn {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--gray-200);
  background: var(--white); color: var(--gray-500);
  font-size: 14px; font-weight: 700; font-family: var(--font);
  cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.help-btn:hover {
  border-color: var(--blue); background: var(--blue); color: var(--white);
  transform: scale(1.06);
}

/* ---------- TOUR ---------- */

.tour-overlay { position: fixed; inset: 0; z-index: 300; pointer-events: none; }

/* Loch im Dunkel: der Schatten faerbt ALLES ausserhalb des Spots ab. */
.tour-spot {
  position: fixed;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .72);
  border: 2px solid var(--blue);
  pointer-events: none;
  transition: top .28s cubic-bezier(.4,0,.2,1), left .28s cubic-bezier(.4,0,.2,1),
              width .28s cubic-bezier(.4,0,.2,1), height .28s cubic-bezier(.4,0,.2,1);
}




.tour-dots { display: flex; gap: 6px; }
.tour-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gray-200); transition: all .2s;
}
.tour-dot.active { background: var(--blue); width: 20px; border-radius: 99px; }
.tour-buttons { display: flex; gap: 6px; }

@media print { .tour-overlay { display: none !important; } }

/* ============================================================
   v0.5.0 — Tour-Popover schlank, Hilfe-Popover, Mobile
   ============================================================ */

/* ---------- TOUR: Popover ---------- */

.tour-pop {
  position: fixed; width: 400px; max-width: calc(100vw - 24px);
  pointer-events: auto;
  background: var(--white); border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0,0,0,.3);
  padding: 20px 22px 16px;
  transition: top .28s cubic-bezier(.4,0,.2,1), left .28s cubic-bezier(.4,0,.2,1);
}
.tour-pop h3 { margin: 0 0 8px; font-size: 18px; font-weight: 700; color: var(--gray-900); }
.tour-pop p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--gray-700); }
.tour-pop p strong { color: var(--gray-900); font-weight: 600; }

.tour-meta {
  display: inline-block; margin-top: 12px;
  font-size: 12px; font-weight: 600; color: var(--green);
  background: var(--green-light); padding: 5px 11px; border-radius: 99px;
}

.tour-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--gray-100);
  gap: 12px;
}
.tour-buttons { display: flex; gap: 6px; align-items: center; }
.tour-buttons #tourSkip { color: var(--gray-400); }
.tour-buttons #tourSkip:hover { color: var(--gray-700); }

/* Element im Spotlight zusaetzlich betonen (z.B. der Erweitert-Toggle) */
.tour-glow {
  position: relative; z-index: 1;
  border-radius: 8px;
  box-shadow: 0 0 0 3px var(--blue), 0 0 0 8px rgba(37, 99, 235, .25);
  animation: tourPulse 1.8s ease-in-out infinite;
}
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--blue), 0 0 0 8px rgba(37, 99, 235, .25); }
  50%      { box-shadow: 0 0 0 3px var(--blue), 0 0 0 13px rgba(37, 99, 235, 0); }
}

/* ---------- HILFE-DOT + POPOVER ---------- */

.help-dot {
  width: 17px; height: 17px; margin-left: 8px;
  border-radius: 50%; border: 1px solid var(--gray-300);
  background: var(--white); color: var(--gray-400);
  font-size: 10px; font-weight: 700; font-family: var(--font);
  cursor: pointer; line-height: 1; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  vertical-align: middle; transition: all .15s;
}
.help-dot:hover { border-color: var(--blue); background: var(--blue); color: var(--white); }

.help-pop {
  position: fixed; z-index: 250;
  width: 420px; max-width: calc(100vw - 24px);
  max-height: 70vh; overflow-y: auto;
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18);
  padding: 16px 18px;
}
.help-pop-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.help-pop-head strong { font-size: 15px; color: var(--gray-900); }
.help-pop-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1; color: var(--gray-400); padding: 0 2px;
}
.help-pop-close:hover { color: var(--gray-900); }
.help-pop-intro {
  margin: 0 0 12px; font-size: 13px; line-height: 1.55; color: var(--gray-500);
  padding-bottom: 12px; border-bottom: 1px solid var(--gray-100);
}
.help-list { margin: 0; }
.help-list dt {
  font-size: 13px; font-weight: 600; color: var(--gray-900);
  margin-top: 10px;
}
.help-list dt:first-child { margin-top: 0; }
.help-list dd {
  margin: 2px 0 0; font-size: 13px; line-height: 1.55; color: var(--gray-500);
}
.help-list dd em { color: var(--gray-700); font-style: normal; font-weight: 500; }

/* ============================================================
   MOBILE — die App wird am Fahrzeug benutzt, nicht am Schreibtisch
   ============================================================ */

@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {

  /* --- Topbar: Marke + Menue + Hilfe, kompakt --- */
  .topbar {
    flex-wrap: wrap; gap: 8px 12px; padding: 10px 14px;
  }
  .topbar-brand h1 { font-size: 16px; }
  .topbar .quote-nr { order: 3; }
  .topbar-nav {
    order: 5; width: 100%; margin-left: 0;
    gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar-nav::-webkit-scrollbar { display: none; }
  .nav-link { padding: 7px 11px; font-size: 13px; white-space: nowrap; }
  .topbar-actions { margin-left: auto; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 13px; }

  /* --- Layout --- */
  .main { padding: 12px; gap: 12px; }
  .section { padding: 16px 14px; border-radius: 10px; }
  .section-header-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .section-header h2 { font-size: 16px; }

  /* --- Eingabe: Mikro gross und mittig, es ist der Haupt-Einstieg --- */
  .input-area { flex-direction: column; align-items: stretch; gap: 12px; }
  .mic-btn {
    width: 100%; height: 64px; border-radius: 12px;
    flex-direction: row; gap: 10px;
  }
  .mic-btn::after {
    content: "Sprechen"; font-size: 15px; font-weight: 600; font-family: var(--font);
  }
  .mic-btn.recording::after { content: "Aufnahme läuft — nochmal drücken zum Stoppen"; font-size: 13px; }

  /* iOS zoomt bei <16px automatisch rein -> alle Eingaben 16px */
  textarea, input[type="text"], input[type="email"], input[type="number"], select {
    font-size: 16px !important;
  }
  #inputText { min-height: 110px; }

  .input-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .input-actions .btn-lg { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }
  .extended-toggle { justify-content: center; padding: 4px 0; }
  #btnAddMore { width: 100%; justify-content: center; }

  /* --- Toolbars: umbrechen statt quetschen --- */
  .pos-toolbar { flex-wrap: wrap; gap: 6px; }
  .positions-actions { flex-direction: column; gap: 8px; }
  .positions-actions .btn { width: 100%; justify-content: center; }

  /* --- Positionen: Karten stapeln --- */
  .position-card { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .position-num { width: 24px; height: 24px; font-size: 11px; }
  .position-body { flex: 1 1 100%; order: 3; width: 100%; }
  .position-actions { order: 2; margin-left: auto; }
  .position-teile { gap: 5px; }
  .teil-tag { font-size: 11px; padding: 5px 8px; }

  /* Touch-Ziele gross genug (Apple/Google: min 44px) */
  .pos-check, .teil-delete, .pos-toggle, .pos-delete { min-width: 32px; min-height: 32px; }

  /* --- Teile: Grid -> Zeilen --- */
  .part-row {
    grid-template-columns: 32px 1fr auto;
    grid-template-areas: "sel info price" "sel src price";
    gap: 4px 8px; padding: 12px 10px;
  }
  .part-row .part-select { grid-area: sel; }
  .part-row .part-info { grid-area: info; }
  .part-row .part-source { grid-area: src; }
  .part-row .part-price { grid-area: price; align-self: center; }
  .part-row input[type="radio"] { width: 20px; height: 20px; }
  .part-name { white-space: normal; }

  .part-group-header { flex-wrap: wrap; gap: 6px 10px; }
  .part-group-title { flex: 1 1 100%; order: 2; font-size: 13px; }
  .part-group-summary { order: 3; margin-left: 0; }
  .part-toggle { order: 1; }

  .labor-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .labor-input { justify-content: space-between; }
  .manual-teil-row { flex-direction: column; }
  .manual-teil-row .manual-teil-price { width: 100%; }

  /* --- Angebot: Tabelle scrollt horizontal, Spalten schmaler --- */
  .quote-table-wrap {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    margin: 0 -14px 16px; padding: 0 14px;
  }
  .quote-table { min-width: 560px; font-size: 13px; }
  .customer-fields .field-row { flex-direction: column; }
  .quote-totals { max-width: none; }

  /* --- Export: Buttons volle Breite, PDF zuerst --- */
  .export-actions { flex-direction: column; gap: 8px; }
  .export-actions .btn { width: 100%; justify-content: center; padding: 12px; }

  /* --- Position hinzufuegen --- */
  .add-pos-fields { flex-direction: column; align-items: stretch; }
  .add-pos-field-grow { min-width: 0; }
  .add-pos-field .input-suffix .field { width: 100%; }
  .add-pos-actions { flex-direction: column; }
  .add-pos-actions .btn { width: 100%; justify-content: center; }

  /* --- Overlays --- */
  .overlay-content { width: calc(100vw - 20px); max-height: 85vh; }
  .quote-list-item { flex-wrap: wrap; }

  /* --- Tour: bleibt am Ziel-Element, nur Breite anpassen --- */
  .tour-pop {
    width: calc(100vw - 24px); max-width: 360px;
    padding: 16px 16px 12px;
  }
  .tour-pop h3 { font-size: 17px; }
  .tour-pop p { font-size: 14px; line-height: 1.55; }
  .tour-nav { flex-wrap: wrap; gap: 10px; padding-top: 12px; margin-top: 14px; }
  .tour-buttons { flex-wrap: wrap; }
  .tour-buttons .btn { padding: 8px 12px; font-size: 12px; }
  .tour-dots { justify-content: flex-start; }

  /* --- Hilfe-Popover: Vollbreite unten --- */
  .help-pop {
    top: auto !important; left: 10px !important; right: 10px;
    bottom: 10px; width: auto; max-width: none; max-height: 65vh;
  }
  .help-dot { width: 20px; height: 20px; font-size: 11px; }

  /* --- Settings --- */
  .settings-group { padding: 16px 14px; }
  .source-add { flex-direction: column; align-items: stretch; }
  .source-add .btn { width: 100%; }
  .field-sm, .settings-group .input-suffix .field { max-width: none; width: 100%; }

  /* --- E-Mail-Gate --- */
  .email-gate-card { width: calc(100vw - 24px); padding: 24px 20px; }
}

@media (max-width: 400px) {
  .topbar-brand h1 { display: none; }
  .nav-link { padding: 7px 9px; font-size: 12px; }
}

/* ============================================================
   v0.6.0 — Demo-Banner + Mikrofon-Hinweis
   ============================================================ */

.demo-banner {
  display: flex; align-items: flex-start; gap: 12px;
  margin-top: 16px; padding: 14px 16px;
  background: var(--blue-light);
  border: 1px solid rgba(37, 99, 235, .22);
  border-radius: var(--radius-sm);
  animation: bannerIn .3s ease-out;
}
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.demo-banner-icon {
  width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px;
  border-radius: 50%; background: var(--blue); color: var(--white);
  font-size: 12px; font-weight: 700; font-style: italic;
  display: flex; align-items: center; justify-content: center;
  font-family: Georgia, serif;
}
.demo-banner-body { flex: 1; min-width: 0; }
.demo-banner-body strong {
  display: block; font-size: 13px; font-weight: 700;
  color: var(--gray-900); margin-bottom: 3px;
}
.demo-banner-body p {
  margin: 0; font-size: 13px; line-height: 1.6; color: var(--gray-700);
}
.demo-banner-body p strong {
  display: inline; font-weight: 600; color: var(--gray-900);
}
.demo-banner-close {
  background: none; border: none; cursor: pointer; flex-shrink: 0;
  font-size: 20px; line-height: 1; color: var(--gray-400);
  padding: 0 2px; margin: -2px -4px 0 0;
}
.demo-banner-close:hover { color: var(--gray-900); }

/* Mikrofon-Hinweis (Berechtigung / kein HTTPS / kein Support) */
.mic-hint {
  margin-top: 12px; padding: 12px 14px;
  background: var(--amber-light, #fef3c7);
  border: 1px solid rgba(217, 119, 6, .25);
  border-left: 3px solid var(--amber, #d97706);
  border-radius: var(--radius-sm);
  font-size: 13px; line-height: 1.6; color: var(--gray-700);
}
.mic-hint strong { color: var(--gray-900); font-weight: 600; }
.mic-hint em { font-style: normal; font-weight: 600; color: var(--gray-900); }

.mic-btn.mic-disabled {
  opacity: .45; cursor: not-allowed;
  border-color: var(--gray-300); background: var(--gray-100); color: var(--gray-400);
}
.mic-btn.mic-disabled:hover { background: var(--gray-100); color: var(--gray-400); }

@media (max-width: 720px) {
  .demo-banner { padding: 12px; gap: 10px; }
  .demo-banner-body p, .demo-banner-body strong { font-size: 12.5px; }
}

@media print { .demo-banner, .mic-hint { display: none !important; } }

/* Mikro-Diagnose (aufklappbar im Hinweis) */
.mic-hint code {
  background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px;
  font-size: 12px; font-family: ui-monospace, Menlo, monospace;
}
.mic-diag { margin-top: 10px; }
.mic-diag summary {
  cursor: pointer; font-size: 12px; color: var(--gray-500);
  font-weight: 600; list-style: none;
}
.mic-diag summary::-webkit-details-marker { display: none; }
.mic-diag summary::before { content: "▸ "; }
.mic-diag[open] summary::before { content: "▾ "; }
.mic-diag summary:hover { color: var(--gray-900); }
.mic-diag > div {
  margin-top: 6px; padding: 8px 10px;
  background: rgba(0,0,0,.04); border-radius: 6px;
  font-size: 12px; line-height: 1.7; color: var(--gray-700);
}

/* ============================================================
   v0.8.0 — DSGVO-Hinweis, Footer, Rechtsseite
   ============================================================ */

.email-gate-legal {
  margin: 14px 0 0; font-size: 11.5px; line-height: 1.55;
  color: var(--gray-400); text-align: center;
}
.email-gate-legal a { color: var(--gray-500); text-decoration: underline; }
.email-gate-legal a:hover { color: var(--blue); }

.app-footer {
  display: flex; justify-content: center; align-items: center; gap: 14px;
  padding: 20px 24px 28px;
  font-size: 12px; color: var(--gray-400);
}
.app-footer a { color: var(--gray-400); text-decoration: none; }
.app-footer a:hover { color: var(--blue); text-decoration: underline; }

.legal-page { max-width: 720px; }
.legal-page h2 { font-size: 22px; margin: 0 0 2px; }
.legal-page h3 {
  font-size: 14px; font-weight: 700; color: var(--gray-900);
  margin: 24px 0 6px;
}
.legal-page p, .legal-page li {
  font-size: 14px; line-height: 1.65; color: var(--gray-700); margin: 0 0 8px;
}
.legal-page ul { margin: 0 0 8px; padding-left: 20px; }
.legal-page li { margin-bottom: 4px; }
.legal-page a { color: var(--blue); }

@media print { .app-footer { display: none !important; } }

/* MONKIDO OVERRIDES */
.btn-primary { color: var(--brand-fg); }
.btn-primary:hover { color: var(--brand-fg); }
.mic-btn:hover { color: var(--brand-fg); }
.mic-btn { color: var(--brand); }
.status-bar.info { color: var(--brand-fg); }
.badge-ki { color: var(--brand-fg); background: var(--brand-light); border: 1px solid var(--brand); }
.logo { color: var(--brand); background: var(--ink); }
.topbar { background: var(--white); border-bottom: 1px solid var(--gray-200); }
body { background: var(--gray-50); }
.editable:hover { color: var(--ink); border-bottom-color: var(--brand); }
