/* 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;
  --shadow-card: 0 20px 60px rgba(25, 41, 70, 0.12);
}

* { box-sizing: border-box; }
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; margin: 0.4rem 0 0.6rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.6rem; color: var(--brand-800); }
p { margin: 0 0 0.6rem; }
.hl { display: inline-block; background: var(--accent); color: var(--brand-800); padding: 0.5rem 0.75rem; }
.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; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 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 320px; width: 320px; 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 {
  border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.1); color: #fff;
  padding: 0.75rem 1rem; font-size: 0.875rem; 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); }
.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); }
.topbar { display: none; }
.view { flex: 1; min-width: 0; max-width: 1080px; padding-top: 0.5rem; }

/* Buttons */
.btn {
  display: inline-flex; min-height: 3rem; align-items: center; justify-content: center; gap: 0.4rem;
  border-radius: 999px; border: 1px solid transparent; padding: 0.75rem 1.25rem;
  font: inherit; font-size: 0.875rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em;
  text-decoration: none; cursor: pointer; transition: 0.15s; color: var(--brand-800); background: transparent;
}
.btn:focus-visible, .input:focus-visible { 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.ghost:hover { background: var(--brand-50); }
.btn.small { min-height: 2.25rem; padding: 0.4rem 0.9rem; font-size: 0.75rem; }
.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; }

