:root {
  --cec-primary: #bb1d27;
  --cec-logo-red: #b51f29;
  --cec-logo-grey: #575756;
  --cec-grey-light: #929191;
  --cec-secondary: #989898;
  --cec-bg: #f0eded;
  --cec-footer: #f1f1f1;
  --cec-surface: #ffffff;
  --cec-elevated: #e3e7ec;

  --text: #2b2b2a;
  --muted: #666564;
  --line: #dcd8d8;
  --ok: #2e7d32;
  --ok-bg: #e8f3e8;
  --warn: #9a5b00;
  --warn-bg: #fff4e0;
  --primary-bg: #fbeaeb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --font: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--cec-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
img, svg { max-width: 100%; }
button, input, textarea { font: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 500; }
h3 { font-size: 1rem; font-weight: 500; }
p { margin: 0; }
a { color: var(--cec-primary); }
code { font-size: .875em; background: var(--cec-elevated); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px; z-index: 10; }
.skip:focus { left: 8px; }
main:focus { outline: none; }
:focus-visible { outline: 3px solid rgba(187,29,39,.45); outline-offset: 2px; }

/* ---------- Kopfzeile ---------- */
.topbar { background: var(--cec-surface); border-bottom: 3px solid var(--cec-primary); position: sticky; top: 0; z-index: 5; }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); min-width: 0; }
.wappen { width: 32px; height: 38px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.viewswitch { display: inline-flex; background: var(--cec-elevated); border-radius: 999px; padding: 3px; }
.viewswitch button { border: 0; background: transparent; padding: 5px 10px; border-radius: 999px; font-size: .8125rem; color: var(--muted); cursor: pointer; }
.viewswitch button[aria-pressed="true"] { background: var(--cec-surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }
.iconbtn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--cec-logo-grey); }
.iconbtn:hover { background: var(--cec-elevated); }
.iconbtn svg { width: 22px; height: 22px; fill: currentColor; }

@media (max-width: 520px) {
  .brand-title { white-space: normal; line-height: 1.1; font-size: .9375rem; }
  .brand-sub { display: none; }
  .viewswitch button { padding: 5px 8px; font-size: .75rem; }
  .iconbtn { width: 34px; }
}

