/* Kauf auf Rechnung Dashboard – Modern Design */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #eff6ff;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --purple: #7c3aed;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
    --radius: 10px;
    --radius-sm: 6px;
}

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

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

/* === LAYOUT === */
.app-container { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.95);
}

.navbar-brand {
    font-weight: 700;
    font-size: 17px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-nav { display: flex; gap: 4px; list-style: none; }
.navbar-nav a {
    padding: 8px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}
.navbar-nav a:hover { background: var(--border-light); color: var(--text); }
.navbar-nav a.active { background: var(--primary-light); color: var(--primary); }

.navbar-actions { display: flex; align-items: center; gap: 12px; }
.main-content { flex: 1; padding: 24px; max-width: 1600px; margin: 0 auto; width: 100%; }

/* === LOGIN === */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 50%, #faf5ff 100%);
}

.login-card {
    background: var(--card-bg);
    padding: 48px 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}

/* === CARDS === */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* === STAT CARDS === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card.active { border-color: var(--primary); }
.stat-card.active::after { background: var(--primary); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
}

.stat-card .stat-value { font-size: 28px; font-weight: 800; margin-bottom: 2px; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-card.pending .stat-value { color: var(--warning); }
.stat-card.approved .stat-value { color: var(--success); }
.stat-card.rejected .stat-value { color: var(--danger); }
.stat-card.total .stat-value { color: var(--primary); }

/* === TABLE === */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead { background: #f8fafc; }
thead th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
.th-center { text-align: center; }
.th-right { text-align: right; }

tbody tr { border-bottom: 1px solid var(--border-light); transition: background 0.1s; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 10px 14px; vertical-align: middle; }
.td-center { text-align: center; }
.td-amount { text-align: right; font-weight: 700; font-size: 13px; white-space: nowrap; }
.td-email { font-size: 12px; color: var(--text-muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.order-number { font-weight: 700; font-size: 13px; color: var(--primary); }
.order-date { font-size: 11px; color: var(--text-muted); }
.addr-name { font-weight: 600; font-size: 13px; }
.addr-company { font-size: 12px; color: var(--primary); font-weight: 500; }
.addr-line { font-size: 11px; color: var(--text-muted); }
.decided-date { font-size: 11px; color: var(--text-muted); }

/* === BADGES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
}

.badge-pending     { background: var(--warning-light); color: #92400e; }
.badge-approved    { background: var(--success-light); color: #065f46; }
.badge-rejected    { background: var(--danger-light); color: #991b1b; }
.badge-manual      { background: var(--warning-light); color: #92400e; }
.badge-approve     { background: var(--success-light); color: #065f46; }
.badge-reject      { background: var(--danger-light); color: #991b1b; }
.badge-low         { background: var(--success-light); color: #065f46; }
.badge-medium      { background: var(--warning-light); color: #92400e; }
.badge-high        { background: var(--danger-light); color: #991b1b; }
.badge-ok          { background: var(--success-light); color: #065f46; }
.badge-unknown     { background: #e2e8f0; color: #475569; }
.badge-business    { background: #dbeafe; color: #1e40af; }
.badge-residential { background: #fce7f3; color: #9d174d; }
.badge-warning     { background: var(--warning-light); color: #92400e; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 500;
    background: #f1f5f9;
    color: var(--text-muted);
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { background: #f1f5f9; border-color: #cbd5e1; }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-icon { padding: 6px; }
.btn-group { display: flex; gap: 6px; }

/* === FORMS === */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; background: var(--primary-light); padding: 8px 12px; border-radius: var(--radius-sm); }
.form-input, .form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.15s;
    background: var(--card-bg);
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-input-sm { padding: 7px 10px; font-size: 13px; }
textarea.form-input { resize: vertical; font-family: inherit; }

/* === TOOLBAR === */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1; min-width: 200px; max-width: 400px; }
.search-box input { padding-left: 36px; }
.search-box svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-muted);
}

