:root {
  --accent:     #1a4fa0;
  --accent-lt:  #2563eb;
  --text:       #e8eaf0;
  --text-muted: #6b7280;
  --bg:         #0f1117;
  --bg-card:    #161b27;
  --bg-input:   #1e2436;
  --border:     #252d40;
  --danger:     #ef4444;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --radius:     8px;
}

body.light {
  --accent:     #1a4fa0;
  --accent-lt:  #2563eb;
  --text:       #111827;
  --text-muted: #6b7280;
  --bg:         #f3f4f6;
  --bg-card:    #ffffff;
  --bg-input:   #f9fafb;
  --border:     #e5e7eb;
  --danger:     #ef4444;
  --success:    #16a34a;
  --warning:    #d97706;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; flex-shrink: 0; background: var(--bg-card); border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.sidebar-logo { padding: 20px 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.sidebar-logo .logo-icon { width: 34px; height: 34px; background: var(--accent); border-radius: 8px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-logo span { font-weight: 600; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); color: var(--text-muted); font-size: 14px; width: 100%; background: none; border: none; transition: background 0.15s, color 0.15s; }
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.nav-item.active { background: rgba(26,79,160,0.18); color: var(--accent-lt); }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; }
.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.sidebar-user { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius); }
.sidebar-avatar { width: 30px; height: 30px; background: var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.sidebar-user-name { font-size: 13px; color: var(--text-muted); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--bg-card); flex-shrink: 0; }
.topbar h1 { font-size: 18px; font-weight: 600; }
.topbar-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; }
.content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Cards / Offer List ────────────────────────────── */
.offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.offer-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: border-color 0.15s; }
.offer-card:hover { border-color: rgba(37,99,235,0.4); }
.offer-card-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.offer-card-sub { font-size: 13px; color: var(--text-muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.offer-card-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.offer-card-actions { display: flex; gap: 6px; margin-top: auto; flex-wrap: wrap; }

/* ── Badges ────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.badge-draft  { background: rgba(107,114,128,0.2); color: #9ca3af; }
.badge-final  { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-sent   { background: rgba(26,79,160,0.2);   color: #60a5fa; }
.badge-archiv { background: rgba(107,114,128,0.15); color: #6b7280; }

/* ── Buttons ────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 14px; font-weight: 500; border: none; transition: opacity 0.15s, background 0.15s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-lt); }
.btn-ghost { background: rgba(255,255,255,0.07); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.12); }
.btn-danger { background: rgba(239,68,68,0.15); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }
.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }

/* ── Forms ─────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 13px; color: var(--text-muted); }
input[type=text], input[type=email], input[type=password], textarea, select {
  background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 14px; padding: 9px 12px; font-family: inherit; width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-lt); }
textarea { resize: vertical; min-height: 80px; }

/* ── Editor ─────────────────────────────────────────── */
.editor-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; max-width: 1100px; }
@media (max-width: 800px) { .editor-layout { grid-template-columns: 1fr; } }
.editor-main { display: flex; flex-direction: column; gap: 16px; }
.editor-panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.editor-panel h3 { font-size: 14px; color: var(--text-muted); margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Image Grid ─────────────────────────────────────── */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.img-tile { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--bg-input); aspect-ratio: 4/3; border: 1px solid var(--border); }
.img-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-tile-actions { position: absolute; top: 4px; right: 4px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.15s; }
.img-tile:hover .img-tile-actions { opacity: 1; }
.img-tile-btn { width: 26px; height: 26px; border-radius: 5px; background: rgba(0,0,0,0.7); border: none; color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.img-tile-btn:hover { background: rgba(0,0,0,0.9); }
.img-tile-comment { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(26,79,160,0.92); padding: 5px 7px; font-size: 11px; color: #fff; line-height: 1.3; }
.img-add-btn { border: 2px dashed var(--border); border-radius: var(--radius); aspect-ratio: 4/3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--text-muted); font-size: 12px; cursor: pointer; background: none; transition: border-color 0.15s, color 0.15s; }
.img-add-btn:hover { border-color: var(--accent-lt); color: var(--text); }

/* ── Alert ─────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.alert-error   { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: rgba(34,197,94,0.12);  color: #4ade80; border: 1px solid rgba(34,197,94,0.3); }
.alert-info    { background: rgba(37,99,235,0.12);  color: #93c5fd; border: 1px solid rgba(37,99,235,0.3); }

/* ── Modal ─────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 28px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-title { font-size: 17px; font-weight: 600; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Review results ─────────────────────────────────── */
.review-verdict { font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.review-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.review-list li { font-size: 13px; padding: 6px 10px; border-radius: 6px; display: flex; gap: 8px; }
.review-issue      { background: rgba(239,68,68,0.1);  color: #fca5a5; }
.review-suggestion { background: rgba(37,99,235,0.1);  color: #93c5fd; }

/* ── Empty state ────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 42px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Loading ─────────────────────────────────────────── */
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent-lt); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 14px; padding: 20px 0; }

/* ── Stats ───────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 20px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.stat-card .stat-val { font-size: 24px; font-weight: 700; }
.stat-card .stat-lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Gallery picker modal ────────────────────────────── */
.gallery-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 340px; overflow-y: auto; margin: 12px 0; }
.gallery-picker-thumb { position: relative; border-radius: 6px; overflow: hidden; aspect-ratio: 4/3; cursor: pointer; border: 2px solid transparent; background: var(--bg-input); }
.gallery-picker-thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery-picker-thumb.selected { border-color: var(--accent-lt); }
.gallery-picker-thumb.selected::after { content: '✓'; position: absolute; top: 4px; left: 4px; background: var(--accent); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; }

/* ── Comment edit overlay ────────────────────────────── */
.img-comment-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px; }
.img-comment-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 24px; width: 100%; max-width: 460px; }

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Gallery list items ──────────────────────────────── */
.gallery-list-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 12px; border-radius: var(--radius);
  background: none; border: 1px solid transparent;
  color: var(--text); font-size: 14px; text-align: left; cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.gallery-list-item:hover { background: rgba(255,255,255,0.05); border-color: var(--border); }
