/* 4smile-Designsprache (CRM-Palette) */
:root {
  --brand-50: #f8f5f3;
  --brand-100: #f2dfdc;
  --brand-300: #d8ecec;
  --brand-400: #b4ddde;
  --brand-600: #627596;
  --brand-700: #2d4267;
  --brand-800: #192946;
  --accent: #ecc9c3;
  --mint: #b4ddde;
  --steel: #b5c4db;
  --canvas: #fffdfa;
  --ink: #1d1d1b;
  --warn: #b4442f;
  --shadow-card: 0 20px 60px rgba(25, 41, 70, 0.12);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-700); }
h1 { font-size: 2rem; line-height: 1.05; margin: 0.4rem 0 0.6rem; color: var(--brand-800); }
h2 { font-size: 1.2rem; margin: 0 0 0.6rem; color: var(--brand-800); }
h3 { font-size: 1rem; margin: 0 0 0.4rem; color: var(--brand-800); }
p { margin: 0 0 0.6rem; }
.eyebrow { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.18em; color: var(--brand-600); margin: 0 0 0.4rem; font-weight: 600; }
.eyebrow.on-dark { color: var(--steel); }
.muted { color: var(--brand-600); font-size: 0.9rem; }
.small { font-size: 0.82rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre { white-space: pre-wrap; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: flex; gap: 1.5rem; padding: 1.25rem; min-height: 100vh; align-items: flex-start; }
.sidebar {
  position: sticky; top: 1.25rem; flex: 0 0 290px; width: 290px; min-height: calc(100vh - 2.5rem);
  display: flex; flex-direction: column; gap: 1rem; padding: 1.25rem;
  background: var(--brand-800); color: #fff; border: 4px solid var(--brand-800); border-radius: 34px; box-shadow: var(--shadow-card);
}
.logo-box { display: block; background: #fff; border-radius: 26px; padding: 1rem; }
.logo-box img { display: block; width: 100%; max-width: 190px; height: auto; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.6rem; }
.nav-pill {
  position: relative; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.1); color: #fff;
  padding: 0.7rem 1rem; font-size: 0.85rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em; text-decoration: none; transition: 0.15s;
}
.nav-pill:hover { border-color: var(--accent); background: var(--accent); color: var(--brand-800); }
.nav-pill.active { border-color: var(--brand-400); background: var(--mint); color: var(--brand-800); }
.nav-pill .zahl { position: absolute; right: 0.8rem; top: 50%; transform: translateY(-50%); background: var(--accent); color: var(--brand-800); border-radius: 999px; min-width: 1.5rem; padding: 0 0.4rem; text-align: center; font-size: 0.75rem; }
.nav-sep { height: 1px; background: rgba(255, 255, 255, 0.15); margin: 0.2rem 0; }
.user-card { margin-top: auto; border-radius: 28px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.1); padding: 1rem; }
.user-name { font-weight: 700; margin: 0; }
.user-hint { font-size: 0.8rem; color: var(--steel); margin: 0.2rem 0 0.6rem; }
.user-card select.input { width: 100%; margin-bottom: 0.6rem; }
.topbar { display: none; }
.view { flex: 1; min-width: 0; max-width: 1180px; padding-top: 0.5rem; }

