/**
 * Unified CRM Styles
 * Clean, professional design system for all pages
 */

/* === RESET & BASE === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(180deg, #f0edff 0%, #f5f3ff 100%);
    color: #13142B;
    min-height: 100vh;
    padding: 0;
    line-height: 1.6;
}

/* === HEADER (matching rep page) === */
.header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid #e4e7f2;
    padding: 16px 32px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.header-logo {
    display: flex;
    align-items: center;
    justify-self: start;
}

.header-logo-img {
    height: 56px;
    width: auto;
    object-fit: contain;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    color: #13142B;
    text-align: center;
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-self: end;
}

.admin-menu {
    position: relative;
}
.admin-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
    min-width: 180px;
    z-index: 200;
    overflow: hidden;
}
.admin-dropdown.show {
    display: block;
}
.admin-dropdown button {
    display: block;
    width: 100%;
    padding: 11px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 14px;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s;
}
.admin-dropdown button:hover {
    background: #f3f4f6;
}
.admin-dropdown button:last-child {
    color: #dc2626;
    border-top: 1px solid #f3f4f6;
}
.admin-dropdown button:last-child:hover {
    background: #fef2f2;
}

.btn-logout {
    background: #e8e6f0;
    color: #13142B;
    border: 1px solid #d5d3e0;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #dbd8e8;
}

/* === CONTAINER === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* === HEADERS === */
h1, h2 {
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
}

/* === NAVIGATION TABS (matching rep page pill style) === */
.nav-tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    margin-bottom: 24px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.nav-tabs::-webkit-scrollbar {
    height: 4px;
}

.nav-tabs::-webkit-scrollbar-track {
    background: #eef2ff;
}

.nav-tabs::-webkit-scrollbar-thumb {
    background: #3D3B8E;
    border-radius: 2px;
}

.nav-tab {
    padding: 10px 18px;
    text-decoration: none;
    color: #6B7280;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav-tab:hover {
    background: #eeeef5;
    border-color: #d1d1e0;
    color: #13142B;
}

.nav-tab.active {
    color: white;
    background: #3D3B8E;
    border-color: #3D3B8E;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.week-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.week-tabs .week-tab {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #6B7280;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.week-tabs .week-tab:hover {
    background: #e5e7eb;
    color: #374151;
}
.week-tabs .week-tab.active {
    background: #3D3B8E;
    color: white;
    border-color: #3D3B8E;
}

/* === CARDS === */
.card {
    background: white;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card h2 {
    color: #13142B;
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
}

.card h3 {
    color: #475569;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

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

@media (min-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .dash-stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* Admin reminders: Personal (left) | Performance (right), grouped by rep */
.reps-reminders-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.reps-reminders-col {
    min-height: 100px;
}
.reps-reminders-col-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}
.reps-reminders-rep-group {
    margin-bottom: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}
.reps-reminders-rep-group:last-child { margin-bottom: 0; }
.reps-reminders-rep-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}
.reps-reminders-rep-name {
    font-weight: 600;
    font-size: 14px;
    color: #13142B;
}
.reps-reminders-two-col .reminder-widget-item {
    padding: 6px 0;
    font-size: 13px;
    color: #374151;
}
@media (max-width: 768px) {
    .reps-reminders-two-col { grid-template-columns: 1fr; }
}

/* Dashboard milestones + stars row (left/right) */
.dash-milestones-stars-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 0;
}
.dash-milestones-card, .dash-stars-card {
    min-height: 140px;
}
.dash-milestones-section {
    margin-bottom: 14px;
}
.dash-milestones-section:last-child { margin-bottom: 0; }
.dash-milestones-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin-bottom: 6px;
}
.dash-milestones-stars-row .empty-state {
    font-size: 13px;
    padding: 8px 0;
}
#dash-recent-stars {
    max-height: 220px;
    overflow-y: auto;
}

