/* ============================================================
   Der Fototyp Immo CRM — Modern UI
   Inter typography · Dark & Light themes · Custom accent
   ============================================================ */

/* ------------------------------------------------------------
   Theme Tokens
   ------------------------------------------------------------ */
:root {
  /* Accent — wird via Inline-Style auf <html> überschrieben */
  --accent:        #7c5cff;
  --accent-hover:  color-mix(in srgb, var(--accent), white 10%);
  --accent-press:  color-mix(in srgb, var(--accent), black 14%);
  --accent-soft:   color-mix(in srgb, var(--accent) 14%, transparent);
  --accent-soft-2: color-mix(in srgb, var(--accent) 22%, transparent);
  --accent-ring:   color-mix(in srgb, var(--accent) 32%, transparent);
  --accent-on:     #ffffff;

  /* Semantic colors (gleich für beide Themes, Sättigung leicht differenziert) */
  --good:        #10b981;
  --bad:         #ef4444;
  --warn:        #f59e0b;
  --info:        #0ea5e9;

  /* Sidebar — IMMER dunkel, eigene Palette */
  --sb-bg:       #0a0b10;
  --sb-bg-2:     #14161d;
  --sb-surface:  #1b1e27;
  --sb-line:     #1f2230;
  --sb-text:     #e6e8ee;
  --sb-text-mut: #7d8497;
  --sb-text-dim: #525767;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;

  /* Layout */
  --sidebar-w: 248px;
  --header-h:  68px;
  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
}

/* Dark Theme */
[data-theme="dark"] {
  --bg:          #0d0e12;
  --bg-soft:     #14161d;
  --surface:     #15171f;
  --surface-2:   #1a1d27;
  --surface-3:   #21242f;
  --line:        #242833;
  --line-2:      #313646;
  --text:        #e8eaf0;
  --text-muted:  #969cae;
  --text-dim:    #5f6577;

  --shadow-1: 0 1px 2px rgba(0,0,0,.30), 0 1px 0 rgba(255,255,255,.02) inset;
  --shadow-2: 0 8px 24px rgba(0,0,0,.35), 0 1px 0 rgba(255,255,255,.03) inset;
  --shadow-3: 0 24px 60px rgba(0,0,0,.50);

  --good-bg:  color-mix(in srgb, var(--good) 14%, transparent);
  --bad-bg:   color-mix(in srgb, var(--bad)  16%, transparent);
  --warn-bg:  color-mix(in srgb, var(--warn) 16%, transparent);
  --info-bg:  color-mix(in srgb, var(--info) 16%, transparent);
}

/* Light Theme */
[data-theme="light"] {
  --bg:          #f7f8fa;
  --bg-soft:     #ffffff;
  --surface:     #ffffff;
  --surface-2:   #f5f6f9;
  --surface-3:   #eceef3;
  --line:        #e5e7ec;
  --line-2:      #d2d6df;
  --text:        #0d0f15;
  --text-muted:  #5b6273;
  --text-dim:    #8a90a1;

  --shadow-1: 0 1px 2px rgba(13,15,21,.04), 0 0 0 1px rgba(13,15,21,.04);
  --shadow-2: 0 6px 16px rgba(13,15,21,.06), 0 1px 0 rgba(255,255,255,1) inset;
  --shadow-3: 0 16px 40px rgba(13,15,21,.10);

  --good-bg:  color-mix(in srgb, var(--good) 12%, white);
  --bad-bg:   color-mix(in srgb, var(--bad)  10%, white);
  --warn-bg:  color-mix(in srgb, var(--warn) 14%, white);
  --info-bg:  color-mix(in srgb, var(--info) 12%, white);
}

/* ------------------------------------------------------------
   Base
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-feature-settings: "cv11", "ss01", "ss03";
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4, h5 {
  margin: 0 0 .4em;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--text);
}
h1 { font-size: 1.6rem; letter-spacing: -0.022em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
h4 { font-size: .9rem; }

::selection { background: var(--accent-soft-2); color: var(--text); }

/* ------------------------------------------------------------
   App Shell
   ------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ------------------------------------------------------------
   Sidebar — IMMER dunkel
   ------------------------------------------------------------ */
.sidebar {
  background: var(--sb-bg);
  border-right: 1px solid var(--sb-line);
  padding: 20px 16px;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  justify-content: center;
  padding: 8px 4px 24px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--sb-line);
}
.sidebar .brand-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px;
}
.sidebar .logo-img {
  max-width: 100%;
  max-height: 76px;
  width: auto;
  height: auto;
  display: block;
}
.sidebar .brand-link--empty .logo-dot {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-press));
  box-shadow: 0 4px 16px var(--accent-soft-2);
}

.sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.sidebar .nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--sb-text-dim);
  padding: 16px 12px 6px;
}
.sidebar .nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sb-text-mut);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
  position: relative;
}
.sidebar .nav .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  stroke-width: 1.75;
}
.sidebar .nav a:hover {
  color: var(--sb-text);
  background: var(--sb-surface);
}
.sidebar .nav a.is-active {
  color: var(--accent-on);
  background: linear-gradient(135deg, var(--accent), var(--accent-press));
  box-shadow: 0 4px 14px var(--accent-soft-2);
}
.sidebar .nav a.is-active .icon { stroke-width: 2; }

.sidebar-foot {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--sb-line);
  color: var(--sb-text-dim);
  font-size: 11px;
  text-align: center;
}

/* ------------------------------------------------------------
   Main Area
   ------------------------------------------------------------ */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

/* ------------------------------------------------------------
   Topbar
   ------------------------------------------------------------ */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg), transparent 20%);
  backdrop-filter: saturate(160%) blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .page-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topbar .page-title small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.topbar .page-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.012em;
  color: var(--text);
}
.topbar .page-title small + * { display: block; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.topbar-right .me {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-right .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-press));
  color: var(--accent-on);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: 0 2px 8px var(--accent-soft-2);
}
.topbar-right .me > div { font-size: 13px; font-weight: 500; color: var(--text); }
.topbar-right .me small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 1px;
}
.topbar-right .me small a { color: var(--text-muted); }
.topbar-right .me small a:hover { color: var(--accent); }

/* Content */
.content { padding: 28px; }

/* ------------------------------------------------------------
   Flash
   ------------------------------------------------------------ */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.flash--success {
  background: var(--good-bg);
  border-color: color-mix(in srgb, var(--good) 35%, transparent);
  color: color-mix(in srgb, var(--good), var(--text) 30%);
}
.flash--error {
  background: var(--bad-bg);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
  color: color-mix(in srgb, var(--bad), var(--text) 30%);
}
.flash--info {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: color-mix(in srgb, var(--accent), var(--text) 25%);
}

/* ------------------------------------------------------------
   Card
   ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card + .card { margin-top: 18px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 22px; }
.card--warn {
  background: linear-gradient(180deg, var(--accent-soft), transparent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.card--warn a { color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------
   Toolbar
   ------------------------------------------------------------ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar .search { flex: 1; min-width: 220px; max-width: 360px; }

/* ------------------------------------------------------------
   Table
   ------------------------------------------------------------ */
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  vertical-align: middle;
  color: var(--text);
}
.table tbody tr { transition: background .12s ease; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

.row-title {
  font-weight: 600;
  color: var(--text);
}
.row-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
/* Klickbarer Zeilen-Titel-Link */
a.row-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: color .12s ease;
}
a.row-link:hover .row-title {
  color: var(--accent);
}
.actions {
  text-align: right;
  white-space: nowrap;
}
.actions a, .actions form { margin-left: 6px; }
.actions a {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background .12s, color .12s;
}
.actions a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -.005em;
}

.input, .select, .textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-dim); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.textarea { resize: vertical; min-height: 90px; font-family: var(--font-sans); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.hint {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}
.hint code {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
}
.req { color: var(--accent); margin-left: 2px; }

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

label.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-press));
  color: var(--accent-on);
  border-color: var(--accent-press);
  box-shadow: 0 4px 14px var(--accent-soft-2), 0 1px 0 rgba(255,255,255,.15) inset;
}
.btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  color: var(--accent-on);
}
.btn-primary:active { transform: translateY(0); filter: brightness(.95); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--line-2);
}

.btn-danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
}
.btn-danger:hover {
  background: var(--bad-bg);
  border-color: var(--bad);
}

button.link-danger {
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  color: var(--bad);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: background .12s;
}
button.link-danger:hover { background: var(--bad-bg); }

/* ------------------------------------------------------------
   Tabs
   ------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tabs a:hover { color: var(--text); }
.tabs a.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-count {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.tabs a.is-active .tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ------------------------------------------------------------
   Badges
   ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -.005em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge--good {
  background: var(--good-bg);
  color: color-mix(in srgb, var(--good), var(--text) 35%);
  border-color: color-mix(in srgb, var(--good) 35%, transparent);
}
.badge--bad {
  background: var(--bad-bg);
  color: color-mix(in srgb, var(--bad), var(--text) 35%);
  border-color: color-mix(in srgb, var(--bad) 35%, transparent);
}
.badge--info {
  background: var(--info-bg);
  color: color-mix(in srgb, var(--info), var(--text) 30%);
  border-color: color-mix(in srgb, var(--info) 35%, transparent);
}
.badge--gold {
  background: var(--warn-bg);
  color: color-mix(in srgb, var(--warn), var(--text) 30%);
  border-color: color-mix(in srgb, var(--warn) 35%, transparent);
}
.badge--muted {
  background: var(--surface-2);
  color: var(--text-muted);
  border-color: var(--line);
}

/* ------------------------------------------------------------
   Empty State
   ------------------------------------------------------------ */
.empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}
.empty .mark {
  font-size: 28px;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 1.5px dashed var(--line-2);
  display: grid;
  place-items: center;
  color: var(--text-dim);
}
.empty p { margin: 0; font-size: 13.5px; }

/* ------------------------------------------------------------
   Detail Grid (Kunden/Shooting Ansicht)
   ------------------------------------------------------------ */
.detail-grid {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 12px 22px;
  margin: 0;
}
.detail-grid dt {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: -.005em;
}
.detail-grid dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
}

/* ------------------------------------------------------------
   Stats (Dashboard) — 4 Kacheln nebeneinander
   ------------------------------------------------------------ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat .label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -.005em;
  line-height: 1.2;
}
.stat .value {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: -.024em;
}
.stat .delta {
  margin-top: 6px;
  font-size: 12.5px;
}
.stat .delta a {
  color: var(--accent);
  font-weight: 600;
}
.stat .delta a:hover { text-decoration: underline; }

/* Legacy-Aliase für ältere Templates */
.stat .stat-label { font-size: 14px; font-weight: 600; color: var(--text); }
.stat .stat-value { font-size: 2.4rem; font-weight: 700; color: var(--text); line-height: 1.05; letter-spacing: -.024em; }
.stat .stat-meta  { font-size: 12.5px; color: var(--accent); font-weight: 600; }

/* ------------------------------------------------------------
   Split / Editorial Rule
   ------------------------------------------------------------ */
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.editorial-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-2), transparent);
  margin: 20px 0;
}

/* ------------------------------------------------------------
   Aufgaben — Check Button
   ------------------------------------------------------------ */
.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--line-2);
  background: var(--surface);
  color: transparent;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: all .15s ease;
}
.check-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.check-btn--done {
  background: var(--accent);
  color: var(--accent-on);
  border-color: var(--accent);
  cursor: default;
}
tr.is-done td .row-title,
tr.is-done td .row-sub {
  text-decoration: line-through;
  opacity: 0.5;
}

/* ------------------------------------------------------------
   E-Mail Verlauf — Detail Row
   ------------------------------------------------------------ */
tr.detail-row { display: none; }
tr.detail-row.is-open { display: table-row; }
tr.detail-row td {
  background: var(--surface-2);
  border-top: 1px dashed var(--line);
  padding: 18px;
}
pre.mail-body {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin: 0;
  line-height: 1.65;
}
.mail-body-rendered {
  background: var(--surface);
  padding: 18px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.55;
  max-width: 720px;
}
.mail-body-rendered img { max-width: 100%; height: auto; border-radius: var(--radius-xs); }
.mail-body-rendered a { color: var(--accent); }
.mail-body-rendered h1, .mail-body-rendered h2, .mail-body-rendered h3 { color: var(--text); margin-top: 0; }
.mail-body-rendered p { margin: 0 0 10px; }
.mail-body-rendered ul, .mail-body-rendered ol { padding-left: 22px; }
.mail-body-rendered blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 12px;
  color: var(--text-muted);
  margin: 10px 0;
}

.card-head .vorlage-select { min-width: 220px; }

/* ------------------------------------------------------------
   Helpers
   ------------------------------------------------------------ */
.text-muted { color: var(--text-muted); }
.text-bad   { color: var(--bad); }
.text-good  { color: var(--good); }

/* ------------------------------------------------------------
   Design / Theme Picker
   ------------------------------------------------------------ */
