/* Outfit lokal laden (eigene Datei-Benennung der v15-latin-Google-Webfonts-Variante) */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('fonts/woff2/outfit-v15-latin-300.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/woff2/outfit-v15-latin-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/woff2/outfit-v15-latin-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/woff2/outfit-v15-latin-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/woff2/outfit-v15-latin-700.woff2') format('woff2');
}

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --border-strong: #d6d3d1;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-subtle: #a8a29e;
  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-soft: #ecfeff;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* LAYOUT ---------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.sidebar-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.sidebar-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin: 20px 0 8px;
  font-weight: 500;
}

.sidebar nav a {
  display: block;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 2px;
  cursor: pointer;
}
.sidebar nav a:hover { background: #f5f5f4; }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 500; }

.sidebar-divider {
  margin-top: auto;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.main {
  padding: 28px 40px 80px;
  max-width: 1200px;
  width: 100%;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.page-head .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* BUTTONS --------------------------------------------------------------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  height: 36px;
  padding: 0 14px;
  line-height: 1;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #f5f5f4; border-color: var(--text-muted); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: #f5f5f4; border-color: transparent; }
.btn-danger { color: var(--danger); border-color: var(--border-strong); }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-icon { padding: 0; width: 36px; justify-content: center; }
.btn-icon.btn-sm { width: 28px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* CARDS / FORMS --------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }

/* Kompakte Meta-Zeile im Rechnungs-Editor: 7 Spalten total (Absender = 2) */
.meta-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  align-items: end;
}
.meta-row .field { margin-bottom: 0; }
@media (max-width: 1100px) {
  .meta-row { grid-template-columns: repeat(4, 1fr); }
  .meta-row .field:first-child { grid-column: span 4; }
}
@media (max-width: 640px) {
  .meta-row { grid-template-columns: repeat(2, 1fr); }
  .meta-row .field:first-child { grid-column: span 2; }
}

/* Zweispalter für Meta-Daten + Empfänger nebeneinander */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.two-col .card { margin-bottom: 0; }
@media (max-width: 1100px) {
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .two-col .card { margin-bottom: 20px; }
}

/* Locked col-config row (Gesamt-Spalte) */
.col-cfg-row.locked {
  opacity: 0.7;
  background: #f5f5f4;
  position: relative;
}
.col-cfg-row.locked input:not([data-f="label"]),
.col-cfg-row.locked select,
.col-cfg-row.locked .btn:disabled {
  cursor: not-allowed;
}
.col-cfg-locked {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 4px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 0.01em;
}

input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select {
  font-family: inherit;
  font-size: 13px;
  height: 36px;
  padding: 0 10px;
  line-height: 1.5;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}
/* Select: eigener Pfeil, damit es identisch zu den Inputs aussieht */
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='none' stroke='%2378716c' stroke-width='1.5' d='M1 1.5l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}
/* Native Date/Number UI-Elemente bändigen */
input[type=date]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}
/* Number-Spinner komplett entfernen */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}
textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  line-height: 1.5;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  width: 100%;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: vertical;
  min-height: 60px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8,145,178,0.12);
}

/* Auto-grow Textareas: Höhe wird per JS gesteuert, kein manuelles Resize */
textarea.auto-grow {
  resize: none;
  min-height: 38px;
  overflow-y: hidden;
}

.field { margin-bottom: 12px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

/* EXCEL-STYLE TABELLE --------------------------------------------------- */
.items-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; background: var(--surface); }

.items-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: #fafaf9;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  gap: 12px;
  flex-wrap: wrap;
}
.items-toolbar .hint { font-style: italic; }

.items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.items-table thead th {
  background: #fafaf9;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-strong);
  border-right: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  position: relative;
}
.items-table thead th:last-child { border-right: none; }
.items-table thead th.num { text-align: right; }
.items-table thead th.col-actions { width: 36px; }

.items-table thead th.col-actions { width: 128px; }

.items-table tbody td.row-actions { padding: 0 4px; vertical-align: middle; }
.row-actions-inner {
  display: flex;
  gap: 1px;
  opacity: 0.25;
  transition: opacity 0.15s;
  justify-content: flex-end;
}
.items-table tbody tr:hover .row-actions-inner,
.items-table tbody tr:focus-within .row-actions-inner { opacity: 1; }

