:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-main: #f8fafc;
    --bg-primary: #ffffff;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --sidebar: #1e293b;
    --text: #0f172a;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar);
    color: white;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    padding: 0 2rem 2rem 2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
}

.logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

nav {
    flex: 1;
}

.nav-item {
    display: block;
    padding: 1rem 2rem;
    color: #94a3b8;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background-color: #334155;
    color: white;
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
}

/* Submenu */
.nav-submenu {
    position: relative;
}

.nav-item.has-submenu {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.submenu-arrow {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-submenu.open .submenu-arrow {
    transform: rotate(180deg);
}

.submenu-items {
    display: none;
    background-color: #0f172a;
}

.nav-submenu.open .submenu-items {
    display: block;
}

.nav-subitem {
    display: block;
    padding: 0.75rem 2rem 0.75rem 3rem;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.nav-subitem:hover {
    background-color: #334155;
    color: white;
}

.nav-subitem.active {
    background-color: var(--primary);
    color: white;
}

/* AI Costs Widget */
.ai-costs {
    padding: 1rem 1.5rem;
    margin: 0 0.5rem 0.5rem 0.5rem;
    background-color: #334155;
    border-radius: 8px;
    font-size: 0.8rem;
}

.cost-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #e2e8f0;
}

.cost-icon {
    font-size: 1rem;
}

.cost-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.cost-row {
    display: flex;
    justify-content: space-between;
    color: #94a3b8;
}

.cost-row span:last-child {
    color: #fbbf24;
    font-weight: 500;
    font-family: 'Consolas', monospace;
}

.status-indicator {
    padding: 1rem 2rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-top: 1px solid #334155;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green { background-color: var(--success); }
.dot.red { background-color: var(--error); }
.dot.gray { background-color: var(--text-muted); }

/* Content */
.content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    margin-left: 260px;
}

h2 {
    margin-bottom: 2rem;
    font-weight: 600;
}

h3 {
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    font-weight: 600;
    font-size: 1.125rem;
}

h4 {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.hidden { display: none; }

/* Tab Container */
.tab-container {
    margin-bottom: 2rem;
}

.tab-nav {
    display: flex;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
    background: none;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: none;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Deckungsbeitrag Report Tabs */
.db-tabs-container {
    margin-bottom: 1.5rem;
}

.db-tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.db-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.db-tab-btn:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

.db-tab-btn.active {
    background: var(--bg-primary);
    color: var(--primary);
    border-color: var(--primary);
    border-bottom: 2px solid var(--bg-primary);
}

.db-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.db-tab-content.active {
    display: block;
}

/* Verkäufe Tab Content */
.verkaeufe-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.verkaeufe-tab-btn:hover {
    background: var(--bg-primary);
    color: var(--success);
}

.verkaeufe-tab-btn.active {
    background: var(--bg-primary);
    color: var(--success);
    border-color: var(--success);
    border-bottom: 2px solid var(--bg-primary);
}

.verkaeufe-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.verkaeufe-tab-content.active {
    display: block;
}

/* Einkäufe Tab Content */
.einkaeufe-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.einkaeufe-tab-btn:hover {
    background: var(--bg-primary);
    color: var(--error);
}

.einkaeufe-tab-btn.active {
    background: var(--bg-primary);
    color: var(--error);
    border-color: var(--error);
    border-bottom: 2px solid var(--bg-primary);
}

.einkaeufe-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.einkaeufe-tab-content.active {
    display: block;
}

/* Stock Report Tabs */
.stock-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.stock-tab-btn:hover {
    background: var(--bg-primary);
    color: var(--primary);
}

.stock-tab-btn.active {
    background: var(--bg-primary);
    color: var(--primary);
    border-color: var(--primary);
    border-bottom: 2px solid var(--bg-primary);
}

.stock-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.stock-tab-content.active {
    display: block;
}

/* ARA Report Tabs */
.ara-tabs-container {
    margin-bottom: 2rem;
}

.ara-tab-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.ara-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.ara-tab-btn:hover {
    background: var(--bg-primary);
    color: #22c55e;
}

.ara-tab-btn.active {
    background: var(--bg-primary);
    color: #22c55e;
    border-color: #22c55e;
    border-bottom: 2px solid var(--bg-primary);
}

.ara-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.ara-tab-content.active {
    display: block;
}

/* ERA Tabs */
.era-tabs-container {
    margin-bottom: 2rem;
}

.era-tab-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.era-tab-btn {
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.2s;
    margin-bottom: -2px;
}

.era-tab-btn:hover {
    background: var(--bg-primary);
    color: #22c55e;
}

.era-tab-btn.active {
    background: var(--bg-primary);
    color: #22c55e;
    border-color: #22c55e;
    border-bottom: 2px solid var(--bg-primary);
}

.era-tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.era-tab-content.active {
    display: block;
}

/* ERA Artikel Detail Rows */
.era-artikel-row {
    transition: background-color 0.2s;
    cursor: pointer;
}

.era-artikel-row:hover {
    background-color: var(--bg-secondary) !important;
}

.era-artikel-row.selected {
    background-color: var(--bg-tertiary) !important;
    font-weight: 500;
}

.era-artikel-detail-row {
    background-color: var(--bg-tertiary) !important;
    transition: all 0.3s ease;
}

.era-artikel-detail-row.hidden {
    display: none;
}

#era-artikel-table {
    table-layout: fixed;
    width: 100%;
}
#era-artikel-table th:nth-child(4),
#era-artikel-table td:nth-child(4) { width: 130px; }
#era-artikel-table th:nth-child(5),
#era-artikel-table td:nth-child(5),
#era-artikel-table th:nth-child(6),
#era-artikel-table td:nth-child(6),
#era-artikel-table th:nth-child(7),
#era-artikel-table td:nth-child(7),
#era-artikel-table th:nth-child(8),
#era-artikel-table td:nth-child(8),
#era-artikel-table th:nth-child(9),
#era-artikel-table td:nth-child(9),
#era-artikel-table th:nth-child(10),
#era-artikel-table td:nth-child(10) { width: 110px; }

/* ARA Artikel Detail Rows */
.ara-artikel-row {
    transition: background-color 0.2s;
}

.ara-artikel-row:hover {
    background-color: var(--bg-secondary) !important;
}

.ara-artikel-row.selected {
    background-color: var(--bg-tertiary) !important;
    font-weight: 500;
}

.expand-icon {
    display: inline-block;
    width: 1rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.ara-artikel-detail-row {
    background-color: var(--bg-tertiary) !important;
    transition: all 0.3s ease;
}

/* Fixed table layout prevents the detail row from expanding the outer table horizontally */
#ara-artikel-table {
    table-layout: fixed;
    width: 100%;
}
#ara-artikel-table th:first-child,
#ara-artikel-table td:first-child { width: 44px; }
#ara-artikel-table th:nth-child(4),
#ara-artikel-table td:nth-child(4) { width: 90px; }
#ara-artikel-table th:nth-child(5),
#ara-artikel-table td:nth-child(5),
#ara-artikel-table th:nth-child(6),
#ara-artikel-table td:nth-child(6),
#ara-artikel-table th:nth-child(7),
#ara-artikel-table td:nth-child(7) { width: 130px; }

.ara-artikel-detail-row.hidden {
    display: none;
}

.ara-detail-loading {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.ara-detail-content {
    padding: 1rem 1.5rem;
}

.ara-detail-table-wrapper {
    max-height: 350px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

.ara-detail-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8rem;
}

/* Clickable invoice number link in detail tables */
.invoice-link {
    color: #22c55e;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 500;
    white-space: nowrap;
}

.invoice-link:hover {
    color: #4ade80;
    text-decoration: none;
}

.ara-detail-table thead {
    position: sticky;
    top: 0;
    z-index: 9;
    background-color: #e0e0e0;
}

.ara-detail-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #e0e0e0;
    background-image: none;
    opacity: 1;
    padding: 0.4rem 0.6rem;
    text-align: right;
    font-weight: 600;
    font-size: 0.7rem;
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 0 -1px var(--border);
}

.ara-detail-table thead th:first-child,
.ara-detail-table thead th:nth-child(2),
.ara-detail-table thead th:nth-child(3) {
    text-align: left;
}

.ara-detail-table td {
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: right;
}

.ara-detail-table td:first-child,
.ara-detail-table td:nth-child(2),
.ara-detail-table td:nth-child(3) {
    text-align: left;
}

.ara-detail-table tbody tr:hover {
    background-color: var(--bg-secondary);
}

.ara-detail-table tfoot td {
    position: relative;
    z-index: 1;
    background-color: var(--bg-primary);
    padding: 0.5rem 0.6rem;
    font-weight: 600;
    border-top: 2px solid var(--border);
    box-shadow: none;
}

.summary-note {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.filter-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.hint-info {
    background: #e0f2fe;
    border: 1px solid #0284c7;
    color: #0369a1;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Filter Card */
.filter-card {
    margin-bottom: 2rem;
}

.filter-card h3 {
    margin-top: 0;
}

/* Extended Report Filter */
.report-filter-extended {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.report-filter-extended .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.report-filter-extended .filter-row label {
    font-weight: 500;
    margin-right: 0.25rem;
}

.report-filter-extended .filter-row select {
    min-width: 180px;
}

.report-filter-extended .filter-actions {
    padding-top: 0.5rem;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    align-items: end;
}

/* Deckungsbeitrag Filter Grid - horizontal layout */
.filter-grid-db {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-grid-db .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-grid-db .filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}

.filter-grid-db .filter-group input,
.filter-grid-db .filter-group select {
    min-width: 160px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.filter-grid-db .filter-actions {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

/* Lagerbestand Filter - Single Row Layout */
.filter-row-inline {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.75rem;
    align-items: center;
}

.filter-row-inline label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
    white-space: nowrap;
}

.filter-row-inline input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 140px;
}

.filter-row-inline select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 120px;
    max-width: 180px;
}

/* ===== Searchable Select ===== */
.searchable-select {
    position: relative;
    display: inline-block;
    min-width: 160px;
    max-width: 220px;
}
.searchable-select-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
    cursor: text;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
    padding-right: 1.8rem;
}
.searchable-select-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.searchable-select-list {
    display: none;
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    z-index: 9000;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    max-height: 240px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}
.searchable-select-list.open {
    display: block;
}
.searchable-select-option {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}
.searchable-select-option:hover {
    background: #eff6ff;
}
.searchable-select-option.selected {
    background: #dbeafe;
    font-weight: 500;
}

.filter-row-inline button {
    white-space: nowrap;
}

/* Lagerbestand Filter Grid (legacy) */
.filter-grid-stock {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-grid-stock .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-grid-stock .filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}

.filter-grid-stock .filter-group input {
    min-width: 180px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.filter-actions-inline {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-actions-inline .button-group {
    display: flex;
    gap: 0.5rem;
}

/* Gemeinsames Filter-Grid für ARA, ERA, Intrastat Reports */
.filter-grid-report {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-grid-report .filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-grid-report .filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
}

.filter-grid-report .filter-group input {
    min-width: 160px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.classify-filter-grid {
    grid-template-columns: repeat(3, 1fr);
}

.classify-filter-grid .form-group {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

.classify-filter-grid .form-group input[type="text"],
.classify-filter-grid .form-group input[type="number"],
.classify-filter-grid .form-group select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #fff;
    box-sizing: border-box;
}

.classify-filter-grid .form-group input[type="text"]:focus,
.classify-filter-grid .form-group input[type="number"]:focus,
.classify-filter-grid .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}

.form-group-checkbox {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0.125rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.filter-actions-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

.preview-count {
    font-weight: 500;
    color: var(--primary);
}

.action-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#classify-result .alert {
    margin-top: 1rem;
}

#classify-result .alert.success {
    border-color: var(--success);
    background-color: rgba(34, 197, 94, 0.1);
}

#classify-result .alert.error {
    border-color: var(--error);
    background-color: rgba(239, 68, 68, 0.1);
}

#gross-fix-result .alert {
    margin-top: 1rem;
}

#gross-fix-result .alert.success {
    border-color: var(--success);
    background-color: rgba(34, 197, 94, 0.1);
}

#gross-fix-result .alert.error {
    border-color: var(--error);
    background-color: rgba(239, 68, 68, 0.1);
}

.gross-fix-table-wrapper {
    margin-top: 1rem;
    max-height: 260px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.gross-fix-table {
    border-collapse: separate;
    border-spacing: 0;
}

.gross-fix-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #e0e0e0;
}

select {
    display: block;
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
}

input[type="date"] {
    display: block;
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

/* Cards & Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stats-grid-large {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stats-grid-3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stats-grid-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

.stats-grid-5 .stat-card {
    padding: 1rem;
}

.stats-grid-5 .stat-number {
    font-size: 1.2rem;
}

.stats-grid-6 {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
}

.stats-grid-6 .stat-card {
    padding: 0.75rem;
}

.stats-grid-6 .stat-number {
    font-size: 1.1rem;
}

.stats-grid-6 .stat-card h4 {
    font-size: 0.7rem;
}

.stats-grid-7 {
    grid-template-columns: repeat(7, 1fr);
    gap: 0.75rem;
}

.stats-grid-7 .stat-card {
    padding: 0.75rem;
}

.stats-grid-7 .stat-number {
    font-size: 1.1rem;
}

.stats-grid-7 .stat-card h4 {
    font-size: 0.65rem;
}

.stats-grid-8 {
    grid-template-columns: repeat(8, 1fr);
    gap: 0.6rem;
}

.stats-grid-8 .stat-card {
    padding: 0.6rem;
}

.stats-grid-8 .stat-number {
    font-size: 1rem;
}

.stats-grid-8 .stat-card h4 {
    font-size: 0.6rem;
}

.stats-grid-4 .stat-card {
    padding: 1rem;
}

.stats-grid-4 .stat-number {
    font-size: 1.25rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
}

.stat-card h4 {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-sub {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

/* Charts */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    max-height: 350px;
    display: flex;
    flex-direction: column;
}

.chart-card h4 {
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.chart-card canvas {
    max-height: 250px !important;
    width: 100% !important;
}

/* Stock Report Charts - larger for horizontal bar charts with many items */
.stock-tab-content .chart-card {
    min-height: 600px;
    max-height: none;
}

.stock-tab-content .chart-card canvas {
    flex: 1;
    min-height: 500px !important;
    max-height: none !important;
}

.chart-wide {
    grid-column: span 2;
    min-height: 350px;
    max-height: none;
}

.chart-wide canvas {
    min-height: 300px !important;
    max-height: 450px !important;
}

/* Timeseries and Comparison Charts */
.timeseries-chart-container,
.comparison-chart-container {
    background: var(--card-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border);
    min-height: 400px;
    max-height: 500px;
    position: relative;
}

.timeseries-chart-container canvas,
.comparison-chart-container canvas {
    min-height: 350px !important;
    max-height: 450px !important;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
    border-radius: 0.5rem;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay span {
    color: #64748b;
    font-size: 0.9rem;
}

/* Positive/Negative change indicators */
.positive-change {
    color: #16a34a;
    font-weight: 600;
}

.negative-change {
    color: #dc2626;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
}

.form-row .form-group-btn {
    flex: 0 0 auto;
}

input[type="file"], input[type="number"] {
    display: block;
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

button {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--primary-hover);
}

.btn {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    text-decoration: none;
}

.btn:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--text-muted);
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: #dc2626;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

/* Checkbox Label Style */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.5rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    cursor: pointer;
}

button.secondary {
    background-color: var(--text-muted);
}

button.secondary:hover {
    background-color: #475569;
}

button.danger {
    background-color: var(--error);
}

button.danger:hover {
    background-color: #b91c1c;
}

button:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
}