.dash-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Reminders widget grid - left/right, grouped by rep */
.reminders-widget-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.reminder-widget {
    background: linear-gradient(135deg, #fafbff 0%, #f8f9fc 100%);
    border: 1px solid #e4e7f2;
    border-radius: 12px;
    padding: 16px;
    min-height: 120px;
}
.reminder-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4e7f2;
}
.reminder-widget-name {
    font-weight: 600;
    font-size: 15px;
    color: #13142B;
}
.reminder-widget-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6b7280;
    margin: 10px 0 6px;
}
.reminder-widget-section:first-of-type { margin-top: 0; }
.reminder-widget-item {
    padding: 6px 0;
    font-size: 13px;
    color: #374151;
}
.reminder-widget-item:not(:last-child) { border-bottom: 1px solid #f3f4f6; }
@media (max-width: 768px) {
    .reminders-widget-grid { grid-template-columns: 1fr; }
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.stat-number, .stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #13142B;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
}

/* === BUTTONS === */
button, .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active, .btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: #3D3B8E;
    color: white;
}

.btn-primary:hover {
    background: #0a0b18;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

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

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

.btn-secondary {
    background: #64748b;
    color: white;
}

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

.btn-lead-action {
    display: inline-block;
    padding: 8px 14px;
    margin: 0 6px;
    font-size: 13px;
    font-weight: 600;
    color: #3D3B8E;
    background: #e8e6f0;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn-lead-action:hover {
    background: #3D3B8E;
    color: white;
    border-color: #3D3B8E;
}

/* Leads table - more spacing */
#panel-leads #cust-lifecycle-tabs { padding: 6px; margin-bottom: 20px; gap: 6px; }
#panel-leads .lifecycle-tab { padding: 12px 14px !important; font-size: 14px !important; }
#panel-leads .filters { margin-bottom: 16px; gap: 16px; }
#panel-leads .filters .filter-group { margin-right: 16px; }
#panel-leads #cust-search { padding: 12px 16px; margin-bottom: 16px; }
#panel-leads table th { padding: 16px 20px; font-size: 14px; }
#panel-leads table td { padding: 18px 20px; font-size: 14px; }
#panel-leads table td:last-child { padding: 16px 20px; min-width: 280px; }
#panel-leads .card { padding: 24px; }

/* === FORMS === */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
textarea,
select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #3D3B8E;
    box-shadow: 0 0 0 3px rgba(61, 74, 140, 0.1);
}

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 5px;
}

.form-group {
    margin-bottom: 14px;
}

/* === TABLES === */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

thead {
    background: #f1f5f9;
}

th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 14px 16px;
    border-top: 1px solid #e2e8f0;
    font-size: 14px;
    color: #13142B;
}

tr:hover {
    background: #f8fafc;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

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

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

.badge-info {
    background: #D4D9F2;
    color: #13142B;
}

/* === FILTERS === */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
}

.filter-group select {
    width: auto;
    min-width: 150px;
}

/* === LOADING STATES === */
.loading {
    text-align: center;
    padding: 40px;
    color: #64748b;
    font-size: 14px;
}

