/* Copyright (c) 2026 PeilPunkt GmbH. Alle Rechte vorbehalten. */
/* Lizenzierte Software — keine Weitergabe ohne schriftliche Genehmigung. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-base: #0a0a0c;
  --bg-panel: #111114;
  --bg-elevated: #18181c;
  --bg-hover: #1f1f24;
  --border: #27272e;
  --border-subtle: #1c1c22;
  --text-primary: #e8e8ec;
  --text-secondary: #9999b0;
  --text-muted: #7777a0;
  --accent: #c8ff00;
  --accent-dim: rgba(200, 255, 0, 0.12);
  --status-ok: #22c55e;
  --status-warn: #eab308;
  --status-error: #ef4444;
  --status-ok-bg: rgba(34, 197, 94, 0.08);
  --status-warn-bg: rgba(234, 179, 8, 0.08);
  --status-error-bg: rgba(239, 68, 68, 0.08);
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --radius: 6px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html { font-size: 14px; }
body { font-family: var(--font-body); background: var(--bg-base); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* =================== Topbar =================== */
.topbar { position: sticky; top: 0; z-index: 100; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 52px; background: var(--bg-base); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-logo { font-weight: 700; font-size: 1.15rem; letter-spacing: 0.15em; color: var(--accent); }
.topbar-sub { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 0.04em; padding-left: 12px; border-left: 1px solid var(--border); }
.topbar-status { display: flex; align-items: center; gap: 16px; }
.topbar-indicator { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-secondary); }
.topbar-icon { display: none; flex-shrink: 0; opacity: 0.6; }
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; transition: all 0.3s var(--ease); }
.dot-ok { background: var(--status-ok); box-shadow: 0 0 6px var(--status-ok); animation: pulse-ok 3s infinite; }
.dot-err { background: var(--status-error); box-shadow: 0 0 6px var(--status-error); animation: pulse-err 1.5s infinite; }
.dot-warn { background: var(--status-warn); }
.dot-off { background: var(--text-muted); }
.topbar-clock { font-size: 0.8rem; color: var(--text-muted); letter-spacing: 0.05em; min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }

/* Auth-Button in Topbar */
.auth-btn { background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: var(--radius); color: var(--text-muted); font-size: 1rem; line-height: 1; transition: color 0.2s, background 0.2s; margin-left: 4px; }
.auth-btn:hover { color: var(--text-primary); background: var(--bg-elevated); }
.auth-btn.is-admin { color: var(--status-ok); }

/* Auth-Dialog */
.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 2000; display: flex; justify-content: center; align-items: center; animation: fadeIn 0.15s ease; }
.auth-panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 320px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Viewer-Modus: Admin-Elemente ausblenden */
.viewer-mode .admin-only { display: none !important; }

@keyframes pulse-ok { 0%, 100% { box-shadow: 0 0 4px var(--status-ok); } 50% { box-shadow: 0 0 10px var(--status-ok); } }
@keyframes pulse-err { 0%, 100% { box-shadow: 0 0 4px var(--status-error); } 50% { box-shadow: 0 0 12px var(--status-error); } }

/* =================== Tabs =================== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); padding: 0 24px; background: var(--bg-base); }
.tab { padding: 12px 20px; font-size: 0.82rem; font-weight: 500; color: var(--text-muted); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; transition: all 0.25s var(--ease); letter-spacing: 0.02em; position: relative; }
.tab:hover { color: var(--text-secondary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* =================== Layout =================== */
.main { padding: 24px; max-width: 1440px; }
.panel-section { display: none; }
.panel-section.active { display: block; animation: fadeUp 0.4s var(--ease); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }

/* =================== Alert Banner =================== */
.alert-banner { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.alert-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 0.82rem; animation: slideDown 0.4s var(--ease) backwards; }
.alert-item:nth-child(2) { animation-delay: 0.05s; }
.alert-item:nth-child(3) { animation-delay: 0.1s; }
.alert-error { background: var(--status-error-bg); border: 1px solid rgba(239, 68, 68, 0.25); color: var(--status-error); }
.alert-warn { background: var(--status-warn-bg); border: 1px solid rgba(234, 179, 8, 0.2); color: var(--status-warn); }
.alert-icon { width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.72rem; flex-shrink: 0; }
.alert-error .alert-icon { background: rgba(239, 68, 68, 0.2); }
.alert-warn .alert-icon { background: rgba(234, 179, 8, 0.15); }