/* === DETAIL VIEW === */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 4px; }
.detail-section { margin-bottom: 20px; }
.detail-section h4 {
    font-size: 12px; font-weight: 700; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.06em;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.detail-section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.detail-section-header h4 { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.detail-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13px; }
.detail-row .label { color: var(--text-muted); font-weight: 500; }
.detail-row .value { font-weight: 500; text-align: right; max-width: 60%; word-break: break-word; }

.detail-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.detail-link { font-size: 12px; margin-top: 8px; color: var(--text-muted); }
.detail-link a { color: var(--primary); text-decoration: none; }
.detail-link a:hover { text-decoration: underline; }

/* Address Cards */
.addr-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.addr-card-name { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.addr-card-company { font-size: 13px; color: var(--primary); font-weight: 500; margin-bottom: 4px; }
.addr-card-line { font-size: 13px; color: var(--text); }
.addr-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Check Grid */
.check-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.check-ok { background: #f0fdf4; border-color: #bbf7d0; }
.check-warn { background: #fef2f2; border-color: #fecaca; }
.check-neutral { background: #f8fafc; }
.check-icon {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.check-ok .check-icon { background: var(--success-light); color: var(--success); }
.check-warn .check-icon { background: var(--danger-light); color: var(--danger); }
.check-neutral .check-icon { background: #e2e8f0; color: var(--text-muted); }
.check-title { font-weight: 600; font-size: 13px; }
.check-detail { font-size: 12px; color: var(--text-muted); }

/* AI Card */
.ai-card { background: #faf5ff; border: 1px solid #e9d5ff; border-radius: var(--radius-sm); padding: 16px; }
.ai-header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.ai-reasoning { font-size: 13px; color: #581c87; line-height: 1.6; }

.reason-card { background: #f8fafc; padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--border); line-height: 1.6; }

/* Activity List */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 10px 0; border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}
.activity-dot {
    width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0;
    background: #cbd5e1;
}
.dot-success { background: var(--success); }
.dot-danger { background: var(--danger); }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* === MODAL === */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.2s;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: var(--card-bg); border-radius: 14px; box-shadow: var(--shadow-lg);
    width: 90%; max-width: 940px; max-height: 85vh; overflow-y: auto;
    transform: translateY(20px); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: flex-start; justify-content: space-between;
    position: sticky; top: 0; background: var(--card-bg); z-index: 1; border-radius: 14px 14px 0 0;
}
.modal-header h3 { font-size: 17px; }
.modal-close {
    background: none; border: none; font-size: 24px; cursor: pointer;
    color: var(--text-muted); padding: 4px; line-height: 1;
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; transition: background 0.15s;
}
.modal-close:hover { background: #f1f5f9; }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 10px; align-items: center;
    position: sticky; bottom: 0; background: var(--card-bg); border-radius: 0 0 14px 14px;
}

/* === TOAST === */
.toast-container {
    position: fixed; top: 72px; right: 24px; z-index: 2000;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 16px; box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 10px; min-width: 300px;
    animation: slideIn 0.3s ease; font-size: 13px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.success svg { color: var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.error svg { color: var(--danger); }
.toast.info { border-left: 4px solid var(--primary); }
.toast.info svg { color: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* === SPINNER === */
.spinner {
    width: 20px; height: 20px; border: 2px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    display: flex; align-items: center; justify-content: center;
    padding: 60px; color: var(--text-muted); gap: 12px; font-size: 14px;
}

/* === SETTINGS === */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-section .card-header { background: #f8fafc; }

/* === EMAIL LOG === */
.email-log-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); margin-bottom: 8px;
}
.email-ok { background: #f0fdf4; border-color: #bbf7d0; }
.email-fail { background: #fef2f2; border-color: #fecaca; }
.email-log-icon {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.email-ok .email-log-icon { background: var(--success-light); color: var(--success); }
.email-fail .email-log-icon { background: var(--danger-light); color: var(--danger); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-box { max-width: 100%; }
    .modal { width: 95%; max-height: 90vh; }
    .navbar-nav { display: none; }
}