.loading::after {
    content: '...';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

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

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

/* === EMPTY STATES === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    font-weight: 500;
}

/* === UTILITY CLASSES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

/* === ACTIONS HEADER === */
.actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.actions-header h2 {
    margin-bottom: 0;
}

.actions-left {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* === INFO BOX === */
.info-box {
    background: #f0edff;
    border: 1px solid #e4e7f2;
    border-radius: 10px;
    padding: 16px 20px;
}

.info-box h3 {
    margin-bottom: 10px;
}

.info-box ol {
    padding-left: 20px;
    font-size: 14px;
    color: #475569;
    line-height: 1.8;
}

/* === CHART === */
.chart-container {
    padding: 12px 0;
}

.chart-bar {
    margin-bottom: 10px;
}

.chart-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.chart-bar-fill {
    background: #3D3B8E;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    min-width: 40px;
    transition: width 0.3s ease;
}

/* === FILTER BUTTONS === */
.filter-btn {
    padding: 8px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #475569;
}

.filter-btn.active {
    background: #3D3B8E;
    color: white;
    border-color: #3D3B8E;
}

.filter-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

/* === LEADERBOARD === */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.leaderboard-card {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border: 1px solid #fbbf24;
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    transition: transform 0.2s;
}

.leaderboard-card:hover {
    transform: translateY(-2px);
}

.leaderboard-card.silver {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-color: #cbd5e1;
}

.leaderboard-card.bronze {
    background: linear-gradient(135deg, #fed7aa, #fdba74);
    border-color: #fb923c;
}

.leaderboard-card .medal {
    font-size: 36px;
    margin-bottom: 8px;
}

.leaderboard-card .rep-name {
    font-size: 16px;
    font-weight: 700;
    color: #13142B;
    margin-bottom: 4px;
}

.leaderboard-card .star-count {
    font-size: 14px;
    color: #92400e;
    font-weight: 600;
}

/* === STAR BUTTONS === */
.btn-star {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #78350f;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-star:hover {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    transform: translateY(-1px);
}

.btn-milestone {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-milestone:hover {
    background: #fef3c7;
    border-color: #fbbf24;
}

/* === RECENT STARS === */
.recent-stars-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.recent-star-item {
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
}

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

.recent-star-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.recent-star-name {
    font-weight: 700;
    color: #13142B;
    font-size: 14px;
}

.recent-star-time {
    font-size: 12px;
    color: #9ca3af;
}

.recent-star-reason {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
}

/* === ICON BUTTONS === */
.btn-icon {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #f1f5f9;
}

/* === STATUS BADGES (extra) === */
.status-active {
    background: #d1fae5;
    color: #065f46;
}

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

.status-synced {
    background: #d1fae5;
    color: #065f46;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .pipeline-stats {
        flex-wrap: wrap;
        gap: 8px;
    }
    .pipeline-stat {
        min-width: 70px;
        padding: 10px 8px;
    }
    .pipeline-count { font-size: 20px; }
    .pipeline-label { font-size: 10px; }
    .pipeline-arrow { font-size: 16px; padding: 0 2px; }
    .action-card { flex-direction: column; align-items: stretch; }
    .action-card .ac-actions { justify-content: flex-end; }

    .header {
        padding: 12px 16px;
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }

    .header-logo-img {
        height: 40px;
    }

    .header-title {
        font-size: 16px;
    }

    .btn-logout {
        padding: 8px 14px;
        font-size: 13px;
    }

    .container {
        padding: 12px;
    }

    .nav-tabs {
        padding: 8px 12px;
        gap: 6px;
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-tab {
        padding: 8px 14px;
        font-size: 13px;
        flex-shrink: 0;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group select {
        width: 100%;
    }
    
    table {
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 10px;
    }
}


/* === MODALS === */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: white;
    margin: 0;
    padding: 0;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    max-height: 85vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

body.modal-open {
    overflow: hidden;
}

#update-plan-modal {
    align-items: flex-start;
}

#update-plan-modal .modal-content {
    display: flex;
    flex-direction: column;
    width: min(100%, 520px);
    max-height: calc(100vh - 40px);
    margin: auto;
}

#update-plan-modal .modal-header {
    position: sticky;
    top: 0;
    z-index: 1;
}

#update-plan-modal > .modal-content > form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-wide {
    max-width: 600px;
}
.modal-wide .modal-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #13142B;
}

.modal-body {
  padding: 20px 28px;
}

.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
}

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

.close-btn:hover {
    background-color: #f1f5f9;
    color: #13142B;
}

.modal-content > form {
    padding: 24px;
}

.modal-content > form .form-actions {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* === FOLLOWUP CARDS === */
.followup-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid #3D3B8E;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.followup-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.followup-card.overdue {
    border-left-color: #dc2626;
}

.followup-card.completed {
    border-left-color: #16a34a;
    opacity: 0.7;
}

.followup-card.today {
    border-left-color: #ea580c;
}

.followup-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.followup-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.followup-title strong {
    font-size: 16px;
    color: #13142B;
}

.followup-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.complete-btn {
    background: #d1fae5;
    color: #065f46;
}

.complete-btn:hover {
    background: #a7f3d0;
}

.edit-btn {
    background: #dbeafe;
    color: #1e40af;
}

.edit-btn:hover {
    background: #bfdbfe;
}

.delete-btn {
    background: #fee2e2;
    color: #991b1b;
}

.delete-btn:hover {
    background: #fecaca;
}

.followup-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.detail-row {
    display: flex;
    gap: 8px;
    font-size: 14px;
}

.detail-row.notes {
    flex-direction: column;
    gap: 4px;
}

.detail-label {
    font-weight: 600;
    color: #64748b;
    min-width: 80px;
}

.detail-value {
    color: #13142B;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.completed {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.overdue {
    background: #fee2e2;
    color: #991b1b;
}

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