/* Progress Bar */
.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

#import-progress-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
}

#import-progress-message {
    color: var(--primary);
    font-weight: 600;
}

#import-progress-percent {
    color: var(--text);
    font-weight: 700;
    font-size: 1rem;
}

#import-progress-count {
    font-weight: 600;
    color: var(--text);
}

.progress-bar-bg {
    height: 16px;
    background-color: var(--bg-main);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}

#progress-bar-fill, #import-progress-bar-fill, #inbound-progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 8px;
}

#import-progress-bar-fill, #inbound-progress-bar-fill {
    background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 50%, var(--primary) 100%);
    background-size: 200% 100%;
    animation: progressPulse 1.5s ease-in-out infinite;
}

#progress-bar-fill.animated {
    background: linear-gradient(90deg, var(--primary) 0%, #60a5fa 50%, var(--primary) 100%);
    background-size: 200% 100%;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-details {
    font-size: 0.875rem;
    color: var(--text);
    text-align: center;
    margin-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-cancel {
    background: #dc2626;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.btn-cancel:hover {
    background: #b91c1c;
}

/* Reports Grid */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.report-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.report-actions input {
    width: 100px;
}

.alert {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.alert.success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Classification Result Detail */
.classification-result-detail {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.result-section {
    background: rgba(255,255,255,0.5);
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid rgba(0,0,0,0.05);
}

.result-section h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.result-section .field-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.result-section .field-label {
    color: var(--text-muted);
}

.result-section .field-value {
    font-weight: 500;
}

.result-section .field-value.yes {
    color: var(--success);
}

.result-section .field-value.no {
    color: var(--text-muted);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.result-header h4 {
    margin: 0;
}

.confidence-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.confidence-badge.high {
    background: #dcfce7;
    color: #166534;
}

.confidence-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-badge.low {
    background: #fecaca;
    color: #991b1b;
}

.reasoning-text {
    margin-top: 1rem;
    padding: 0.75rem;
    background: rgba(0,0,0,0.03);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Klassifizierungs-Protokoll */
#classify-log-container {
    margin-top: 1rem;
}

#classify-log-container h4 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.classify-log {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.8rem;
}

.log-entry {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry.success {
    background: #f0fdf4;
    border-left: 3px solid #22c55e;
}

.log-entry.error {
    background: #fef2f2;
    border-left: 3px solid #ef4444;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.log-artikelnummer {
    font-weight: 600;
    color: var(--primary);
}

.log-bezeichnung {
    flex: 1;
    color: #64748b;
    font-size: 0.85rem;
    margin-left: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.log-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.log-status.success {
    background: #dcfce7;
    color: #166534;
}

.log-status.error {
    background: #fee2e2;
    color: #991b1b;
}

.log-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
}

.log-detail-item {
    display: flex;
    gap: 0.25rem;
}

.log-detail-label {
    color: #94a3b8;
}

.log-reasoning {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #64748b;
    background: #fff;
    padding: 0.5rem;
    border-radius: 4px;
    max-height: 60px;
    overflow-y: auto;
}

/* Tables */
.tables-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.table-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-card.full-width {
    max-height: 800px;
    overflow-y: auto;
    overflow-x: hidden;
}

.table-card h4 {
    margin-bottom: 1rem;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.table-header-row h4 {
    margin: 0;
}

.excel-export-btn {
    background-color: #22c55e;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background-color 0.2s;
}

.excel-export-btn:hover {
    background-color: #16a34a;
}

/* Executive Summary / Management Dashboard */
.executive-summary {
    background: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.executive-summary h4 {
    color: var(--text-main);
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.executive-summary .stat-card {
    background: #f8fafc;
    border: 1px solid var(--border);
}

.executive-summary .stat-card h4 {
    color: var(--text-muted);
}

.executive-summary .stat-number {
    color: var(--text-main);
}

.executive-summary .stat-sub {
    color: var(--text-muted);
}

.executive-summary .stat-card.highlight {
    background: #dcfce7;
    border-color: #22c55e;
}

.executive-summary .stat-card.highlight .stat-number {
    color: #15803d;
}

.executive-summary .stat-card.highlight h4 {
    color: #166534;
}

/* Alerts Card */
.alerts-card {
    background: #fef3c7;
    border: 1px solid #f59e0b;
}

.alerts-card h4 {
    color: #92400e;
}

.alerts-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    flex-wrap: wrap;
}

.alert-item .alert-text {
    flex: 1;
}

.alert-item .alert-action-btn {
    margin-left: auto;
    white-space: nowrap;
}

.alert-item.warning {
    background: #fff7ed;
    border: 1px solid #fb923c;
    color: #9a3412;
}

.alert-item.danger {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #991b1b;
}

.alert-item.info {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    color: #1e40af;
}

.alert-icon {
    font-size: 1.2rem;
}

/* Two Column Grid */
.two-column-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .two-column-grid {
        grid-template-columns: 1fr;
    }
}

/* Compact Table */
.data-table.compact {
    font-size: 0.85rem;
}

.data-table.compact th,
.data-table.compact td {
    padding: 0.5rem 0.75rem;
}

.data-table.compact .btn-small {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
}

/* Progress bar in table */
.progress-bar-mini {
    width: 100%;
    height: 8px;
    background-color: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-mini-fill {
    height: 100%;
    background-color: var(--success);
    border-radius: 4px;
    transition: width 0.3s ease;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table thead th {
    text-align: left;
    padding: 0.75rem 0.5rem;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
}

/* Sortable table headers */
table.sortable thead th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.5rem;
}

table.sortable thead th[data-sort]:hover {
    background: #f1f5f9;
}

table.sortable thead th[data-sort]::after {
    content: '⇅';
    position: absolute;
    right: 0.25rem;
    opacity: 0.3;
    font-size: 0.7rem;
}

table.sortable thead th[data-sort].sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--primary);
}

table.sortable thead th[data-sort].sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--primary);
}

table tbody td {
    padding: 0.625rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

table tbody tr:hover {
    background-color: var(--bg-main);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* Clickable Stat Cards */
.stat-card.clickable {
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: var(--primary);
}

/* Section Description */
.section-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    margin-top: -0.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #ffffff;
    border-radius: 0.75rem;
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    border: 1px solid #e2e8f0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.modal-header h3 {
    margin: 0;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: #1e293b;
    background: #e2e8f0;
    border-radius: 4px;
}

.modal-search {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.modal-search input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: #ffffff;
    color: #1e293b;
}

.modal-search input::placeholder {
    color: #94a3b8;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    background: #ffffff;
}

.modal-body table {
    margin: 0;
    background: #ffffff;
}

.modal-body table thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
    color: #475569;
    z-index: 1;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
}

.modal-body table tbody td {
    background: #ffffff;
    color: #1e293b !important;
    border-bottom: 1px solid #f1f5f9;
    padding: 0.75rem 1rem;
}

.modal-body table tbody tr td {
    color: #1e293b !important;
}

.modal-body table tbody tr:hover td {
    background: #f8fafc;
    color: #1e293b !important;
}

/* Ensure article row text is visible in modals */
.modal-body .article-row td {
    color: #1e293b !important;
    background: #ffffff !important;
}

.modal-body .article-row:hover td {
    color: #1e293b !important;
    background: #f8fafc !important;
}

.modal-body .article-row.selected td {
    color: #1e293b !important;
    background: #e0e7ff !important;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: center;
    background: #ffffff;
    color: #64748b;
}

.modal-footer.modal-buttons {
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-small {
    max-width: 450px;
}

.modal-small .modal-body {
    padding: 1.5rem;
}

.modal-small .modal-body p {
    margin: 0;
    white-space: pre-line;
    line-height: 1.6;
}

/* Alert/Confirm Modal Icons */
.modal-icon {
    text-align: center;
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-icon.warning {
    color: var(--warning);
}

.modal-icon.error {
    color: var(--error);
}

.modal-icon.success {
    color: var(--success);
}

.modal-icon.info {
    color: var(--primary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pagination button {
    padding: 0.5rem 1rem;
}

#page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

.badge.warning {
    background: #fef3c7;
    color: #92400e;
}

.badge.info {
    background: #dbeafe;
    color: #1e40af;
}

/* Report Styles */
.report-filter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
}

.report-filter label {
    font-weight: 500;
    white-space: nowrap;
}

.report-filter input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.9rem;
}

.report-filter input[type="number"] {
    width: 100px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.report-filter button {
    white-space: nowrap;
}

.report-filter select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.9rem;
    background: white;
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
    color: white;
}

.stat-card.highlight h4 {
    color: rgba(255,255,255,0.9);
}

.stat-card.highlight small {
    color: rgba(255,255,255,0.7);
}

.total-row {
    background-color: #f1f5f9;
    font-weight: 600;
}

.total-row td {
    border-top: 2px solid var(--border);
}

.no-data-message {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--card-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border);
}

.table-scroll {
    max-height: 500px;
    overflow-y: auto;
}

.table-scroll table {
    width: 100%;
}

.table-scroll thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

/* Margin colors */
.positive {
    color: var(--success);
    font-weight: 600;
}

.negative {
    color: var(--error);
    font-weight: 600;
}

.muted {
    color: var(--text-muted);
}

.no-margin {
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive */
@media (max-width: 1200px) {
    .tables-container,
    .charts-container {
        grid-template-columns: 1fr;
    }
    
    .chart-wide {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .report-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .report-filter input[type="number"] {
        width: 100%;
    }
}

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.scroll-to-top:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Article Details in List */
.article-row {
    transition: background-color 0.2s ease;
}

.article-row[style*="cursor: pointer"]:hover:not(.selected) {
    background-color: var(--bg-secondary) !important;
}

.article-row.selected {
    background-color: var(--primary) !important;
    color: white;
}

.article-row.selected td {
    color: white;
}

.article-row.selected .badge {
    border-color: white;
}

.article-detail-row {
    background-color: var(--bg-tertiary) !important;
    transition: all 0.3s ease;
}

.article-detail-row.hidden {
    display: none;
}

.article-details-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.article-details-loading,
.article-details-error {
    padding: 2rem;
    text-align: center;
    color: var(--text-light);
}

.article-details-error {
    color: var(--danger);
}

.details-section {
    background-color: var(--bg);
    border-radius: 8px;
    padding: 1rem;
}

.details-section h5 {
    margin: 0 0 1rem 0;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.75rem;
}

.detail-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    font-size: 0.9rem;
}

.detail-label {
    font-weight: 600;
    color: var(--text);
    margin-right: 0.5rem;
    min-width: 140px;
}

.detail-item .badge {
    margin-left: auto;
}

.details-section .reasoning-text {
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ==================== MODAL STYLES ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
}

.modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    border: 1px solid #e2e8f0;
}

.modal-large {
    width: 90%;
    max-width: 1100px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: #1e293b;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    background: #ffffff;
    color: #1e293b;
}

.modal-article-info {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    color: #1e293b;
    border: 1px solid #e2e8f0;
}

.modal-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-card {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    color: #1e293b;
}

.summary-card h5 {
    margin: 0 0 0.75rem 0;
    color: #64748b;
    font-size: 0.9rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #1e293b;
}

.summary-card.highlight {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: #ffffff;
    border: none;
}

.summary-card.highlight h5 {
    color: #ffffff;
}

.summary-card.highlight .summary-row {
    color: #ffffff;
}

.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
}

.modal-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    color: #64748b;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.modal-tab:hover {
    color: #1e293b;
}

.modal-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 500;
}

.modal-tab-content {
    display: block;
    background: #ffffff;
}

.modal-tab-content.hidden {
    display: none;
}

/* Modal Tabellen */
.modal-tab-content .data-table {
    background: #ffffff;
}

.modal-tab-content .data-table th {
    background: #f1f5f9;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}

.modal-tab-content .data-table td {
    background: #ffffff;
    color: #1e293b;
    border-bottom: 1px solid #f1f5f9;
}

.modal-tab-content .data-table tr:hover td {
    background: #f8fafc;
}

/* Klickbare Zeilen im Modal */
.clickable-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.clickable-row:hover {
    background: #f1f5f9 !important;
}

.clickable-row:hover td {
    background: inherit !important;
}

/* Invoice Summary Grid mit 2 Spalten */
.invoice-summary {
    grid-template-columns: repeat(2, 1fr) !important;
}

@media (max-width: 768px) {
    .modal-summary {
        grid-template-columns: 1fr;
    }
    
    .modal-article-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .invoice-summary {
        grid-template-columns: 1fr !important;
    }
}
/* Autocomplete Suggestions */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.autocomplete-suggestions.hidden {
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover {
    background: var(--bg-main);
}

/* Form Group mit relativer Positionierung für Autocomplete */
.form-group {
    position: relative;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Section Header mit Titel und Button */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h4 {
    margin: 0;
}

/* Filter Row Styles */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 200px;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
    min-width: 200px;
}

.filter-group input[type="text"] {
    min-width: 280px;
}

.filter-row .btn {
    align-self: flex-end;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 1rem 0;
}

#stock-page-info {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Stock Modal Dark Theme */
#stock-modal .modal-content {
    max-width: 600px;
}

#stock-modal .form-group input[readonly] {
    background: #f1f5f9;
    color: var(--text-muted);
}

/* Header Buttons Container */
.header-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Import Panel Styles */
.import-panel {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.import-panel h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.import-panel .import-info {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.import-form .form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.import-form .form-group {
    flex: 1;
    min-width: 200px;
}

.import-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.import-form .form-group input[type="date"],
.import-form .form-group input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 0.875rem;
}

.import-form .checkbox-group {
    display: flex;
    align-items: center;
}

.import-form .checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: normal;
}

.import-form .form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

.import-progress {
    margin-top: 1rem;
}

.import-progress .progress-bar {
    width: 100%;
    height: 12px;
    background: #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.import-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.import-progress p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 41, 59, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 8px;
    min-height: 200px;
}

.loading-overlay.hidden {
    display: none;
}

.loading-overlay p {
    color: #fff;
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#stock-report-content {
    position: relative;
}

/* Stock Comparison Styles */
.comparison-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.comparison-header .date-label {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1.1rem;
}

.comparison-header .vs-label {
    color: var(--text-muted);
    font-size: 1.5rem;
}

.comparison-values {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.comparison-values .arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.comparison-values .stat-sub {
    color: #475569;
    font-weight: 500;
}

.stat-change {
    font-size: 0.875rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.stat-change.positive {
    color: #15803d;
}

.stat-change.negative {
    color: #b91c1c;
}

.data-table td.positive {
    color: #15803d;
    font-weight: 500;
}

.data-table td.negative {
    color: #b91c1c;
    font-weight: 500;
}

/* =============================================
   EINSTELLUNGEN / SETTINGS PAGE
   ============================================= */

.settings-header {
    margin-bottom: 1.5rem;
}

.settings-header h2 {
    margin-bottom: 0.25rem;
}

/* Provider Selector */
.provider-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 0.5rem;
}

.provider-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-main);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    color: var(--text-main);
}