/* =================== Progress Bar =================== */
.batch-progress { margin-bottom: 16px; padding: 14px 16px; background: var(--bg-panel); border: 1px solid var(--accent); border-radius: var(--radius); animation: slideDown 0.4s var(--ease); box-shadow: 0 0 20px rgba(200, 255, 0, 0.06); }
.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.progress-label { font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.progress-count { font-size: 0.82rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.progress-track { height: 4px; background: var(--bg-base); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #e0ff66); border-radius: 2px; transition: width 0.5s var(--ease); width: 0; position: relative; }
.progress-fill::after { content: ''; position: absolute; right: 0; top: -2px; width: 8px; height: 8px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 8px var(--accent); }
.progress-file { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-progress.queued { border-color: var(--border); box-shadow: none; opacity: 0.7; }
.batch-progress.queued .progress-label { color: var(--text-secondary); }
.batch-progress.queued .progress-file { color: var(--text-muted); }
.batch-progress.done { border-color: #4ade80; box-shadow: 0 0 12px rgba(74, 222, 128, 0.1); opacity: 1; transition: opacity 1s ease; }
.batch-progress.done .progress-label { color: #4ade80; }
.batch-progress.done .progress-count { color: #4ade80; font-weight: 600; }
.batch-progress.done .progress-fill { background: linear-gradient(90deg, #4ade80, #86efac); }
.batch-progress.done .progress-fill::after { background: #4ade80; box-shadow: 0 0 8px #4ade80; }

/* =================== Cards =================== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.card { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 18px; transition: all 0.3s var(--ease); animation: fadeUp 0.5s var(--ease) backwards; overflow: hidden; }
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5) { animation-delay: 0.2s; }
.card:hover { border-color: var(--border); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }
.card-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); margin-bottom: 12px; }
.card-value { font-size: 1.6rem; font-weight: 600; color: var(--text-primary); line-height: 1; transition: color 0.3s; }
.card-detail { font-size: 0.78rem; color: var(--text-secondary); margin-top: 8px; }
.card-status-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.card-status-row { display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; }
.card-status-name { color: var(--text-secondary); }
.card-status-val { font-size: 0.75rem; display: flex; align-items: center; gap: 6px; }

/* Card wide variant */
.card-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .card-wide { grid-column: span 1; } }

/* Health grid */
.health-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 32px; }
.health-item { display: grid; grid-template-columns: 8px 90px 1fr; align-items: center; gap: 8px; padding: 5px 0; font-size: 0.78rem; min-width: 0; }
.health-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.health-dot-ok { background: var(--status-ok); }
.health-dot-error { background: var(--status-error); }
.health-dot-warn { background: var(--status-warn); }
.health-dot-info { background: var(--text-muted); }
.health-name { color: var(--text-muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em; }
.health-val { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-repair-webhook { font-size: 0.65rem; padding: 1px 8px; border: 1px solid var(--status-error); color: var(--status-error); background: transparent; border-radius: 4px; cursor: pointer; margin-left: 4px; transition: all 0.15s; }
.btn-repair-webhook:hover { background: var(--status-error); color: #fff; }

/* Server-Steuerung */
.btn-server { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; padding: 5px 11px; border: 1px solid var(--border); color: var(--text-secondary); background: transparent; border-radius: 4px; cursor: pointer; transition: all 0.15s; font-family: var(--font-body); }
.btn-server:hover { border-color: var(--text-secondary); color: var(--text-primary); background: var(--bg-elevated); }
.btn-server:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-server-warn { border-color: rgba(234, 179, 8, 0.5); color: var(--status-warn); }
.btn-server-warn:hover { border-color: var(--status-warn); background: var(--status-warn-bg); color: var(--status-warn); }
.btn-server-danger { border-color: rgba(239, 68, 68, 0.4); color: var(--status-error); }
.btn-server-danger:hover { border-color: var(--status-error); background: var(--status-error-bg); color: var(--status-error); }

/* =================== Action Bar =================== */
.action-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.action-status { font-size: 0.82rem; color: var(--text-muted); }

/* =================== Buttons =================== */
.btn-action { display: inline-flex; align-items: center; gap: 8px; padding: 12px 28px; background: var(--accent); color: var(--bg-base); font-family: var(--font-body); font-weight: 600; font-size: 0.85rem; border: none; border-radius: var(--radius); cursor: pointer; letter-spacing: 0.02em; transition: all 0.2s var(--ease); position: relative; overflow: hidden; }
.btn-action:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200, 255, 0, 0.2); }
.btn-action:active { transform: translateY(0) scale(0.98); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: none; box-shadow: none; }
.btn-action.loading { pointer-events: none; }
.btn-action.loading::after { content: ''; width: 14px; height: 14px; border: 2px solid transparent; border-top-color: var(--bg-base); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-secondary { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--bg-elevated); color: var(--text-secondary); font-family: var(--font-body); font-weight: 500; font-size: 0.82rem; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all 0.2s var(--ease); text-decoration: none; }
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-muted); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(0); }
.btn-outline-accent { display: inline-flex; align-items: center; gap: 8px; padding: 10px 26px; background: transparent; color: var(--accent); font-family: var(--font-body); font-weight: 600; font-size: 0.85rem; border: 2px solid var(--accent); border-radius: var(--radius); cursor: pointer; letter-spacing: 0.02em; transition: all 0.2s var(--ease); box-sizing: border-box; }
.btn-outline-accent:hover { background: rgba(200, 255, 0, 0.08); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(200, 255, 0, 0.15); }
.btn-outline-accent:active { transform: translateY(0) scale(0.98); }
.btn-outline-accent:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-danger-subtle { color: var(--status-error); border-color: rgba(239,68,68,0.3); }
.btn-danger-subtle:hover { background: var(--status-error-bg); border-color: var(--status-error); }

/* =================== Tables =================== */
.table-wrap { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; animation: fadeUp 0.4s var(--ease); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); gap: 12px; flex-wrap: wrap; }
.table-toolbar-left { display: flex; align-items: center; gap: 8px; }
.filter-select, .cfg-select { padding: 6px 10px; background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.8rem; cursor: pointer; transition: border-color 0.2s; }
.filter-select:focus, .cfg-select:focus { outline: none; border-color: var(--text-muted); }
.filter-input { padding: 6px 10px; background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.8rem; width: 180px; transition: all 0.2s var(--ease); }
.filter-input:focus { outline: none; border-color: var(--accent); width: 220px; }
.filter-input::placeholder { color: var(--text-muted); }
.table-count { font-size: 0.75rem; color: var(--text-muted); }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th { text-align: left; padding: 10px 16px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); border-bottom: 1px solid var(--border-subtle); white-space: nowrap; transition: color 0.2s; }
tbody td { padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; transition: background 0.15s; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-hover); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 0.7rem; font-weight: 500; letter-spacing: 0.03em; transition: transform 0.15s; }
.badge-done { background: var(--status-ok-bg); color: var(--status-ok); }
.badge-error { background: var(--status-error-bg); color: var(--status-error); }
.eq-badge { display:inline-block;min-width:18px;height:18px;line-height:18px;text-align:center;border-radius:9px;background:var(--accent);color:#000;font-size:0.7rem;font-weight:700;margin-left:6px;vertical-align:middle; }
.badge-pending { background: var(--accent-dim); color: var(--accent); }
.badge-processing { background: var(--status-warn-bg); color: var(--status-warn); }
.badge-internal { background: rgba(99, 102, 241, 0.1); color: #818cf8; }
.badge-verlag { background: rgba(236, 72, 153, 0.1); color: #f472b6; }
.badge-datencheck { background: rgba(168, 85, 247, 0.1); color: #c084fc; }

/* Sortable headers */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text-secondary); }
th.active-sort { color: var(--accent) !important; }
.sort-arrow { font-size: 0.65rem; margin-left: 2px; }

/* Expandable job rows */
.job-row { cursor: pointer; }
.job-detail-row td { padding: 0 !important; border-bottom: 1px solid var(--border-subtle) !important; }
.job-detail { padding: 12px 16px; background: var(--bg-base); animation: slideDown 0.25s var(--ease); }
.job-detail-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 24px; font-size: 0.8rem; color: var(--text-secondary); }
.job-detail-label { display: block; font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }

/* =================== Billing =================== */
.billing-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.month-picker { display: flex; align-items: center; gap: 8px; }
.month-label { font-size: 0.92rem; font-weight: 600; color: var(--text-primary); min-width: 120px; text-align: center; }
.billing-total { font-size: 1.2rem; font-weight: 600; }
.billing-total span { color: var(--accent); }
.btn-delete { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 2px 6px; border-radius: 3px; transition: all 0.15s; opacity: 0.4; }
.btn-delete:hover { opacity: 1; color: var(--status-error); background: var(--status-error-bg); }
.billing-project-row td { background: var(--bg-elevated) !important; font-weight: 600; font-size: 0.82rem; color: var(--text-primary); border-bottom: 2px solid var(--border) !important; padding: 10px 16px !important; }

/* Datencheck price rows */
.cfg-dc-price-row { padding: 10px; background: var(--bg-base); border: 1px solid var(--border-subtle); border-radius: var(--radius); display: flex; flex-direction: column; gap: 6px; }
.cfg-dc-label { font-size: 0.82rem; font-weight: 500; color: var(--text-primary); }
.cfg-dc-price-row .cfg-label { flex-direction: row; align-items: center; gap: 8px; }
.cfg-dc-price-row .cfg-input { width: 90px; }

/* Wrike Workflow Mapping */
.cfg-wf-map-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.cfg-wf-map-label { flex: 0 0 140px; font-size: 0.82rem; color: var(--text-secondary); }
.cfg-wf-map-row .cfg-select { flex: 1; font-size: 0.8rem; }
.cfg-wf-accordion-item { border: 1px solid var(--border-subtle); border-radius: var(--radius); margin-bottom: 4px; overflow: hidden; }
.cfg-wf-accordion-header { display: flex; align-items: center; justify-content: space-between; padding: 7px 10px; background: var(--bg-elevated); cursor: pointer; font-size: 0.82rem; font-weight: 500; user-select: none; }
.cfg-wf-accordion-header:hover { background: var(--bg-panel); }
.cfg-wf-accordion-chevron { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.2s; }
.cfg-wf-accordion-item.open .cfg-wf-accordion-chevron { transform: rotate(90deg); }
.cfg-wf-accordion-body { display: none; padding: 8px 10px; }
.cfg-wf-accordion-item.open .cfg-wf-accordion-body { display: block; }
.cfg-wf-status-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 0.78rem; border-bottom: 1px solid var(--border-subtle); }
.cfg-wf-status-row:last-child { border-bottom: none; }
.cfg-wf-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cfg-wf-status-name { flex: 1; color: var(--text-primary); }
.cfg-wf-status-group { font-size: 0.7rem; color: var(--text-muted); flex: 0 0 70px; }
.cfg-wf-status-id { font-size: 0.7rem; color: var(--text-muted); font-family: monospace; flex-shrink: 0; }
.cfg-wf-status-copy { padding: 1px 6px; font-size: 0.7rem; cursor: pointer; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; display: flex; align-items: center; justify-content: center; animation: fadeUp 0.2s var(--ease); }
.modal { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 24px; min-width: 360px; max-width: 480px; box-shadow: 0 16px 48px rgba(0,0,0,0.5); animation: fadeUp 0.3s var(--ease); }
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 12px; }
.modal-body { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* =================== Toast =================== */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 14px 20px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.82rem; color: var(--text-primary); box-shadow: 0 8px 32px rgba(0,0,0,0.4); transform: translateY(120%); opacity: 0; visibility: hidden; transition: all 0.4s var(--ease); z-index: 200; max-width: 400px; }
.toast.show { transform: translateY(0); opacity: 1; visibility: visible; }
.toast-ok { border-left: 3px solid var(--status-ok); }
.toast-err { border-left: 3px solid var(--status-error); }

/* =================== Result Panel =================== */
.result-panel { margin-top: 16px; padding: 16px; background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--radius); display: none; }
.result-panel.show { display: block; animation: slideDown 0.4s var(--ease); }
.result-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; font-size: 0.82rem; border-bottom: 1px solid var(--border-subtle); animation: slideIn 0.3s var(--ease) backwards; }
.result-row:nth-child(1) { animation-delay: 0s; }
.result-row:nth-child(2) { animation-delay: 0.03s; }
.result-row:nth-child(3) { animation-delay: 0.06s; }
.result-row:nth-child(4) { animation-delay: 0.09s; }
.result-row:nth-child(5) { animation-delay: 0.12s; }
.result-row:last-child { border-bottom: none; }
.result-file { color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.result-dest { font-size: 0.75rem; color: var(--text-muted); }

/* =================== Empty State =================== */
.empty { text-align: center; padding: 48px 24px; color: var(--text-muted); font-size: 0.85rem; }
.empty-icon { font-size: 2rem; margin-bottom: 12px; opacity: 0.3; }

/* =================== Refresh Bar =================== */
.refresh-bar { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: transparent; z-index: 101; pointer-events: none; }
.refresh-bar.active { background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: sweep 0.8s var(--ease); }
@keyframes sweep { from { opacity: 1; transform: scaleX(0); transform-origin: left; } to { opacity: 0; transform: scaleX(1); transform-origin: left; } }

/* =================== Activity Feed =================== */
.activity-section { margin-top: 24px; background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; animation: fadeUp 0.5s var(--ease) 0.25s backwards; }
.activity-header { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.activity-feed { max-height: 320px; overflow-y: auto; }
.activity-empty { padding: 24px 16px; color: var(--text-muted); font-size: 0.82rem; text-align: center; }
.activity-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 0.82rem; border-bottom: 1px solid var(--border-subtle); transition: all 0.2s var(--ease); }
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--bg-hover); padding-left: 20px; }
.activity-time { font-size: 0.72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 60px; }
.activity-icon { width: 18px; text-align: center; flex-shrink: 0; transition: transform 0.2s; }
.activity-item:hover .activity-icon { transform: scale(1.2); }
.activity-msg { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-ok .activity-icon { color: var(--status-ok); }
.activity-error .activity-icon { color: var(--status-error); }
.activity-skip .activity-icon { color: var(--text-muted); }
.activity-info .activity-icon { color: var(--accent); }
.activity-count { display: inline-block; background: var(--text-muted); color: var(--bg-card); font-size: 0.68rem; font-weight: 600; padding: 1px 5px; border-radius: 8px; margin-left: 4px; vertical-align: middle; }

/* =================== Settings Sub-Tabs =================== */
.settings-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.settings-tabs { display: flex; gap: 2px; background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.settings-tab { padding: 7px 18px; font-size: 0.78rem; font-weight: 500; color: var(--text-muted); background: transparent; border: none; border-radius: calc(var(--radius) - 2px); cursor: pointer; transition: all 0.25s var(--ease); font-family: var(--font-body); white-space: nowrap; }
.settings-tab:hover { color: var(--text-secondary); background: var(--bg-hover); }
.settings-tab.active { background: var(--bg-elevated); color: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.settings-panel { display: none; }
.settings-panel.active { display: block; animation: fadeUp 0.3s var(--ease); }

/* =================== Config Form =================== */
.cfg-section { margin-bottom: 28px; }
.cfg-section + .cfg-section { padding-top: 20px; border-top: 1px solid var(--border); }
.cfg-section-title { font-size: 0.88rem; font-weight: 600; color: var(--text-primary); margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--accent); display: flex; align-items: center; justify-content: space-between; }
.cfg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cfg-label { display: flex; flex-direction: column; gap: 4px; font-size: 0.75rem; color: var(--text-muted); }
.cfg-input, .cfg-select { padding: 8px 10px; background: var(--bg-base); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.82rem; transition: all 0.2s var(--ease); width: 100%; }
.cfg-input:focus, .cfg-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(200, 255, 0, 0.08); }
.cfg-input::placeholder { color: var(--text-muted); font-style: italic; opacity: 0.5; }
.cfg-readonly { opacity: 0.6; cursor: default; }
.cfg-row { display: flex; align-items: center; gap: 8px; padding: 10px; background: var(--bg-base); border-radius: var(--radius); border: 1px solid var(--border-subtle); transition: border-color 0.2s; }
.cfg-row:hover { border-color: var(--border); }
.cfg-row-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.cfg-toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.cfg-toggle input { opacity: 0; width: 0; height: 0; }
.cfg-toggle-track { position: absolute; inset: 0; background: var(--bg-base); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: all 0.3s var(--ease); }
.cfg-toggle-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; background: var(--text-muted); border-radius: 50%; transition: all 0.3s var(--ease); }
.cfg-toggle input:checked + .cfg-toggle-track { background: var(--accent-dim); border-color: var(--accent); }
.cfg-toggle input:checked + .cfg-toggle-track::after { left: 18px; background: var(--accent); }
.cfg-day-picker { display: flex; gap: 4px; }
.cfg-day { width: 32px; height: 28px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-base); color: var(--text-muted); font-size: 0.72rem; font-weight: 500; cursor: pointer; transition: all 0.2s var(--ease); display: flex; align-items: center; justify-content: center; }
.cfg-day:hover { border-color: var(--text-muted); color: var(--text-secondary); }
.cfg-day.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); transform: scale(1.05); }
.cfg-price-grid { display: grid; grid-template-columns: 80px 1fr 1fr 1fr; gap: 6px; align-items: center; font-size: 0.8rem; }
.cfg-price-grid .cfg-input { padding: 6px 8px; }
.cfg-price-header { font-size: 0.68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.cfg-status-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-secondary); }