.theme-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 480px;
}
.theme-card {
  position: relative;
  cursor: pointer;
}
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-card .preview {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all .15s;
  background: var(--surface);
}
.theme-card .preview-head {
  display: flex; gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid;
}
.theme-card .preview-head span {
  width: 8px; height: 8px; border-radius: 50%;
}
.theme-card .preview-body {
  padding: 16px;
  height: 110px;
  display: flex; flex-direction: column; gap: 8px;
}
.theme-card .preview-body .line {
  height: 8px; border-radius: 4px;
}
.theme-card .preview-body .line:nth-child(1) { width: 60%; }
.theme-card .preview-body .line:nth-child(2) { width: 90%; }
.theme-card .preview-body .pill {
  width: 64px; height: 22px; border-radius: 999px;
  margin-top: auto;
}
.theme-card.dark .preview { background: #15171f; }
.theme-card.dark .preview-head { background: #0d0e12; border-bottom-color: #242833; }
.theme-card.dark .preview-head span { background: #2a2e3a; }
.theme-card.dark .preview-body .line { background: #2a2e3a; }
.theme-card.light .preview { background: #ffffff; }
.theme-card.light .preview-head { background: #f7f8fa; border-bottom-color: #e5e7ec; }
.theme-card.light .preview-head span { background: #d2d6df; }
.theme-card.light .preview-body .line { background: #e5e7ec; }
.theme-card .preview-body .pill {
  background: linear-gradient(135deg, var(--accent), var(--accent-press));
}
.theme-card .label {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.theme-card input:checked + .preview {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.theme-card input:checked ~ .label { color: var(--accent); font-weight: 600; }

.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.swatch {
  position: relative;
  cursor: pointer;
}
.swatch input { position: absolute; opacity: 0; pointer-events: none; }
.swatch .dot {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 2px solid var(--line);
  transition: all .15s;
  display: block;
}
.swatch input:checked + .dot {
  border-color: var(--text);
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(0,0,0,.2);
}
.swatch .dot::after {
  content: "";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: white;
  font-size: 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
}
.swatch input:checked + .dot::after {
  content: "✓";
  opacity: 1;
}

.accent-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.accent-custom input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}
.accent-custom input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 8px;
}
.accent-custom input[type="text"] {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: uppercase;
  width: 110px;
}

/* ------------------------------------------------------------
   Logo Preview
   ------------------------------------------------------------ */
.logo-preview {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 18px;
}
.logo-preview img {
  background: #0a0b10;
  padding: 14px;
  border-radius: var(--radius-sm);
  max-height: 140px;
}

/* ------------------------------------------------------------
   Login
   ------------------------------------------------------------ */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  background: #0a0b10;
  background-image:
    radial-gradient(800px 500px at 20% -10%, var(--accent-soft-2), transparent 60%),
    radial-gradient(700px 500px at 100% 110%, var(--accent-soft), transparent 60%);
  color: #e6e8ee;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: #14161d;
  border: 1px solid #242833;
  border-radius: 18px;
  padding: 40px 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.login-card h1 {
  color: #e8eaf0;
  text-align: center;
  margin-bottom: 6px;
  font-size: 1.5rem;
}
.login-card .subtitle {
  text-align: center;
  color: #7d8497;
  font-size: 13px;
  margin-bottom: 28px;
}
.login-card .field { margin-bottom: 16px; }
.login-card label { color: #e8eaf0; }
.login-card .input {
  background: #1b1e27;
  border-color: #242833;
  color: #e8eaf0;
}
.login-card .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.login-card .btn-primary { width: 100%; margin-top: 8px; padding: 12px; }
.login-card .flash { margin-bottom: 16px; }

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */

/* ------------------------------------------------------------
   Location Card (Wetter / Distanz / Karte)
   ------------------------------------------------------------ */
.weather-block {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.weather-icon {
  font-size: 44px;
  line-height: 1;
  flex-shrink: 0;
}
.weather-temp {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -.022em;
  color: var(--text);
  line-height: 1.05;
}
.weather-meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.distance-block {
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13.5px;
  color: var(--text);
}
.distance-block a {
  font-size: 11.5px;
  margin-top: 4px;
  color: var(--text-muted);
  align-self: flex-start;
}
.distance-block a:hover { color: var(--accent); }

.location-map iframe {
  width: 100%;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  display: block;
}


/* ============================================================
   Modal / Slide-Over Panel
   ============================================================ */

/* Overlay-Hintergrund */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 12, 0.55);
  backdrop-filter: blur(3px);
  z-index: 100;
  opacity: 0;
  transition: opacity .25s ease;
}
.modal-backdrop.is-open { opacity: 1; }

/* Panel von rechts */
.modal-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 720px;
  background: var(--bg);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 50px rgba(0,0,0,.35);
  z-index: 101;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .3s cubic-bezier(.22,.8,.35,1);
  overflow: hidden;
}
.modal-panel.is-open { transform: translateX(0); }

/* Geschachteltes (Sub-)Panel: schmaler und tiefer */
.modal-panel.is-nested {
  max-width: 640px;
  z-index: 103;
  box-shadow: -16px 0 50px rgba(0,0,0,.45);
}
.modal-backdrop.is-nested { z-index: 102; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  flex-shrink: 0;
}
.modal-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.modal-title small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.modal-title strong {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -.012em;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-close {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all .15s;
}
.modal-close:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--line-2);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg);
}

.modal-body .form-actions {
  position: sticky;
  bottom: -24px;
  left: 0;
  right: 0;
  margin: 24px -24px -24px;
  padding: 18px 24px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  z-index: 2;
}

/* Loading-State */
.modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 14px;
  gap: 12px;
}
.modal-loading::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Verstecke Tabs im Modal-Body wenn sie nicht gebraucht werden */
.modal-shell .toolbar { display: none; }

@media (max-width: 640px) {
  .modal-panel { max-width: 100%; }
}


/* ============================================================
   Kalender
   ============================================================ */

/* Toolbar */
.cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cal-nav .btn {
  padding: 7px 12px;
  font-size: 14px;
}
.cal-title {
  margin: 0 0 0 14px;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -.015em;
  color: var(--text);
}
.cal-views {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.cal-views a {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  transition: all .12s;
}
.cal-views a:hover { color: var(--text); }
.cal-views a.is-active {
  background: var(--accent);
  color: var(--accent-on);
}
.cal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.cal-actions .btn { padding: 7px 12px; font-size: 13.5px; }

.cal-filter-bar {
  padding: 8px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ---------- Monatsansicht ---------- */
.cal-month {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.cal-month-head {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.cal-wd {
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: minmax(110px, 1fr);
}
.cal-day {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 110px;
  min-width: 0;
  background: var(--surface);
  position: relative;
  transition: background .12s;
}
.cal-day:nth-child(7n) { border-right: none; }
.cal-day.is-other { background: var(--bg); opacity: .5; }
.cal-day.is-today { background: var(--accent-soft); }
.cal-day.has-conflict::before {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--bad);
  box-shadow: 0 0 0 2px var(--surface);
}
.cal-day-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  padding: 2px 6px;
  border-radius: 100%;
  min-width: 22px;
  text-align: center;
}
.cal-day.is-today .cal-day-num {
  background: var(--accent);
  color: var(--accent-on);
}
.cal-day-add {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 14px;
  opacity: 0;
  transition: opacity .15s, background .15s;
  text-decoration: none;
}
.cal-day:hover .cal-day-add { opacity: 1; }
.cal-day-add:hover {
  background: var(--accent);
  color: var(--accent-on);
}
.cal-day-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
}

/* Events in Monatsansicht */
.cal-ev {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
  border-left: 3px solid var(--text-dim);
  cursor: pointer;
  transition: all .12s;
  overflow: hidden;
  min-width: 0;
}
.cal-ev:hover {
  background: var(--surface-3);
  transform: translateX(2px);
}
.cal-ev.is-dragging { opacity: .4; }
.cal-ev-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
  line-height: 1.45;
}
.cal-ev-title {
  flex: 1;
  min-width: 0;
  /* Bis zu 2 Zeilen erlaubt, danach mit Ellipsis abschneiden */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  hyphens: auto;
}

/* Mehrtägige Balken behalten Single-Line, sonst kollabiert die durchgehende Optik */
.cal-ev.cal-ev--span-first,
.cal-ev.cal-ev--span-middle,
.cal-ev.cal-ev--span-last {
  align-items: center;
}
.cal-ev.cal-ev--span-first .cal-ev-title,
.cal-ev.cal-ev--span-middle .cal-ev-title,
.cal-ev.cal-ev--span-last .cal-ev-title {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  -webkit-line-clamp: initial;
  -webkit-box-orient: initial;
}

.cal-ev--shooting {
  background: var(--accent-soft);
  border-left-color: var(--accent);
  color: var(--text);
}
.cal-ev--shooting.cal-ev--angefragt   { border-left-color: var(--info); }
.cal-ev--shooting.cal-ev--bestaetigt  { border-left-color: var(--good); }
.cal-ev--shooting.cal-ev--durchgefuehrt { opacity: .65; }
.cal-ev--shooting.cal-ev--abgesagt    { border-left-color: var(--bad); opacity: .55; text-decoration: line-through; }

.cal-ev--aufgabe {
  background: var(--surface-2);
  border-left-color: var(--warn);
}
.cal-ev--aufgabe.cal-ev--prio-hoch { border-left-color: var(--bad); }
.cal-ev--aufgabe.cal-ev--prio-niedrig { border-left-color: var(--text-dim); opacity: .8; }
.cal-ev--aufgabe.cal-ev--erledigt { opacity: .5; text-decoration: line-through; }

.cal-ev--extern {
  background: var(--surface-2);
  font-style: italic;
  opacity: .85;
}

/* Drop-Target Highlight */
.is-drop-target {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft) !important;
}

/* ---------- Wochen/Tag-Ansicht ---------- */
.cal-week, .cal-day-view {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.cal-week-head {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.cal-week-day-head {
  padding: 10px 12px;
  border-left: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.cal-week-day-head.is-today {
  background: var(--accent-soft);
  color: var(--accent);
}
.cal-week-wd { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.cal-week-num { font-size: 16px; font-weight: 700; color: var(--text); }
.cal-week-day-head.is-today .cal-week-num { color: var(--accent); }

.cal-week-body { overflow-y: auto; max-height: 700px; }
.cal-week-grid {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  position: relative;
}
.cal-day-view .cal-week-grid { grid-template-columns: 60px 1fr; }

.cal-week-time-col {
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.cal-hour-label {
  height: 40px;
  padding: 4px 8px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
  border-bottom: 1px solid var(--line);
}
.cal-week-col {
  position: relative;
  border-right: 1px solid var(--line);
}
.cal-week-col:last-child { border-right: none; }
.cal-hour-slot {
  height: 40px;
  border-bottom: 1px solid var(--line);
}
.cal-hour-slot:nth-child(2n) { border-bottom-style: dashed; opacity: .6; }

.cal-week-ev {
  position: absolute;
  left: 4px;
  right: 4px;
  background: var(--surface-2);
  border-left: 3px solid var(--text-dim);
  border-radius: var(--radius-xs);
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
  transition: all .12s;
  z-index: 2;
}
.cal-week-ev.cal-ev--shooting {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.cal-week-ev.cal-ev--shooting.cal-ev--angefragt   { border-left-color: var(--info); }
.cal-week-ev.cal-ev--shooting.cal-ev--bestaetigt  { border-left-color: var(--good); }
.cal-week-ev.cal-ev--shooting.cal-ev--durchgefuehrt { opacity: .65; }

.cal-week-ev.cal-ev--aufgabe {
  background: var(--warn-bg);
  border-left-color: var(--warn);
}
.cal-week-ev.cal-ev--aufgabe.cal-ev--prio-hoch    { border-left-color: var(--bad); }
.cal-week-ev.cal-ev--aufgabe.cal-ev--prio-niedrig { border-left-color: var(--text-dim); opacity: .85; }
.cal-week-ev.cal-ev--aufgabe.cal-ev--erledigt     { opacity: .5; text-decoration: line-through; }

.cal-week-ev.cal-ev--extern {
  background: var(--surface-2);
  font-style: italic;
  opacity: .85;
}
.cal-week-ev:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,.15);
  z-index: 3;
}
.cal-week-ev.is-dragging { opacity: .4; }
.cal-week-ev.has-conflict {
  background-image: repeating-linear-gradient(45deg, transparent 0, transparent 4px, color-mix(in srgb, var(--bad) 20%, transparent) 4px, color-mix(in srgb, var(--bad) 20%, transparent) 8px);
  border-left-color: var(--bad);
}
.cal-week-ev-time {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}
.cal-week-ev-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-week-ev-meta {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.cal-week-ev.cal-ev--shooting.cal-ev--abgesagt { opacity: .55; text-decoration: line-through; }

.cal-week-allday {
  position: relative;
  display: block;
  margin: 2px 0;
  padding: 4px 8px;
  background: var(--warn-bg);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-xs);
  font-size: 11.5px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.cal-week-allday.cal-ev--prio-hoch { border-left-color: var(--bad); }
.cal-week-allday.cal-ev--prio-niedrig { border-left-color: var(--text-dim); opacity: .8; }

/* All-Day-Streifen (oben in Wochen-/Tages-Ansicht) */
.cal-week-allday-row {
  display: grid;
  grid-template-columns: 60px repeat(7, 1fr);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  min-height: 32px;
}
.cal-day-view .cal-week-allday-row {
  grid-template-columns: 60px 1fr;
}
.cal-week-allday-label {
  padding: 6px 8px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  text-align: right;
  border-right: 1px solid var(--line);
  align-self: start;
}
.cal-week-allday-cell {
  padding: 4px 4px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.cal-week-allday-cell:last-child { border-right: none; }

/* ---------- Agenda ---------- */
.cal-agenda { display: flex; flex-direction: column; gap: 14px; }
.cal-agenda-day.is-today .card-head { background: var(--accent-soft); }

/* ---------- Druckansicht ---------- */
@media print {
  body { background: white !important; color: black !important; }
  .sidebar, .topbar, .cal-toolbar, .cal-filter-bar, .modal-backdrop, .modal-panel { display: none !important; }
  .main, .content { padding: 0 !important; background: white !important; }
  .cal-month, .cal-week, .cal-day-view, .card {
    box-shadow: none !important;
    border-color: #ccc !important;
    background: white !important;
    color: black !important;
  }
  .cal-month-grid { grid-auto-rows: minmax(95px, 1fr); }
  .cal-day { background: white !important; min-height: 90px; page-break-inside: avoid; }
  .cal-day.is-today { background: #f3f0ff !important; }
  .cal-ev, .cal-week-ev {
    background: white !important;
    color: black !important;
    border: 1px solid #999 !important;
    border-left-width: 3px !important;
  }
  .cal-day-add, .cal-actions { display: none !important; }
  @page { size: A4 landscape; margin: 12mm; }
}


/* ============================================================
   Quill Rich-Text-Editor (Theme-Anpassung)
   ============================================================ */
.quill-wrapper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
}
.quill-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Toolbar */
.ql-toolbar.ql-snow {
  border: none !important;
  border-bottom: 1px solid var(--line) !important;
  background: var(--surface-2);
  padding: 8px 10px !important;
}
.ql-toolbar.ql-snow .ql-formats { margin-right: 12px !important; }

/* Button colors */
.ql-toolbar.ql-snow .ql-stroke { stroke: var(--text-muted); }
.ql-toolbar.ql-snow .ql-fill { fill: var(--text-muted); }
.ql-toolbar.ql-snow .ql-picker { color: var(--text-muted); }
.ql-toolbar.ql-snow button:hover .ql-stroke,
.ql-toolbar.ql-snow .ql-picker-label:hover .ql-stroke { stroke: var(--text); }
.ql-toolbar.ql-snow button:hover .ql-fill,
.ql-toolbar.ql-snow .ql-picker-label:hover .ql-fill { fill: var(--text); }
.ql-toolbar.ql-snow button.ql-active .ql-stroke,
.ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label .ql-stroke { stroke: var(--accent); }
.ql-toolbar.ql-snow button.ql-active .ql-fill,
.ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label .ql-fill { fill: var(--accent); }
.ql-toolbar.ql-snow .ql-picker-options {
  background: var(--surface);
  border-color: var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
}
.ql-toolbar.ql-snow .ql-picker-item:hover { color: var(--accent); }

/* Container */
.ql-container.ql-snow {
  border: none !important;
  font-family: var(--font-sans) !important;
  font-size: 14px !important;
  color: var(--text);
  background: var(--surface);
}
.ql-editor {
  min-height: 180px;
  padding: 14px 16px !important;
  line-height: 1.55;
}
.ql-editor.ql-blank::before {
  color: var(--text-dim) !important;
  font-style: normal !important;
  left: 16px !important;
}
.ql-editor h1, .ql-editor h2, .ql-editor h3 { color: var(--text); }
.ql-editor a { color: var(--accent); }
.ql-editor img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-xs);
}

/* Tooltip (Link-Eingabe) */
.ql-snow .ql-tooltip {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-2) !important;
}
.ql-snow .ql-tooltip input[type=text] {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-xs);
}
.ql-snow .ql-tooltip a { color: var(--accent); }


/* ============================================================
   Mehrtägige Events (Span-Balken)
   ============================================================ */

/* Monatsansicht – Pille beim ersten Tag, durchgehende Balken danach */
.cal-ev--span-first {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  margin-right: -7px; /* ragt in den Folgetag rein für visuelle Verbindung */
  padding-right: 12px;
  position: relative;
  z-index: 2;
}
.cal-ev--span-middle {
  border-radius: 0;
  border-left-width: 0;
  margin-left: -7px;
  margin-right: -7px;
  padding-left: 12px;
  padding-right: 12px;
}
.cal-ev--span-last {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 0;
  margin-left: -7px;
  padding-left: 12px;
}

/* In der Wochen-/Tages-Stundenraster-Ansicht analog */
.cal-week-ev.cal-ev--span-first {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  right: -2px;
}
.cal-week-ev.cal-ev--span-middle {
  border-radius: 0;
  border-left-width: 0;
  left: -2px;
  right: -2px;
}
.cal-week-ev.cal-ev--span-last {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 0;
  left: -2px;
}

/* All-Day-Streifen genauso */
.cal-week-allday.cal-ev--span-first {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}
.cal-week-allday.cal-ev--span-middle {
  border-radius: 0;
  border-left-width: 0;
}
.cal-week-allday.cal-ev--span-last {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left-width: 0;
}


/* ============================================================
   Paket-Karten (Immobilien-Detailansicht)
   ============================================================ */
.paket-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.paket-card {
  display: block;
  position: relative;
  cursor: pointer;
}
.paket-card input.paket-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.paket-card-body {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: all .15s;
}
.paket-card:hover .paket-card-body {
  border-color: var(--line-2);
  background: var(--surface-2);
}
.paket-card input.paket-checkbox:checked + .paket-card-body {
  border-color: var(--accent);
  border-width: 2px;
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-ring), 0 4px 12px var(--accent-ring);
  padding: 11px 13px;
}
.paket-card input.paket-checkbox:checked + .paket-card-body strong {
  color: var(--accent);
}
.paket-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.paket-card-head strong {
  font-size: 14px;
  color: var(--text);
}
.paket-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-on);
  font-size: 12px;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .15s;
}
.paket-card input.paket-checkbox:checked + .paket-card-body .paket-check {
  opacity: 1;
}
.paket-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.paket-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 6px;
}
.paket-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}
.paket-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}
.paket-card input.paket-checkbox:checked + .paket-card-body .paket-pill {
  background: var(--bg);
  border-color: var(--accent-ring);
}


