/* === RESET & BASE === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f5f7fa; color: #2d3748; font-size: 14px; line-height: 1.5; }

/* === LAYOUT === */
.app { display: flex; min-height: 100vh; }

/* === SIDEBAR === */
.sidebar { width: 240px; background: #1a365d; color: #fff; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-header h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.sidebar-header .version { font-size: 11px; color: rgba(255,255,255,0.5); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 13px; font-weight: 500; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.08); }
.nav-item.active { color: #fff; background: rgba(255,255,255,0.12); border-left-color: #63b3ed; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer span { color: rgba(255,255,255,0.6); }
.sidebar-footer a { color: rgba(255,255,255,0.5); text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }

/* === MAIN === */
.main { margin-left: 240px; flex: 1; padding: 28px 32px; min-height: 100vh; }

/* === HEADER === */
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.view-header h1 { font-size: 22px; font-weight: 700; color: #1a365d; }
.view-header .subtitle { font-size: 13px; color: #718096; margin-top: 2px; }

/* === CARDS === */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; }
.card-label { font-size: 12px; font-weight: 600; color: #718096; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; }
.card-value { font-size: 28px; font-weight: 700; color: #1a365d; }
.card-sub { font-size: 12px; color: #a0aec0; margin-top: 4px; }
.card.success .card-value { color: #38a169; }
.card.warning .card-value { color: #d69e2e; }
.card.danger .card-value { color: #e53e3e; }

/* === TABLE === */
.table-container { background: #fff; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border: 1px solid #e2e8f0; overflow: hidden; }
.table-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.table-header h3 { font-size: 15px; color: #1a365d; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f7fafc; color: #718096; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
tbody td { padding: 12px 16px; border-bottom: 1px solid #f0f4f8; font-size: 13px; color: #4a5568; }
tbody tr:hover { background: #f7fafc; }
tbody tr:last-child td { border-bottom: none; }

/* === BUTTONS === */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: #1a365d; color: #fff; }
.btn-primary:hover { background: #2a4a7f; }
.btn-secondary { background: #edf2f7; color: #4a5568; }
.btn-secondary:hover { background: #e2e8f0; }
.btn-success { background: #38a169; color: #fff; }
.btn-success:hover { background: #2f855a; }
.btn-danger { background: #e53e3e; color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-warning { background: #d69e2e; color: #fff; }
.btn-warning:hover { background: #b7791f; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; background: none; color: #718096; }
.btn-icon:hover { color: #1a365d; background: #edf2f7; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === BADGES === */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-neu { background: #ebf8ff; color: #2b6cb0; }
.badge-eingereicht { background: #fefcbf; color: #975a16; }
.badge-warten { background: #fef3c7; color: #92400e; }
.badge-geloescht { background: #f0fff4; color: #276749; }
.badge-abgelehnt { background: #fff5f5; color: #c53030; }
.badge-einspruch { background: #fed7e2; color: #97266d; }
.badge-zurueckgekehrt { background: #fbd38d; color: #7b341e; }
.badge-nicht_loeschbar { background: #e2e8f0; color: #4a5568; }
.badge-entwurf { background: #fefcbf; color: #975a16; }
.badge-offen { background: #ebf8ff; color: #2b6cb0; }
.badge-bezahlt { background: #f0fff4; color: #276749; }
.badge-ueberfaellig { background: #fff5f5; color: #c53030; }
.badge-aktiv { background: #f0fff4; color: #276749; }
.badge-inaktiv { background: #e2e8f0; color: #718096; }
.badge-in_bearbeitung { background: #fefcbf; color: #975a16; }
.badge-storniert { background: #e2e8f0; color: #718096; }

/* === FORMS === */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #4a5568; margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 7px;
  font-size: 13px; color: #2d3748; background: #fff; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: #1a365d; box-shadow: 0 0 0 3px rgba(26,54,93,0.08);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 16px; border-top: 1px solid #e2e8f0; }

/* === MODAL === */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; justify-content: center; align-items: flex-start; padding-top: 60px; }
.modal-overlay.active { display: flex; }
.modal { background: #fff; border-radius: 12px; width: 680px; max-width: 95vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px; border-bottom: 1px solid #e2e8f0; position: sticky; top: 0; background: #fff; z-index: 1; border-radius: 12px 12px 0 0; }
.modal-header h3 { font-size: 16px; color: #1a365d; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: #a0aec0; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: #2d3748; }
.modal-body { padding: 24px; }

/* === TASKS === */
.tasks { margin-bottom: 24px; }
.task-item { background: #fff; border-radius: 8px; padding: 14px 18px; margin-bottom: 8px; border: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.task-item .task-text { font-size: 13px; color: #4a5568; }
.task-item .task-count { background: #ebf8ff; color: #2b6cb0; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }

/* === REVIEW CARD === */
.review-card { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 10px; border: 1px solid #e2e8f0; }
.review-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.review-card .bewerter { font-weight: 600; color: #1a365d; font-size: 14px; }
.review-card .bewerter-info { color: #a0aec0; font-size: 11px; }
.review-card .stars { color: #d69e2e; font-size: 13px; }
.review-card .text { color: #4a5568; font-size: 13px; margin: 8px 0; line-height: 1.6; max-height: 80px; overflow: hidden; }
.review-card .text.expanded { max-height: none; }
.review-card .meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: #a0aec0; margin-top: 8px; }

/* === DETAIL PANEL === */
.detail-panel { background: #fff; border-radius: 10px; border: 1px solid #e2e8f0; margin-bottom: 20px; }
.detail-panel-header { padding: 18px 22px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; }
.detail-panel-header h3 { font-size: 15px; color: #1a365d; }
.detail-panel-body { padding: 20px 22px; }
.detail-row { display: flex; padding: 8px 0; border-bottom: 1px solid #f7fafc; }
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 160px; font-size: 12px; font-weight: 600; color: #718096; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 13px; color: #2d3748; }
.detail-value a { color: #2b6cb0; text-decoration: none; }
.detail-value a:hover { text-decoration: underline; }

/* === TABS === */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 13px; font-weight: 500; color: #718096; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; }
.tab:hover { color: #1a365d; }
.tab.active { color: #1a365d; border-bottom-color: #1a365d; font-weight: 600; }

/* === FILTERS === */
.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: 7px 12px; border: 1px solid #e2e8f0; border-radius: 7px; font-size: 13px; background: #fff; }
.filter-count { font-size: 12px; color: #a0aec0; margin-left: auto; }

/* === FILTER BUTTONS === */
.filter-buttons { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-btn { padding: 7px 16px; font-size: 13px; font-weight: 500; border: 1px solid #e2e8f0; border-radius: 7px; background: #fff; color: #718096; cursor: pointer; transition: all 0.15s; }
.filter-btn:hover { background: #edf2f7; color: #1a365d; }
.filter-btn.active { background: #1a365d; color: #fff; border-color: #1a365d; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 48px 24px; color: #a0aec0; }
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* === TOAST === */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; }
.toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 13px; margin-bottom: 8px; animation: slideIn 0.3s ease; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.toast-success { background: #38a169; }
.toast-error { background: #e53e3e; }
.toast-info { background: #2b6cb0; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === SEARCH === */
.search-box { position: relative; }
.search-box input { padding-left: 36px; width: 280px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #a0aec0; }

/* === PROFILE CHIP === */
.profile-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 6px; background: #edf2f7; font-size: 12px; color: #4a5568; margin: 2px 4px 2px 0; }
.profile-chip .platform { font-weight: 600; color: #1a365d; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-header h2, .sidebar-header .version, .nav-item span, .sidebar-footer span { display: none; }
  .nav-item { justify-content: center; padding: 12px; }
  .main { margin-left: 60px; padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .cards { grid-template-columns: 1fr 1fr; }
}
.letter-btn{display:inline-flex;flex-direction:column;align-items:center;justify-content:center;width:34px;height:40px;border-radius:8px;cursor:pointer;font-size:14px;font-weight:700;background:#f7fafc;color:#2d3748;border:1px solid #e2e8f0;transition:all .15s;line-height:1;user-select:none}
.letter-btn:hover:not(.disabled){background:#edf2f7;border-color:#a0aec0}
.letter-btn.active{background:#2d3748;color:#fff;border-color:#2d3748}
.letter-btn.disabled{color:#d2d6dc;cursor:default;background:#fafafa;border-color:#f0f0f0}
.letter-btn small{font-size:9px;color:#a0aec0;font-weight:500;margin-top:1px}
.letter-btn.active small{color:#a0aec0}
.badge-auftrag{background:#ebf8ff;color:#2b6cb0}
.badge-rechnung{background:#fefcbf;color:#975a16}
.badge-fertig{background:#f0fff4;color:#276749}
.badge-alle_kunden{background:#edf2f7;color:#4a5568}
.badge-keine_loeschung{background:#fff5f5;color:#c53030}

/* === GRENKE LÖSCHBESTÄTIGUNGEN === */
.grenke-alert { background: #fff5f5; border: 1px solid #feb2b2; border-radius: 10px; padding: 14px 20px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grenke-alert-text { color: #c53030; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.grenke-alert-count { background: #e53e3e; color: #fff; border-radius: 50%; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }

.grenke-search { position: relative; margin-bottom: 20px; }
.grenke-search input { width: 100%; max-width: 420px; padding: 10px 14px 10px 38px; border: 1px solid #e2e8f0; border-radius: 8px; font-size: 13px; background: #fff; transition: border-color 0.15s; }
.grenke-search input:focus { outline: none; border-color: #1a365d; box-shadow: 0 0 0 3px rgba(26,54,93,0.08); }
.grenke-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #a0aec0; pointer-events: none; }

.grenke-cards { display: flex; flex-direction: column; gap: 12px; }

.grenke-card { background: #fff; border-radius: 10px; border: 1px solid #e2e8f0; padding: 18px 22px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); transition: box-shadow 0.15s, border-color 0.15s; }
.grenke-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); border-color: #cbd5e0; }

.grenke-card-header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.grenke-card-header .badge { flex-shrink: 0; }
.grenke-card-vorgangsnr { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 11px; background: #edf2f7; padding: 3px 8px; border-radius: 4px; color: #4a5568; flex-shrink: 0; }
.grenke-card-datum { font-size: 12px; color: #a0aec0; margin-left: auto; flex-shrink: 0; }

.grenke-card-kunde { font-size: 17px; font-weight: 700; color: #1a365d; margin-bottom: 2px; line-height: 1.3; }
.grenke-card-kunde a { color: #1a365d; text-decoration: none; }
.grenke-card-kunde a:hover { color: #2b6cb0; }
.grenke-card-profil { font-size: 13px; color: #718096; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.grenke-card-profil a { color: #718096; text-decoration: none; }
.grenke-card-profil a:hover { color: #2b6cb0; }
.grenke-maps-link { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 5px; background: #edf2f7; color: #718096; text-decoration: none; transition: all 0.15s; flex-shrink: 0; }
.grenke-maps-link:hover { background: #1a365d; color: #fff; }

.grenke-card-bewerter { margin-bottom: 12px; }
.grenke-card-bewerter-title { font-size: 12px; font-weight: 600; color: #718096; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.grenke-card-bewerter-list { display: flex; flex-wrap: wrap; gap: 6px; }
.grenke-card-bewerter-chip { display: inline-block; padding: 3px 10px; background: #f7fafc; border: 1px solid #e2e8f0; border-radius: 5px; font-size: 12px; color: #4a5568; }

.grenke-card-preis { font-size: 13px; color: #2d3748; font-weight: 500; margin-bottom: 12px; }

.grenke-card-footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 12px; border-top: 1px solid #f0f4f8; flex-wrap: wrap; }

/* Nicht zugeordnet */
.grenke-card.unassigned { border-left: 4px solid #e53e3e; background: #fffbfb; }
.grenke-card.unassigned:hover { border-color: #e53e3e; }
.grenke-card-unassigned-label { font-size: 14px; font-weight: 600; color: #c53030; margin-bottom: 2px; }

/* Kunde-Zuordnung inline */
.grenke-assign-box { margin-top: 10px; }
.grenke-assign-input { width: 100%; max-width: 300px; padding: 8px 12px; border: 1px solid #feb2b2; border-radius: 6px; font-size: 13px; background: #fff; }
.grenke-assign-input:focus { outline: none; border-color: #e53e3e; box-shadow: 0 0 0 3px rgba(229,62,62,0.1); }
.grenke-assign-results { position: absolute; top: 100%; left: 0; width: 320px; max-height: 200px; overflow-y: auto; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); z-index: 100; margin-top: 4px; }
.grenke-assign-result { padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f7fafc; }
.grenke-assign-result:hover { background: #f7fafc; }
.grenke-assign-result strong { color: #1a365d; }
.grenke-assign-result small { color: #a0aec0; }

/* LöschFlat badge */
.badge-loeschflat { background: #ebf8ff; color: #2b6cb0; }
.badge-einzelloeschung { background: #fefcbf; color: #975a16; }
.badge-rueckfrage { background: #fef3c7; color: #92400e; }
.badge-reaktiviert { background: #fbd38d; color: #7b341e; }

/* Stats cards specific to grenke */
.grenke-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
@media (max-width: 900px) { .grenke-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .grenke-stats { grid-template-columns: 1fr; } }
