:root {
    --bg: #0f1114; --surface: #181b20; --surface-2: #1f2329; --surface-hover: #252a31;
    --border: #2a2f38; --border-active: #3d4450;
    --text: #e8eaed; --text-muted: #8b919a; --text-dim: #5a6270;
    --accent: #f59e0b; --accent-dim: #92600a;
    --success: #22c55e; --danger: #ef4444; --info: #3b82f6;
    --font-body: 'DM Sans', sans-serif; --font-mono: 'Space Mono', monospace;
    --radius: 6px;
    --env-banner-h: 0px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-body); background: var(--bg) url('/images/Bild6.png') no-repeat center center fixed; background-size: cover; color: var(--text); line-height: 1.5; min-height: 100vh; }
.app { display: flex; height: calc(100vh - var(--env-banner-h)); margin-top: var(--env-banner-h); overflow: hidden; }

/* SIDEBAR */
.sidebar { width: 240px; background: rgba(24,27,32,0.92); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 20px 16px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h1 { font-family: var(--font-mono); font-size: 18px; font-weight: 700; letter-spacing: 2px; color: var(--accent); }
.sidebar-header .subtitle { font-size: 11px; color: var(--text-dim); letter-spacing: 0.5px; margin-top: 2px; }
.nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted); transition: all 0.15s; user-select: none; text-decoration: none; }
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--accent); border: 1px solid var(--border); }
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .badge { margin-left: auto; background: var(--accent-dim); color: var(--accent); font-family: var(--font-mono); font-size: 10px; padding: 1px 6px; border-radius: 10px; }
.nav-group-header { font-size: 10px; text-transform: uppercase; color: var(--text-muted); padding: 12px 16px 4px; letter-spacing: 0.05em; }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(24,27,32,0.88); border-bottom: 1px solid var(--border); }
.toolbar h2 { font-size: 15px; font-weight: 600; margin-right: auto; }
.content { flex: 1; overflow-y: auto; padding: 24px; background: rgba(15,17,20,0.85); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-family: var(--font-body); font-size: 12px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn:hover { border-color: var(--border-active); background: var(--surface-hover); }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.btn-primary:hover { background: #eab308; }
.btn-success { background: #22c55e; color: #000; border-color: #22c55e; font-weight: 700; }
.btn-success:hover { background: #16a34a; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-sm { padding: 4px 10px; font-size: 11px; }

/* SEARCH */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; flex: 0 1 320px; }
.search-bar .icon { color: var(--text-dim); font-size: 14px; }
.search-bar input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-family: var(--font-body); font-size: 12px; padding: 8px 0; }
.search-bar input::placeholder { color: var(--text-dim); }

/* TABLE */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 8px 12px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); border-bottom: 1px solid var(--border); position: sticky; top: 0; background: rgba(15,17,20,0.92); z-index: 1; cursor: pointer; user-select: none; }
.data-table td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid var(--border); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table td.bool-true { color: #22c55e; }
.data-table td.bool-false { color: #ef4444; }
.data-table tr td { background: rgba(24,27,32,0.6); }
.data-table tr:hover td { background: var(--surface); }
.data-table tr { cursor: pointer; }
.data-table .mono { font-family: var(--font-mono); font-size: 12px; }
.data-table .muted { color: var(--text-muted); }
.data-table th .sort-indicator { font-size: 10px; margin-left: 4px; opacity: 0.5; }
.data-table th.sorted .sort-indicator { opacity: 1; }
.data-table .filter-row { cursor: default; }
.data-table .filter-row td { padding: 4px 4px 6px; border-bottom: 1px solid var(--border); background: rgba(15,17,20,0.92); position: sticky; top: 28px; z-index: 1; }
.data-table .filter-row .filter-cell { position: relative; display: flex; align-items: center; }
.data-table .filter-row input { width: 100%; font-size: 11px; padding: 2px 18px 2px 4px; border: 1px solid var(--border); border-radius: 3px; background: var(--bg); color: var(--text); font-family: var(--font-body); outline: none; }
.data-table .filter-row input:focus { border-color: var(--border-active); }
.data-table .filter-row input::placeholder { color: var(--text-dim); }
.data-table .filter-row .filter-clear { position: absolute; right: 4px; cursor: pointer; color: var(--text-muted); font-size: 14px; line-height: 1; }
.data-table .filter-row .filter-clear:hover { color: var(--text); }

/* PAGER */
.pager-bar { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--card-bg); font-size: 0.9em; }
.pager-size-wrapper { display: flex; align-items: center; gap: 6px; }
.pager-size-wrapper select { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 2px 6px; font-size: 12px; }
.pager-info { color: var(--text-muted); font-size: 12px; }
.pager-bar .btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* STATUS */
.status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.status-open { background: rgba(59,130,246,0.15); color: var(--info); }
.status-done { background: rgba(34,197,94,0.15); color: var(--success); }
.status-wip { background: rgba(245,158,11,0.15); color: var(--accent); }
.status-closed { background: rgba(128,128,128,0.15); color: var(--text-muted); }

/* STATS */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: rgba(24,27,32,0.88); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-card .label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .number { font-family: var(--font-mono); font-size: 28px; font-weight: 700; color: var(--text); margin-top: 4px; }

/* DETAIL PANEL */
.detail-panel { position: fixed; right: 0; top: var(--env-banner-h); width: min(960px, calc(100vw - 240px - 24px)); height: calc(100vh - var(--env-banner-h)); background: rgba(24,27,32,0.95); border-left: 1px solid var(--border); z-index: 100; display: flex; flex-direction: column; box-shadow: -8px 0 32px rgba(0,0,0,0.4); transform: translateX(100%); transition: transform 0.2s ease-out; }
.detail-panel.open { transform: translateX(0); }
.detail-panel.wide { width: calc(100vw - 240px - 24px); }
.detail-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.detail-header h3 { font-size: 14px; font-weight: 600; }
.detail-body { flex: 1; overflow-y: auto; padding: 20px; }
.detail-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* TAB BAR */
.tab-bar { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-bar button { background: none; border: none; color: var(--text-dim); font-size: 13px; font-weight: 500; padding: 8px 16px; cursor: pointer; border-bottom: 2px solid transparent; transition: color 0.15s, border-color 0.15s; }
.tab-bar button:hover { color: var(--text); }
.tab-bar button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* FIELD LINKS (inline creation) */
.field-link { font-size: 12px; color: var(--accent); cursor: pointer; text-decoration: none; margin-top: 2px; display: inline-block; }
.field-link:hover { text-decoration: underline; }

/* FORM FIELDS */
.field-group { margin-bottom: 16px; }
.field-group label { display: block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 4px; }
.field-group .value { font-size: 14px; color: var(--text); }
.field-group .value.mono { font-family: var(--font-mono); font-size: 13px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.field-group input, .field-group select, .field-group textarea {
    width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 8px 10px; color: var(--text); font-family: var(--font-body); font-size: 13px; outline: none;
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: var(--accent); }
.field-group textarea { resize: vertical; min-height: 60px; }
.field-group input[type="checkbox"] { width: auto; margin-right: 6px; }
.checkbox-row { display: flex; align-items: center; padding: 4px 0; }
.checkbox-row label { text-transform: none; font-size: 13px; color: var(--text); font-weight: 400; letter-spacing: 0; margin-bottom: 0; }
.tri-toggle { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; font-size: 14px; margin-right: 8px; user-select: none; outline: none; transition: all 0.15s; }
.tri-toggle:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.tri-toggle.tri-true { color: #22c55e; border-color: #22c55e; background: rgba(34,197,94,0.1); }
.tri-toggle.tri-false { color: #ef4444; border-color: #ef4444; background: rgba(239,68,68,0.1); }
.tri-toggle.tri-null { color: var(--text-dim); }

/* TABS */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab { padding: 8px 16px; font-size: 12px; font-weight: 500; color: var(--text-dim); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* MISC */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 99; }
.loading { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; padding: 20px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 300; display: flex; align-items: center; justify-content: center; }
.cnc-loader { background: #0a0a0a; border: 1px solid #333; border-radius: 6px; padding: 16px 20px; min-width: 320px; box-shadow: 0 8px 32px rgba(0,0,0,0.6); font-family: 'Courier New', monospace; }
.cnc-header { color: #888; font-size: 11px; letter-spacing: 2px; margin-bottom: 8px; border-bottom: 1px solid #222; padding-bottom: 6px; }
.cnc-blink { color: #22c55e; animation: cncBlink 0.8s step-end infinite; }
.cnc-code { color: #22c55e; font-size: 13px; line-height: 1.6; min-height: 96px; white-space: pre; }
@keyframes cncBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.toast-container { position: fixed; top: 60px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); animation: slideIn 0.2s ease-out; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--accent); background: rgba(245,158,11,0.15); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.toast-history-btn { padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 12px; cursor: pointer; user-select: none; }
.toast-history-btn:hover { background: var(--surface-3); }
.toast-history-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.4); display: flex; align-items: flex-start; justify-content: flex-end; padding: 60px 24px 0; }
.toast-history-panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); width: 360px; max-height: 480px; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.toast-history-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.toast-history-header span { flex: 1; }
.toast-history-list { overflow-y: auto; flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.toast-history-item { padding: 8px 12px; border-radius: 4px; font-size: 13px; border-left: 3px solid var(--border); background: var(--surface-2); }
.toast-history-item.error { border-left-color: var(--danger); }
.toast-history-item.success { border-left-color: var(--success); }
[x-cloak] { display: none !important; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.section-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--accent-dim); margin: 20px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.field-group input:required, .field-group select:required, .field-group textarea:required { border-left: 2px solid var(--accent); }

/* AUTOCOMPLETE */
.autocomplete-wrapper { position: relative; }
.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); max-height: 200px; overflow-y: auto;
    z-index: 50; display: none;
}
.autocomplete-dropdown.show { display: block; }
.autocomplete-item {
    padding: 8px 12px; cursor: pointer; font-size: 12px;
    display: flex; gap: 8px; align-items: center;
}
.autocomplete-item:hover, .autocomplete-item.selected { background: var(--surface-hover); color: var(--accent); }
.autocomplete-item .key { font-family: var(--font-mono); font-weight: 600; }
.autocomplete-item .label { color: var(--text-muted); font-size: 11px; }

/* PRINT DROPDOWN */
.print-dropdown { position: relative; display: inline-block; }
.print-menu { position: absolute; top: 100%; right: 0; min-width: 220px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 0; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.print-menu a { display: block; padding: 8px 14px; font-size: 12px; color: var(--text); text-decoration: none; cursor: pointer; }
.print-menu a:hover { background: var(--surface-hover); color: var(--accent); }

/* LOGIN SCREEN */
.login-screen { display: none; position: fixed; inset: 0; background: linear-gradient(rgba(15,17,20,0.65), rgba(15,17,20,0.65)), url('/images/Bild1.png') no-repeat center center / cover; z-index: 1000; justify-content: center; align-items: center; }
.login-inner { text-align: center; position: relative; z-index: 1; }
.login-title { font-family: var(--font-mono); font-size: 24px; color: var(--accent); letter-spacing: 3px; margin-bottom: 8px; }
.login-subtitle { font-size: 12px; color: var(--text-dim); margin-bottom: 32px; }
.login-btn { padding: 12px 32px; font-size: 14px; }
.login-hint { font-size: 11px; color: var(--text-dim); margin-top: 16px; }

/* SIDEBAR USER / FOOTER */
.sidebar-user { padding: 12px 16px; border-top: 1px solid var(--border); }
.sidebar-username { font-size: 12px; color: var(--text); margin-bottom: 4px; }
.sidebar-roles { font-size: 10px; color: var(--text-dim); margin-bottom: 8px; }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; }
.sidebar-build-info { font-size: 10px; color: var(--text-dim); font-family: var(--font-mono); }
.btn-logout { font-size: 10px; }

/* DASHBOARD */
.dashboard-section-title { font-size: 14px; margin-bottom: 12px; color: var(--text-muted); }
.row-overdue td { color: var(--danger) !important; }
.row-overdue { background: rgba(239,68,68,0.07); }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 40px; color: var(--text-dim); }

/* SEARCH FORM */
.search-form { display: flex; gap: 12px; margin-bottom: 20px; align-items: end; flex-wrap: wrap; }
.search-entity-group { flex: 0 0 160px; }
.search-criteria-row { display: flex; gap: 6px; align-items: end; }
.search-field-select { width: 160px; }
.search-operator-select { width: 80px; }
.search-value-input { width: 140px; }
.search-result-count { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.search-result-cell { font-size: 12px; }
.search-results-scroll { overflow-x: auto; max-width: 100%; }

/* DETAIL HEADER */
.detail-header-actions { display: flex; gap: 6px; }
.detail-footer-spacer { flex: 1; }

/* PERSONAL */
.auto-generate-hint { color: var(--text-dim); font-size: 10px; }

/* HISTORY */
.history-list { margin-top: 12px; }
.history-entry { padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; font-size: 11px; font-family: var(--font-mono); }
.history-current { border-color: var(--accent); }
.history-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.history-version-label { color: var(--accent); font-weight: 600; }
.history-current-badge { background: #22c55e; color: #fff; padding: 1px 8px; border-radius: 9999px; font-size: 10px; font-weight: 600; }
.history-initial { margin-top: 4px; color: var(--text-muted); font-style: italic; }
.history-changes { margin-top: 4px; }
.history-change { color: var(--text-muted); font-size: 10px; }
.history-change-field { font-weight: 600; }
.history-change-old { color: #ef4444; text-decoration: line-through; }
.history-change-new { color: #22c55e; }

/* FIELD HINTS */
.field-hint { display: block; font-size: 10px; margin-top: 2px; }
.field-hint.warning { color: var(--accent); }

/* FILE INPUT */
.file-input-wrapper { margin-top: 4px; }
.file-input-wrapper input[type="file"] { width: 100%; font-size: 12px; color: var(--text-muted); }
.file-input-wrapper input[type="file"]::file-selector-button { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); padding: 4px 10px; font-size: 11px; cursor: pointer; margin-right: 8px; }

/* ENVIRONMENT BANNER */
.env-banner { position: fixed; top: 0; left: 0; right: 0; height: 28px; z-index: 10000; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.env-banner.test { background: #ff6b00; color: #fff; }
.env-banner.integration { background: #f59e0b; color: #000; }

/* FORM COLUMNS (two-column layout for wider panels) */
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.form-columns .form-section { break-inside: avoid; }
.form-columns .form-section.full-width { grid-column: 1 / -1; }

/* FAI STATUS */
.fai-status-card { padding: 16px; border-radius: 6px; border-left: 4px solid; margin-bottom: 16px; }
.fai-status-card.fai-ok { border-color: var(--success); background: rgba(34,197,94,0.08); }
.fai-status-card.fai-required { border-color: var(--accent); background: rgba(245,158,11,0.08); }
.fai-status-card.fai-unknown { border-color: var(--border); background: var(--surface); }
.fai-status-card .fai-status-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.fai-status-card .fai-status-reason { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.fai-status-card .fai-status-dates { font-size: 12px; color: var(--text-dim); }
.fai-info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.fai-info-block { padding: 12px; border: 1px solid var(--border); border-radius: 6px; }
.fai-info-block .fai-block-title { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-dim); margin-bottom: 8px; }
.fai-info-block .fai-field { font-size: 13px; margin-bottom: 4px; }
.fai-info-block .fai-field .fai-label { color: var(--text-dim); }

/* Chat Widget */
.chat-widget { position: fixed; bottom: 20px; right: 20px; z-index: 9999; transition: right 0.2s ease-out; }
body:has(.detail-panel.open) .chat-widget { right: calc(min(960px, 100vw - 240px - 24px) + 28px); }
body.panel-open .chat-widget { right: calc(min(960px, 100vw - 240px - 24px) + 28px); }
.chat-fab { width: 48px; height: 48px; border-radius: 50%; background: var(--accent); color: #000; border: none; font-size: 20px; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.4); transition: all 0.2s; display: flex; align-items: center; justify-content: center; position: absolute; bottom: 0; right: 0; }
.chat-fab:hover { transform: scale(1.1); }
.chat-fab-active { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.chat-panel { position: absolute; bottom: 60px; right: 0; width: 400px; height: 500px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--accent); display: flex; align-items: center; justify-content: space-between; }
.chat-clear-btn { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 4px; }
.chat-clear-btn:hover { background: var(--surface-hover); color: var(--text); }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.chat-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 40px 20px; }
.chat-bubble { max-width: 85%; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap; }
.chat-user { align-self: flex-end; background: var(--accent-dim); color: var(--text); border-bottom-right-radius: 2px; }
.chat-assistant { align-self: flex-start; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
.chat-tools { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.chat-tool-badge { font-size: 10px; font-family: var(--font-mono); padding: 1px 6px; border-radius: 4px; background: var(--surface-hover); color: var(--text-dim); border: 1px solid var(--border); }
.chat-feedback { margin-top: 6px; display: flex; gap: 4px; align-items: center; }
.chat-feedback-btn { background: transparent; border: 1px solid var(--border); border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 12px; line-height: 1; }
.chat-feedback-btn:hover:not(:disabled) { background: var(--surface-hover); }
.chat-feedback-btn:disabled { cursor: not-allowed; opacity: 0.5; }
.chat-feedback-done { font-size: 11px; color: var(--text-dim); font-style: italic; }
.chat-feedback-form { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.chat-feedback-form textarea { background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; color: var(--text); font-family: var(--font-body); font-size: 12px; resize: vertical; outline: none; }
.chat-feedback-form textarea:focus { border-color: var(--accent); }
.chat-feedback-actions { display: flex; gap: 6px; }
.chat-feedback-submit { background: var(--accent); color: #000; border: none; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 11px; font-weight: 600; }
.chat-feedback-cancel { background: transparent; border: 1px solid var(--border); color: var(--text-dim); border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 11px; }
.chat-loading { align-self: flex-start; padding: 8px 12px; }
.chat-dots { color: var(--text-dim); font-size: 20px; letter-spacing: 2px; animation: chatDots 1.2s infinite; }
@keyframes chatDots { 0%, 20% { opacity: 0.3; } 50% { opacity: 1; } 80%, 100% { opacity: 0.3; } }
.chat-input-row { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-input-row input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; color: var(--text); font-family: var(--font-body); font-size: 12px; outline: none; }
.chat-input-row input:focus { border-color: var(--accent); }
.chat-send-btn { background: var(--accent); color: #000; border: none; border-radius: 6px; padding: 8px 12px; cursor: pointer; font-size: 14px; font-weight: 700; }
.chat-send-btn:hover { opacity: 0.9; }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.chat-feedback-row { margin-top: 4px; display: flex; gap: 4px; }
.chat-feedback-btn { background: none; border: none; cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; opacity: 0.5; transition: opacity 0.15s; }
.chat-feedback-btn:hover { opacity: 1; background: var(--surface-hover); }
.chat-feedback-sent { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.chat-feedback-comment { margin-top: 4px; display: flex; gap: 4px; }
.chat-feedback-input { flex: 1; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 4px 8px; color: var(--text); font-size: 11px; font-family: var(--font-body); outline: none; }
.chat-feedback-input:focus { border-color: var(--accent); }
.chat-feedback-submit { background: var(--accent); color: #000; border: none; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 11px; font-weight: 600; }
.chat-feedback-submit:hover { opacity: 0.9; }

/* Help Overlay */
.help-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.help-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 600px; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.help-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.help-header h3 { font-size: 16px; font-weight: 600; }
.help-body { padding: 20px; overflow-y: auto; }
.help-description { color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }
.help-body h4 { font-size: 13px; font-weight: 600; color: var(--accent); margin: 16px 0 8px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.help-field { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.help-field:last-child { border-bottom: none; }
.help-field-name { font-weight: 600; min-width: 140px; color: var(--text); }
.help-field-text { color: var(--text-muted); }
.help-shortcuts { margin-top: 16px; }

/* Field Info Icon */
.help-icon { color: var(--text-dim); cursor: help; font-size: 12px; margin-left: 4px; }
.help-icon:hover { color: var(--accent); }

/* Email Modal Overlay — uses absolute positioning to work correctly inside transformed detail-panel */
.email-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); z-index: 1000; display: flex; align-items: center; justify-content: center; }

/* Email Comparison Modal — Split-View */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 10000; display: flex; align-items: center; justify-content: center; }
.email-comparison-modal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 95%; max-width: 1400px; max-height: 90vh; display: flex; flex-direction: column; }
.email-comparison-modal .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.email-comparison-modal .modal-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.split-view { display: grid; grid-template-columns: 1fr 1fr; gap: 0; flex: 1; overflow: hidden; }
.split-left, .split-right { padding: 16px; overflow-y: auto; max-height: 75vh; }
.split-left { border-right: 2px solid var(--border); }
.split-left h4, .split-right h4 { margin: 0 0 10px 0; font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.split-email-text { font-size: 13px; white-space: pre-line; line-height: 1.7; color: var(--text); }
.split-email-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
/* Field highlight colors — 8 distinct hues for matched fields */
.hl-0 { background: rgba(76, 175, 80, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-1 { background: rgba(33, 150, 243, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-2 { background: rgba(156, 39, 176, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-3 { background: rgba(255, 152, 0, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-4 { background: rgba(0, 188, 212, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-5 { background: rgba(233, 30, 99, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-6 { background: rgba(139, 195, 74, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-7 { background: rgba(255, 87, 34, 0.18); border-radius: 3px; padding: 1px 4px; }
.hl-diff { background: rgba(255, 152, 0, 0.25); border-radius: 3px; padding: 1px 4px; outline: 2px solid #ff9800; }
/* Entity field table */
.entity-fields-table { width: 100%; border-collapse: collapse; }
.entity-fields-table td { padding: 5px 8px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
.entity-fields-table td:first-child { font-weight: 600; white-space: nowrap; width: 140px; color: var(--text-muted); }
/* Legend */
.cmp-legend { display: flex; gap: 12px; margin-bottom: 12px; font-size: 11px; color: var(--text-muted); flex-wrap: wrap; padding: 6px 20px; border-bottom: 1px solid var(--border); }
.cmp-legend-item { display: flex; align-items: center; gap: 4px; }
.cmp-legend-swatch { width: 12px; height: 12px; border-radius: 2px; }
/* Abweichungen */
.email-diffs { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--border); }
.diff-item { color: var(--error); font-size: 13px; padding: 4px 0; }
.diff-item::before { content: "! "; font-weight: 700; }
.pos-comparison-table th { padding: 6px 8px; font-size: 11px; font-weight: 600; text-align: left; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.pos-comparison-table td { padding: 5px 8px; font-size: 12px; border-bottom: 1px solid var(--border); }