/* ============================================================
   Platzhalter-Grid in Vertrags-/E-Mail-Vorlagen
   ============================================================ */
.platzhalter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
}
.platzhalter-group h4 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  font-weight: 600;
}
.platzhalter-chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .12s;
}
.platzhalter-chip:hover {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--text);
}
.platzhalter-chip.is-copied {
  background: var(--good);
  color: white;
  border-color: var(--good);
}


/* ============================================================
   Galerien — Liste & Detail (CRM)
   ============================================================ */
.galerie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.galerie-grid-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: all .15s;
}
.galerie-grid-card:hover {
  border-color: var(--accent-ring);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}
.galerie-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
}
.galerie-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galerie-cover-empty {
  display: grid; place-items: center; height: 100%;
  color: var(--text-muted); font-size: 13px;
}
.galerie-bild-count {
  position: absolute; left: 10px; bottom: 10px;
  background: rgba(0,0,0,.6); color: white; font-size: 11px;
  padding: 3px 8px; border-radius: 4px; font-family: var(--font-mono);
}
.galerie-cover .badge {
  position: absolute; right: 10px; top: 10px;
}
.galerie-card-body { padding: 12px 14px; }
.galerie-card-title { font-weight: 500; margin-bottom: 4px; }
.galerie-card-meta { color: var(--text-muted); font-size: 12px; line-height: 1.55; }

