@font-face { font-family: 'Lexend'; src: url('fonts/Lexend.woff2') format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Cinzel'; src: url('fonts/Cinzel.woff2') format('woff2'); font-weight: 400 900; font-display: swap; }
:root {
  --bg: var(--bg2); --card: #fff; --line: #dfe4ea; --text: #1b2430; --muted: #687482;
  --brand: #0b5cad; --brand-dark: #084785; --ok: #16803c; --warn: #c27a00; --err: #c0262d; --off: #9aa3ad;
  --radius: 8px;
  --bg2: #f3f5f8; --hover: #eef2f6; --sel: #e8f0fa; --toast: #1b2430; --input: #fff;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0e141c; --card: #151e29; --line: #283444; --text: #e3e8ee; --muted: #8e9bab;
  --brand: #3d8fe0; --brand-dark: #2c7acb; --ok: #2fb35f; --warn: #e3a336; --err: #ef5b60; --off: #5d6876;
  --bg2: #1a2431; --hover: #1e2a38; --sel: #193250; --toast: #2a3646; --input: #101820;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Lexend", "Segoe UI", system-ui, Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
.hidden { display: none !important; }

header.top { display: flex; align-items: center; gap: 18px; padding: 0 24px; height: 58px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1000; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; white-space: nowrap; }
.dt-logo { height: 30px; width: auto; display: block; }
.product { font-family: 'Cinzel', serif; font-size: 19px; font-weight: 500; letter-spacing: 6px; color: var(--text); border-left: 1px solid var(--line); padding-left: 14px; line-height: 30px; }
.custbox { display: flex; align-items: center; gap: 10px; }
.cust-logo { height: 36px; width: 36px; object-fit: cover; border-radius: 50%; }
nav.tabs { display: flex; gap: 4px; }
nav.tabs a { white-space: nowrap; padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 500; }
nav.tabs a.active { background: var(--sel); color: var(--brand); }
.top .spacer { flex: 1; }
.top select { width: auto; min-width: 180px; }
.usermenu { color: var(--muted); font-size: 13px; display: flex; gap: 10px; align-items: center; }

main.page { max-width: 1400px; margin: 0 auto; padding: 22px 24px 60px; }
h1 { font-size: 20px; margin: 0 0 16px; font-weight: 600; }
h2 { font-size: 16px; margin: 0; font-weight: 600; }
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.bar .spacer { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 18px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

button, .btn { font: inherit; font-family: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 7px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
button:hover { background: var(--hover); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--err); }
button.link { border: none; background: none; color: var(--brand); padding: 4px 6px; }
button.small { padding: 4px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: 8px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--input); color: var(--text); }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; }

/* Anmeldung */
.auth { max-width: 380px; margin: 10vh auto; }
.auth .card { padding: 26px; }
.auth h1 { text-align: center; }
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo .dt-logo { height: auto; width: 100%; max-width: 300px; margin: 0 auto; }
.product-big { font-family: 'Cinzel', serif; font-size: 24px; font-weight: 500; color: var(--text); letter-spacing: 9px; text-transform: uppercase; margin-top: 14px; padding-left: 9px; }
.err { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* Karte */
#map { height: min(560px, 62vh); border-radius: var(--radius); border: 1px solid var(--line); margin-bottom: 18px; background: var(--bg2); }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }

/* Struktur */
.branch-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.branch-head .spacer { flex: 1; }
.dept { margin-top: 16px; }
.dept-head { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.dept-head h3 { font-size: 14px; margin: 0; font-weight: 600; }
.dept-head .spacer { flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.tile { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); display: flex; flex-direction: column; }
.screen { position: relative; background: #000; aspect-ratio: 3 / 2; display: flex; align-items: center; justify-content: center; color: #8a94a0; font-size: 13px; overflow: hidden; }
.screen img { width: 100%; height: 100%; }
.screen .code { color: #fff; font-size: 13px; text-align: center; }
.tile .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tile .name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tile .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dot { width: 9px; height: 9px; min-width: 9px; max-height: 9px; border-radius: 50%; background: var(--off); flex-shrink: 0; display: inline-block; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.err { background: var(--err); }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--hover); color: var(--muted); }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

/* Mediathek */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); margin-bottom: 18px; background: var(--card); }
.drop.over { border-color: var(--brand); background: var(--sel); color: var(--brand); }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress div { height: 100%; background: var(--brand); width: 0; transition: width .2s; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.mcard { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); cursor: default; }
.mcard.pick { cursor: pointer; }
.mcard.pick:hover, .mcard.selected { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(11,92,173,.25); }
.mthumb { aspect-ratio: 16 / 10; background: #111 center/cover no-repeat; position: relative; }
.mthumb .badge { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.65); color: #fff; }
.mcard .body { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.mcard input { font-weight: 600; padding: 5px 7px; }

/* Tabelle */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Dialog */
.modal { position: fixed; inset: 0; background: rgba(20,28,38,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 2000; padding: 6vh 16px; overflow: auto; }
.modal-box { background: var(--card); border-radius: 10px; width: 100%; max-width: 480px; padding: 22px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal-box.wide { max-width: 860px; }
.modal-box h2 { margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--toast); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 3000; max-width: 90vw; }
.toast.show { opacity: 1; }

@media (max-width: 720px) {
  header.top { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  main.page { padding: 16px 12px 60px; }
  .row3 { grid-template-columns: 1fr; }
}

/* Liste Land › Provinz › Stadt › Geschäft */
.places details { margin: 2px 0; }
.places summary { cursor: pointer; padding: 7px 8px; border-radius: 6px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
.places summary::-webkit-details-marker { display: none; }
.places summary::before { content: '▸'; color: var(--muted); width: 12px; transition: transform .15s; }
.places details[open] > summary::before { transform: rotate(90deg); }
.places summary:hover { background: var(--hover); }
.places .lvl { padding-left: 18px; border-left: 1px solid var(--line); margin-left: 13px; }
.places .shop { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.places .shop:hover { background: var(--sel); color: var(--brand); }
.back { text-decoration: none; font-size: 13px; }

/* Display-Kachel */
.tile-top { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #000; }
.loc-photo { width: 100%; aspect-ratio: var(--ar, 3 / 2); object-fit: contain; background: #0a0f15; cursor: zoom-in; display: block; }
.loc-photo.none { background: var(--hover); color: var(--muted); font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; text-align: center; }
.tile-top .screen { aspect-ratio: var(--ar, 3 / 2) !important; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.tile-top .screen img { position: absolute; inset: 0; width: 100%; height: 100%; }
.num, .mnum { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 6px; background: var(--brand); color: #fff; font-weight: 700; font-size: 14px; }
.mthumb .mnum { position: absolute; right: 6px; top: 6px; }
.tile .name .dot { margin-left: auto; }
.row-num { display: grid; grid-template-columns: 90px 1fr; gap: 10px; }
.row-num.small-num { grid-template-columns: 70px 1fr; gap: 6px; }
.numinput { font-weight: 700; color: var(--brand); text-align: center; }

/* Bildauswahl */
.imgpick { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: start; }
.imgprev { width: 100px; height: 150px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg2); display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.imgprev img { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; background: var(--bg2); }
.imgprev span { font-size: 11px; color: var(--muted); }

/* Karte mit Kundenlogo */
.logo-pin { position: relative; width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.35); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.logo-pin img { width: 100%; height: 100%; object-fit: contain; }
.logo-pin.plain { width: 22px; height: 22px; border-width: 3px; margin: 11px; background: currentColor; }
.tbl-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 6px; }
.cred { background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 12px; white-space: pre-wrap; font-size: 13px; }

.ov-split { display: grid; grid-template-columns: 320px 1fr; gap: 18px; align-items: start; }
.ov-split #map { height: calc(100vh - 170px); min-height: 420px; margin: 0; }
.ov-split .places-card { margin: 0; max-height: calc(100vh - 170px); overflow: auto; }
@media (max-width: 900px) { .ov-split { grid-template-columns: 1fr; } .ov-split #map { height: min(560px, 62vh); } }

/* Nachtmodus: Karte, Logo, Steuerelemente */
body { transition: background .2s, color .2s; }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.6); }
[data-theme="dark"] .leaflet-container { background: #0b1118; }
[data-theme="dark"] .leaflet-bar a { background: var(--card); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .leaflet-control-attribution { background: rgba(21,30,41,.8) !important; color: var(--muted); }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--brand); }
[data-theme="dark"] .leaflet-tooltip { background: var(--card); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .dt-logo { filter: brightness(1.55) saturate(1.1); }
[data-theme="dark"] .modal { background: rgba(0,0,0,.6); }
[data-theme="dark"] .num, [data-theme="dark"] .mnum, [data-theme="dark"] button.primary { color: #fff; }
.theme-btn { font-size: 16px; line-height: 1; padding: 6px 9px; }
.dot.err { min-height: 0; margin: 0; }
.filebtn { display: inline-flex; align-items: center; gap: 10px; margin: 0; cursor: pointer; color: var(--text); font-size: 13px; }
.lang-sel { width: auto; min-width: 0; padding: 5px 6px; font-size: 12px; }
.auth-tools { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.top select.lang-sel, .auth-tools select.lang-sel { min-width: 0; width: 62px; }

.hero { display: flex; align-items: center; gap: 16px; }
.hero-logo { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; background: none; box-shadow: none; }
.hero-name { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.pin-wrap { background: none; border: none; }

.logo-pin { overflow: visible; }
.logo-pin img { border-radius: 50%; }
.pin-badge { position: absolute; top: -6px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--err); color: #fff; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.places .shop .alert { color: var(--err); font-size: 12px; margin-left: 8px; font-weight: 500; }
.places .shop .note { color: var(--muted); font-size: 12px; margin-left: 8px; }
.places .shop { display: block; line-height: 1.45; }
.places .shop .alert, .places .shop .note { display: inline-block; }

.places .shop-name { font-weight: 500; }
.places .offline-line { font-size: 12px; color: var(--muted); margin: 3px 0 0 14px; }
.places .off { color: var(--err); font-weight: 700; letter-spacing: .5px; }

.places .shop { position: relative; }
.places .off-sum { position: relative; display: inline-block; margin-left: 10px; font-size: 12px; color: var(--muted); cursor: help; }
.places .off-pop { display: none; position: absolute; left: 0; top: calc(100% + 6px); z-index: 50; min-width: 360px; max-width: 560px; width: max-content;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; box-shadow: 0 8px 24px rgba(0,0,0,.35); white-space: normal; }
.places .off-pop::before { content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px; }
.places .off-sum:hover .off-pop, .places .off-sum:focus-within .off-pop { display: block; }
.places .off-pop .offline-line { margin: 6px 0 0; font-size: 13px; color: var(--text); }
.places-card { overflow: visible; }
.places .off-pop .offline-line { white-space: nowrap; }

.mini-map { height: 260px; border-radius: 8px; border: 1px solid var(--line); }
.geo-pick { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.geo-pick .pick { text-align: left; white-space: normal; font-size: 12px; }
.drag-pin { width: 26px; height: 26px; border-radius: 50% 50% 50% 0; background: var(--brand); transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.45); cursor: grab; }

/* Geschäfte als Kacheln pro Ort */
.places-top { display: flex; align-items: center; gap: 10px; margin: 4px 0 14px; flex-wrap: wrap; }
.places-top h2 { margin: 0 6px 0 0; }
.places-top input[type=search] { flex: 1; min-width: 200px; }
.chip { border: 1px solid var(--line); border-radius: 16px; padding: 6px 12px; font-size: 12px; color: var(--muted); background: var(--card); }
.chip.on { background: var(--sel); color: var(--brand); border-color: var(--sel); }
.chip .r { color: var(--err); font-weight: 700; }
.city-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.country-head { font-size: 15px; margin: 18px 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }
.city-tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.city-tile.bad { border-color: color-mix(in srgb, var(--err) 65%, transparent); }
.city-head { padding: 12px 16px 10px; background: linear-gradient(180deg, var(--hover), var(--card)); border-radius: 12px 12px 0 0; border-bottom: 1px solid var(--line); border-left: 4px solid var(--brand); }
.city-tile.bad .city-head { border-left-color: var(--err); }
.city-row { display: flex; align-items: center; gap: 8px; }
.city-pin { width: 16px; height: 16px; fill: var(--brand); flex-shrink: 0; }
.city-name { font-size: 20px; font-weight: 600; letter-spacing: .3px; }
.city-meta { color: var(--muted); font-size: 12px; margin-top: 3px; padding-left: 24px; }
.city-badge { margin-left: auto; background: var(--err); color: #fff; font-size: 11px; font-weight: 700; border-radius: 10px; padding: 2px 9px; }
.city-list { padding: 4px 16px 10px; }
.shop-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 6px; margin: 0 -6px; border-top: 1px solid var(--line); text-decoration: none; color: var(--text); border-radius: 6px; }
.shop-row:first-child { border-top: none; }
.shop-row:hover { background: var(--hover); }
.shop-row .shop-name { font-weight: 500; }
.shop-row .shop-addr { font-size: 12px; color: var(--muted); }
.shop-row .off-sum { position: relative; cursor: help; border-bottom: 1px dashed color-mix(in srgb, var(--err) 60%, transparent); white-space: nowrap; }
.shop-row .off { color: var(--err); font-weight: 700; font-size: 12px; letter-spacing: .5px; }
.shop-row .off-pop { display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 10px; box-shadow: 0 10px 28px rgba(0,0,0,.35); width: max-content; max-width: 520px; }
.shop-row .off-pop::before { content: ''; position: absolute; top: -10px; left: 0; right: 0; height: 10px; }
.shop-row .off-sum:hover .off-pop, .shop-row .off-sum:focus .off-pop { display: block; }
.shop-row .off-pop .offline-line { font-size: 13px; margin-top: 6px; white-space: nowrap; color: var(--text); }
.shop-row .off-pop .off { font-size: 12px; }
.ov-split .places-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.ov-split .city-grid { grid-template-columns: 1fr; }