.provider-btn:hover {
    border-color: var(--primary);
    background: #eff6ff;
    color: var(--text-main);
}

.provider-btn.active {
    border-color: var(--primary);
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.provider-btn-icon {
    font-size: 1.75rem;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.provider-btn-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
}

.provider-btn-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Provider panels */
.settings-provider-panel {
    transition: opacity 0.2s;
}

.settings-provider-panel.inactive {
    opacity: 0.4;
    pointer-events: none;
}

.settings-panel-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.settings-panel-icon {
    font-size: 2rem;
    line-height: 1;
}

/* Settings field layouts */
.settings-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.settings-three-col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.5rem;
}

.settings-field-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.settings-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.settings-text-input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.15s;
}

.settings-text-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* API Key row */
.settings-key-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.key-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.3rem 0.75rem;
    border-radius: 99px;
    align-self: flex-start;
}

.key-status-badge.configured {
    background: #dcfce7;
    color: #15803d;
}

.key-status-badge.missing {
    background: #fef3c7;
    color: #92400e;
}

/* Model row */
.settings-model-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.settings-select {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: white;
    transition: border-color 0.15s;
    min-width: 0;
}

.settings-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.settings-load-btn {
    flex-shrink: 0;
    padding: 0.625rem 1rem;
    background: white;
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.settings-load-btn:hover {
    background: var(--primary);
    color: white;
}

.settings-load-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: white;
    color: var(--text-muted);
    border-color: var(--border);
}