/* Notification alert rows */
.cfg-notif-row { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); }
.cfg-notif-row:last-child { border-bottom: none; }
.cfg-notif-label { flex: 1; font-size: 0.82rem; color: var(--text-secondary); }

/* =================== KI Regelwerk =================== */
.ki-rule { display: flex; align-items: flex-start; gap: 8px; padding: 10px; background: var(--bg-base); border-radius: var(--radius); border: 1px solid var(--border-subtle); transition: border-color 0.2s; }
.ki-rule:hover { border-color: var(--border); }
.ki-rule-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.ki-rule-top { display: flex; gap: 8px; align-items: center; }
.ki-rule-top input { flex: 1; }
.ki-severity { padding: 6px 10px; background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.8rem; }
.ki-rule textarea { width: 100%; padding: 6px 10px; background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font-body); font-size: 0.8rem; resize: vertical; min-height: 36px; }
.ki-rule textarea:focus { outline: none; border-color: var(--accent); }
.ki-chat-msg { padding: 8px 12px; border-radius: var(--radius); margin-bottom: 8px; font-size: 0.82rem; line-height: 1.5; }
.ki-chat-user { background: var(--accent-dim); color: var(--text-primary); margin-left: 40px; }
.ki-chat-ai { background: var(--bg-elevated); color: var(--text-secondary); margin-right: 40px; }
.ki-chat-action { margin-top: 6px; }
.ki-finding { display: flex; align-items: center; gap: 8px; padding: 8px; background: var(--bg-base); border-radius: var(--radius); border: 1px solid var(--border-subtle); font-size: 0.82rem; transition: border-color 0.2s; }
.ki-finding:hover { border-color: var(--border); }
.ki-finding-text { flex: 1; color: var(--text-secondary); }
.ki-finding-actions { display: flex; gap: 4px; }