/* Upload-Zone in der Detailansicht */
.upload-zone {
  border: 2px dashed var(--line-2);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  background: var(--surface-2);
  transition: all .15s;
}
.upload-zone:hover, .upload-zone.is-hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-zone strong { font-size: 14px; }
.upload-progress { margin-top: 14px; }
.upload-progress-text { font-size: 13px; margin-bottom: 6px; color: var(--text-muted); }
.upload-progress-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.upload-progress-bar > div { height: 100%; background: var(--accent); width: 0%; transition: width .2s; }
.upload-progress-error { color: #e66; font-size: 12px; margin-top: 8px; }

/* Admin-Grid */
.galerie-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.galerie-admin-tile {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  transition: all .12s;
}
.galerie-admin-tile.is-dragging { opacity: .5; }
.galerie-admin-tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.tile-actions {
  position: absolute; top: 6px; right: 6px;
  display: flex; gap: 4px;
  opacity: 0; transition: opacity .12s;
}
.galerie-admin-tile:hover .tile-actions { opacity: 1; }
.tile-actions button, .tile-actions form button {
  background: rgba(0,0,0,.65); color: white; border: none;
  width: 28px; height: 28px; border-radius: 4px; cursor: pointer;
  font-size: 12px;
}
.tile-actions button.is-cover { background: var(--accent); }
.tile-fav-count {
  position: absolute; left: 6px; bottom: 6px;
  background: rgba(0,0,0,.65); color: white; font-size: 11px;
  padding: 2px 6px; border-radius: 3px;
}
.tile-cover-badge {
  position: absolute; left: 6px; top: 6px;
  background: var(--accent); color: var(--accent-on);
  font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 3px; text-transform: uppercase; letter-spacing: .05em;
}

/* Favoriten-Übersicht im CRM */
.galerie-fav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.galerie-fav-tile { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; }
.galerie-fav-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galerie-fav-tile span {
  position: absolute; right: 5px; bottom: 5px;
  background: rgba(0,0,0,.7); color: white;
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
}

@media (max-width: 1200px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--sb-line);
    padding: 16px;
  }
  .sidebar .brand { padding-bottom: 14px; margin-bottom: 14px; }
  .sidebar .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar .nav-label { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { padding-top: 12px; }
  .content, .topbar { padding-left: 18px; padding-right: 18px; }
  .theme-options { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
}
