/* Reset & Base */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 11px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: #f0f1f3;
    color: #1a1a2e;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: #1a1a2e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 16px; }
.logo { font-size: 15px; font-weight: 700; letter-spacing: -.3px; }
.sidebar-toggle {
    background: none; border: none; color: #fff; cursor: pointer;
    padding: 4px; border-radius: 4px; display: flex; align-items: center;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.1); }
.user-info { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .85; }
.logout-btn { border: none; background: none; font-family: inherit;
    color: #fff; opacity: .7; display: flex; align-items: center;
    padding: 4px; border-radius: 4px; text-decoration: none;
}
.logout-btn:hover { opacity: 1; background: rgba(255,255,255,.1); }

/* Sidebar */
.sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 220px;
    background: #16213e;
    overflow-y: auto;
    z-index: 90;
    transition: transform .25s ease;
    padding: 12px 0;
}
.sidebar.collapsed { transform: translateX(-220px); }
.nav-category {
    color: rgba(255,255,255,.45);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    padding: 16px 20px 6px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,.7);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
    background: rgba(255,255,255,.08);
    color: #fff;
    border-left-color: #4e7cff;
}

/* Main Content */
.main-content {
    margin-top: 52px;
    margin-left: 220px;
    padding: 28px 32px;
    transition: margin-left .25s ease;
    min-height: calc(100vh - 52px);
}
.main-content.expanded { margin-left: 0; }