.gallery-list-item.selected { background: rgba(26,79,160,0.18); border-color: var(--accent-lt); color: var(--accent-lt); }

/* ── Card delete button ──────────────────────────────── */
.btn-card-delete {
  position: absolute;
  top: 8px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.offer-card:hover .btn-card-delete { opacity: 1; }
.btn-card-delete:hover { background: rgba(239,68,68,0.15); color: #f87171; }

/* ── Archiv Jahr/Monats-Hierarchie ───────────────────── */
.archiv-year-group { margin-bottom: 8px; }
.archiv-year-header {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  font-weight: 700; font-size: 15px; color: var(--text);
  user-select: none;
  transition: background 0.15s;
}
.archiv-year-header:hover { background: var(--bg-input); }
.archiv-year-chevron { font-size: 11px; color: var(--text-muted); width: 12px; }
.archiv-year-count { margin-left: auto; font-size: 12px; font-weight: 400; color: var(--text-muted); }

.archiv-month-group { margin: 10px 0 4px 16px; }
.archiv-month-header {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 6px;
  border-left: 2px solid var(--accent);
  background: transparent;
  font-weight: 600; font-size: 13px; color: var(--text);
  user-select: none;
  transition: background 0.15s;
}
.archiv-month-header:hover { background: var(--bg-input); }
.archiv-month-chevron { font-size: 10px; color: var(--text-muted); width: 10px; }
.archiv-month-count { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--text-muted); }
.archiv-month-group .offer-grid { margin: 10px 0 10px 4px; }

/* ── Profil-Icon Button (Topbar) ─────────────────────── */
.btn-profile-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-secondary);
  color: var(--text-muted); cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn-profile-icon:hover { background: var(--bg-input); color: var(--text); border-color: var(--accent); }

/* ── Neues Angebot Button (Mobile Bottom Nav) ─────────── */
.bottom-nav-new {
  background: #1d6ef5 !important;
  color: #fff !important;
}
.bottom-nav-new:hover, .bottom-nav-new.active { background: #1558d6 !important; color: #fff !important; }

/* ── Send modal recipient rows ───────────────────────── */
.send-recipient-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-secondary);
  font-size: 14px; color: var(--text);
  transition: border-color 0.15s;
}
.send-recipient-row:has(input:checked) { border-color: var(--accent); }
.send-recipient-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }

/* ── Mobile bottom navigation ────────────────────────── */
.bottom-nav { display: none; }

@media (max-width: 640px) {
  .sidebar { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 100;
    height: 58px;
  }
  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    font-family: inherit;
    padding: 6px 4px;
    cursor: pointer;
    transition: color 0.15s;
    position: relative;
  }
  .bottom-nav-item.active { color: var(--accent-lt); }
  .bottom-nav-item svg { flex-shrink: 0; }
  .bottom-nav-badge {
    position: absolute;
    top: 5px; right: calc(50% - 14px);
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  /* Push content above bottom nav */
  .main { padding-bottom: 58px; }

  /* Topbar compact on mobile */
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .topbar-sub { display: none; }

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

  /* Offer grid: single column */
  .offer-grid { grid-template-columns: 1fr; }

  /* Editor: stack panels */
  .editor-layout { grid-template-columns: 1fr; }
}