.settings-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-height: 1rem;
}

/* Additional Prompt textarea */
.settings-prompt-textarea {
    display: block;
    width: 100%;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-family: 'Inter', -apple-system, sans-serif;
    resize: vertical;
    line-height: 1.6;
    background: white;
    transition: border-color 0.15s;
    margin-top: 1rem;
}

.settings-prompt-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Settings footer */
.settings-footer {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.settings-save-btn {
    padding: 0.875rem 2rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 0.625rem;
}

.settings-save-feedback {
    flex: 1;
}

.settings-save-feedback .alert {
    margin: 0;
}

.settings-save-feedback .alert.success {
    border-color: var(--success);
    background: #f0fdf4;
    color: #15803d;
}

.settings-save-feedback .alert.error {
    border-color: var(--error);
    background: #fef2f2;
    color: #991b1b;
}

@media (max-width: 900px) {
    .provider-selector { grid-template-columns: 1fr; }
    .settings-two-col,
    .settings-three-col { grid-template-columns: 1fr; }
}

/* ═══════════════════════ AI CHAT WINDOW ═══════════════════════════════════ */

#open-ai-chat-btn {
    display: block;
    width: calc(100% - 2rem);
    margin: 0.75rem 1rem 0.75rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.02em;
    transition: opacity 0.15s;
}
#open-ai-chat-btn:hover { opacity: 0.9; }