/* Section-Row (Abschnittsüberschrift, zählt nicht als Position) */
.items-table tbody tr.section-row td {
  background: #f5f5f4;
  border-right: none;
  border-top: 1px solid var(--border-strong);
  padding-left: 4px;
}
.items-table tbody tr.section-row input.section-input {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  padding: 6px 10px;
  background: transparent;
  border: none;
}
.items-table tbody tr.section-row input.section-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(8,145,178,0.15);
}
.items-table tbody tr.section-row input.section-input::placeholder {
  color: var(--text-subtle);
  font-weight: 400;
}

/* Legacy: sub-row für alte, nicht migrierte Rechnungen identisch wie section */
.items-table tbody tr.sub-row td { background: #f5f5f4; padding-left: 4px; }
.items-table tbody tr.sub-row input.sub-input {
  font-size: 13px; font-weight: 600; color: var(--text);
  padding: 6px 10px; background: transparent; border: none;
}

/* Description-Zelle: Titel-Input oben + Toggle-Icon rechts + optionale Textarea unten */
.items-table td.desc-cell {
  padding: 2px 6px;
  vertical-align: top;
}
.desc-cell .desc-main {
  display: flex;
  align-items: center;
  gap: 2px;
}
.desc-cell .desc-main input {
  flex: 1;
  min-width: 0;
}
.desc-cell .desc-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.12s, color 0.12s, background 0.12s, border-color 0.12s;
}
/* Bei Hover der Zelle: Icon wird deutlich sichtbar */
.items-table tr:hover .desc-cell .desc-toggle,
.desc-cell:hover .desc-toggle {
  opacity: 1;
}
.desc-cell .desc-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
/* Wenn Beschreibung bereits aktiv ist: permanent sichtbar hervorgehoben */
.desc-cell.has-desc .desc-toggle {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.desc-cell textarea.desc-text {
  display: block;
  width: 100%;
  margin-top: 2px;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 0;
  line-height: 1.4;
  resize: none;
  overflow-y: hidden;
  font-family: inherit;
  min-height: 22px;
}
.desc-cell textarea.desc-text:focus {
  outline: none;
  background: #fafaf9;
  box-shadow: none;
}
.desc-cell textarea.desc-text::placeholder {
  color: var(--text-subtle);
  font-style: italic;
}

/* ============================================================
 * StBVV-Zellen: Leistung-Dropdown + dynamische Berechnungs-Inputs
 * ============================================================ */
.items-table td.stbvv-input-cell {
  padding: 4px 8px;
  background: #fafaf9;
}
.stbvv-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.stbvv-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.stbvv-field-satz {
  flex: 0 0 110px;
}
.stbvv-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stbvv-range {
  color: var(--text-subtle);
  font-weight: normal;
  letter-spacing: 0;
}
.stbvv-field input {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.3;
  width: 100%;
  min-width: 0;
}
.stbvv-field input:focus {
  outline: none;
  border-color: var(--accent);
}
.stbvv-satz-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}
.stbvv-satz-wrap input {
  width: 3.5em;
  text-align: right;
}
.stbvv-denom {
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}
.stbvv-hint {
  color: var(--text-subtle);
  font-size: 12px;
  font-style: italic;
}
.stbvv-service-select {
  padding: 6px 8px;
}
.stbvv-total-cell {
  text-align: right;
  padding: 8px 10px !important;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.items-table tbody td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 0;
  vertical-align: top;
}
.items-table tbody td:last-child { border-right: none; }
.items-table tbody tr:last-child td { border-bottom: none; }

.items-table input, .items-table select {
  border: none;
  background: transparent;
  height: auto;
  padding: 8px 10px;
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  border-radius: 0;
}
.items-table input:focus, .items-table select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: none;
  background: var(--accent-soft);
}
.items-table input.num { text-align: right; font-variant-numeric: tabular-nums; }