/* Karten */
.card {
  border-radius: 30px; border: 4px solid var(--brand-800); background: rgba(255, 255, 255, 0.88);
  padding: 1.25rem; box-shadow: var(--shadow-card); margin-bottom: 1.25rem;
}
.card.flush { padding: 0; overflow: hidden; }
.card.empty ol { padding-left: 1.2rem; margin-bottom: 1.2rem; }
.card.empty li { margin-bottom: 0.4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.actions, .form-actions, .row-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.form-actions { justify-content: flex-end; margin-top: 1rem; }
.crumb { margin: 0 0 0.5rem; font-size: 0.9rem; }
.badge { display: inline-block; border-radius: 999px; background: var(--brand-50); padding: 0.2rem 0.7rem; font-size: 0.75rem; font-weight: 600; color: var(--brand-800); white-space: nowrap; }
.badge.ueberfaellig { background: var(--accent); }
.badge.ueberfaellig::before { content: '! '; }
.badge.bald { background: var(--brand-100); }
.badge.ok { background: var(--brand-300); }
.archived { margin-top: -0.5rem; }

/* Kennzahlen */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { border-radius: 24px; border: 2px solid var(--brand-800); background: #fff; padding: 1rem 1.25rem; }
.tile-num { font-size: 2.25rem; font-weight: 700; line-height: 1; margin: 0; color: var(--brand-800); }

/* 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.75rem; letter-spacing: 0.06em; text-align: left; padding: 0.7rem 0.9rem; border-bottom: 2px solid var(--accent); }
.table th.num { text-align: right; }
.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.plain td { padding: 0.35rem 0; }
.table.plain { margin-bottom: 0.8rem; }

/* 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: 22px; padding: 0.6rem 0.9rem;
}
textarea.input { border-radius: 24px; min-height: 7rem; resize: vertical; }
.input.compact { width: auto; margin: 0; padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 999px; }
.grid-2, .grid-3 { display: grid; gap: 0 1rem; grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.span-2 { grid-column: span 2; }
.check { display: flex; gap: 0.5rem; align-items: center; font-size: 0.9rem; }

/* Leitfaden & Phasen */
.phase-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem; }
.phase-head h2 { margin: 0; flex: 1; }
.phase-no { display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 50%; background: var(--mint); color: var(--brand-800); font-weight: 800; flex: none; }
.goal { font-style: italic; color: var(--brand-700); }
.phase ul, .principles ul { margin: 0; padding-left: 1.2rem; }
.phase li, .principles li { margin-bottom: 0.35rem; }
details { margin-bottom: 0.6rem; }
summary { cursor: pointer; font-weight: 700; color: var(--brand-700); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.4rem; }

/* Bewertungsskala */
.rating { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.45rem 0; border-top: 1px solid var(--brand-100); flex-wrap: wrap; }
.rating + .eyebrow, .table + .eyebrow { margin-top: 1.2rem; }
.scale { display: flex; gap: 0.35rem; }
.scale input { position: absolute; opacity: 0; pointer-events: none; }
.scale span { display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 2px solid var(--brand-800); background: #fff; font-weight: 700; cursor: pointer; transition: 0.1s; }
.scale span:hover { background: var(--brand-50); }
.scale input:checked + span { background: var(--brand-800); color: #fff; }
.scale input:focus-visible + span { box-shadow: 0 0 0 3px var(--brand-300); }

/* Vereinbarungen */
.agreements { list-style: none; margin: 0; padding: 0; }
.agreements li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--brand-100); }
.agreements li:first-child { border-top: 0; }
.agreement-edit { display: grid; grid-template-columns: 1fr 9rem 10rem auto; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.agreement-edit .input { margin: 0; }

/* Verlauf */
.timeline { border-left: 3px solid var(--steel); margin-left: 0.4rem; padding-left: 1.2rem; display: grid; gap: 0.8rem; }
.talk { position: relative; display: grid; grid-template-columns: 9.5rem 1fr; gap: 1rem; padding: 0.8rem 1rem; border-radius: 22px; border: 2px solid var(--brand-800); background: #fff; text-decoration: none; color: inherit; transition: 0.15s; }
.talk:hover { background: var(--brand-50); }
.talk::before { content: ''; position: absolute; left: calc(-1.2rem - 9px); top: 1.2rem; width: 11px; height: 11px; border-radius: 50%; background: var(--brand-800); border: 2px solid var(--canvas); }
.talk-date { display: flex; flex-direction: column; gap: 0.3rem; align-items: flex-start; }
.talk-body p { margin: 0; }
.talk-meta { font-size: 0.82rem; color: var(--brand-600); margin-top: 0.3rem !important; }
.delta { font-weight: 600; color: var(--brand-700); font-size: 0.8rem; white-space: nowrap; }

/* Entwicklung (Small Multiples) */
.trends { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.8rem; margin-bottom: 1.2rem; }
.trend { border-radius: 22px; border: 2px solid var(--brand-100); background: #fff; padding: 0.8rem 1rem; }
.trend-label { font-size: 0.85rem; font-weight: 600; margin: 0; }
.trend-value { font-size: 1.6rem; font-weight: 700; color: var(--brand-800); margin: 0 0 0.2rem; line-height: 1.2; }
.trend-value small { font-size: 0.85rem; font-weight: 500; color: var(--brand-600); }
.spark { display: block; width: 100%; height: auto; overflow: visible; }
.spark .grid { stroke: var(--brand-100); stroke-width: 1; }
.spark .axis { font-size: 9px; fill: var(--brand-600); font-family: inherit; }
.spark .line { fill: none; stroke: var(--brand-800); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark .dot { fill: var(--brand-800); stroke: #fff; stroke-width: 2; }
.spark .hit { fill: transparent; cursor: pointer; }
.tip { position: fixed; z-index: 50; background: var(--brand-800); color: #fff; font-size: 0.78rem; padding: 0.3rem 0.6rem; border-radius: 10px; pointer-events: none; white-space: nowrap; }
[hidden] { display: none !important; }

/* Dialog & Toast */
.dialog { border: 4px solid var(--brand-800); border-radius: 30px; padding: 1.5rem; width: min(520px, calc(100vw - 2rem)); box-shadow: var(--shadow-card); background: var(--canvas); }
.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); }
.print-only { display: none; }

/* Mittlere Fensterbreiten: schmalere Sidebar */
@media (max-width: 1200px) {
  .sidebar { flex-basis: 250px; width: 250px; }
}

/* 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.6rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .agreement-edit { grid-template-columns: 1fr 1fr; padding-bottom: 0.6rem; border-bottom: 1px solid var(--brand-100); }
  .agreement-edit [name='a_text'] { grid-column: 1 / -1; }
  .talk { grid-template-columns: 1fr; gap: 0.4rem; }
  .agreements li { flex-direction: column; align-items: flex-start; gap: 0.4rem; }

  /* Tabelle → gestapelte Karten */
  .card.flush { border: 0; box-shadow: none; background: none; border-radius: 0; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  .table tr[data-href] { border: 2px solid var(--brand-800); border-radius: 24px; background: #fff; padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; }
  .table tr[data-href] td { border: 0; padding: 0.25rem 0; text-align: left; display: flex; justify-content: space-between; gap: 1rem; }
  .table tr[data-href] 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; }
  .table tr[data-href] td:first-child::before { content: none; }
  .table tr[data-href] td:first-child { display: block; }
}

/* Druck: Protokoll bzw. Leitfaden ohne Navigation */
@media print {
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .no-print, .toast, .tip { display: none !important; }
  .shell { display: block; padding: 0; }
  .view { max-width: none; }
  .card { border: 1px solid #999; border-radius: 8px; box-shadow: none; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; break-inside: avoid; }
  .hl { background: none; padding: 0; }
  .print-only { display: block; }
  .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 3rem; margin-top: 3.5rem; }
  .signatures div { border-top: 1px solid #333; padding-top: 0.3rem; font-size: 9pt; }
}
