:root {
    --primaer: #0B2E6B;
    --akzent: #1E88E5;
    --grau: #6B7280;
    --hintergrund: #F4F6FA;
    --karte: #FFFFFF;
    --linie: #E3E8F0;
    --text: #1F2937;
    --ok: #15803D;
    --fehler: #B91C1C;
    --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--hintergrund);
    background-color: var(--hintergrund);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; color: var(--primaer); margin: .2rem 0; }
h2 { font-size: 1.05rem; color: var(--primaer); margin: 0 0 .8rem; }
h3 { font-size: .95rem; color: var(--primaer); margin: 1rem 0 .3rem; }
code { background: #EEF2F8; padding: 0 .3em; border-radius: 4px; font-size: .9em; }
.klein { font-size: .85rem; color: var(--grau); }
.untertitel { color: var(--grau); margin: .1rem 0 0; }
.hinweis-oben { color: var(--grau); margin: 0 0 1rem; }

/* Kopf */
.kopf { background: var(--karte); border-bottom: 3px solid var(--akzent); }
.kopf-innen { max-width: 1180px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.marke img { height: 44px; display: block; }
.menue { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: auto; }
.menue a { padding: .45rem .75rem; border-radius: 8px; color: var(--primaer); font-weight: 600; }
.menue a:hover { background: #E8F1FC; text-decoration: none; }
.menue a.ab { color: var(--grau); font-weight: 400; }

.inhalt { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.4rem 16px 3rem; }
.fuss { text-align: center; color: var(--grau); font-size: .8rem; padding: 1rem; border-top: 1px solid var(--linie); background: var(--karte); }

/* Karten & Raster */
.karte { background: var(--karte); border-radius: var(--radius); padding: 1.2rem 1.3rem; box-shadow: 0 1px 2px rgba(11,46,107,.06), 0 4px 16px rgba(11,46,107,.05); margin-bottom: 1.2rem; }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .9rem 1.1rem; }
.raster.zwei { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.kopfzeile { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.aktionen { display: flex; gap: .5rem; flex-wrap: wrap; }
.aktionsleiste { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.leer-hinweis { color: var(--grau); }

/* Knöpfe & Chips */
.knopf { display: inline-block; border: 0; background: var(--akzent); color: #fff; padding: .6rem 1.05rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.knopf:hover { background: #1670C0; text-decoration: none; color: #fff; }
.knopf:disabled { opacity: .45; cursor: not-allowed; }
.knopf.hell { background: #E9EEF7; color: var(--primaer); }
.knopf.hell:hover { background: #DCE5F3; color: var(--primaer); }
.klein-knopf { padding: .45rem .8rem; font-size: .9rem; }
.chip { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--linie); border-radius: 999px; padding: .4rem .9rem; margin: 0 .4rem .4rem 0; cursor: pointer; background: #fff; }
.chip input { accent-color: var(--akzent); }
.chip:has(input:checked) { border-color: var(--akzent); background: #E8F1FC; color: var(--primaer); font-weight: 600; }
.auswahl { display: flex; flex-wrap: wrap; margin-bottom: .6rem; }

/* Formularfelder */
.feld { display: flex; flex-direction: column; gap: .3rem; }
.feld.breit { grid-column: 1 / -1; }
.feld-label, label { font-size: .88rem; font-weight: 600; color: #374151; }
.feld-hilfe { color: var(--grau); font-weight: 400; font-size: .8rem; }
input, select, textarea {
    font: inherit; font-weight: 400; color: var(--text);
    border: 1px solid #CBD5E1; border-radius: 8px; padding: .55rem .65rem; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #9CC8F4; border-color: var(--akzent); }
input[type=radio], input[type=checkbox] { width: auto; }
input[disabled] { display: none; }
.feld[hidden], .karte[hidden] { display: none !important; }
textarea.texteditor { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .88rem; min-height: 60vh; }

/* Tabellen */
.tabelle-rahmen { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabelle th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--grau); border-bottom: 2px solid var(--linie); padding: .6rem .5rem; }
.tabelle td { border-bottom: 1px solid var(--linie); padding: .6rem .5rem; vertical-align: middle; }
.tabelle td a { font-weight: 600; }
.aktion-zellen a { margin-right: .8rem; white-space: nowrap; }
.tabelle.preise td { vertical-align: top; }
.preis-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.preis-form label { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; }
.preis-form input { width: 120px; }
.preis-form .einheit input { width: 180px; }
.preis-form .datum input { width: 150px; }
.verlauf { margin-top: .5rem; font-size: .85rem; }
.verlauf summary { cursor: pointer; color: var(--akzent); }

/* Status */
.status { display: inline-block; font-size: .78rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; background: #E8F1FC; color: var(--primaer); }
.status.unterschrieben { background: #DCFCE7; color: var(--ok); }
.meldung { padding: .7rem 1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.meldung.ok { background: #DCFCE7; color: #166534; }
.meldung.fehler { background: #FEE2E2; color: #991B1B; }
.status-zeile { font-weight: 600; min-height: 1.4em; }
.status-zeile.fehler { color: var(--fehler); }
.status-zeile.ok { color: var(--ok); }

/* Detail */
.angaben { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.angaben dt { color: var(--grau); }
.angaben dd { margin: 0; }
.versionen { list-style: none; padding: 0; margin: 0 0 .6rem; }
.versionen li { padding: .5rem 0; border-bottom: 1px solid var(--linie); display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Login */
.login { max-width: 380px; margin: 6vh auto; }
.login .karte { padding: 1.8rem; }
.login form { display: flex; flex-direction: column; gap: .9rem; }

/* Tabs */
.tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab { padding: .5rem .9rem; border-radius: 9px; background: #E9EEF7; color: var(--primaer); font-weight: 600; }
.tab.aktiv { background: var(--primaer); color: #fff; }
.texte-raster { grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); }
.platzhalter { list-style: none; padding: 0; margin: 0 0 .5rem; font-size: .85rem; columns: 1; }
.platzhalter li { margin-bottom: .2rem; word-break: break-all; }

/* Unterschrift */
.sign-layout { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 1.2rem; align-items: start; }
.sign-werkzeug { position: sticky; top: 12px; }
.quellen { margin-bottom: .8rem; }
.quelle-block { margin-bottom: .9rem; }
.vorschau-rahmen { border: 1px dashed #B6C4DA; border-radius: 10px; padding: .8rem; background: #fff; display: flex; align-items: center; justify-content: center; min-height: 90px; }
.vorschau-rahmen img { max-width: 100%; max-height: 110px; }
#pad { width: 100%; height: auto; aspect-ratio: 3 / 1; border: 1px dashed #B6C4DA; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.breite { display: block; margin: .8rem 0 1.1rem; font-weight: 600; }
.breite input { margin-top: .4rem; padding: 0; }
.hinweis-box { border-top: 1px solid var(--linie); padding-top: .8rem; margin-top: 1.2rem; }
.sign-viewer { background: #D9DFEA; border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 1rem; align-items: center; min-height: 70vh; overflow: auto; max-height: 85vh; }
.sign-viewer .seite { position: relative; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.18); cursor: crosshair; line-height: 0; flex: 0 0 auto; }
.sign-viewer .seite canvas { display: block; }
.sign-viewer .overlay { position: absolute; pointer-events: auto; cursor: pointer; opacity: .95; }
.sign-viewer .overlay:hover { outline: 2px dashed var(--akzent); }
.sign-viewer .laedt { color: var(--primaer); font-weight: 600; padding: 2rem; }

/* Mobil */
@media (max-width: 760px) {
    .kopf-innen { justify-content: space-between; }
    .menue { margin-left: 0; width: 100%; }
    .menue a { padding: .35rem .5rem; font-size: .92rem; }
    .inhalt { padding: 1rem 12px 2.5rem; }
    .karte { padding: 1rem; }
    .raster, .raster.zwei { grid-template-columns: 1fr; }
    .sign-layout, .texte-raster { grid-template-columns: 1fr; }
    .sign-werkzeug { position: static; }
    .sign-viewer { max-height: none; min-height: 50vh; }
    .tabelle th:nth-child(n+3) { display: none; }
    .tabelle td[data-label] { display: block; border: 0; padding: .25rem .5rem; }
    .tabelle tr { display: block; border-bottom: 1px solid var(--linie); padding: .5rem 0; }
    .tabelle thead { display: none; }
    .kopfzeile { align-items: stretch; }
    .aktionen .knopf { flex: 1 1 auto; text-align: center; }
    .preis-form input, .preis-form .einheit input, .preis-form .datum input { width: 100%; }
    .preis-form label { flex: 1 1 45%; }
}

/* Grunddaten: Schaltflächen, Gefahr */
.knopf.gefahr { background: #B91C1C; }
.knopf.gefahr:hover { background: #991B1B; }
.aktionen form { margin: 0; }

/* Unterschrift: Einfügen, Verschieben */
.einfuegen { margin-bottom: .6rem; }
.einfuegen-zeile { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .6rem; align-items: center; }
.einfuegen-zeile input[type=text] { flex: 1 1 140px; width: auto; }
.einfuegen-zeile input[type=date] { width: auto; }
.einfuegen-zeile select { width: auto; }
.modus-zeile { color: var(--primaer); font-weight: 600; min-height: 1.3em; font-size: .9rem; }
body.platzieren .sign-viewer { cursor: crosshair; }
.sign-viewer .overlay { position: absolute; cursor: move; touch-action: none; user-select: none; }
.sign-viewer .overlay.text { background: rgba(255,255,255,.55); color: #1f3fbf; padding: 0 3px; white-space: nowrap; line-height: 1.2; font-family: Helvetica, Arial, sans-serif; }
.sign-viewer .overlay.zieht { outline: 2px solid var(--akzent); }
.sign-viewer .overlay:hover { outline: 1px dashed var(--akzent); }
.sign-viewer .overlay-x { position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: #B91C1C; color: #fff; font-size: 14px; line-height: 20px; padding: 0; cursor: pointer; opacity: .85; }
.sign-viewer .overlay-x:hover { opacity: 1; }

/* Objekte und Zuordnung */
.linkknopf { background: none; border: 0; color: var(--akzent); cursor: pointer; font: inherit; padding: 0; }
.linkknopf:hover { text-decoration: underline; }
.zuordnung { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .4rem; }
.zuordnung select { width: auto; min-width: 220px; }

/* Antwort auf Angebote */
.status.antwort-ausstehend { background: #FEF3C7; color: #92400E; }
.status.antwort-angenommen { background: #DCFCE7; color: #166534; }
.status.antwort-abgelehnt { background: #FEE2E2; color: #991B1B; }

/* Navigation mit Gruppen */
.menue { display: flex; gap: .3rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.menue > a, .menue details.gruppe > summary { padding: .45rem .75rem; border-radius: 8px; color: var(--primaer); font-weight: 600; cursor: pointer; list-style: none; }
.menue > a:hover, .menue details.gruppe > summary:hover { background: #E8F1FC; text-decoration: none; }
.menue details.gruppe { position: relative; }
.menue details.gruppe > summary::-webkit-details-marker { display: none; }
.menue details.gruppe > summary::after { content: " ▾"; font-size: .8em; color: var(--grau); }
.menue details.gruppe .panel { position: absolute; top: 100%; left: 0; background: #fff; border: 1px solid var(--linie); border-radius: 10px; box-shadow: 0 8px 24px rgba(11,46,107,.12); padding: .35rem; min-width: 190px; z-index: 20; display: flex; flex-direction: column; }
.menue details.gruppe .panel a { padding: .45rem .7rem; border-radius: 7px; color: var(--text); font-weight: 500; white-space: nowrap; }
.menue details.gruppe .panel a:hover { background: #E8F1FC; color: var(--primaer); text-decoration: none; }
.menue a.ab { color: var(--grau); font-weight: 400; }
@media (max-width: 760px) {
    .menue details.gruppe .panel { position: static; box-shadow: none; border: 0; padding: 0 0 .3rem .6rem; }
}

/* Adressbücher, Dienstleister, Versand */
.raster > .breit, .raster > h2 { grid-column: 1 / -1; }
.vorschau-mail { border: 1px solid var(--linie); border-radius: 10px; padding: .8rem 1rem; margin-bottom: .8rem; background: #fff; }
.vorschau-mail h3 { margin-top: 0; }
pre.mailtext { white-space: pre-wrap; font-family: inherit; font-size: .92rem; background: #F8FAFD; border-radius: 8px; padding: .8rem; margin: 0; }
input[size] { width: auto; }

/* Aushang (PDF-Gestaltung wird im PDF-Layout gesetzt) */
textarea { font: inherit; width: 100%; border: 1px solid #CBD5E1; border-radius: 8px; padding: .55rem .65rem; }