/* Buttons */
.btn {
  display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 999px; border: 1px solid transparent; padding: 0.6rem 1.15rem;
  font: inherit; font-size: 0.82rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer; transition: 0.15s; color: var(--brand-800); background: transparent; white-space: nowrap;
}
.btn:focus-visible, .input:focus-visible, .chip input:focus-visible + span { outline: none; box-shadow: 0 0 0 3px var(--brand-300); }
.btn.primary { border-color: var(--brand-400); background: var(--mint); box-shadow: inset 0 -2px 0 rgba(25, 41, 70, 0.12); }
.btn.primary:hover { background: var(--brand-300); }
.btn.secondary { border-color: var(--brand-800); background: var(--accent); box-shadow: inset 0 -2px 0 rgba(25, 41, 70, 0.12); }
.btn.secondary:hover { background: var(--brand-100); }
.btn.outline { border-color: var(--brand-800); background: #fff; }
.btn.outline:hover, .btn.ghost:hover { background: var(--brand-50); }
.btn.danger { color: var(--warn); }
.btn.small { min-height: 2.1rem; padding: 0.35rem 0.85rem; font-size: 0.72rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn { height: 3rem; width: 3rem; border-radius: 18px; border: 2px solid var(--brand-800); background: #fff; color: var(--brand-800); font-size: 1.2rem; cursor: pointer; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--brand-700); text-decoration: underline; cursor: pointer; }

/* Karten & Kopf */
.card {
  border-radius: 30px; border: 4px solid var(--brand-800); background: rgba(255, 255, 255, 0.9);
  padding: 1.25rem; box-shadow: var(--shadow-card); margin-bottom: 1.25rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card.flush.stapel { overflow-x: auto; }
.card.soft { border-width: 2px; box-shadow: none; }
.card.hinweis { border-width: 2px; border-color: var(--brand-400); background: var(--brand-300); box-shadow: none; }
.card.warnung { border-width: 2px; border-color: var(--accent); background: var(--brand-100); box-shadow: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.card-head h2 { margin: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions, .row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: flex-end; align-items: center; margin-top: 1rem; }
.crumb { margin: 0 0 0.3rem; font-size: 0.9rem; }
.crumb a { text-decoration: none; }
.leer { color: var(--brand-600); font-style: italic; }

/* Kennzahlen */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.9rem; margin-bottom: 1.25rem; }
.tile { border-radius: 24px; border: 2px solid var(--brand-800); background: #fff; padding: 0.9rem 1.1rem; }
.tile-num { font-size: 2rem; font-weight: 700; line-height: 1; margin: 0; color: var(--brand-800); }
.tile.warn .tile-num { color: var(--warn); }
.tile .eyebrow { margin-top: 0.35rem; letter-spacing: 0.1em; }
/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { background: var(--brand-800); color: #fff; text-transform: uppercase; font-weight: 600; font-size: 0.72rem; letter-spacing: 0.06em; text-align: left; padding: 0.7rem 0.9rem; border-bottom: 2px solid var(--accent); }
.table td { padding: 0.6rem 0.9rem; border-top: 1px solid var(--brand-100); vertical-align: middle; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr[data-href]:hover { background: var(--brand-50); }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--brand-800); }
.person-zelle strong { display: block; }
.toolbar { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .input { width: auto; margin: 0; min-width: 12rem; }

/* Formulare */
.field { display: block; font-size: 0.8rem; font-weight: 600; color: var(--brand-700); margin-bottom: 0.8rem; }
.input {
  display: block; width: 100%; margin-top: 0.25rem; font: inherit; font-size: 1rem; color: var(--ink); background: #fff;
  border: 2px solid var(--brand-800); border-radius: 18px; padding: 0.55rem 0.85rem;
}
textarea.input { border-radius: 20px; min-height: 5.5rem; resize: vertical; line-height: 1.45; }
select.input { appearance: auto; }
.input.compact { width: auto; margin: 0; padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 999px; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.check { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9rem; font-weight: 500; color: var(--ink); }


/* Dialog & Toast */
.dialog { border: 4px solid var(--brand-800); border-radius: 30px; padding: 1.5rem; width: min(560px, calc(100vw - 2rem)); box-shadow: var(--shadow-card); background: var(--canvas); color: var(--ink); }
.dialog::backdrop { background: rgba(25, 41, 70, 0.45); backdrop-filter: blur(3px); }
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%); background: var(--brand-800); color: #fff; padding: 0.7rem 1.2rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem; z-index: 60; box-shadow: var(--shadow-card); max-width: calc(100vw - 2rem); }
.laden { padding: 3rem 0; text-align: center; color: var(--brand-600); }
.blatt { background: #fff; border: 1px solid var(--brand-100); border-radius: 12px; padding: 2rem 2.2rem; box-shadow: var(--shadow-card); }
.blatt-kopf { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 3px solid var(--brand-800); padding-bottom: 0.8rem; margin-bottom: 1rem; }
.blatt-kopf img { width: 130px; }
/* Mittlere Fensterbreiten */
@media (max-width: 1200px) {
  .sidebar { flex-basis: 240px; width: 240px; }
}

/* Mobil */
@media (max-width: 900px) {
  .shell { flex-direction: column; padding: 0.75rem; gap: 0.75rem; }
  .topbar { display: flex; width: 100%; align-items: center; justify-content: space-between; border: 4px solid var(--brand-800); border-radius: 28px; padding: 0.5rem 0.75rem; background: #fff; }
  .topbar .logo-box { padding: 0.2rem 0.4rem; }
  .topbar .logo-box img { width: 110px; }
  .sidebar { display: none; position: static; width: 100%; flex: none; min-height: 0; border-radius: 30px; }
  .sidebar.open { display: flex; }
  .sidebar > .logo-box { display: none; }
  .view { width: 100%; }
  h1 { font-size: 1.55rem; }
  .card { border-radius: 24px; padding: 1rem; }
  .grid-2, .grid-3, .grid-4, .gegenueber, .kaestchen, .meta-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .stepper { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-top: 0.4rem; }
  .blatt { padding: 1.2rem; }
  .sticky-bar { border-radius: 24px; flex-wrap: wrap; }
  .toolbar .input, .toolbar .btn { width: 100%; }

  /* Tabelle → gestapelte Karten */
  .card.flush.stapel { border: 0; box-shadow: none; background: none; border-radius: 0; overflow: visible; }
  .stapel .table thead { display: none; }
  .stapel .table, .stapel .table tbody, .stapel .table tr, .stapel .table td { display: block; }
  .stapel .table tr { border: 2px solid var(--brand-800); border-radius: 22px; background: #fff; padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; }
  .stapel .table td { border: 0; padding: 0.2rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  .stapel .table td::before { content: attr(data-label); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--brand-600); flex: none; padding-top: 0.2rem; text-align: left; }
  .stapel .table td:first-child { display: block; text-align: left; }
  .stapel .table td:first-child::before { content: none; }
  .stapel .table tfoot { display: block; }
}

/* Druck */
@media print {
  @page { size: A4; margin: 14mm 14mm 16mm; }
  body { background: #fff; font-size: 10.5pt; }
  .sidebar, .topbar, .no-print, .toast, .druck-leiste { display: none !important; }
  .shell { display: block; padding: 0; }
  .view { max-width: none; }
  .blatt { border: 0; box-shadow: none; padding: 0; border-radius: 0; }
  .blatt h2 { break-after: avoid; }
  .frage-block, .vb-tabelle tr { break-inside: avoid; }
  .badge { border: 1px solid #999; }
}


/* ===== Preisliste ===== */
.view { max-width: 1400px; }
.formel p { margin: 0 0 0.3rem; }
.formel .op { display: inline-block; min-width: 1.2rem; text-align: center; font-weight: 800; color: var(--brand-700); }
.kat-kopf { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.9rem 1.2rem 0.7rem; }
.kat-kopf h2 { margin: 0; }
.scroll { overflow-x: auto; }
.table.kalk th { white-space: nowrap; line-height: 1.25; padding: 0.55rem 0.6rem; }
.table.kalk td { padding: 0.35rem 0.6rem; white-space: nowrap; }
.table.kalk td:first-child { white-space: normal; min-width: 12rem; }
.table th.pkv, .table th.gkv { background: var(--brand-700); }
.table td.pkv, .table td.gkv { background: var(--brand-300); }
.table td.liste { color: var(--brand-600); font-size: 0.85rem; }
.table tr.offen td.pkv, .table tr.offen td.gkv { background: var(--brand-50); color: var(--brand-600); }
.table tr.individuell td { background: var(--brand-50); }
.table tr.gespeichert td { animation: blink 1.2s ease-out; }
@keyframes blink { from { background: var(--accent); } }
.name { font-weight: 700; text-decoration: none; color: var(--brand-800); text-align: left; }
.name:disabled { cursor: default; }
.name:not(:disabled):hover { text-decoration: underline; }
.detail { display: block; font-size: 0.8rem; color: var(--brand-600); }
.notiz { display: inline-block; margin-left: 0.3rem; color: var(--brand-600); cursor: help; font-size: 0.85rem; }
.satz { display: block; font-size: 0.68rem; color: var(--warn); }
.zelle { width: 5.2rem; font: inherit; font-size: 0.9rem; text-align: right; font-variant-numeric: tabular-nums; border: 1.5px solid var(--brand-100); border-radius: 10px; padding: 0.3rem 0.45rem; background: #fff; color: var(--ink); }
.zelle:hover { border-color: var(--brand-600); }
.zelle:focus { outline: none; border-color: var(--brand-800); box-shadow: 0 0 0 3px var(--brand-300); }
.zelle::placeholder { color: #a7b0bf; }
.zelle.fehlt { border-color: var(--warn); background: var(--brand-100); }
.delta { font-weight: 700; font-size: 0.85rem; }
.delta.plus { color: #2f7a4a; }
.delta.minus { color: var(--warn); }
.sort { width: 1%; }
.mini { border: 1px solid var(--brand-100); background: #fff; border-radius: 8px; width: 1.6rem; height: 1.6rem; cursor: pointer; color: var(--brand-600); font-size: 0.6rem; margin-left: 0.15rem; }
.mini:hover { background: var(--brand-50); color: var(--brand-800); }
.btn.ghost { border-color: transparent; }
.abschnitt { margin: 1rem 0 0.5rem; padding-top: 0.6rem; border-top: 2px solid var(--brand-100); }
.form-actions .spacer { flex: 1; }
.dialog { width: min(640px, calc(100vw - 2rem)); }
.small-table td, .small-table th { font-size: 0.82rem; padding: 0.4rem 0.6rem; }
.nowrap { white-space: nowrap; }
.toolbar .input[type=search] { min-width: 16rem; }

/* Preisliste-Blatt */
.card.blatt { border: 1px solid var(--brand-100); border-radius: 12px; }
.liste-druck td { padding: 0.35rem 0.8rem; }
.liste-druck tbody tr.erste td { border-top: 2px solid var(--brand-800); }
.liste-druck td:first-child { width: 22%; }
.liste-druck td.num { width: 14%; }
@media print {
  .card.blatt { box-shadow: none; border: 0; padding: 0; }
  .liste-druck th { background: #fff !important; color: #000; border-bottom: 2px solid #000; }
  .liste-druck tbody { break-inside: avoid; }
}