/* Button group for KI + History */
.ai-btn-group {
    display: flex;
    gap: 0.4rem;
    margin: 0.75rem 1rem 0.75rem;
}
.ai-btn-group #open-ai-chat-btn {
    display: block;
    flex: 1;
    width: auto;
    margin: 0;
}
.ai-history-btn {
    flex-shrink: 0;
    padding: 0.6rem 0.75rem;
    background: #374151;
    color: #d1d5db;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}
.ai-history-btn:hover { background: #4b5563; }

/* ─── Chat History Panel ────────────────────────────────────── */
.chat-history-panel {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 360px;
    max-height: 540px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    z-index: 8900;
    overflow: hidden;
}
.chat-history-panel.hidden { display: none; }

.chat-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.chat-history-list {
    overflow-y: auto;
    flex: 1;
    padding: 0.5rem;
}

.chat-history-loading {
    padding: 1.5rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.85rem;
}

.chat-history-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.9rem;
}

.chat-history-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    border-radius: 8px;
    margin-bottom: 0.4rem;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: border-color 0.15s;
}
.chat-history-item:hover { border-color: #2563eb; }

.chat-history-load {
    flex: 1;
    padding: 0.6rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}
.chat-history-load:hover { background: #eff6ff; }

.chat-history-item-title {
    font-size: 0.84rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 230px;
}

.chat-history-item-meta {
    font-size: 0.74rem;
    color: #6b7280;
    margin-top: 0.2rem;
}

.chat-history-delete {
    flex-shrink: 0;
    padding: 0 0.65rem;
    background: none;
    border: none;
    border-left: 1px solid #e5e7eb;
    cursor: pointer;
    color: #9ca3af;
    font-size: 1rem;
    transition: color 0.12s, background 0.12s;
}
.chat-history-delete:hover { color: #ef4444; background: #fef2f2; }


.ai-chat-window {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9000;
    min-width: 320px;
    min-height: 300px;
    user-select: none;
}
.ai-chat-window.hidden { display: none; }

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem 0.85rem;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    color: #ffffff;
    cursor: grab;
    flex-shrink: 0;
    border-radius: 12px 12px 0 0;
}
.ai-chat-header:active { cursor: grabbing; }

/* Conversation title bar (shows AI-set title, outside scroll area) */
.ai-chat-conv-title-bar {
    display: flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    background: #eef2f7;
    border-bottom: 1px solid #dde3ec;
    flex-shrink: 0;
    min-height: 1.6rem;
}
.ai-chat-conv-title-bar.hidden { display: none; }
.ai-chat-conv-title-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: #4a6a8a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.ai-chat-icon { font-size: 1.1rem; }
.ai-chat-status {
    font-size: 0.72rem;
    font-weight: 400;
    opacity: 0.75;
    min-width: 3.5rem;
}
.ai-chat-status--error { color: #fca5a5; }
.ai-chat-header-actions { display: flex; gap: 0.3rem; }
.ai-chat-action-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0.25rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s;
}
.ai-chat-action-btn:hover { background: rgba(255,255,255,0.2); color: #ffffff; }

/* Messages */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: #f8fafc;
    user-select: text;
}

/* Message bubbles */
.ai-chat-msg {
    max-width: 88%;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
}
.ai-chat-msg--user {
    align-self: flex-end;
    background: #2563eb;
    color: #ffffff;
    border-bottom-right-radius: 3px;
}
.ai-chat-msg--assistant {
    align-self: flex-start;
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 3px;
    max-width: 96%;
}
.ai-chat-msg--assistant p { margin: 0 0 0.4rem; }
.ai-chat-msg--assistant p:last-child { margin-bottom: 0; }
.ai-chat-msg--assistant h2,
.ai-chat-msg--assistant h3,
.ai-chat-msg--assistant h4 {
    margin: 0.6rem 0 0.3rem;
    color: #1e3a5f;
    font-size: 0.9rem;
}
.ai-chat-msg--assistant h5,
.ai-chat-msg--assistant h6 {
    margin: 0.4rem 0 0.2rem;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 600;
}
.ai-chat-msg--assistant ul,
.ai-chat-msg--assistant ol { margin: 0.3rem 0 0.3rem 1.2rem; padding: 0; }
.ai-chat-msg--assistant li { margin-bottom: 0.2rem; }
.ai-chat-msg--assistant hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0.6rem 0;
}
.ai-chat-msg--assistant code {
    background: #f1f5f9;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.82rem;
}
.ai-chat-msg--error {
    align-self: center;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 0.82rem;
}
/* ─── Comic Thought Bubble ──────────────────────────────────────────────── */
.ai-chat-think-bubble {
    position: relative;
    align-self: flex-start;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 22px;
    padding: 0.6rem 1.15rem;
    margin-left: 8px;
    margin-bottom: 24px;
    max-width: 85%;
    box-shadow: 0 3px 12px rgba(0,0,0,0.08);
    animation: thinkFloat 3s ease-in-out infinite;
}
.ai-chat-think-bubble--leaving {
    animation: thinkDisappear 0.38s ease forwards !important;
}
.ai-chat-think-puff {
    position: absolute;
    background: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
}
.ai-chat-think-puff--1 { width: 12px; height: 12px; bottom: -18px; left: 26px; }
.ai-chat-think-puff--2 { width: 7px;  height: 7px;  bottom: -28px; left: 18px; }
.ai-chat-think-content {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 1.3em;
}
.ai-chat-think-text {
    font-size: 0.84rem;
    color: #64748b;
    font-style: italic;
    transition: opacity 0.2s ease;
}
.ai-chat-think-text--fading { opacity: 0; }
.ai-chat-think-dots span {
    display: inline-block;
    animation: chatDot 1.2s infinite;
    font-size: 1.3rem;
    line-height: 0.8;
    color: #94a3b8;
    letter-spacing: 0.05em;
}
.ai-chat-think-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-think-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatDot {
    0%, 80%, 100% { opacity: 0.2; transform: translateY(0); }
    40%            { opacity: 1;   transform: translateY(-3px); }
}
@keyframes thinkFloat {
    0%, 100% { transform: translateY(0px); }
    50%      { transform: translateY(-4px); }
}
@keyframes thinkDisappear {
    0%   { opacity: 1; transform: scale(1) translateY(0); }
    100% { opacity: 0; transform: scale(0.88) translateY(-6px); }
}

/* Tool log */
.ai-chat-tool-log {
    align-self: flex-start;
    width: 100%;
    max-width: 96%;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: #475569;
    background: #f1f5f9;
    border-radius: 8px;
}

/* Table in assistant messages */
.ai-chat-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.8rem;
    margin: 0.4rem 0;
}
.ai-chat-table th, .ai-chat-table td {
    border: 1px solid #e2e8f0;
    padding: 0.3rem 0.5rem;
    text-align: left;
}
.ai-chat-table th { background: #f1f5f9; color: #1e3a5f; font-weight: 600; }
.ai-chat-table tr:nth-child(even) td { background: #f8fafc; }

/* Tool indicator */
.ai-chat-tool-indicator {
    padding: 0.3rem 1rem;
    font-size: 0.78rem;
    color: #2563eb;
    background: #eff6ff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.ai-chat-tool-indicator.hidden { display: none; }
.ai-chat-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid #bfdbfe;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Region fallback warning banner */
.ai-chat-warning {
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    color: #92400e;
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    line-height: 1.4;
}
.ai-chat-warning.hidden { display: none; }

/* Input area */
.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    max-height: 120px;
    line-height: 1.45;
    color: #1e293b;
    background: #f8fafc;
    outline: none;
    transition: border-color 0.15s;
}
.ai-chat-input:focus { border-color: #2563eb; background: #ffffff; }
.ai-chat-input:disabled { opacity: 0.6; }
.ai-chat-send-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.65rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    height: 36px;
    width: 36px;
}
.ai-chat-send-btn:hover:not(:disabled) { background: #1d4ed8; }
.ai-chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Resize handle */
.ai-chat-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 40%, #cbd5e1 40%, #cbd5e1 55%, transparent 55%, transparent 70%, #cbd5e1 70%);
    border-radius: 0 0 12px 0;
}

/* Welcome redesign */
.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1.25rem 1rem;
    gap: 0.35rem;
    text-align: center;
}
.ai-chat-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
    line-height: 1;
}
.ai-chat-welcome-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}
.ai-chat-welcome-desc {
    font-size: 0.82rem;
    color: #64748b;
    line-height: 1.5;
    max-width: 280px;
    margin-bottom: 0.5rem;
}