.rep-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.rep-name {
    font-size: 18px;
    font-weight: 700;
    color: #13142B;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.rep-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* === MODAL CLOSE BUTTON (alternate class) === */
.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f1f5f9;
}

.readonly-field {
    background: #f1f5f9;
    cursor: not-allowed;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}


/* === FORM ACTIONS === */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e2e8f0;
}

.form-actions button {
    flex: 1;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.form-actions .btn-primary {
    background: #3D3B8E;
    color: white;
    border: none;
}

.form-actions .btn-primary:hover {
    background: #0a0b18;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(61, 74, 140, 0.4);
}

.form-actions .btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 2px solid #e2e8f0;
}

.form-actions .btn-secondary:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}


/* === TEMPERATURE TAB === */
.temp-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 768px) {
    .temp-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.temp-card {
    border-radius: 12px;
    padding: 24px 16px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.temp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.temp-card.hot {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border: 1px solid #fecaca;
}

.temp-card.warm {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    border: 1px solid #fde68a;
}

.temp-card.cold {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
}

.temp-card.dormant {
    background: linear-gradient(135deg, #f9fafb, #f3f4f6);
    border: 1px solid #e5e7eb;
}

.temp-icon {
    font-size: 32px;
    margin-bottom: 8px;
    line-height: 1;
}

.temp-value {
    font-size: 36px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 4px;
}

.temp-card.hot .temp-value { color: #dc2626; }
.temp-card.warm .temp-value { color: #d97706; }
.temp-card.cold .temp-value { color: #2563eb; }
.temp-card.dormant .temp-value { color: #6b7280; }

.temp-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.temp-card.hot .temp-label { color: #991b1b; }
.temp-card.warm .temp-label { color: #92400e; }
.temp-card.cold .temp-label { color: #1e40af; }
.temp-card.dormant .temp-label { color: #4b5563; }

.temp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}

.temp-badge.hot {
    background: #fee2e2;
    color: #dc2626;
}

.temp-badge.warm {
    background: #fef3c7;
    color: #d97706;
}

.temp-badge.cold {
    background: #dbeafe;
    color: #2563eb;
}

.temp-badge.dormant {
    background: #f3f4f6;
    color: #6b7280;
}

/* Followup Grid Layout */
.followup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

/* Plan approval buttons */
.btn-approve {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #dcfce7;
    color: #166534;
}
.btn-approve:hover { background: #bbf7d0; }
.btn-reject {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: #fee2e2;
    color: #991b1b;
}
.btn-reject:hover { background: #fecaca; }
.actions-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}
.progress-mini {
    display: inline-block;
    width: 60px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 4px;
}
.progress-mini-bar {
    height: 100%;
    background: #3D3B8E;
    border-radius: 3px;
    transition: width 0.3s;
}
.admin-sub-tabs {
    display: flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 3px;
    margin-bottom: 16px;
}
.admin-sub-tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
}
.admin-sub-tab.active {
    background: white;
    color: #3D3B8E;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.admin-sub-tab:hover:not(.active) {
    color: #374151;
}
.pipeline-stats {
    display: flex;
    gap: 0;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.pipeline-stat {
    flex: 1;
    min-width: 100px;
    text-align: center;
    padding: 16px 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    border: 2px solid transparent;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.pipeline-stat:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.pipeline-stat.active-filter { border-color: #3D3B8E; }
.pipeline-stat.requested { border-left: 4px solid #f59e0b; background: linear-gradient(135deg, #fffbeb 0%, #ffffff 60%); }
.pipeline-stat.shipped { border-left: 4px solid #3b82f6; background: linear-gradient(135deg, #eff6ff 0%, #ffffff 60%); }
.pipeline-stat.approved { border-left: 4px solid #3b82f6; background: linear-gradient(135deg, #eff6ff 0%, #ffffff 60%); }
.pipeline-stat.fulfilled { border-left: 4px solid #10b981; background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 60%); }
.pipeline-stat.overdue-stat { border-left: 4px solid #ef4444; background: linear-gradient(135deg, #fef2f2 0%, #ffffff 60%); }
.pipeline-stat.total-stat { border-left: 4px solid #6b7280; }
.pipeline-count { font-size: 28px; font-weight: 700; color: #1f2937; }
.pipeline-label { font-size: 13px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.pipeline-stat.requested .pipeline-label { color: #92400e; }
.pipeline-stat.fulfilled .pipeline-label { color: #065f46; }
.pipeline-sub { font-size: 13px; color: #9ca3af; margin-top: 2px; }
.pipeline-arrow { font-size: 20px; color: #d1d5db; padding: 0 4px; flex-shrink: 0; }
.action-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.15s;
}
.action-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.action-card .ac-info { flex: 1; min-width: 0; }
.action-card .ac-name { font-weight: 600; font-size: 14px; color: #1f2937; }
.action-card .ac-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.action-card .ac-product { font-size: 12px; color: #3D3B8E; font-weight: 500; }
.action-card .ac-actions { display: flex; gap: 6px; flex-shrink: 0; }
.action-card .ac-overdue { background: #fef2f2; border-color: #fecaca; }
.overdue-tag { display: inline-block; background: #fee2e2; color: #991b1b; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.due-tag { display: inline-block; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 10px; margin-left: 6px; }
.due-tag.soon { background: #fef3c7; color: #92400e; }
.due-tag.ok { background: #dcfce7; color: #166534; }
.section-label { font-size: 13px; font-weight: 700; color: #374151; text-transform: uppercase; letter-spacing: 0.5px; padding: 12px 0 6px; border-bottom: 2px solid #e5e7eb; margin-bottom: 8px; }
.section-row td {
    background: #f9fafb;
    padding: 8px 12px !important;
    font-size: 13px;
    border-top: 2px solid #e5e7eb;
}
#cust-lifecycle-tabs .lifecycle-tab.active {
    background: white !important;
    color: #3D3B8E !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
#cust-lifecycle-tabs .lifecycle-tab:not(.active):hover {
    background: rgba(255,255,255,0.5) !important;
}
.status-badge.status-active { background: #dcfce7; color: #166534; }

/* Shared Performance Board Tokens + Utilities (Rep/Admin parity) */
:root {
  --perf-bg: #ffffff;
  --perf-muted: #6b7280;
  --perf-text: #111827;
  --perf-border: #e5e7eb;
  --perf-soft: #f8fafc;
  --perf-danger: #dc2626;
  --perf-danger-soft: #fff7f7;
  --perf-warn: #b45309;
  --perf-warn-soft: #fff7ed;
  --perf-ok: #0f766e;
}

.perf-board-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 10px; margin-bottom: 10px; }
.perf-board-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; margin-bottom: 10px; }
.perf-board-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.perf-tile {
  padding: 10px;
  border: 1px solid var(--perf-border);
  border-radius: 8px;
  background: var(--perf-bg);
  text-align: left;
  cursor: pointer;
}
.perf-tile-label { font-size: 11px; color: var(--perf-muted); }
.perf-tile-value { font-size: 20px; font-weight: 800; color: var(--perf-text); }
.perf-tile-sub { font-size: 12px; font-weight: 700; }
.perf-tile-sub.muted { color: var(--perf-muted); }
.perf-tile-sub.warn { color: var(--perf-warn); }
.perf-tile-sub.danger { color: var(--perf-danger); }
.perf-tile-sub.ok { color: var(--perf-ok); }

.perf-box {
  padding: 10px;
  border: 1px solid var(--perf-border);
  border-radius: 8px;
  background: var(--perf-soft);
  margin-bottom: 10px;
}
.perf-box.white { background: var(--perf-bg); }
.perf-box-title { font-size: 12px; font-weight: 700; color: #374151; margin-bottom: 6px; }
.perf-box-text { font-size: 13px; color: #374151; }

.perf-tile-soft-danger { border-color: #fecaca; background: var(--perf-danger-soft); }
.perf-tile-soft-warn { border-color: #ffedd5; background: var(--perf-warn-soft); }

/* Activity Log filters */
.act-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.act-filter-select {
    flex: 1;
    min-width: 130px;
    padding: 9px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    background: #f9fafb;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.act-filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.act-filter-select:hover {
    border-color: #c7d2fe;
    background-color: #fff;
}
.act-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
@media (max-width: 640px) {
    .act-filters {
        flex-direction: column;
    }
    .act-filter-select {
        flex: none;
        width: 100%;
    }
    .act-stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ===== ADMIN MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    /* Tables: horizontal scroll wrapper */
    .tab-panel {
        overflow-x: hidden;
        max-width: 100%;
    }
    .card {
        max-width: 100%;
        min-width: 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .card table,
    .tab-panel table {
        min-width: 500px;
    }

    /* Two-column grids stack on mobile */
    .dash-two-col,
    .dash-milestones-stars-row {
        grid-template-columns: 1fr !important;
    }

    /* Dashboard overview header */
    #panel-dashboard .card > div[style*="justify-content:space-between"] {
        flex-direction: column;
        gap: 8px;
        align-items: stretch !important;
    }
    #panel-dashboard .card > div[style*="justify-content:space-between"] select {
        width: 100% !important;
        min-width: unset !important;
    }

    /* Cards: tighter padding */
    .card {
        padding: 14px;
        margin-bottom: 12px;
    }
    .card h2 {
        font-size: 16px;
    }

    /* Modals: full width on mobile */
    .modal-content {
        max-width: 95vw !important;
        max-height: 90vh;
        overflow-y: auto;
    }
    .modal {
        padding: 10px;
    }

    /* Stars podium: stack on small screens */
    .leaderboard-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .leaderboard-card {
        min-width: unset;
    }
    .leaderboard-card .medal {
        font-size: 28px;
    }

    /* Pipeline sub-tabs */
    .admin-sub-tabs {
        flex-wrap: wrap;
    }

    /* Customer lifecycle tabs: scroll on mobile */
    #cust-lifecycle-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
    }
    #cust-lifecycle-tabs .lifecycle-tab {
        flex-shrink: 0 !important;
        min-width: 0;
        white-space: nowrap;
        font-size: 12px !important;
        padding: 8px 6px !important;
    }

    /* Actions header stacks on mobile */
    .actions-header {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .actions-left {
        justify-content: flex-start;
    }

    /* Reps buttons stack */
    #panel-reps .card > div:first-child {
        flex-direction: column;
        gap: 8px;
    }
    #panel-reps .card > div:first-child > div {
        flex-wrap: wrap;
    }

    /* Samples tab: scroll on mobile, prevent overlap */
    #panel-samples .card {
        min-width: 0;
    }
    #panel-samples .samples-table-scroll {
        margin: 0 -14px;
        padding: 0 14px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        max-width: 100%;
    }
    #panel-samples table {
        min-width: 650px;
    }
    #panel-samples .pipeline-stats {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Plans tab: wider scroll for 7-col tables */
    #panel-plans table {
        min-width: 650px;
    }
    .actions-cell {
        white-space: nowrap;
    }
    .progress-mini {
        width: 40px;
    }
    .btn-approve, .btn-reject {
        padding: 4px 8px;
        font-size: 11px;
    }
    .modal-wide {
        max-width: 95vw !important;
    }
    .modal-wide .modal-body {
        overflow-x: auto;
    }

    /* Calendar header stacks */
    .calendar-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    .filter-buttons {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        display: flex;
        gap: 6px;
    }
    .filter-btn {
        flex-shrink: 0;
        font-size: 12px;
        padding: 6px 12px;
    }
    .followup-header {
        flex-direction: column;
    }
    .followup-actions {
        align-self: flex-end;
    }

    /* Sample/Order dashboard stats */
    .dash-stats-grid,
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Login overlay */
    #admin-login-overlay > div {
        width: 90vw !important;
        max-width: 360px;
    }
}

@media (max-width: 480px) {
    /* Even tighter on small phones */
    .header {
        padding: 8px 12px;
    }
    .header-logo-img {
        height: 32px;
    }
    .header-title {
        font-size: 14px;
    }
    .btn-logout {
        padding: 6px 10px;
        font-size: 12px;
    }
    .nav-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    .container {
        padding: 8px;
    }
    .card {
        padding: 12px;
        border-radius: 10px;
    }
    .stats-grid {
        gap: 8px;
    }
    .stat-card {
        padding: 12px 8px;
    }
    .stat-value {
        font-size: 22px;
    }
    .stat-label {
        font-size: 10px;
    }
    .act-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    .pipeline-stats {
        gap: 4px;
    }
    .pipeline-stat {
        min-width: 60px;
        padding: 8px 4px;
    }
    .pipeline-count {
        font-size: 18px;
    }
    .action-card {
        padding: 10px 12px;
    }
    .temp-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
}
