:root {
    --primary: #1a365d;
    --primary-light: #2d4a7c;
    --accent: #e53e3e;
    --bg: #f7fafc;
    --card: #ffffff;
    --text: #2d3748;
    --text-light: #718096;
    --border: #e2e8f0;
    --success: #38a169;
    --warning: #d69e2e;
    --danger: #e53e3e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.5;
}

/* Navigation */
nav {
    background: var(--primary); color: white; padding: 0.75rem 1.5rem;
    display: flex; align-items: center; gap: 2rem;
}
nav .brand { font-weight: 700; font-size: 1.1rem; }
nav a { color: rgba(255,255,255,0.7); text-decoration: none; font-size: 0.9rem;
    padding: 0.3rem 0.6rem; border-radius: 4px; transition: all 0.2s; }
nav a:hover, nav a.active { color: white; background: rgba(255,255,255,0.15); }
nav .spacer { flex: 1; }
nav .nav-user { font-size: 0.85rem; color: rgba(255,255,255,0.7); }
.btn-nav {
    background: transparent; color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.3);
    padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.8rem; cursor: pointer;
    transition: all 0.2s;
}
.btn-nav:hover { color: white; border-color: white; }

/* Layout */
.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }

/* Cards */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 8px; padding: 1.25rem; margin-bottom: 1rem;
}
.card h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: var(--primary); }

/* Summary Cards */
.summary-grid {
    display: grid; gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1.5rem;
}
.summary-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 8px; padding: 1.25rem;
}
.summary-card.highlight {
    border-left: 4px solid var(--primary);
}
.summary-card.warn {
    border-left: 4px solid var(--warning);
}
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-value.large { font-size: 2rem; }
.stat-label { font-size: 0.85rem; color: var(--text-light); margin-top: 0.25rem; }

/* Toolbar */
.toolbar {
    display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem;
    flex-wrap: wrap;
}
.toolbar select {
    padding: 0.4rem 0.6rem; border: 1px solid var(--border); border-radius: 4px;
    font-size: 0.9rem; background: white;
}
.toolbar label { font-size: 0.9rem; color: var(--text-light); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th {
    text-align: left; padding: 0.6rem 0.5rem; border-bottom: 2px solid var(--border);
    color: var(--text-light); font-weight: 600; white-space: nowrap;
    cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
th .sort-arrow { font-size: 0.7rem; margin-left: 0.3rem; }
td { padding: 0.5rem; border-bottom: 1px solid var(--border); }
tr:hover { background: #edf2f7; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-light); }
.text-nowrap { white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px;
    font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-open { background: #fefcbf; color: #975a16; }
.badge-sent { background: #bee3f8; color: #2a4365; }
.badge-partial { background: #feebc8; color: #7b341e; }
.badge-delivered { background: #c6f6d5; color: #276749; }
.badge-cancelled { background: #e2e8f0; color: #4a5568; }

/* Detail-Rows */
.detail-row { display: none; }
.detail-row.open { display: table-row; }
.detail-row td { padding: 0; background: #f7fafc; }
.detail-table { width: 100%; font-size: 0.85rem; margin: 0; }
.detail-table th { border-bottom: 1px solid var(--border); font-size: 0.8rem; padding: 0.4rem 0.5rem; }
.detail-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #edf2f7; }
.toggle-btn {
    background: none; border: none; cursor: pointer; font-size: 1rem;
    color: var(--text-light); padding: 0.2rem; transition: transform 0.2s;
}
.toggle-btn.open { transform: rotate(90deg); }

/* Buttons */
.btn {
    display: inline-block; padding: 0.5rem 1rem; border-radius: 6px;
    font-size: 0.9rem; font-weight: 500; cursor: pointer; border: none;
    text-decoration: none; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-outline {
    background: white; color: var(--primary); border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--primary); }

/* Inputs */
input[type="text"], input[type="password"], select {
    padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px;
    font-size: 0.9rem; width: 100%;
}

/* Flash Messages */
.flash { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash-error { background: #fed7d7; color: #9b2c2c; }
.flash-success { background: #c6f6d5; color: #276749; }
.flash-info { background: #bee3f8; color: #2a4365; }
.flash-warning { background: #fefcbf; color: #975a16; }

/* Cache Info */
.cache-info {
    font-size: 0.8rem; color: var(--text-light);
    display: flex; align-items: center; gap: 0.5rem;
}

/* Lieferanten-Übersicht */
.supplier-table { margin-top: 1.5rem; }
.supplier-table .supplier-total { font-weight: 700; background: #edf2f7; }

/* Error Box */
.error-box {
    background: #fed7d7; border: 1px solid #feb2b2; border-radius: 8px;
    padding: 1.5rem; text-align: center; color: #9b2c2c;
}
.error-box h3 { margin-bottom: 0.5rem; }
.error-box code { font-size: 0.85rem; background: rgba(0,0,0,0.05); padding: 0.2rem 0.5rem; border-radius: 3px; }

/* Loading Screen */
.loading-screen {
    display: flex; justify-content: center; align-items: center;
    min-height: 60vh;
}
.loading-card {
    text-align: center; max-width: 500px; padding: 3rem 2rem;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px;
}
.loading-card h2 { color: var(--primary); margin-bottom: 0.75rem; }
.loading-progress {
    font-size: 1rem; color: var(--text-light); margin-bottom: 1.5rem;
    min-height: 1.5em;
}
.loading-warning {
    background: #fefcbf; color: #975a16; padding: 1rem; border-radius: 8px;
    font-size: 0.9rem; line-height: 1.6;
}
.loading-error {
    background: #fed7d7; color: #9b2c2c; padding: 1rem; border-radius: 8px;
    margin-top: 1rem; font-size: 0.9rem;
}
.spinner {
    width: 48px; height: 48px; border: 4px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.8s linear infinite; margin: 0 auto 1.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    nav { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 1rem; }
    .container { padding: 1rem; }
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .stat-value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
    .summary-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