/* Suggestion chips */
.ai-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
    align-items: stretch;
    position: relative;
    padding-bottom: 2rem; /* space for refresh btn */
}
.ai-chat-suggestion-chip {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
    color: #1e293b;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    line-height: 1.4;
}
.ai-chat-suggestion-chip:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}
.ai-chat-suggestion-chip--pinned {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
    font-weight: 600;
    flex: 1 1 0;
    min-width: 0;
}
.ai-chat-suggestions-pinned-row {
    display: flex;
    flex-direction: row;
    gap: 0.4rem;
    width: 100%;
}
.ai-chat-suggestion-chip--pinned:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
}
.ai-chat-suggestion-refresh {
    position: absolute;
    bottom: 0;
    right: 0;
    background: none;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 0.95rem;
    cursor: pointer;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s, transform 0.25s;
    line-height: 1;
}
.ai-chat-suggestion-refresh:hover {
    color: #2563eb;
    border-color: #93c5fd;
    transform: rotate(180deg);
}

/* Mic button */
.ai-chat-mic-btn {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    height: 36px;
    width: 36px;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ai-chat-mic-btn:hover:not(:disabled) {
    background: #e2e8f0;
    color: #1e293b;
}
.ai-chat-mic-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.ai-chat-mic-btn--active {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
    color: #ffffff !important;
    animation: micPulse 1.2s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
    50%       { box-shadow: 0 0 0 6px rgba(220,38,38,0); }
}

/* Muted TTS button */
.ai-chat-action-btn--muted {
    opacity: 0.5;
}

/* Download button (appears inside assistant messages) */
.ai-chat-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0.4rem 0;
    padding: 0.45rem 1rem;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff !important;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: opacity 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.ai-chat-download-btn:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}