.items-table tbody tr:hover td { background: #fafaf9; }
.items-table tbody tr.row-del td { background: #fef2f2; }

.row-action-btn {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.row-action-btn svg { display: block; }
.row-action-btn:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.row-action-btn.del:hover:not(:disabled) { color: var(--danger); background: #fef2f2; }
.row-action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.col-handle {
  cursor: grab;
  color: var(--text-subtle);
  text-align: center;
  user-select: none;
  font-size: 14px;
}
.col-handle:hover { color: var(--text-muted); }

/* TOTALS ---------------------------------------------------------------- */
.totals {
  margin-top: 20px;
  margin-left: auto;
  max-width: 600px;
  font-variant-numeric: tabular-nums;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 14px;
}
.totals-row.sep { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 12px; }
.totals-row.sum {
  font-weight: 600;
  font-size: 16px;
  border-top: 2px solid var(--text);
  margin-top: 4px;
  padding-top: 12px;
}
.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.inline-field .suffix { color: var(--text-muted); }

/* Anpassungs-Zeilen (Rabatt, Gebühr, ...) */
.totals-add { justify-content: flex-start !important; padding: 4px 12px !important; }
.totals-add .btn { font-weight: 400; color: var(--text-muted); }
.totals-add .btn:hover { color: var(--accent-hover); }

.adj-row {
  display: grid;
  grid-template-columns: 1fr 68px 70px 68px 120px 36px;
  gap: 8px;
  align-items: center;
  padding: 4px 12px;
}
.adj-row input,
.adj-row select {
  width: 100%;
  /* Erbt 36px Höhe von der globalen Input-Regel */
}
.adj-row .adj-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}
.adj-amount.adj-minus { color: var(--danger); }
.adj-amount.adj-plus  { color: var(--success); }
@media (max-width: 700px) {
  .adj-row {
    grid-template-columns: 1fr 1fr auto;
    row-gap: 6px;
  }
  .adj-row input[data-f="label"] { grid-column: 1 / -1; }
  .adj-row [data-del] { grid-row: 2; }
}

/* LIST (Rechnungen / Absender) ----------------------------------------- */
.filter-bar {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-bar .field { margin-bottom: 0; }
@media (max-width: 700px) {
  .filter-bar { grid-template-columns: 1fr; }
}

.list-group-head {
  padding: 14px 18px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: #fafaf9;
  border-bottom: 1px solid var(--border);
}
.list-group-head:first-child { border-top: none; }
.list > .list-group-head + .list-item { border-top: none; }
.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.list-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 16px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #fafaf9; }
.list-item .title { font-weight: 500; }
.list-item .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-item .amount { font-weight: 500; font-variant-numeric: tabular-nums; }

/* Service-Register: Kind-Badges */
.svc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.svc-badge-value   { background: #dbeafe; color: #1e40af; }
.svc-badge-hourly  { background: #fef3c7; color: #92400e; }
.svc-badge-unit    { background: #d1fae5; color: #065f46; }
.svc-badge-flat    { background: #e5e7eb; color: #374151; }
.svc-badge-unknown { background: #fecaca; color: #991b1b; }

/* Sender-Form: Templates-Gruppen */
.templates-group {
  padding: 14px 16px 10px;
  background: #fafaf9;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.templates-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

/* Offer-Status-Badges in der Liste */
.offer-status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.offer-status.valid    { background: #d1fae5; color: #065f46; }
.offer-status.expiring { background: #fef3c7; color: #92400e; }
.offer-status.expired  { background: #fecaca; color: #991b1b; }

.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* MODAL ----------------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.4);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease-out;
}
.modal-body {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 720px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease-out;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* COL-CONFIG ROW -------------------------------------------------------- */
.col-cfg-row {
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 0.8fr 0.9fr 0.7fr auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: #fafaf9;
}
.col-cfg-row .field { margin-bottom: 0; }
.col-cfg-actions { display: flex; gap: 4px; }
.col-cfg-actions .btn { padding: 6px 8px; font-size: 12px; }
@media (max-width: 760px) {
  .col-cfg-row { grid-template-columns: 1fr 1fr; }
  .col-cfg-actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* HEADER INLINE CONTROLS ------------------------------------------------ */
.items-table thead th {
  padding: 0;
}
.th-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 10px;
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.th-inner.num { justify-content: flex-end; }
.th-inner .th-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.th-inner.num .th-label { text-align: right; }
.th-controls {
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.15s;
}
.items-table thead th:hover .th-controls { opacity: 1; }
.th-btn {
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  transition: background 0.1s, color 0.1s;
}
.th-btn svg { display: block; }
.th-btn:hover { color: var(--accent); background: var(--accent-soft); }
.th-btn.del:hover { color: var(--danger); background: #fef2f2; }

/* INSERT-COL dropdown menu --------------------------------------------- */
.menu {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 150;
  padding: 4px;
  min-width: 200px;
  font-size: 13px;
}
.menu-item {
  display: block;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 3px;
  color: var(--text);
}
.menu-item:hover { background: var(--accent-soft); color: var(--accent-hover); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.menu-label { padding: 4px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-subtle); }

/* TOAST ----------------------------------------------------------------- */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease-out;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* LOGO UPLOAD ----------------------------------------------------------- */
.logo-drop {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  background: #fafaf9;
}
.logo-drop:hover { border-color: var(--accent); color: var(--accent); }
.logo-preview {
  max-width: 180px;
  max-height: 70px;
  display: block;
  margin: 0 auto 10px;
}

/* ============================================================
 * MOBILE / RESPONSIVE
 * ============================================================ */

/* Desktop-Defaults für neue Elemente: ausblenden */
.mobile-topbar { display: none; }
.sidebar-backdrop { display: none; }

/* Tablet + Mobile (≤ 900px) */
@media (max-width: 900px) {
  /* App: einspaltig, Sidebar als Drawer */
  .app { grid-template-columns: 1fr; }

  /* Mobile-Topbar mit Hamburger + Brand */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
  }
  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text);
    padding: 0;
  }
  .mobile-menu-btn:hover { background: var(--surface-2, #f5f5f4); }
  .mobile-brand {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
  }
  .mobile-brand img {
    max-height: 32px;
    max-width: 180px;
    object-fit: contain;
  }
  .mobile-brand span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Sidebar als Slide-in-Drawer von links */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease-out;
    box-shadow: 2px 0 20px rgba(0,0,0,0.05);
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 20px rgba(0,0,0,0.15);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.4);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s;
  }
  .sidebar-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* Main-Content: Mobile-Padding, kein max-width */
  .main {
    padding: 20px 16px 60px;
    max-width: 100%;
  }

  /* Page-Head: von flex-end auf Stack wenn eng */
  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .page-head h1 { font-size: 22px; }
  .page-head .btn-row { flex-wrap: wrap; }

  /* Grid-Layouts: single column */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }

  /* Filter-Bar: stack */
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .field { width: 100%; }

  /* Tabellen horizontal scrollbar machen */
  .items-wrap,
  .card > .items-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .items-table {
    font-size: 12px;
    min-width: 560px; /* damit nicht alles gequetscht wird */
  }
  .items-table input, .items-table select { padding: 6px 8px; font-size: 12px; }

  /* List-Items kompakter */
  .list-item {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 14px;
  }
  .list-item .btn-row { flex-wrap: wrap; }

  /* Row-Actions immer sichtbar auf Mobile (kein Hover!) */
  .items-table tbody tr .row-actions-inner { opacity: 1; }
  .desc-cell .desc-toggle { opacity: 1; }

  /* Modals: volle Breite, weniger Padding */
  .modal { padding: 20px 12px; }
  .modal-body { padding: 18px; }

  /* Totals-Tabelle: weniger breit, besser lesbar */
  .totals { width: 100%; }
  .totals-row { flex-wrap: wrap; }

  /* Buttons: Text nicht mehr komplett schmal abschneiden */
  .btn { white-space: nowrap; }
}

/* Kleine Smartphones */
@media (max-width: 480px) {
  .main { padding: 16px 12px 48px; }
  .card { padding: 14px; }
  .page-head h1 { font-size: 20px; }
  .btn { font-size: 12px; padding: 7px 10px; }
  .btn-sm { font-size: 11px; padding: 5px 8px; }
}

/* Login-Logo */
.login-logo {
  display: block;
  max-width: 200px;
  max-height: 80px;
  object-fit: contain;
  margin: 0 auto 12px;
}

/* Logo-Uploader (Einstellungen-View) */
.logo-uploader .logo-preview-wrap {
  padding: 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fafaf9;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* UTILS ----------------------------------------------------------------- */
.input-sm {
  width: 80px;
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
  text-align: right;
}
.select-sm {
  width: auto;
  height: 28px;
  padding: 0 28px 0 8px;
  font-size: 13px;
  display: inline-block;
  background-position: right 6px center;
}

/* LOGIN SCREEN ---------------------------------------------------------- */
body.login-locked {
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-overlay {
  width: 100%;
  max-width: 380px;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px 28px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.login-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
#login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-error {
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
