.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); padding: 16px 12px; overflow-y: auto; }
.sidebar .brand { padding: 8px 10px 16px; font-size: 1.05rem; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--muted);
  cursor: pointer; font-size: .9rem; text-decoration: none; }
.side-link:hover { background: var(--surface); color: var(--text); }
.side-link.active { background: var(--surface); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.side-link .ic { font-family: var(--font-mono); width: 18px; text-align: center; color: var(--faint); }
.side-link.danger { color: var(--danger); }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); z-index: 10; }
.topbar input.search { max-width: 320px; }
.content { padding: 24px; overflow-y: auto; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.kpi .v { font-family: var(--font-display); font-size: 1.8rem; }
.kpi .l { color: var(--faint); font-family: var(--font-mono); font-size: .78rem; text-transform: uppercase; }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 820px) { .shell { grid-template-columns: 1fr; } .sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; transform: translateX(-100%); transition: .2s; z-index: 60; } .sidebar.open { transform: none; } }
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar-chart .b { flex: 1; background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.bank-balance { font-family: var(--font-display); font-size: 2.6rem; }
.row-actions { display: flex; gap: 6px; }
.hidden { display: none !important; }
.perm-matrix label { display: inline-flex; align-items: center; gap: 6px; margin: 4px 10px 4px 0; font-size: .82rem; }
.perm-matrix input { width: auto; }

/* Website-Monitor: Sparkline */
.spark { display: inline-flex; align-items: flex-end; gap: 2px; height: 34px; }
.spark i { width: 6px; min-height: 4px; border-radius: 2px; opacity: .85; }

/* Medien-Bibliothek */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { padding: 10px; }
.media-thumb { aspect-ratio: 4/3; border-radius: 10px; overflow: hidden; background: var(--bg); display: flex; align-items: center; justify-content: center; border: 1px solid var(--border); margin-bottom: 8px; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-file { color: var(--muted); letter-spacing: .12em; font-size: .8rem; }

/* Balkendiagramm mit Zahlen */
.bar-chart.labeled { height: 180px; align-items: stretch; gap: 8px; }
.bar-chart.labeled .bcol { flex: 1; display: grid; grid-template-rows: auto 1fr auto; align-items: end; justify-items: center; gap: 4px; min-width: 0; }
.bar-chart.labeled .bcol > .b { align-self: end; }
.bar-chart.labeled .bval { font-size: .68rem; font-family: var(--font-mono); color: var(--muted); white-space: nowrap; }
.bar-chart.labeled .b { width: 100%; flex: 0 0 auto; min-height: 3px; }
.bar-chart.labeled .bday { font-size: .62rem; font-family: var(--font-mono); color: var(--faint); white-space: nowrap; }
@media (max-width: 640px) { .bar-chart.labeled .bval, .bar-chart.labeled .bday { font-size: .55rem; } }

/* Dokumente: kompaktes Kunden-Dropdown in der Tabelle */
select.doc-cust { margin: 0; padding: 6px 8px; font-size: .82rem; min-width: 150px; max-width: 200px; }

/* Statistik: Spitzenwert hervorheben */
.bar-chart.labeled .b { transition: height .35s cubic-bezier(.2,.8,.2,1); }
.bar-chart.labeled .b.peak { background: linear-gradient(var(--accent-2), var(--accent)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent); }
.bar-chart.labeled .bcol:hover .b { filter: brightness(1.15); }

/* ---- Live-Chat ---- */
.chat-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 16px; margin-top: 16px; align-items: start; }
@media (max-width: 900px) { .chat-wrap { grid-template-columns: 1fr; } }
.chat-list { max-height: 70vh; overflow-y: auto; }
.ch-item { padding: 11px 12px; border-radius: 10px; border: 1px solid var(--border); margin-bottom: 8px; cursor: pointer; transition: .14s; }
.ch-item:hover { border-color: var(--accent); }
.ch-item.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.ch-item.closed { opacity: .6; }
.ch-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ch-top .chip { margin-left: auto; font-size: .68rem; }
.ch-last { font-size: .82rem; margin: 4px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-meta { font-size: .68rem; color: var(--faint); }
.chat-view h3 { display: flex; align-items: center; gap: 8px; }
.ch-thread { display: flex; flex-direction: column; gap: 10px; max-height: 46vh; overflow-y: auto; padding: 12px 2px; }
.ch-msg { max-width: 76%; }
.ch-msg .ch-b { padding: 9px 13px; border-radius: 14px; font-size: .9rem; line-height: 1.5; white-space: pre-wrap; }
.ch-msg .ch-t { font-size: .66rem; color: var(--faint); margin-top: 3px; }
.ch-msg.team { align-self: flex-end; }
.ch-msg.team .ch-b { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ch-msg.team .ch-t { text-align: right; }
.ch-msg.bot .ch-b { background: var(--bg-2); border: 1px dashed var(--border); border-bottom-left-radius: 4px; }
.ch-msg.kunde .ch-b, .ch-msg.gast .ch-b { background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ch-send { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; padding-top: 10px; border-top: 1px solid var(--border); }
.ch-send textarea { margin: 0; resize: vertical; }

/* ---- Benachrichtigungs-Glocke ---- */
.bell { position: relative; font-size: 1rem; padding: 6px 10px; }
.bell-dot { position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700;
  display: grid; place-items: center; font-family: var(--font-mono); }
.bell-panel { position: fixed; top: 60px; right: 18px; z-index: 120; width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden; animation: bpIn .16s ease-out; }
@keyframes bpIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.bp-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.bp-head strong { flex: 1; font-size: .95rem; }
.bp-x { background: none; border: 0; color: var(--muted); font-size: 1rem; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.bp-x:hover { background: var(--bg-2); color: var(--text); }
.bp-list { max-height: min(420px, 60vh); overflow-y: auto; }
.bp-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); }
.bp-item:last-child { border-bottom: 0; }
.bp-item.unread { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.bp-ic { width: 22px; text-align: center; flex-shrink: 0; }
.bp-msg { font-size: .86rem; line-height: 1.45; }
.bp-t { font-size: .66rem; color: var(--faint); margin-top: 2px; }

/* Statistik: Live-Kacheln */
.kpi .k { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 6px; }
.kpi .s { font-size: .72rem; color: var(--faint); margin-top: 2px; }
.live-kpi { border-top-color: var(--ok); }
.live-pulse { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: lp 1.6s infinite; }
@keyframes lp { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 50% { opacity: .6; box-shadow: 0 0 0 5px transparent; } }

/* Pakete & Preise */
.pk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; align-items: start; }
.pk-card { display: flex; flex-direction: column; }
.pk-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pk-name { font-weight: 700; font-size: 1rem; margin: 0; }
.pk-hl { display: flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.pk-hl input { width: auto; margin: 0; }
.pk-card textarea { font-size: .85rem; }
.pk-preview { margin-top: 12px; padding: 12px; border-radius: 10px; background: var(--bg-2); border: 1px dashed var(--border);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.pv-old { text-decoration: line-through; color: var(--faint); font-weight: 700; }
.pv-new { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; }
.pv-new.sale { color: var(--danger); }
.pv-badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 999px; padding: 3px 10px; font-size: .7rem; font-weight: 700; }

/* E-Mail-Design-Editor: Editor links, Live-Vorschau rechts (sticky) */
.mail-editor { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; margin-top: 16px; align-items: start; }
.mail-edit-col { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.mail-prev-col { position: sticky; top: 12px; min-width: 0; }
.mail-prev-col iframe { display: block; }
@media (max-width: 900px) { .mail-editor { grid-template-columns: 1fr; } .mail-prev-col { position: static; } }

/* SEO-Editor: Texte links, Live-Vorschau (Tab + Google) rechts */
.seo-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; margin-top: 16px; align-items: start; }
@media (max-width: 900px) { .seo-grid { grid-template-columns: 1fr; } }
.seo-count { font-size: .74rem; color: var(--faint); margin-top: 4px; font-family: var(--font-mono); }
.seo-sub { font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
/* Browser-Tab-Vorschau */
.tab-prev { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px 10px 0 0; padding: 8px 12px; }
.tab-fav img, .g-fav img { width: 16px; height: 16px; display: block; border-radius: 4px; }
.tab-title { font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.tab-x { color: var(--faint); font-size: .8rem; }
/* Google-Treffer-Vorschau */
.g-prev { background: #ffffff; border: 1px solid #e5e9f2; border-radius: 10px; padding: 14px 16px; color: #202124; }
.g-top { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.g-fav { width: 26px; height: 26px; border-radius: 50%; background: #f1f3f4; display: grid; place-items: center; }
.g-site { display: flex; flex-direction: column; line-height: 1.25; }
.g-name { font-size: .82rem; color: #202124; }
.g-url { font-size: .74rem; color: #5f6368; }
.g-title { color: #1a0dab; font-size: 1.25rem; line-height: 1.3; margin-bottom: 3px;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.g-desc { color: #4d5156; font-size: .88rem; line-height: 1.45;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ===========================================================================
   Handy-Ansicht: das Dashboard war fuer breite Bildschirme gebaut. Tabellen
   liefen aus dem Bild, die Kopfzeile war gequetscht, Formulare zu eng.
   =========================================================================== */

/* Tabellen brechen nicht mehr zeichenweise um, sondern scrollen in ihrer Karte. */
.content .card { overflow-x: auto; }
.content table.data { min-width: 520px; }
.content table.data th, .content table.data td { white-space: nowrap; }
.content table.data td:first-child,
.content table.data td[style*="max-width"] { white-space: normal; }

@media (max-width: 820px) {
  /* Menue-Knopf sichtbar lassen, Suche darf schrumpfen. */
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar input.search { max-width: none; flex: 1 1 160px; min-width: 0; }
  .content { padding: 16px 14px; }
  h1 { font-size: 1.6rem; }
  /* Geoeffnete Seitenleiste bekommt einen Schatten – sonst „klebt" sie am Inhalt. */
  .sidebar.open { box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
}

@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px; }
  .kpi .v { font-size: 1.4rem; }
  .card { padding: 16px; }
  .card.pad-lg { padding: 18px; }
  /* Zwei-Spalten-Formulare werden einspaltig (Klasse kommt aus components.css). */
  .content .grid.cols-2, .content .grid.cols-3, .content .grid.cols-4 { grid-template-columns: 1fr; }
  .row-actions { flex-wrap: wrap; gap: 4px; }
  .row-actions .btn { padding: 6px 9px; font-size: .78rem; }
  .topbar .chip { display: none; }          /* Name/Version brauchen hier keinen Platz */
  .topbar .bell, .topbar #themeBtn { padding: 6px 9px; }
  .bell-panel { top: 54px; right: 8px; left: 8px; width: auto; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .chat-wrap { gap: 12px; }
  .ch-msg { max-width: 92%; }
}

/* Eingabefelder auf iOS nicht mehr hineinzoomen (unter 16px zoomt Safari). */
@media (max-width: 560px) {
  input, select, textarea { font-size: 16px; }
}

/* Statistik-Diagramm auf schmalen Bildschirmen: die Tagesbeschriftungen liefen
   ineinander ("So 0Mo 1Di 1…"). Jede Spalte bekommt eine Mindestbreite, das
   Diagramm scrollt dann waagerecht in seiner Karte statt zu verschmelzen. */
.bar-chart.labeled .bcol { min-width: 30px; }
.bar-chart .b { min-width: 8px; }
@media (max-width: 560px) {
  .bar-chart.labeled { gap: 5px; }
  .bar-chart.labeled .bcol { min-width: 27px; }
  .bar-chart.labeled .bday, .bar-chart.labeled .bval { font-size: .58rem; letter-spacing: -.02em; }
  /* Ueberschrift der Karte umbricht sauber statt die Zahlen zu zerreissen. */
  .content .card h3 { line-height: 1.35; }
}

/* ===========================================================================
   Tabellen als Karten (Handy)
   Auf dem Handy wird nicht mehr seitlich gescrollt: jede Zeile ist eine Karte,
   die Werte stehen untereinander, die Spaltenueberschrift steht als
   Beschriftung davor (data-label kommt von /tables.js).
   =========================================================================== */
@media (max-width: 720px) {
  .content .card { overflow-x: visible; }
  .content table.data { min-width: 0; display: block; }
  .content table.data thead { display: none; }
  .content table.data tbody, .content table.data tr, .content table.data td { display: block; width: 100%; }
  .content table.data tr { border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface-2); padding: 4px 14px; margin-bottom: 10px; }
  .content table.data tr:hover td { background: transparent; }
  .content table.data td { border-bottom: 1px solid var(--border); padding: 9px 0;
    display: flex; gap: 14px; align-items: flex-start; justify-content: space-between;
    text-align: right; white-space: normal; overflow-wrap: anywhere; }
  .content table.data tr td:last-child { border-bottom: 0; }
  .content table.data td::before { content: attr(data-label); flex: 0 0 40%; text-align: left;
    font-family: var(--font-mono); font-size: .66rem; letter-spacing: .06em; text-transform: uppercase;
    color: var(--faint); padding-top: 3px; }
  .content table.data td[data-noLabel]::before { content: ''; }
  /* Zusatzzeilen unter den Wert, nicht daneben. */
  .content table.data td { flex-wrap: wrap; }
  .content table.data td .sub, .content table.data td > div:not(:first-child) { flex: 1 0 100%; text-align: right; margin-top: 2px; }
  /* Aktionsknöpfe brauchen die volle Breite. */
  .content table.data td:has(.row-actions) { display: block; }
  .content table.data td:has(.row-actions)::before { display: none; }
  .content table.data td .row-actions { justify-content: flex-end; }
  .content table.data td select, .content table.data td input { max-width: 60%; }
}

/* Rechte-Auswahl: deutsche Bezeichnung mit kurzer Erklaerung darunter. */
.perm-matrix { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.perm-matrix label { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 8px 0; font-size: .9rem; color: var(--text); }
.perm-matrix label > span { display: block; line-height: 1.35; }
.perm-matrix .perm-hint { display: block; color: var(--faint); font-size: .74rem; margin-top: 2px; }

/* Das Diagramm laesst sich nicht sinnvoll untereinander stapeln – es scrollt
   deshalb in sich selbst, ohne die Seite mitzuziehen. */
.bar-chart.labeled { overflow-x: auto; padding-bottom: 4px; }

/* Menü-Knopf (≡): ab 820 px übernimmt die feste Seitenleiste, darunter wird der
   Knopf gebraucht. Steuerung per CSS – nicht per JavaScript beim Rendern, sonst
   verschwindet er, wenn das Fenster nachträglich schmaler wird. */
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-flex; }
  .sidebar { z-index: 60; }
}

/* Social-Media-Zeilen in den Firmendaten */
.soc-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.soc-row select, .soc-row input { margin: 0; }
.soc-row .btn { padding: 8px 11px; }
@media (max-width: 560px) { .soc-row { grid-template-columns: 1fr auto; } .soc-row select { grid-column: 1 / -1; } }