.ai-chat-ext-link {
    color: #2563eb;
    text-decoration: underline;
}

.ai-chat-msg--chart {
    background: none;
    box-shadow: none;
    max-width: 100%;
    padding: 0;
}
.ai-chat-chart-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.35rem;
    padding-left: 0.25rem;
}
.ai-chat-chart-wrapper {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.9rem 1rem 0.75rem;
    max-width: 100%;
}
.ai-chat-chart-wrapper canvas {
    max-height: 300px;
}

.stock-dates-panel {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem 1.25rem;
}
.stock-dates-panel h4 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
    color: #374151;
}
.stock-dates-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}
.stock-date-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.5rem 0.9rem;
    font-size: 0.875rem;
    color: #374151;
}
.stock-date-card .date-label {
    font-weight: 600;
    color: #1e3a5f;
}
.stock-date-card .date-meta {
    color: #6b7280;
    font-size: 0.8rem;
}
.stock-date-card .btn-delete-date {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}
.stock-date-card .btn-delete-date:hover {
    opacity: 1;
}

/* ──────────────────────────────────────────────
   Inventurdifferenzen
   ────────────────────────────────────────────── */

/* ──────────────────────────────────────────────
   Artikel Detail Modal
   ────────────────────────────────────────────── */
.modal-large {
    max-width: 900px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}
.modal-large .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.article-detail-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    padding: 0 1rem;
    background: var(--card-bg);
    flex-shrink: 0;
}
.ad-tab {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: color 0.2s, border-color 0.2s;
}
.ad-tab:hover {
    color: var(--text-color);
}
.ad-tab.active {
    color: #3b82f6;
    border-bottom-color: #3b82f6;
}
.article-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}
.ad-panel {
    display: block;
}
.ad-panel.hidden {
    display: none;
}
.ad-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.ad-info-card {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 1rem;
}
.ad-info-card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.ad-info-card .ad-field {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color);
}
.ad-info-card .ad-field:last-child {
    border-bottom: none;
}
.ad-info-card .ad-field .ad-label {
    color: var(--text-muted);
}
.ad-info-card .ad-field .ad-value {
    font-weight: 500;
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}
.ad-summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.ad-summary-item {
    background: var(--hover-bg);
    border-radius: 8px;
    padding: 0.75rem;
    text-align: center;
}
.ad-summary-item .ad-sum-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ad-summary-item .ad-sum-value {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.25rem;
}
.ad-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.ad-detail-table th {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 2px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
}
.ad-detail-table td {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.ad-detail-table tr:hover td {
    background: var(--hover-bg);
}
.ad-no-data {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-style: italic;
}

.stat-card.negative .stat-number {
    color: #ef4444;
}
#inventur-diff-table td.diff-negative {
    color: #ef4444;
    font-weight: 600;
}
#inventur-diff-table td.diff-positive {
    color: #16a34a;
    font-weight: 600;
}

/* ──────────────────────────────────────────────
   Kontrolldaten
   ────────────────────────────────────────────── */
.control-data-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: #f8fafc;
    transition: border-color 0.2s, background 0.2s;
    cursor: default;
}
.control-data-dropzone.dragging {
    border-color: #4f8ef7;
    background: #eff6ff;
}
.control-data-dropzone .dropzone-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.75rem;
}
.control-data-dropzone .dropzone-text {
    margin: 0 0 0.25rem;
    font-size: 1rem;
    color: #374151;
}
.control-data-dropzone .dropzone-hint {
    margin: 0;
    font-size: 0.82rem;
    color: #9ca3af;
}
.control-data-file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
}
.control-data-file-info .file-info-icon {
    font-size: 2rem;
    flex-shrink: 0;
}
.control-data-file-info .file-info-name {
    font-weight: 600;
    color: #1e3a5f;
    font-size: 0.95rem;
}
.control-data-file-info .file-info-detail {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 0.15rem;
}
.control-data-sheet-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}
.sheet-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.7rem;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    font-size: 0.78rem;
    color: #1e40af;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.sheet-chip:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}