/* Footer */
.app-footer { text-align: center; padding: 24px 0 16px; font-size: 0.72rem; color: var(--text-muted); letter-spacing: 0.02em; }

/* =================== Mobile (< 768px) =================== */
@media (max-width: 768px) {
  .main { padding: 12px; }

  /* Topbar: kompakter, kein Overflow */
  .topbar { padding: 0 12px; height: 46px; overflow: hidden; }
  .topbar-sub { display: none; }
  .topbar-clock { display: none; }
  .topbar-status { gap: 6px; flex-shrink: 1; min-width: 0; overflow: hidden; }
  .topbar-indicator { gap: 3px; }
  .topbar-label { display: none; }
  .topbar-icon { display: block; }

  /* Tabs: scrollbar statt umbrechen */
  .tabs { padding: 0 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 10px 14px; font-size: 0.78rem; white-space: nowrap; flex-shrink: 0; }

  /* Cards: eine Spalte */
  .card-grid { grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
  .card { padding: 12px; }
  .card-wide { grid-column: span 2; }
  .card-value { font-size: 1.3rem; }
  .card-label { font-size: 0.65rem; margin-bottom: 8px; }

  /* Health: eine Spalte */
  .health-grid { grid-template-columns: 1fr; gap: 0; }
  .health-item { grid-template-columns: 8px 80px 1fr; }

  /* Action-Buttons: gestapelt */
  .action-bar { flex-direction: column; align-items: stretch; gap: 6px; }
  .btn-action { justify-content: center; padding: 10px 16px; font-size: 0.8rem; }
  .btn-outline-accent { justify-content: center; padding: 10px 16px; font-size: 0.8rem; }
  .btn-secondary { justify-content: center; padding: 8px 12px; }

  /* Server-Steuerung: wrap */
  #server-controls { flex-wrap: wrap; gap: 4px; }
  .btn-server { font-size: 0.65rem; padding: 4px 8px; gap: 4px; }

  /* Tabellen: horizontal scrollbar */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-toolbar { flex-direction: column; align-items: stretch; }
  .table-toolbar-left { flex-wrap: wrap; }
  .filter-input { width: 100%; }
  .filter-input:focus { width: 100%; }

  /* Job-Details: eine Spalte */
  .job-detail-grid { grid-template-columns: 1fr 1fr; gap: 6px 16px; }

  /* Activity Feed + Log: gleiche Groesse wie Card-Labels */
  .activity-header { font-size: 0.65rem; padding: 10px 12px; }
  .activity-item { padding: 8px 12px; font-size: 0.78rem; }
  .activity-section { margin-top: 16px; }

  /* Billing */
  .billing-header { flex-direction: column; align-items: stretch; }

  /* Modal: volle Breite */
  .modal-backdrop { padding: 12px; }
  .modal { min-width: auto; max-width: 100%; width: 100%; }

  /* Auth-Dialog */
  .auth-panel { width: calc(100vw - 32px); max-width: 320px; }

  /* Toast: volle Breite unten */
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }

  /* Settings */
  .cfg-grid { grid-template-columns: 1fr !important; }
  .cfg-section { padding: 12px !important; }

  /* Progress */
  .batch-progress { padding: 10px 12px; }
}

