/* ==========================================================================
   ADSCode.pl - Professional Service System UI v4.0 (Final)
   ========================================================================== */

:root {
    --bg-color: #f4f7fb;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --border: #e2e8f0;
    --border-focus: #93c5fd;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 15px -3px rgba(0,0,0,0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1);
    
    /* Status Colors */
    --status-do: #e62020;
    --status-ob: #3b82f6;
    --status-po: #10b981;
    --status-oc: #000000;
    --status-wypelniona: #16a34a;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* --- ANIMACJE BAZOWE --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(30px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulseUpdate {
    0% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); transform: scale(1); }
    50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); transform: scale(1.02); }
    100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); transform: scale(1); }
}

/* --- LOGOWANIE --- */
.login-body { display: flex; justify-content: center; align-items: center; height: 100vh; }
.login-container { 
    background: var(--white); padding: 2.5rem 2rem; border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-lg); width: 100%; max-width: 400px; text-align: center;
    animation: fadeIn 0.5s ease-out;
}
.login-container h1 { color: var(--primary); margin-bottom: 1.5rem; font-size: 1.8rem; }
.login-container h1 span { color: var(--text-main); font-weight: 300; }
.login-container input { 
    width: 100%; padding: 0.9rem; margin-bottom: 1rem; border: 1px solid var(--border); 
    border-radius: var(--radius-sm); outline: none; transition: all 0.3s;
}
.login-container input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--border-focus); }
.login-container button { 
    width: 100%; padding: 0.9rem; background: var(--primary); color: var(--white); 
    border: none; border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; 
    font-size: 1rem; transition: background 0.3s, transform 0.2s; 
}
.login-container button:hover { background: var(--primary-hover); transform: translateY(-2px); }
.error { color: var(--danger); margin-bottom: 1rem; font-size: 0.875rem; font-weight: 500; background: #fee2e2; padding: 0.5rem; border-radius: var(--radius-sm); }

/* --- NAWIGACJA --- */
.top-nav { 
    background: var(--white); padding: 1rem 5%; display: flex; justify-content: space-between; 
    align-items: center; box-shadow: var(--shadow-sm); position: sticky; top: 0; z-index: 100;
}
.logo { font-weight: 800; color: var(--primary); font-size: 1.4rem; letter-spacing: -0.5px; }
.logo span { color: var(--text-main); font-weight: 400; }
.user-info { font-size: 0.95rem; display: flex; align-items: center; gap: 15px; }
.btn-logout { 
    color: var(--danger); text-decoration: none; font-weight: 600; padding: 0.4rem 0.8rem; 
    border-radius: var(--radius-sm); transition: background 0.2s; 
}
.btn-logout:hover { background: #fee2e2; }

/* --- GŁÓWNY KONTENER --- */
.container { 
    width: 95%; max-width: 1200px; margin: 2rem auto; 
    animation: fadeIn 0.4s ease-out forwards;
}

/* --- KARTY FORMULARZY (ADMIN GRID) --- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.add-visit-card { 
    background: var(--white); padding: 2rem; border-radius: var(--radius-md); 
    box-shadow: var(--shadow-md); transition: transform 0.3s;
}
.add-visit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.add-visit-card h2 { margin-bottom: 1.5rem; font-size: 1.25rem; color: var(--text-main); }

.inline-form { display: flex; flex-direction: column; gap: 1rem; }
.form-row { display: flex; gap: 1rem; }
.form-row input { flex: 1; }

.inline-form input, .inline-form select, .inline-form textarea { 
    width: 100%; padding: 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-sm); 
    outline: none; transition: border-color 0.2s, box-shadow 0.2s; font-size: 0.95rem; background: #fff;
}
.inline-form input:focus, .inline-form select:focus, .inline-form textarea:focus { 
    border-color: var(--primary); box-shadow: 0 0 0 3px var(--border-focus); 
}
.inline-form textarea { resize: vertical; min-height: 80px; }

.inline-form button { 
    padding: 0.9rem; background: var(--primary); color: var(--white); border: none; 
    border-radius: var(--radius-sm); cursor: pointer; font-weight: bold; font-size: 1rem;
    transition: all 0.2s; margin-top: 0.5rem;
}
.inline-form button:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3); }

/* --- PASEK FILTRÓW --- */
.filter-bar { 
    margin-bottom: 1.5rem; display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap;
    background: var(--white); padding: 1.2rem; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.filter-bar span { font-weight: 600; margin-right: 0.5rem; color: var(--text-muted); }
.filter-btn {
    padding: 0.5rem 1.2rem; border: 1px solid var(--border); background: var(--white);
    border-radius: 30px; cursor: pointer; font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
    transition: all 0.2s ease;
}
.filter-btn:hover { background: #f1f5f9; color: var(--text-main); }
.filter-btn.active { background: var(--primary); color: var(--white); border-color: var(--primary); box-shadow: 0 2px 8px rgba(37,99,235,0.3); }

/* --- TABELA WIZYT --- */
.visits-table-container { 
    background: var(--white); 
    border-radius: var(--radius-md); 
    padding: 1.5rem; 
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    position: relative;
    /* Usuwamy overflow: hidden, aby nie ucinało cieni ani menu rozwijanego */
}

.visits-table { 
    width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    table-layout: auto;
}

.visits-table th { 
    text-align: left; 
    padding: 1.2rem 1rem; 
    color: var(--text-muted); 
    font-size: 0.75rem; 
    text-transform: uppercase; 
    border-bottom: 2px solid var(--bg-color);
}

.visits-table td { 
    padding: 1.5rem 1rem; /* Zwiększony padding pionowy rozwiązuje problem ucinania */
    border-bottom: 1px solid #f1f5f9; 
    vertical-align: middle; 
    line-height: 1.4;
}

.visit-row { transition: background 0.3s ease; }
.visit-row:hover td { background-color: #f8fafc; }

.tel-link { color: var(--primary); text-decoration: none; font-weight: 700; font-size: 0.9rem; }
.tel-link:hover { text-decoration: underline; }

/* Status Select UI */
.status-select { 
    padding: 0.6rem; 
    border-radius: var(--radius-sm); 
    font-weight: bold; 
    border: 1px solid var(--border); 
    outline: none; 
    cursor: pointer; 
    background: #fff; 
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
}

.status-select:hover { border-color: var(--text-muted); }
.status-select.oczekuje-na-ankiete { color: var(--status-oc); background-color: #f8fafc; border-color: #cbd5e1; }
.status-select.do-obdzwonienia { color: var(--status-do); background-color: #fef2f2; border-color: #fecaca; }
.status-select.obdzwoniony { color: var(--status-ob); background-color: #eff6ff; border-color: #bfdbfe; }
.status-select.ankieta-wypelniona { color: var(--status-wypelniona); background-color: #ecfdf5; border-color: #86efac; }

.loading { opacity: 0.5; pointer-events: none; }
.pulse-update { animation: pulseUpdate 1.5s ease-out; }

/* Akcje w tabeli */
td.actions-cell {
    white-space: nowrap;
    vertical-align: middle;
}

td.actions-cell > * {
    vertical-align: middle;
}

td.actions-cell > * + * {
    margin-left: 8px;
}

.actions-cell:not(td) {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    min-height: 44px;
    flex-wrap: wrap;
}

td.actions-cell form,
.actions-cell form {
    display: inline-flex;
    margin: 0;
}

.highlight-form {
    display: inline-flex;
}

.highlight-select {
    width: 44px;
    min-width: 44px;
    min-height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    text-align-last: center;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.highlight-select option {
    text-align: center;
}

.highlight-select option[value=""] {
    color: #ffffff;
}

.highlight-select option[value="czerwony"] {
    color: #dc2626;
}

.highlight-select option[value="zielony"] {
    color: #16a34a;
}

.highlight-select option[value="zolty"] {
    color: #ca8a04;
}

.highlight-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--border-focus);
}

.highlight-select.highlight-czerwony {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.highlight-select.highlight-zielony {
    color: #166534;
    background: #ecfdf5;
    border-color: #86efac;
}

.highlight-select.highlight-zolty {
    color: #a16207;
    background: #fefce8;
    border-color: #fde68a;
}

.btn-action { 
    background: var(--white); border: 1px solid var(--border); padding: 8px; cursor: pointer; 
    border-radius: var(--radius-sm); transition: all 0.2s; display: inline-flex; align-items: center; justify-content: center;
}
.btn-action.edit:hover { background: #eff6ff; border-color: var(--primary); transform: translateY(-2px); }
.btn-action.delete:hover { background: #fef2f2; border-color: var(--danger); transform: translateY(-2px); }

.btn-reminder {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); cursor: pointer; 
    padding: 8px; font-size: 14px; transition: all 0.2s; display: inline-flex;
}
.btn-reminder:hover { transform: translateY(-2px) scale(1.05); background: #fef3c7; border-color: #f59e0b; box-shadow: 0 4px 6px rgba(245, 158, 11, 0.2); }

/* Ikona pytajnika podglądu notatki */
.btn-info-note {
    background: #e2e8f0; color: #475569; width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
    font-size: 14px; font-weight: bold; transition: all 0.2s; border: none; margin-left: 5px;
}
.btn-info-note:hover { background: #cbd5e1; transform: scale(1.1); }

/* --- PAGINACJA --- */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid #f1f5f9; }
.page-link { 
    padding: 8px 14px; border: 1px solid var(--border); background: var(--white); 
    text-decoration: none; color: var(--text-muted); border-radius: var(--radius-sm); font-weight: 600; transition: all 0.2s;
}
.page-link:hover { background: #f1f5f9; color: var(--text-main); }
.page-link.active { background: var(--primary); color: var(--white); border-color: var(--primary); box-shadow: 0 2px 5px rgba(37,99,235,0.3); }

/* --- MODAL (POPUP) --- */
.modal { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
    display: none; justify-content: center; align-items: center; z-index: 1000;
}
.modal-content { 
    background: var(--white); padding: 2.5rem; border-radius: var(--radius-lg); 
    width: 100%; max-width: 500px; box-shadow: var(--shadow-lg);
    animation: slideUpModal 0.3s ease-out forwards;
}
.modal-content h3 { margin-bottom: 1.5rem; color: var(--primary); font-size: 1.4rem; border-bottom: 2px solid #f1f5f9; padding-bottom: 0.5rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 2rem; }

.view-note-body { white-space: pre-wrap; margin: 1.5rem 0; color: var(--text-main); font-style: italic; line-height: 1.6; }

.btn-cancel { 
    padding: 0.8rem 1.5rem; background: #f1f5f9; color: var(--text-main); border: none; 
    border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; transition: all 0.2s;
}
.btn-cancel:hover { background: #e2e8f0; }
.btn-save { 
    padding: 0.8rem 1.5rem; background: var(--primary); color: var(--white); border: none; 
    border-radius: var(--radius-sm); cursor: pointer; font-weight: bold; transition: all 0.2s;
}
.btn-save:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3); }

/* --- PODŚWIETLENIE REKORDÓW --- */

.visit-row.highlight-czerwony td { background-color: #fef2f2 !important; }
.visit-row.highlight-zielony td { background-color: #ecfdf5 !important; }
.visit-row.highlight-zolty td { background-color: #fefce8 !important; }

.visit-row[class*="highlight-"]:hover td {
    filter: brightness(0.96);
}

/* Wiadomości systemowe */
.system-msg { 
    background: #ecfdf5; color: #065f46; padding: 1.2rem; border-radius: var(--radius-md); 
    margin-bottom: 1.5rem; font-weight: 500; border: 1px solid #a7f3d0; 
    display: flex; align-items: center; animation: fadeIn 0.4s ease-out; box-shadow: var(--shadow-sm);
}

/* Responsywność */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 1rem; }
    .top-nav { flex-direction: column; gap: 10px; padding: 1rem; }
    .filter-bar { justify-content: center; }
    .admin-grid { grid-template-columns: 1fr; }
    .visits-table td:nth-child(4) { display: none; } /* Ukrywa opis usterki na mobile */
    .visits-table th:nth-child(4) { display: none; }
}

/* --- Style przeniesione z dashboard.php --- */
.btn-info-note {
            background: #e2e8f0; color: #475569; width: 24px; height: 24px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
            font-size: 14px; font-weight: bold; transition: all 0.2s; border: none; margin-left: 5px;
        }
        .btn-info-note:hover { background: #cbd5e1; transform: scale(1.1); }
        .view-note-body { white-space: pre-wrap; margin: 1.5rem 0; color: var(--text-main); font-style: italic; line-height: 1.6; }
        .status-select.klient-nie-odebral { color: #7f1d1d; border-color: #7f1d1d; }
        .status-extra-meta { display: block; margin-top: 6px; color: #64748b; }
        .filter-bar.loading, .visits-table-container.loading { opacity: 0.6; pointer-events: none; }
        .stats-section { margin: 1.5rem 0 2rem; }
        .stats-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
        .stats-heading h2 { margin: 0; }
        .stats-heading p { margin: 6px 0 0; color: #64748b; }
        .stats-summary-grid, .stats-ranking-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
        .stats-ranking-grid { margin-top: 16px; }
        .stats-card, .stats-table-card {
            background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            padding: 18px;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
        }
        .stats-card h3, .stats-table-card h3 { margin: 0 0 14px; }
        .stats-kicker { display: block; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #64748b; margin-bottom: 10px; }
        .stats-value { display: block; font-size: 30px; font-weight: 800; line-height: 1.1; color: #0f172a; }
        .stats-meta { display: block; margin-top: 8px; color: #475569; }
        .stats-meta strong { color: #0f172a; }
        .stats-ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
        .stats-ranking li {
            display: flex;
            justify-content: space-between;
            align-items: center;
            gap: 12px;
            padding: 12px 14px;
            border-radius: 14px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
        }
        .stats-ranking strong { display: block; margin-bottom: 4px; }
        .stats-ranking small { color: #64748b; }
        .stats-score { font-size: 22px; font-weight: 800; color: #0f172a; white-space: nowrap; }
        .stats-table-card { margin: 18px 0 0; padding: 0; overflow: hidden; }
        .stats-table-header { padding: 18px; border-bottom: 1px solid #e2e8f0; }
        .stats-table-header p { margin: 6px 0 0; color: #64748b; }
        .stats-table-wrapper { overflow-x: auto; }
        .stats-table { width: 100%; border-collapse: collapse; }
        .stats-table th, .stats-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
        .stats-table th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; background: #f8fafc; }
        .stats-table tbody tr:hover { background: #f8fafc; }
        .stats-table tbody tr:last-child td { border-bottom: none; }
        .stats-table .metric-strong { font-weight: 800; color: #0f172a; }
        .stats-empty { color: #64748b; margin: 0; }

        .advisor-results-section {
            margin-top: 18px;
            padding: 22px;
            border: 1px solid #e2e8f0;
            border-radius: 20px;
            background: #ffffff;
            box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
        }
        .advisor-results-header {
            display: flex;
            align-items: flex-start;
            justify-content: space-between;
            gap: 20px;
            margin-bottom: 18px;
        }
        .advisor-results-header h3 { margin: 0; font-size: 22px; color: #0f172a; }
        .advisor-results-header p { margin: 7px 0 0; color: #64748b; max-width: 760px; }
        .advisor-results-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 420px; }
        .legend-dot,
        .advisor-status-name {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 12px;
            font-weight: 700;
            color: #475569;
        }
        .legend-dot::before,
        .advisor-status-name::before {
            content: '';
            width: 9px;
            height: 9px;
            border-radius: 999px;
            background: #94a3b8;
            flex: 0 0 auto;
        }
        .legend-dot.awaiting::before, .advisor-status-name.awaiting::before, .advisor-status-progress.awaiting span { background: #64748b; }
        .legend-dot.to-call::before, .advisor-status-name.to-call::before, .advisor-status-progress.to-call span { background: #dc2626; }
        .legend-dot.no-answer::before, .advisor-status-name.no-answer::before, .advisor-status-progress.no-answer span { background: #7f1d1d; }
        .legend-dot.called::before, .advisor-status-name.called::before, .advisor-status-progress.called span { background: #2563eb; }
        .legend-dot.completed::before, .advisor-status-name.completed::before, .advisor-status-progress.completed span { background: #16a34a; }
        .advisor-results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); gap: 16px; }
        .advisor-result-card {
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            padding: 18px;
            background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
        }
        .advisor-result-card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
        .advisor-card-label { display: block; margin-bottom: 4px; color: #94a3b8; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
        .advisor-result-card h4 { margin: 0; color: #0f172a; font-size: 20px; }
        .advisor-total-badge {
            min-width: 70px;
            padding: 9px 12px;
            border-radius: 14px;
            background: #0f172a;
            color: #ffffff;
            text-align: center;
        }
        .advisor-total-badge strong { display: block; font-size: 22px; line-height: 1; }
        .advisor-total-badge span { display: block; margin-top: 4px; font-size: 11px; color: #cbd5e1; }
        .advisor-status-list { display: grid; gap: 12px; }
        .advisor-status-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
        .advisor-status-row-top strong { color: #0f172a; }
        .advisor-status-progress { height: 7px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
        .advisor-status-progress span { display: block; height: 100%; border-radius: inherit; min-width: 0; }
        .advisor-result-metrics {
            display: grid;
            grid-template-columns: repeat(3, minmax(0, 1fr));
            gap: 8px;
            margin-top: 18px;
            padding-top: 15px;
            border-top: 1px solid #e2e8f0;
        }
        .advisor-result-metrics div { min-width: 0; }
        .advisor-result-metrics span { display: block; min-height: 30px; color: #64748b; font-size: 11px; line-height: 1.3; }
        .advisor-result-metrics strong { display: block; margin-top: 4px; color: #0f172a; font-size: 17px; }

        .visit-filter-panel {
            display: block;
            margin: 0 0 18px;
            padding: 18px;
            border: 1px solid #e2e8f0;
            border-radius: 18px;
            background: #ffffff;
            box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
        }
        .visit-filter-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
        .visit-filter-heading h2 { margin: 0; color: #0f172a; }
        .visit-filter-heading p { margin: 5px 0 0; color: #64748b; }
        .visit-result-count {
            display: inline-flex;
            align-items: center;
            min-height: 34px;
            padding: 7px 12px;
            border-radius: 999px;
            background: #eff6ff;
            color: #1d4ed8;
            font-size: 13px;
            font-weight: 800;
            white-space: nowrap;
        }
        .visit-filter-form { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 12px; align-items: end; }
        .visit-filter-field { display: grid; gap: 6px; min-width: 0; }
        .visit-filter-field > span { color: #475569; font-size: 12px; font-weight: 800; }
        .visit-filter-field select,
        .visit-filter-field input {
            width: 100%;
            min-height: 42px;
            box-sizing: border-box;
            border: 1px solid #cbd5e1;
            border-radius: 10px;
            padding: 9px 11px;
            background: #ffffff;
            color: #0f172a;
        }
        .visit-filter-field select:focus,
        .visit-filter-field input:focus { outline: 3px solid rgba(59, 130, 246, .14); border-color: #3b82f6; }
        .visit-date-field { display: none; }
        .visit-date-field.is-visible { display: grid; }
        .visit-filter-actions { display: flex; align-items: center; gap: 9px; min-height: 42px; }
        .visit-filter-submit,
        .visit-filter-reset {
            min-height: 42px;
            border-radius: 10px;
            padding: 10px 14px;
            font-weight: 800;
            text-decoration: none;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            box-sizing: border-box;
        }
        .visit-filter-submit { border: 0; background: #2563eb; color: #ffffff; cursor: pointer; }
        .visit-filter-submit:hover { background: #1d4ed8; }
        .visit-filter-reset { border: 1px solid #cbd5e1; background: #ffffff; color: #475569; }
        .visit-filter-reset:hover { background: #f8fafc; }

        .advisor-badge {
            display: inline-flex;
            align-items: center;
            gap: 7px;
            padding: 7px 10px;
            border-radius: 999px;
            background: #eef2ff;
            color: #3730a3;
            font-size: 12px;
            font-weight: 800;
            white-space: nowrap;
        }
        .advisor-badge-icon { font-size: 13px; }
        .status-timeline { display: grid; gap: 5px; margin-top: 9px; }
        .status-extra-meta {
            display: flex;
            align-items: baseline;
            justify-content: space-between;
            gap: 10px;
            margin-top: 0;
            padding: 6px 8px;
            border-radius: 8px;
            background: #f8fafc;
            color: #64748b;
            line-height: 1.35;
        }
        .status-extra-meta span { font-size: 11px; }
        .status-extra-meta strong { color: #334155; font-size: 11px; white-space: nowrap; }
        .status-extra-meta.no-answer-meta { border-left: 3px solid #7f1d1d; }
        .status-extra-meta.called-meta { border-left: 3px solid #2563eb; }
        .status-extra-meta.completed-meta { border-left: 3px solid #16a34a; background: #f0fdf4; }
        /* Stabilny układ tabeli wizyt. Nadpisuje ewentualne szerokości ze style.css. */
        .visits-table-container {
            width: 100%;
            max-width: 100%;
            overflow-x: auto !important;
            overflow-y: hidden;
            box-sizing: border-box;
            -webkit-overflow-scrolling: touch;
        }
        .visits-table {
            width: 100% !important;
            max-width: 100%;
            min-width: 0 !important;
            table-layout: fixed;
            border-collapse: collapse;
        }
        .visits-table th,
        .visits-table td {
            min-width: 0;
            box-sizing: border-box;
            padding-left: 12px;
            padding-right: 12px;
            vertical-align: middle;
        }
        .visits-table th {
            overflow-wrap: normal;
            word-break: normal;
        }
        .visits-table td {
            overflow-wrap: anywhere;
            word-break: normal;
        }
        .visits-table td a,
        .visits-table td strong,
        .visits-table td small {
            max-width: 100%;
        }
        .visits-table .tel-link {
            display: inline-block;
            overflow-wrap: anywhere;
        }
        .visits-table td:nth-child(1),
        .visits-table td:nth-child(2) {
            white-space: normal;
        }
        .visits-table td:nth-child(6) small {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 4;
            overflow: hidden;
            line-height: 1.4;
        }
        .status-control-row {
            display: grid !important;
            grid-template-columns: minmax(0, 1fr) auto auto;
            align-items: center;
            gap: 5px;
            width: 100%;
            min-width: 0;
        }
        .status-control-row .status-select {
            width: 100% !important;
            min-width: 0 !important;
            max-width: 100%;
            box-sizing: border-box;
        }
        .status-control-row .btn-info-note,
        .status-control-row .btn-reminder {
            flex: 0 0 auto;
            margin-left: 0;
        }
        .status-timeline {
            min-width: 0;
        }
        .status-extra-meta {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            align-items: center;
        }
        .status-extra-meta span {
            min-width: 0;
            overflow-wrap: normal;
        }
        .status-extra-meta strong {
            text-align: right;
        }
        .actions-cell {
            white-space: nowrap;
            padding-left: 10px !important;
            padding-right: 10px !important;
        }
        .actions-group {
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 7px;
            width: 100%;
            min-width: 0;
        }
        .actions-group .btn-action,
        .actions-group .highlight-form,
        .actions-group .highlight-select {
            flex: 0 0 auto;
            margin: 0;
        }
        .actions-group .btn-action {
            width: 36px;
            min-width: 36px;
            height: 36px;
            padding: 0;
            box-sizing: border-box;
        }
        .actions-group .highlight-form {
            display: block;
        }
        .actions-group .highlight-select {
            width: 44px;
            min-width: 44px;
            height: 36px;
            padding-left: 8px;
            padding-right: 18px;
            box-sizing: border-box;
        }
        .visits-empty-state { padding: 40px 20px !important; text-align: center !important; color: #64748b; }
        .visits-empty-state strong { display: block; margin-bottom: 6px; color: #0f172a; }
        .visits-empty-state span { display: block; }

        .visits-table-admin col.col-survey-date { width: 8%; }
        .visits-table-admin col.col-created-date { width: 9%; }
        .visits-table-admin col.col-advisor { width: 10%; }
        .visits-table-admin col.col-client { width: 20%; }
        .visits-table-admin col.col-vehicle { width: 14%; }
        .visits-table-admin col.col-notes { width: 6.5%; }
        .visits-table-admin col.col-status { width: 19%; }
        .visits-table-admin col.col-actions { width: 13.5%; }

        .visits-table-advisor col.col-survey-date { width: 9%; }
        .visits-table-advisor col.col-created-date { width: 10%; }
        .visits-table-advisor col.col-advisor { width: 11%; }
        .visits-table-advisor col.col-client { width: 23%; }
        .visits-table-advisor col.col-vehicle { width: 16%; }
        .visits-table-advisor col.col-notes { width: 9%; }
        .visits-table-advisor col.col-status { width: 22%; }

        @media (max-width: 1100px) {
            .visits-table {
                width: 1120px !important;
                min-width: 1120px !important;
            }
        }

        @media (max-width: 1200px) {
            .visit-filter-form { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
        }
        @media (max-width: 760px) {
            .advisor-results-header,
            .visit-filter-heading { flex-direction: column; }
            .advisor-results-legend { justify-content: flex-start; }
            .visit-filter-form { grid-template-columns: 1fr; }
            .visit-filter-actions { flex-wrap: wrap; }
            .visit-filter-submit, .visit-filter-reset { flex: 1 1 130px; }
            .advisor-result-metrics { grid-template-columns: 1fr; }
            .advisor-result-metrics span { min-height: auto; }
        }

/* ========================================================================== 
   Dashboard v5.0 — szeroki układ wykorzystujący pełną powierzchnię ekranu
   ========================================================================== */

.dashboard-page {
    min-width: 320px;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.07), transparent 28rem),
        var(--bg-color);
}

.dashboard-page .top-nav {
    padding: 0.9rem clamp(1rem, 2.5vw, 3.25rem);
    border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

.dashboard-container {
    width: calc(100% - clamp(1.5rem, 4vw, 4.5rem));
    max-width: 1920px;
    margin: clamp(1.25rem, 2vw, 2rem) auto 3.5rem;
}

.dashboard-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding: clamp(1.5rem, 2.4vw, 2.5rem);
    overflow: hidden;
    position: relative;
    color: #fff;
    border-radius: 22px;
    background:
        linear-gradient(115deg, rgba(15, 23, 42, 0.98), rgba(30, 64, 175, 0.94)),
        #0f172a;
    box-shadow: 0 24px 60px -28px rgba(15, 23, 42, 0.65);
}

.dashboard-hero::after {
    content: '';
    position: absolute;
    width: 26rem;
    height: 26rem;
    right: -8rem;
    top: -12rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}

.dashboard-hero-copy,
.dashboard-hero-meta {
    position: relative;
    z-index: 1;
}

.dashboard-eyebrow,
.section-kicker {
    display: block;
    margin-bottom: 0.45rem;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.dashboard-eyebrow { color: #bfdbfe; }
.dashboard-hero h1 { margin: 0; font-size: clamp(1.85rem, 3vw, 3rem); line-height: 1.05; letter-spacing: -0.035em; }
.dashboard-hero p { max-width: 760px; margin: 0.75rem 0 0; color: #dbeafe; font-size: clamp(0.95rem, 1.2vw, 1.08rem); }

.dashboard-hero-meta {
    min-width: 210px;
    padding: 1rem 1.25rem;
    text-align: right;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}
.dashboard-role-chip { display: inline-flex; margin-bottom: 0.55rem; padding: 0.3rem 0.65rem; border-radius: 999px; color: #dbeafe; background: rgba(37, 99, 235, 0.38); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; }
.dashboard-hero-meta strong { display: block; font-size: 2rem; line-height: 1; }
.dashboard-hero-meta small { display: block; margin-top: 0.4rem; color: #dbeafe; }

.dashboard-workspace {
    display: grid;
    grid-template-columns: minmax(0, 2.15fr) minmax(320px, 0.85fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dashboard-workspace .add-visit-card {
    height: 100%;
    padding: clamp(1.35rem, 2vw, 2rem);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 20px;
    box-shadow: 0 18px 45px -30px rgba(15, 23, 42, 0.45);
}
.dashboard-workspace .add-visit-card:hover { transform: none; box-shadow: 0 22px 50px -30px rgba(15, 23, 42, 0.48); }

.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.card-heading h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.card-heading p { max-width: 720px; margin: 0.4rem 0 0; color: var(--text-muted); }
.card-heading-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex: 0 0 auto; border-radius: 13px; color: var(--primary); background: #eff6ff; font-size: 1.35rem; font-weight: 800; }
.card-heading-icon--success { color: #047857; background: #ecfdf5; font-size: 1.05rem; }

.visit-create-form { gap: 1.25rem; }
.visit-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.form-field { display: flex; min-width: 0; flex-direction: column; gap: 0.42rem; }
.form-field > span { color: #475569; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.form-field--wide { grid-column: span 2; }
.dashboard-page .form-field input,
.dashboard-page .form-field select,
.dashboard-page .form-field textarea { margin: 0; }
.dashboard-page .form-field textarea { min-height: 92px; }
.form-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 0.25rem; }
.form-submit-row small { max-width: 560px; color: var(--text-muted); }
.form-submit-row button { min-width: 190px; margin: 0; }

.add-visit-card--team { position: relative; display: flex; flex-direction: column; }
.team-create-form { flex: 1; }
.button-success { background: var(--success) !important; }
.button-success:hover { background: var(--success-hover) !important; }
.team-card-note { display: flex; align-items: baseline; gap: 0.5rem; margin-top: 1.3rem; padding: 1rem; border: 1px solid #d1fae5; border-radius: 14px; color: #065f46; background: #ecfdf5; }
.team-card-note strong { font-size: 1.65rem; line-height: 1; }
.team-card-note span { font-weight: 700; }

.stats-section { margin: 1.5rem 0; }
.stats-heading { margin-bottom: 1rem; }
.stats-heading h2 { font-size: clamp(1.4rem, 2vw, 1.8rem); letter-spacing: -0.025em; }
.stats-summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-ranking-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-card,
.advisor-results-section { border-radius: 18px; }
.stats-card { min-width: 0; }
.stats-value { font-size: clamp(1.8rem, 2.6vw, 2.45rem); }
.advisor-results-section { padding: clamp(1.25rem, 2vw, 2rem); }
.advisor-results-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.visit-filter-panel {
    display: block;
    margin: 1.5rem 0;
    padding: clamp(1.25rem, 2vw, 1.75rem);
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 18px;
    box-shadow: 0 16px 40px -30px rgba(15, 23, 42, 0.4);
}
.visit-filter-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.15rem; }
.visit-filter-heading h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.visit-filter-heading p { margin: 0.35rem 0 0; color: var(--text-muted); }
.visit-result-count { flex: 0 0 auto; padding: 0.5rem 0.8rem; border: 1px solid #bfdbfe; border-radius: 999px; color: #1d4ed8; background: #eff6ff; font-weight: 800; }
.visit-filter-form { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)) auto; align-items: end; gap: 0.85rem; }
.visit-filter-field { min-width: 0; }
.visit-filter-field select,
.visit-filter-field input { width: 100%; min-height: 44px; }
.visit-filter-actions { display: flex; align-items: center; gap: 0.55rem; }
.visit-filter-submit,
.visit-filter-reset { min-height: 44px; white-space: nowrap; }

.visits-table-container {
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(226, 232, 240, 0.95);
    border-radius: 20px;
    box-shadow: 0 18px 50px -34px rgba(15, 23, 42, 0.5);
}
.visits-table-topline { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.5rem 1rem; border-bottom: 1px solid #eef2f7; }
.visits-table-topline h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.table-page-badge { padding: 0.45rem 0.75rem; border-radius: 999px; color: var(--text-muted); background: #f1f5f9; font-size: 0.78rem; font-weight: 800; }
.visits-table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-gutter: stable; }
.visits-table { width: 100%; min-width: 1320px; table-layout: fixed; border-collapse: separate; border-spacing: 0; }
.visits-table th { padding: 1rem 0.8rem; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-size: 0.69rem; letter-spacing: 0.055em; }
.visits-table td { min-width: 0; padding: 1.15rem 0.8rem; vertical-align: top; overflow-wrap: anywhere; word-break: normal; }
.visits-table td strong { color: #172033; }
.visits-table td small { color: var(--text-muted); }
.visits-table tbody tr:last-child td { border-bottom: 0; }
.visits-table .tel-link { overflow-wrap: anywhere; }
.visits-table td:nth-child(6) small { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 5; }

.visits-table-admin .col-survey-date { width: 7.5%; }
.visits-table-admin .col-created-date { width: 8.5%; }
.visits-table-admin .col-advisor { width: 9%; }
.visits-table-admin .col-client { width: 17.5%; }
.visits-table-admin .col-vehicle { width: 13%; }
.visits-table-admin .col-notes { width: 13%; }
.visits-table-admin .col-status { width: 22%; }
.visits-table-admin .col-actions { width: 9.5%; }

.visits-table-advisor .col-survey-date { width: 8%; }
.visits-table-advisor .col-created-date { width: 10%; }
.visits-table-advisor .col-advisor { width: 10%; }
.visits-table-advisor .col-client { width: 20%; }
.visits-table-advisor .col-vehicle { width: 15%; }
.visits-table-advisor .col-notes { width: 15%; }
.visits-table-advisor .col-status { width: 22%; }

.advisor-badge { max-width: 100%; }
.status-control-row { align-items: flex-start; flex-wrap: nowrap; }
.status-select { width: 100%; min-width: 0; min-height: 42px; padding: 0.65rem 2rem 0.65rem 0.75rem; }
.status-timeline { margin-top: 0.45rem; }
.status-extra-meta { grid-template-columns: minmax(0, 1fr) auto; gap: 0.6rem; padding: 0.45rem 0.55rem; }
.status-extra-meta span { min-width: 0; }
.status-extra-meta strong { white-space: nowrap; font-size: 0.72rem; }
.actions-cell { padding-left: 0.55rem !important; padding-right: 0.55rem !important; }
.actions-group { display: flex; align-items: center; justify-content: flex-start; flex-wrap: nowrap; gap: 0.45rem; }
.actions-group .btn-action,
.actions-group .highlight-select { width: 38px; min-width: 38px; height: 38px; min-height: 38px; }
.actions-group .btn-action { padding: 0; }
.actions-cell > * + * { margin-left: 0; }

.pagination { margin: 0; padding: 1rem 1.5rem 1.3rem; background: #fff; }
.form-help { display: block; margin: -0.5rem 0 0.75rem; color: var(--text-muted); }

@media (max-width: 1500px) {
    .advisor-results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .visit-filter-form { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
    .visit-filter-actions { grid-column: auto; }
}

@media (max-width: 1180px) {
    .dashboard-workspace { grid-template-columns: 1fr; }
    .visit-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-field--wide { grid-column: span 1; }
    .stats-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .dashboard-container { width: calc(100% - 1.5rem); }
    .dashboard-hero { align-items: flex-start; flex-direction: column; }
    .dashboard-hero-meta { width: 100%; text-align: left; }
    .advisor-results-grid,
    .stats-ranking-grid { grid-template-columns: 1fr; }
    .visit-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .visit-filter-actions { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
    .dashboard-container { width: calc(100% - 1rem); margin-top: 0.75rem; }
    .dashboard-hero { padding: 1.25rem; border-radius: 16px; }
    .visit-form-grid,
    .stats-summary-grid,
    .visit-filter-form { grid-template-columns: 1fr; }
    .form-submit-row,
    .visit-filter-heading,
    .advisor-results-header { align-items: stretch; flex-direction: column; }
    .form-submit-row button { width: 100%; }
    .visit-filter-actions { grid-column: auto; }
    .visit-filter-submit,
    .visit-filter-reset { flex: 1; text-align: center; }
    .visits-table-topline { align-items: flex-start; flex-direction: column; }
    .dashboard-page .visits-table th:nth-child(4),
    .dashboard-page .visits-table td:nth-child(4) { display: table-cell !important; }
}

/* ==========================================================================
   Dashboard v5.1 — archiwum 30 dni i maksymalnie czytelna tabela
   ========================================================================== */

/* Przełącznik Bieżące / Archiwum */
.visit-view-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(240px, 1fr));
    gap: 0.8rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e2e8f0;
}

.visit-view-option {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    border: 1px solid #dbe4f0;
    border-radius: 14px;
    color: #334155;
    background: #f8fafc;
    text-decoration: none;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.visit-view-option:hover {
    border-color: #93c5fd;
    background: #eff6ff;
    box-shadow: 0 8px 24px -18px rgba(37, 99, 235, 0.75);
    transform: translateY(-1px);
}

.visit-view-option.active {
    border-color: #2563eb;
    color: #1e40af;
    background: #eff6ff;
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.18), 0 8px 22px -18px rgba(37, 99, 235, 0.9);
}

.visit-view-option--archive.active {
    border-color: #d97706;
    color: #92400e;
    background: #fffbeb;
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.14), 0 8px 22px -18px rgba(217, 119, 6, 0.85);
}

.visit-view-icon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #2563eb;
    background: #dbeafe;
    font-size: 0.95rem;
    font-weight: 900;
}

.visit-view-option--archive .visit-view-icon {
    color: #b45309;
    background: #fef3c7;
}

.visit-view-option > span:nth-child(2) {
    min-width: 0;
    display: grid;
    gap: 0.1rem;
}

.visit-view-option strong {
    color: inherit;
    font-size: 0.95rem;
}

.visit-view-option small {
    overflow: hidden;
    color: #64748b;
    font-size: 0.76rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visit-view-option em {
    min-width: 34px;
    padding: 0.28rem 0.48rem;
    border-radius: 999px;
    color: #0f172a;
    background: #ffffff;
    font-size: 0.8rem;
    font-style: normal;
    font-weight: 900;
    text-align: center;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.archive-rule-banner {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin: 0 1rem 0.4rem;
    padding: 0.85rem 1rem;
    border: 1px solid #fde68a;
    border-radius: 12px;
    color: #92400e;
    background: #fffbeb;
}

.archive-rule-banner > span {
    flex: 0 0 auto;
    font-size: 1.3rem;
}

.archive-rule-banner > div {
    min-width: 0;
    display: grid;
    gap: 0.12rem;
}

.archive-rule-banner strong,
.archive-rule-banner small {
    color: inherit;
}

.archive-rule-banner small {
    line-height: 1.35;
}

/* Nagłówek tabeli */
.table-heading-copy {
    min-width: 0;
}

.table-heading-copy p {
    max-width: 850px;
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.86rem;
}

/* Kontener i tabela — rekordy wyglądają jak oddzielne, czytelne karty */
.visits-table-container {
    background: #f1f5f9;
}

.visits-table-scroll {
    padding: 0 0.9rem 0.8rem;
    background: #f1f5f9;
}

.visits-table {
    min-width: 1500px;
    border-collapse: separate;
    border-spacing: 0 10px;
    table-layout: fixed;
}

.visits-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.visits-table th {
    padding: 0.8rem 0.75rem;
    border: 0;
    color: #475569;
    background: #f1f5f9;
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.075em;
    line-height: 1.2;
}

.visits-table th:first-child {
    padding-left: 1rem;
}

.visits-table td {
    padding: 1rem 0.8rem;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
    background: #ffffff;
    vertical-align: top;
}

.visits-table td:first-child {
    padding-left: 1rem;
    border-left: 1px solid #e2e8f0;
    border-radius: 14px 0 0 14px;
}

.visits-table td:last-child {
    padding-right: 1rem;
    border-right: 1px solid #e2e8f0;
    border-radius: 0 14px 14px 0;
}

.visits-table tbody tr:last-child td {
    border-bottom: 1px solid #e2e8f0;
}

.visit-row td {
    transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.visit-row:hover td {
    border-top-color: #bfdbfe;
    border-bottom-color: #bfdbfe;
    background: #f8fbff;
}

.visit-row:hover td:first-child {
    border-left-color: #bfdbfe;
    box-shadow: -4px 0 0 #3b82f6;
}

.visit-row:hover td:last-child {
    border-right-color: #bfdbfe;
}

.visit-row--archived td {
    background: #fffdf7;
    border-top-color: #fde7b2;
    border-bottom-color: #fde7b2;
}

.visit-row--archived td:first-child {
    border-left-color: #fbbf24;
    box-shadow: -4px 0 0 #f59e0b;
}

.visit-row--archived td:last-child {
    border-right-color: #fde7b2;
}

/* Stabilne proporcje kolumn */
.visits-table-admin .col-survey-date { width: 7.5%; }
.visits-table-admin .col-created-date { width: 9%; }
.visits-table-admin .col-advisor { width: 9.5%; }
.visits-table-admin .col-client { width: 17%; }
.visits-table-admin .col-vehicle { width: 13.5%; }
.visits-table-admin .col-notes { width: 11.5%; }
.visits-table-admin .col-status { width: 18%; }
.visits-table-admin .col-actions { width: 14%; }

.visits-table-advisor .col-survey-date { width: 8%; }
.visits-table-advisor .col-created-date { width: 10%; }
.visits-table-advisor .col-advisor { width: 11%; }
.visits-table-advisor .col-client { width: 21%; }
.visits-table-advisor .col-vehicle { width: 16%; }
.visits-table-advisor .col-notes { width: 14%; }
.visits-table-advisor .col-status { width: 20%; }

/* Zawartość komórek */
.date-display,
.client-details,
.vehicle-details {
    min-width: 0;
    display: grid;
    align-content: start;
    gap: 0.28rem;
}

.date-display strong {
    color: #0f172a;
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
}

.date-display > span {
    color: #475569;
    font-size: 0.8rem;
    font-weight: 700;
}

.date-display > small {
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 700;
}

.date-display .archive-since {
    margin-top: 0.2rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid #fde68a;
    border-radius: 7px;
    color: #92400e;
    background: #fffbeb;
    line-height: 1.25;
    white-space: normal;
}

.advisor-badge {
    width: fit-content;
    max-width: 100%;
    padding: 0.45rem 0.65rem;
    border: 1px solid #ddd6fe;
    border-radius: 999px;
    color: #5b21b6;
    background: #f5f3ff;
    line-height: 1.2;
}

.advisor-badge > span:last-child {
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-name,
.vehicle-details > strong {
    color: #0f172a !important;
    font-size: 0.88rem;
    line-height: 1.3;
}

.contact-line {
    min-width: 0;
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr);
    align-items: start;
    gap: 0.35rem;
    font-size: 0.8rem !important;
    line-height: 1.25;
}

.contact-line > span {
    color: #64748b;
    font-size: 0.7rem;
    text-align: center;
}

.contact-line {
    overflow-wrap: anywhere;
}

.vin-code {
    display: block;
    max-width: 100%;
    padding: 0.34rem 0.45rem;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    overflow: hidden;
    color: #475569;
    background: #f8fafc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
}

.notes-preview {
    display: -webkit-box;
    overflow: hidden;
    color: #475569;
    font-size: 0.78rem;
    line-height: 1.45;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 6;
}

.empty-value {
    color: #94a3b8;
    font-size: 0.74rem;
    font-style: italic;
}

/* Status */
.status-control-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 0.4rem;
}

.status-select {
    width: 100%;
    min-height: 42px;
    padding: 0.62rem 2rem 0.62rem 0.72rem;
    border-width: 1px;
    font-size: 0.8rem;
    line-height: 1.2;
}

.status-timeline {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.status-extra-meta {
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0.45rem 0.55rem;
    border-left-width: 3px;
    border-radius: 8px;
    background: #f8fafc;
}

.status-extra-meta span {
    color: #64748b;
    font-size: 0.68rem;
    line-height: 1.2;
}

.status-extra-meta strong {
    color: #334155 !important;
    font-size: 0.69rem;
    line-height: 1.2;
    text-align: right;
    white-space: nowrap;
}

.archived-meta {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.archived-meta span,
.archived-meta strong {
    color: #92400e !important;
}

/* Akcje opisane tekstem zamiast samych, niejednoznacznych ikon */
.actions-cell {
    padding-left: 0.7rem !important;
    padding-right: 0.9rem !important;
}

.actions-group {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 0.45rem;
}

.actions-group .btn-action {
    width: 100%;
    min-width: 0;
    height: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0 0.55rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.actions-group .btn-action strong {
    color: inherit !important;
    font-size: inherit;
}

.actions-group .highlight-form {
    grid-column: 1 / -1;
    width: 100%;
    display: block;
}

.highlight-control {
    width: 100%;
    display: grid;
    gap: 0.25rem;
}

.highlight-control > span {
    color: #64748b;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.actions-group .highlight-select,
.highlight-control .highlight-select {
    width: 100%;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    padding: 0 1.8rem 0 0.55rem;
    color: #334155;
    background-color: #ffffff;
    font-size: 0.74rem;
    text-align: left;
    text-align-last: left;
}

.highlight-select option,
.highlight-select option[value=""] {
    color: #334155;
    text-align: left;
}

.highlight-select.highlight-czerwony { color: #991b1b; }
.highlight-select.highlight-zielony { color: #166534; }
.highlight-select.highlight-zolty { color: #854d0e; }

/* Wyróżnienia muszą zachować czytelność w kartowym układzie */
.visit-row.highlight-czerwony td { background-color: #fff5f5 !important; }
.visit-row.highlight-zielony td { background-color: #f0fdf7 !important; }
.visit-row.highlight-zolty td { background-color: #fffdf0 !important; }

/* Puste wyniki */
.visits-empty-state {
    padding: 3rem 1rem !important;
    border: 1px dashed #cbd5e1 !important;
    border-radius: 14px !important;
    background: #ffffff !important;
    text-align: center;
}

.visits-empty-state::before {
    content: "Brak danych";
    display: inline-flex;
    margin-bottom: 0.7rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    color: #64748b;
    background: #f1f5f9;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Tablet: zachowujemy pełną tabelę i bezpieczny poziomy scroll */
@media (max-width: 1100px) {
    .visit-view-switch {
        grid-template-columns: 1fr;
    }

    .visits-table {
        min-width: 1450px;
    }
}

/* Telefon: każdy rekord staje się pełną kartą z własnymi etykietami */
@media (max-width: 760px) {
    .visit-view-switch {
        grid-template-columns: 1fr;
    }

    .visit-view-option small {
        white-space: normal;
    }

    .archive-rule-banner {
        margin-inline: 0.65rem;
        align-items: flex-start;
    }

    .visits-table-scroll {
        overflow: visible;
        padding: 0.5rem 0.65rem 0.9rem;
    }

    .visits-table,
    .visits-table tbody {
        min-width: 0;
        width: 100%;
        display: block;
    }

    .visits-table colgroup,
    .visits-table thead {
        display: none;
    }

    .visits-table tr.visit-row {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin: 0 0 0.75rem;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        overflow: hidden;
        background: #ffffff;
        box-shadow: 0 8px 24px -22px rgba(15, 23, 42, 0.75);
    }

    .visits-table tr.visit-row--archived {
        border-color: #fcd34d;
        background: #fffdf7;
    }

    .dashboard-page .visits-table td,
    .dashboard-page .visits-table td:nth-child(n) {
        width: auto;
        min-width: 0;
        display: block !important;
        padding: 0.8rem;
        border: 0;
        border-bottom: 1px solid #eef2f7;
        border-radius: 0;
        background: transparent !important;
        box-shadow: none !important;
    }

    .visits-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.42rem;
        color: #94a3b8;
        font-size: 0.61rem;
        font-weight: 900;
        letter-spacing: 0.07em;
        text-transform: uppercase;
    }

    .visits-table .cell-client,
    .visits-table .cell-vehicle,
    .visits-table .cell-notes,
    .visits-table .cell-status,
    .visits-table .cell-actions {
        grid-column: 1 / -1;
    }

    .visits-table .cell-actions {
        border-bottom: 0;
    }

    .actions-group {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .status-extra-meta strong {
        white-space: normal;
    }

    .visits-empty-state {
        display: block !important;
    }

    .visits-empty-state::before {
        content: "Brak danych";
    }
}