/* Page Title Bar */
.page-title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.meta-pills { display: flex; gap: 8px; }
.pill {
    background: #e8e9ed;
    color: #555;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}
.pill-green { background: #d4edda; color: #155724; }

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px 14px;
    margin-bottom: 20px;
    max-width: 400px;
}
.search-bar input {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 12px;
    width: 100%;
    background: transparent;
}
.search-bar svg { color: #999; flex-shrink: 0; }

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #eee;
}
.stat-icon {
    width: 44px; height: 44px;
    background: #eef1fb;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #4e7cff;
}
.stat-value { font-size: 20px; font-weight: 700; display: block; }
.stat-label { font-size: 11px; color: #888; }

/* Table Card */
.table-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #eee;
    overflow: hidden;
}
.table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.table-header h2 { font-size: 14px; font-weight: 600; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.data-table th {
    text-align: left;
    padding: 10px 20px;
    font-weight: 600;
    color: #666;
    background: #fafafa;
    border-bottom: 1px solid #eee;
    cursor: default;
    user-select: none;
    font-size: 11px;
}
.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { color: #333; }
.data-table td {
    padding: 10px 20px;
    border-bottom: 1px solid #f5f5f5;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #f9fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}
.badge-green { background: #d4edda; color: #155724; }
.badge-yellow { background: #fff3cd; color: #856404; }
.badge-red { background: #f8d7da; color: #721c24; }

/* Login */
.login-body {
    background: #1a1a2e;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 30px rgba(0,0,0,.3);
}
.login-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 28px;
    color: #1a1a2e;
}
.login-error {
    background: #f8d7da;
    color: #721c24;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 12px;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #333;
}
.form-group input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    transition: border-color .15s;
}
.form-group input:focus { outline: none; border-color: #4e7cff; box-shadow: 0 0 0 3px rgba(78,124,255,.12); }
.login-btn {
    width: 100%;
    padding: 10px;
    background: #4e7cff;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.login-btn:hover { background: #3d6ae0; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-220px); }
    .sidebar.mobile-open { transform: translateX(0); }
    .main-content { margin-left: 0; }
}

/* Kunden-Liste Erweiterungen */
.cell-nr { white-space: nowrap; font-weight: 600; color: #4e7cff; font-size: 11px; }
.cell-name strong { font-size: 12px; }
.cell-addr { font-size: 11px; line-height: 1.5; }
.cell-phone { white-space: nowrap; font-size: 11px; }
.cell-email a { color: #4e7cff; text-decoration: none; font-size: 11px; }
.cell-email a:hover { text-decoration: underline; }
.text-muted { color: #888; font-size: 10px; }
.empty-state { text-align: center; padding: 40px 20px !important; color: #999; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
    font-size: 12px;
}
.page-link {
    color: #4e7cff;
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-weight: 500;
}
.page-link:hover { background: #f0f3ff; border-color: #4e7cff; }
.page-info { color: #666; }

/* Clickable stat cards */
a.stat-card-link { text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.stat-card-link:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); }

/* Artikel-spezifisch */
.cell-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-icon-orange { background: #fff3e0; color: #e67e22; }
.stat-icon-green { background: #d4edda; color: #28a745; }

/* Sort & Filter */
.sortable-header { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-header:hover { color: #4e7cff; }
.sort-icon { font-size: 10px; opacity: .5; margin-left: 3px; }
.sortable-header:hover .sort-icon { opacity: 1; }
.filter-row th { padding: 4px 8px 8px; background: #fafafa; }
.col-filter {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    background: #fff;
    transition: border-color .15s;
}
.col-filter:focus { outline: none; border-color: #4e7cff; box-shadow: 0 0 0 2px rgba(78,124,255,.1); }
.col-filter::placeholder { color: #bbb; }

/* Dropdown Filter */
.col-filter-select {
    width: 100%;
    padding: 5px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s;
}
.col-filter-select:focus { outline: none; border-color: #4e7cff; box-shadow: 0 0 0 2px rgba(78,124,255,.1); }

/* Detail Page */
.back-link {
    color: #4e7cff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 4px;
}
.back-link:hover { text-decoration: underline; }
.name-link { color: inherit; text-decoration: none; }
.name-link:hover { color: #4e7cff; }
.cell-nr a { color: #4e7cff; text-decoration: none; font-weight: 600; }
.cell-nr a:hover { text-decoration: underline; }

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border: 1px solid #eee;
    overflow: hidden;
}
.detail-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 20px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    background: #fafafa;
    border-bottom: 1px solid #eee;
}
.detail-card-body { padding: 16px 20px; }

.detail-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px solid #f5f5f5;
    font-size: 12px;
    line-height: 1.6;
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
    width: 140px;
    flex-shrink: 0;
    color: #888;
    font-weight: 500;
    font-size: 11px;
}
.detail-value { color: #333; }
.detail-value a { color: #4e7cff; text-decoration: none; }
.detail-value a:hover { text-decoration: underline; }

/* KPI Boxes */
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}
.kpi-box {
    background: #f8f9fc;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    border: 1px solid #eef0f4;
}
.kpi-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}
.kpi-label {
    display: block;
    font-size: 10px;
    color: #888;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .3px;
}

/* KPI Erweiterungen */
.kpi-value-sm { font-size: 12px !important; font-weight: 600 !important; line-height: 1.4; }
.kpi-box-warn { background: #fff8f0; border-color: #f0d0a0; }
.kpi-box-warn .kpi-value { color: #c0392b; }
.kpi-sub { display: block; font-size: 11px; color: #888; margin-top: 2px; font-weight: 500; }

/* Kaufstatus */
.kpi-box-danger { background: #fdf0f0; border-color: #f0b0b0; }
.kpi-box-ok { background: #f0fdf4; border-color: #b0e0c0; }
.kpi-danger { color: #c0392b !important; }
.kpi-ok { color: #27ae60 !important; }

/* Historie / Expandable Rows */
.beleg-row { cursor: pointer; }
.beleg-row:hover td { background: #f0f3ff !important; }
.expand-toggle { text-align: center; padding: 10px 8px !important; }
.expand-icon { transition: transform .2s; color: #999; }
.belegart-link { color: #4e7cff; font-weight: 500; }
.positionen-cell { padding: 0 !important; background: #f8f9fc !important; }
.positionen-loading, .positionen-empty { padding: 16px 24px; color: #888; font-size: 12px; }
.pos-table { width: 100%; border-collapse: collapse; font-size: 11px; margin: 0; }
.pos-table th { text-align: left; padding: 8px 16px; font-weight: 600; color: #666; background: #eef1f6; font-size: 10px; text-transform: uppercase; letter-spacing: .3px; }
.pos-table td { padding: 7px 16px; border-bottom: 1px solid #eee; }
.pos-table tr:last-child td { border-bottom: none; }

/* Historie Filter */
.historie-header { flex-wrap: wrap; gap: 10px; }.historie-title { display: flex; align-items: center; gap: 8px; }.historie-filter { display: flex; align-items: center; gap: 20px; margin-left: auto; padding-left: 32px; }.filter-check { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px; color: #666; user-select: none; }.filter-check input { accent-color: #4e7cff; cursor: pointer; width: 15px; height: 15px; }.filter-check-label { font-weight: 400; }

/* Top Artikel / Half-width grid */
.detail-grid-half { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .detail-grid-half { grid-template-columns: 1fr; } }
.price-diff { font-size: 10px; font-weight: 700; margin-left: 3px; }
.price-below { color: #c0392b; }
.price-above { color: #27ae60; }