/* =================== Kleine Phones (< 400px) =================== */
@media (max-width: 400px) {
  .card-grid { grid-template-columns: 1fr; }
  .card-wide { grid-column: span 1; }
  .job-detail-grid { grid-template-columns: 1fr; }
  .tab { padding: 8px 10px; font-size: 0.72rem; }
}

/* =================== Help Panel =================== */

.help-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1499;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}
.help-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.help-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 420px;
  z-index: 1500;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}
.help-panel.open {
  transform: translateX(0);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}
.help-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: color 0.2s, background 0.2s;
}
.help-close:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  background: var(--bg-elevated);
}
.help-toc a {
  font-size: 0.73rem;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 8px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
}
.help-toc a:hover {
  color: var(--accent);
  background: var(--accent-dim);
}

.help-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 24px;
  scroll-behavior: smooth;
}
.help-content::-webkit-scrollbar { width: 4px; }
.help-content::-webkit-scrollbar-track { background: transparent; }
.help-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.help-section {
  padding: 20px 20px 4px;
  border-bottom: 1px solid var(--border-subtle);
}
.help-section:last-child {
  border-bottom: none;
}
.help-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.help-section p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}
.help-section strong {
  color: var(--text-primary);
  font-weight: 600;
}

.help-list {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0 0 10px 18px;
}
.help-list li {
  margin-bottom: 4px;
}

.help-example {
  display: inline-block;
  transform: scale(0.9);
  transform-origin: left top;
  margin-bottom: 4px;
  pointer-events: none;
  user-select: none;
}

.help-dots-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}
.help-dot-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.help-dot-row .dot {
  margin-top: 4px;
}

.help-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-bottom: 10px;
}
.help-table thead th {
  text-align: left;
  padding: 7px 10px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.help-table tbody td {
  padding: 8px 10px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
  line-height: 1.5;
}
.help-table tbody tr:last-child td {
  border-bottom: none;
}
.help-table tbody td:first-child {
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  width: 44%;
}

@media (max-width: 768px) {
  .help-panel { width: 100vw; }
}