/* ---------- Layout ---------- */
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; }
.layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.cards { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-content: start; }
@media (min-width: 760px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards .span-2 { grid-column: 1 / -1; }
}
@media (min-width: 1040px) {
  .layout { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .chat { position: sticky; top: 76px; max-height: calc(100vh - 92px); }
}

.card { background: var(--cec-surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head h2 svg { width: 22px; height: 22px; fill: var(--cec-primary); flex: none; }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.source { display: inline-block; font-size: .75rem; color: var(--muted); background: var(--cec-footer); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 8px; border: 1px solid transparent; padding: 10px 16px; min-height: 44px; font-weight: 500; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--cec-primary); color: #fff; }
.btn-primary:hover { background: #a2171f; }
.btn-outline { background: var(--cec-surface); color: var(--cec-primary); border-color: var(--cec-primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-ghost { background: transparent; color: var(--cec-logo-grey); border-color: var(--line); }
.btn-ghost:hover { background: var(--cec-footer); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--cec-primary); text-decoration: underline; cursor: pointer; font-size: .875rem; }

/* ---------- Startseite ---------- */
.start { max-width: 560px; margin: 8px auto 24px; display: grid; gap: 16px; }
.start-hero { background: var(--cec-surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.start-hero .band { background: linear-gradient(135deg, var(--cec-logo-grey), #3c3c3b); color: #fff; padding: 20px 16px; position: relative; }
.start-hero .band h1 { font-size: 1.5rem; }
.start-hero .band p { opacity: .9; margin-top: 6px; }
.start-hero .band svg.fibre { position: absolute; right: 0; bottom: 0; width: 180px; height: 100%; opacity: .18; pointer-events: none; }
.start-hero .band > * { position: relative; }
.start-form { padding: 16px; display: grid; gap: 12px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .875rem; font-weight: 500; }
.field input, .field textarea { width: 100%; border: 1px solid #bdb8b8; border-radius: 8px; padding: 10px 12px; font-size: 1rem; background: #fff; }
.field input:focus, .field textarea:focus { border-color: var(--cec-primary); outline: none; box-shadow: 0 0 0 3px rgba(187,29,39,.15); }
.code-input { font-size: 1.375rem !important; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; text-align: center; }
.form-error { color: var(--cec-primary); font-size: .875rem; }
.privacy { display: flex; gap: 8px; font-size: .8125rem; color: var(--muted); }
.privacy svg { width: 18px; height: 18px; flex: none; fill: var(--cec-secondary); margin-top: 1px; }
.democodes { display: grid; gap: 8px; }
.democode { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.democode:hover { border-color: var(--cec-primary); }
.democode .c { font-weight: 700; letter-spacing: .05em; }
.democode .a { font-size: .875rem; color: var(--muted); min-width: 0; }
.democode .s { font-size: .75rem; background: var(--cec-elevated); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.start-facts { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.fact { background: var(--cec-surface); border-radius: 10px; padding: 10px; text-align: center; box-shadow: var(--shadow); }
.fact b { display: block; font-size: 1.25rem; color: var(--cec-primary); }
.fact span { font-size: .75rem; color: var(--muted); }

/* ---------- Kopf Anschluss ---------- */
.anschluss-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.anschluss-head .meta { font-size: .875rem; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 500; border-radius: 999px; padding: 3px 10px; background: var(--cec-elevated); color: var(--cec-logo-grey); }
.pill-red { background: var(--primary-bg); color: var(--cec-primary); }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }

/* ---------- Statusleiste ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); position: relative; }
.steps::before { content: ""; position: absolute; left: 7%; right: 7%; top: 15px; height: 3px; background: var(--line); }
.steps .bar { position: absolute; left: 7%; top: 15px; height: 3px; background: var(--cec-primary); }
.step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; min-width: 0; }
.step .dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--cec-surface); border: 3px solid var(--line); font-size: .8125rem; font-weight: 700; color: var(--muted); z-index: 1; }
.step.done .dot { background: var(--cec-primary); border-color: var(--cec-primary); color: #fff; }
.step.current .dot { border-color: var(--cec-primary); color: var(--cec-primary); box-shadow: 0 0 0 5px rgba(187,29,39,.16); }
.step .lbl { font-size: .6875rem; line-height: 1.2; color: var(--muted); hyphens: auto; -webkit-hyphens: auto; overflow-wrap: normal; max-width: 100%; }
@media (max-width: 520px) { .step .lbl { font-size: .625rem; } .step .dot { width: 28px; height: 28px; } .steps::before, .steps .bar { top: 13px; } }
.step.current .lbl { color: var(--text); font-weight: 700; }
.step-current { margin-top: 14px; padding: 12px; border-radius: 10px; background: var(--primary-bg); }
.step-current .t { font-weight: 700; }
.timeline { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding-bottom: 12px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 10px; top: 20px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .tdot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); background: #fff; margin-top: 1px; }
.timeline .erledigt .tdot { background: var(--cec-primary); border-color: var(--cec-primary); }
.timeline .aktuell .tdot { border-color: var(--cec-primary); box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 11px var(--cec-primary); }
.timeline .tt { font-weight: 500; }
.timeline .td { font-size: .875rem; color: var(--muted); }
details.more summary { cursor: pointer; color: var(--cec-primary); font-size: .875rem; margin-top: 10px; }

/* ---------- Nächster Schritt ---------- */
.next-date { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.cal { flex: none; width: 60px; border-radius: 10px; overflow: hidden; text-align: center; border: 1px solid var(--line); background: #fff; }
.cal .m { background: var(--cec-primary); color: #fff; font-size: .6875rem; text-transform: uppercase; padding: 2px 0; font-weight: 500; }
.cal .d { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.cal .w { font-size: .6875rem; color: var(--muted); padding-bottom: 3px; }
.next-title { font-weight: 700; font-size: 1.0625rem; }
.checklist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.checklist li { display: grid; grid-template-columns: 20px 1fr; gap: 8px; font-size: .9375rem; }
.checklist svg { width: 20px; height: 20px; fill: var(--cec-primary); margin-top: 2px; }
.notice { border-radius: 10px; padding: 10px 12px; font-size: .9375rem; margin-top: 12px; }
.notice-warn { background: var(--warn-bg); color: #5c3a00; }
.notice-ok { background: var(--ok-bg); color: #1d4d20; }
.feedback { margin-top: 10px; font-size: .875rem; color: var(--ok); font-weight: 500; }

/* ---------- Skizzen ---------- */
.sketch { width: 100%; height: auto; display: block; background: #fafafa; border-radius: 10px; border: 1px solid var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .8125rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 18px; height: 8px; border-radius: 2px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .9375rem; margin-top: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; }
.sperr { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.sperr li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; font-size: .875rem; }
.sperr b { white-space: nowrap; }

/* ---------- Vorher / Nachher ---------- */
.photos { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 8px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: #ddd; aspect-ratio: 4 / 3; }
.photo svg { width: 100%; height: 100%; display: block; }
.photo .cap { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.72)); color: #fff; padding: 18px 8px 6px; font-size: .75rem; line-height: 1.3; }
.photo .cap b { display: block; font-size: .8125rem; }
@media (max-width: 520px) { .photos { grid-template-columns: minmax(0,1fr); } }
.photo .tag { position: absolute; top: 6px; left: 6px; background: rgba(255,255,255,.9); border-radius: 4px; font-size: .625rem; padding: 1px 5px; color: var(--muted); }
.photo.pending { display: grid; place-items: center; background: repeating-linear-gradient(45deg, #efeded, #efeded 10px, #e7e4e4 10px, #e7e4e4 20px); color: var(--muted); text-align: center; padding: 10px; font-size: .8125rem; }
.mangel-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: .875rem; }
.mangel-list li { background: var(--cec-footer); border-radius: 8px; padding: 8px 10px; }
.mangel-preview { max-height: 160px; border-radius: 8px; object-fit: cover; }

/* ---------- Anschluss-Pass ---------- */
.pass { border: 2px solid var(--cec-primary); }
.pass-grid { display: grid; gap: 12px; grid-template-columns: minmax(0,1fr); }
@media (min-width: 760px) { .pass-grid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); } }
.pass-locked { opacity: .9; border: 2px dashed var(--line); box-shadow: none; background: transparent; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; background: var(--cec-surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-height: 420px; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-head h2 { font-size: 1rem; }
.chat-head p { font-size: .75rem; color: var(--muted); }
.mode { font-size: .6875rem; font-weight: 500; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.mode-live { background: var(--ok-bg); color: var(--ok); }
.mode-off { background: var(--cec-elevated); color: var(--cec-logo-grey); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; min-height: 180px; }
.msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: .9375rem; overflow-wrap: anywhere; }
.msg p + p { margin-top: 6px; }
.msg-user { align-self: flex-end; background: var(--cec-logo-grey); color: #fff; border-bottom-right-radius: 4px; }
.msg-bot { align-self: flex-start; background: var(--cec-footer); border-bottom-left-radius: 4px; }
.msg-bot .source { margin-top: 6px; background: #fff; }
.msg-note { font-size: .6875rem; color: var(--muted); margin-top: 4px; }
.msg-actions { margin-top: 8px; }
.msg-actions .btn { min-height: 36px; padding: 6px 10px; font-size: .8125rem; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--cec-secondary); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chips { display: flex; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 10px; font-size: .8125rem; cursor: pointer; text-align: left; color: var(--text); }
.chip:hover { border-color: var(--cec-primary); color: var(--cec-primary); }
.chat-form { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; min-width: 0; resize: none; border: 1px solid #bdb8b8; border-radius: 10px; padding: 10px 12px; font-size: 1rem; max-height: 120px; }
.chat-form textarea:focus { border-color: var(--cec-primary); outline: none; }
.chat-form .btn { padding: 0 14px; }
.handed { border-top: 1px solid var(--line); padding: 10px 16px; font-size: .8125rem; background: var(--cec-footer); }
.handed summary { cursor: pointer; font-weight: 500; }
.handed ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.fab { position: fixed; right: 16px; bottom: 16px; z-index: 4; box-shadow: 0 4px 14px rgba(0,0,0,.25); border-radius: 999px; }
@media (min-width: 1040px) { .fab { display: none; } }

/* ---------- Auftraggeber ---------- */
.bars { display: grid; gap: 12px; }
.barrow { display: grid; gap: 4px; }
.barrow .top { display: flex; justify-content: space-between; gap: 8px; font-size: .9375rem; }
.barrow .track { height: 10px; background: var(--cec-elevated); border-radius: 999px; overflow: hidden; }
.barrow .fill { height: 100%; background: var(--cec-primary); border-radius: 999px; }
.barrow .ex { font-size: .8125rem; color: var(--muted); }
.barrow .gap { font-size: .8125rem; color: var(--warn); }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; }
.table-wrap { overflow-x: auto; }
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, minmax(0,1fr)); } }
.kpi { background: var(--cec-surface); border-radius: 10px; padding: 12px; box-shadow: var(--shadow); }
.kpi b { display: block; font-size: 1.5rem; color: var(--cec-primary); }
.kpi span { font-size: .8125rem; color: var(--muted); }

/* ---------- Footer, Dialoge, Toast ---------- */
.footer { background: var(--cec-footer); border-top: 1px solid var(--line); margin-top: 24px; }
.footer-inner { max-width: 1200px; margin: 0 auto; padding: 16px 16px 88px; display: grid; gap: 8px; font-size: .8125rem; color: var(--muted); }
@media (min-width: 1040px) { .footer-inner { padding-bottom: 16px; } }
.footer-cec { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.footer-cec img { height: 20px; width: auto; }
.footer-cec .claim { font-style: italic; }
.footer-demo { background: #fff; border: 1px dashed var(--cec-secondary); border-radius: 8px; padding: 8px 10px; }
.dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(0,0,0,.35); }
.dialog-body { padding: 20px; display: grid; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-size: .9375rem; }
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #323232; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .9375rem; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 4px 14px rgba(0,0,0,.3); }

/* ---------- Druck: nur Anschluss-Pass ---------- */
.print-only { display: none; }
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  body * { visibility: hidden; }
  #pass, #pass * { visibility: visible; }
  #pass { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: 0; padding: 0; }
  #pass .no-print { display: none !important; }
  #pass .print-only { display: block; }
  .sketch { border: 1px solid #999; }
  .photo .cap { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