.sheet-chip.active {
    background: #1e40af;
    border-color: #1e40af;
    color: #fff;
}
.sheet-chip.active .chip-rows {
    color: #bfdbfe;
}
.sheet-chip .chip-rows {
    color: #6b7280;
}
.btn-danger-outline {
    background: transparent;
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-danger-outline:hover {
    background: #fef2f2;
}

/* Kontrolldaten preview: two-directional scroll, compact font */
.kontrolldaten-preview-scroll {
    overflow: auto;
    max-height: 520px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    -webkit-overflow-scrolling: touch;
}
.kontrolldaten-preview-table {
    font-size: 0.72rem;
    line-height: 1.35;
    white-space: nowrap;
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}
.kontrolldaten-preview-table th,
.kontrolldaten-preview-table td {
    padding: 3px 8px;
    border: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}
.kontrolldaten-preview-table thead tr {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e3a5f;
    color: #fff;
}
.kontrolldaten-preview-table thead th {
    font-weight: 600;
    font-size: 0.70rem;
    letter-spacing: 0.02em;
    border-color: #2d4f7a;
    color: #fff;
}
.kontrolldaten-preview-table tbody tr:nth-child(even) {
    background: #f8fafc;
}
.kontrolldaten-preview-table tbody tr:hover {
    background: #eff6ff;
}
.kontrolldaten-preview-table td:empty::after {
    content: '\00a0';
}

/* ── IK Sync: Bezeichnungsänderungen ─────────────────────────── */
.upd-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.3rem 0.5rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
}
.upd-code {
    color: #2563eb;
    font-size: 0.85em;
    white-space: nowrap;
    min-width: 5.5rem;
    padding-top: 0.05rem;
}
.upd-changes {
    flex: 1;
    font-size: 0.8em;
    line-height: 1.55;
}
.upd-label { color: #6b7280; }
.upd-old   { color: #9ca3af; font-style: italic; }
.upd-arrow { color: #9ca3af; }
.upd-new   { color: #16a34a; }

/* =============================================
   ANMELDUNG, BENUTZER & RECHTE
   ============================================= */

/* Rechte: ohne Recht ausblenden (Body-Klassen setzt auth.js) */
body.ti-no-perm-import [data-permission~="tradeinsight.import"],
body.ti-no-perm-edit [data-permission~="tradeinsight.edit"],
body.ti-no-perm-classify [data-permission~="tradeinsight.classify"],
body.ti-no-perm-chat [data-permission~="tradeinsight.chat"],
body.ti-no-perm-settings [data-permission~="tradeinsight.settings"] {
    display: none !important;
}

/* Vor der Sitzungsprüfung und abgemeldet: keine App-Oberfläche */
body.ti-auth-pending .app-container,
body.ti-logged-out .app-container,
body.ti-logged-out #ai-chat-window,
body.ti-logged-out #chat-history-panel,
body.ti-logged-out .modal,
body.ti-auth-pending #ai-chat-window,
body.ti-auth-pending #chat-history-panel {
    display: none !important;
}

/* Anmeldemaske */
.login-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--sidebar) 0%, #0f172a 100%);
    overflow-y: auto;
}

body.ti-logged-out .login-screen {
    display: flex;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.login-logo {
    background: var(--sidebar);
    color: white;
    padding: 1.75rem 2rem 1.5rem;
    border-bottom: 3px solid var(--primary);
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
}

.login-logo p {
    color: #94a3b8;
    font-size: 0.875rem;
}

.login-form {
    padding: 1.75rem 2rem 1.25rem;
}

.login-intro {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    line-height: 1.5;
}

.login-form .form-group {
    margin-bottom: 1rem;
}

.login-form input[type="text"],
.login-form input[type="password"] {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.15s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.login-submit {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
}

.login-message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-line;
}

.login-message-error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.login-message-warning {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.login-message-info {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.login-footer {
    padding: 0.75rem 2rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Benutzer in der Seitenleiste */
.user-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: -1rem 0.5rem 1rem;
    padding: 0.6rem 0.75rem 0.6rem 1.5rem;
    background-color: #334155;
    border-radius: 8px;
    font-size: 0.85rem;
}

.user-box-icon {
    flex-shrink: 0;
}

.user-box-name {
    flex: 1;
    min-width: 0;
    color: #e2e8f0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-box-logout {
    flex-shrink: 0;
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    background-color: transparent;
    color: #cbd5e1;
    border: 1px solid #475569;
    border-radius: 0.375rem;
}

.user-box-logout:hover {
    background-color: var(--error);
    border-color: var(--error);
    color: white;
}

/* Hinweise (Toast) */
.ti-toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 11000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(420px, calc(100vw - 2rem));
    pointer-events: none;
}

.ti-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0.75rem 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.45;
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    pointer-events: auto;
    animation: tiToastIn 0.2s ease;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ti-toast-error { border-left-color: var(--error); }
.ti-toast-warning { border-left-color: var(--warning); }
.ti-toast-success { border-left-color: var(--success); }

.ti-toast-hide {
    opacity: 0;
    transform: translateX(1rem);
}

.ti-toast-text {
    flex: 1;
    white-space: pre-line;
}

.ti-toast-close {
    flex-shrink: 0;
    padding: 0 0.35rem;
    background: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
}

.ti-toast-close:hover {
    background: none;
    color: var(--text-main);
}

@keyframes tiToastIn {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   LETZTE IMPORTE
   ============================================= */

.import-runs-card {
    padding: 1.25rem 1.5rem;
}

.import-runs-card .table-header-row {
    margin-bottom: 0.75rem;
}

.import-runs-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.import-runs-actions select {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.import-runs-scroll {
    max-height: 320px;
    overflow: auto;
}

.import-runs-table th,
.import-runs-table td {
    white-space: nowrap;
}

.import-runs-table th.num,
.import-runs-table td.num {
    text-align: right;
}

.import-runs-table td.import-runs-file {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-runs-table .import-runs-message {
    display: block;
    max-width: 320px;
    margin-top: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: normal;
}

.import-runs-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 1rem !important;
}

.badge.error {
    background: #fee2e2;
    color: #991b1b;
}

/* =============================================
   EINSTELLUNGEN: Anbieter aus dem CMS
   ============================================= */

.settings-provider-status {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.settings-provider-status .settings-provider-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.settings-row-gap {
    margin-top: 1.5rem;
}

.settings-select option:disabled {
    color: #94a3b8;
}

.settings-hint.warning {
    color: #b45309;
}
