@import url('https://cdn.jsdelivr.net/npm/remixicon@4.1.0/fonts/remixicon.css');

:root {
    --primary: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

@media (min-width: 769px) {
    .app { display: flex; height: 100vh; }
    .sidebar { width: 200px; background: var(--card); border-right: 1px solid var(--border); padding: 20px 0; flex-shrink: 0; display: flex; flex-direction: column; }
    .main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
    .header { background: var(--card); border-bottom: 1px solid var(--border); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
    .content { flex: 1; overflow: auto; padding: 24px; }
    .calculator-panel { width: 280px; background: var(--card); border-left: 1px solid var(--border); padding: 20px; flex-shrink: 0; overflow: auto; }
    .bottom-nav { display: none !important; }
    .sidebar-item { padding: 12px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); transition: all 0.2s; }
    .sidebar-item:hover { background: var(--bg); }
    .sidebar-item.active { background: #eff6ff; color: var(--primary); border-right: 3px solid var(--primary); font-weight: 500; }
    .sidebar-item i { font-size: 20px; width: 20px; text-align: center; }
    .tab-content { display: none; }
    .tab-content.active { display: block; }
}

.footer { text-align: center; padding: 12px; font-size: 12px; color: var(--text-secondary); background: var(--card); border-top: 1px solid var(--border); }
.footer a { color: var(--text-secondary); text-decoration: none; }
.footer a:hover { color: var(--primary); text-decoration: underline; }

@media (max-width: 768px) {
    .app { display: flex; flex-direction: column; height: 100vh; }
    .sidebar { display: none; }
    .main { flex: 1; overflow: auto; }
    .header { background: var(--card); border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 10; }
    .content { padding: 16px; padding-bottom: 140px; }
    .calculator-panel { position: fixed; bottom: 60px; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); padding: 16px; box-shadow: 0 -4px 12px rgba(0,0,0,0.1); max-height: 50vh; overflow: auto; transform: translateY(calc(100% - 50px)); transition: transform 0.3s; z-index: 20; }
    .calculator-panel.expanded { transform: translateY(0); }
    .calc-toggle { display: flex; justify-content: center; align-items: center; padding: 8px; cursor: pointer; }
    .calc-handle { width: 40px; height: 4px; background: var(--border); border-radius: 2px; }
    .bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); border-top: 1px solid var(--border); display: flex; z-index: 30; }
    .nav-item { flex: 1; padding: 12px 8px; text-align: center; cursor: pointer; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 4px; text-decoration: none; color: var(--text); }
    .nav-item.active { color: var(--primary); }
    .nav-item i { font-size: 22px; }
    .tab-content { display: none; }
    .tab-content.active { display: block; }
    .page-content { display: none; }
    .page-content.active { display: block; }
}

@media (min-width: 769px) {
    .page-content { display: none; }
    .page-content.active { display: block; }
}

.card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card-header { font-weight: 600; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.card-body { }
.btn { padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; width: 100%; }
.input:focus { outline: none; border-color: var(--primary); }

.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.badge-eligible { background: #dcfce7; color: #166534; }
.badge-risk { background: #fef3c7; color: #92400e; }
.badge-sleep { background: #f1f5f9; color: #475569; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-failed { background: #fee2e2; color: #991b1b; }
.badge-ev { background: #ecfdf5; color: #047857; }
.badge-ice { background: #fef2f2; color: #b91c1c; }
.badge-contacted { background: #f1f5f9; color: #64748b; }
.badge-period { background: linear-gradient(135deg, #667eea, #764ba2); color: white; }
.badge-nosample { background: #fee2e2; color: #991b1b; }
.badge-expired { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-scored { background: linear-gradient(135deg, #16a34a, #15803d); color: white; }
.badge-window { background: #dbeafe; color: #1e40af; font-size: 11px; }
.badge-lowscore { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; padding: 4px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }

.customer-card.risk-customer { background: linear-gradient(135deg, #fef2f2, #fee2e2); border-color: #fca5a2; }
.customer-card.expired-customer { background: #fffbeb; border-color: #fcd34d; opacity: 0.8; }
.customer-card.scored { border-left: 3px solid #16a34a; }

.customer-card { background: var(--card); border-radius: var(--radius); border: 1px solid var(--border); padding: 16px; margin-bottom: 12px; transition: all 0.3s; }
.customer-card.contacted { background: #f8fafc; border-color: #cbd5e1; opacity: 0.75; }
.customer-card-body { display: flex; justify-content: space-between; align-items: stretch; gap: 16px; }
.customer-card-left { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.customer-card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.customer-card-actions { display: flex; flex-direction: column; gap: 8px; min-width: 90px; }
.customer-info-row { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--text-secondary); }
.customer-info-row span { white-space: nowrap; }
.customer-info-row strong { color: var(--text); font-weight: 500; }
.customer-primary { font-weight: 600; font-size: 16px; }
.customer-phone-link { font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none; color: var(--text); }
.customer-phone-link:hover { color: var(--primary); text-decoration: underline; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: center; }
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 13px; color: var(--text-secondary); }
select.input { width: auto; min-width: 120px; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

.calc-section { margin-bottom: 20px; }
.calc-section-title { font-weight: 600; margin-bottom: 12px; font-size: 14px; color: var(--text-secondary); }
.calc-result { background: linear-gradient(135deg, var(--primary), #7c3aed); color: white; border-radius: var(--radius); padding: 20px; text-align: center; margin-bottom: 16px; }
.calc-score { font-size: 48px; font-weight: 700; }
.calc-target { font-size: 14px; opacity: 0.9; }
.calc-progress { height: 8px; background: rgba(255,255,255,0.3); border-radius: 4px; margin-top: 12px; overflow: hidden; }
.calc-progress-bar { height: 100%; background: white; border-radius: 4px; transition: width 0.3s; }
.calc-inputs { display: flex; flex-direction: column; gap: 12px; }
.calc-input-row { display: flex; align-items: center; justify-content: space-between; }
.calc-input-row label { font-size: 13px; }
.calc-input-row input { width: 80px; text-align: center; }
.calc-value-group { display: flex; align-items: center; gap: 4px; }
.correction-sign { color: var(--text-secondary); font-size: 13px; font-weight: 600; }
.correction-input { width: 60px !important; text-align: center; border-color: #dbeafe; }
.correction-input:focus { border-color: var(--primary); background: #eff6ff; }
.correction-input::-webkit-inner-spin-button,
.correction-input::-webkit-outer-spin-button { opacity: 1; }
.input-sm { width: 65px !important; padding: 6px 4px; font-size: 13px; }
.calc-need { background: var(--bg); border-radius: var(--radius); padding: 16px; text-align: center; }
.calc-need-value { font-size: 24px; font-weight: 700; color: var(--success); }

.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 40px; text-align: center; cursor: pointer; transition: all 0.2s; }
.upload-zone:hover { border-color: var(--primary); background: #eff6ff; }
.upload-zone.dragover { border-color: var(--primary); background: #dbeafe; }
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-text { color: var(--text-secondary); }
.upload-zone .ri-upload-cloud-2-line { font-size: 48px; color: var(--primary); margin-bottom: 16px; }

.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--bg); font-weight: 600; }
tr:hover { background: var(--bg); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 64px; margin-bottom: 16px; color: var(--border); }

.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: var(--text); color: white; padding: 12px 24px; border-radius: 8px; z-index: 100; animation: fadeIn 0.3s; }

.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: all 0.3s; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal { background: var(--card); border-radius: var(--radius); width: 90%; max-width: 400px; max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; transform: scale(0.9); transition: transform 0.3s; }
.modal-overlay.active .modal { transform: scale(1); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.modal-close { width: 32px; height: 32px; border: none; background: none; cursor: pointer; font-size: 20px; color: var(--text-secondary); border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg); }
.modal-body { padding: 20px; overflow: auto; flex: 1; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

@keyframes fadeIn { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

.consultant-select { display: flex; gap: 8px; flex-wrap: wrap; }
.consultant-btn { padding: 8px 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); cursor: pointer; transition: all 0.2s; font-size: 14px; }
.consultant-btn:hover { border-color: var(--primary); }
.consultant-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.logo { padding: 16px 20px; font-size: 18px; font-weight: 700; color: var(--primary); border-bottom: 1px solid var(--border); margin-bottom: 10px; }

#fileInput { display: none; }

/* Archive month edit section */
.btn-group-month { background: #fffbeb; border: 1px solid #fcd34d; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

/* Clear scope warning styles */
.clear-scope-warning { background: #fef2f2; border: 1px solid #fee2e2; border-radius: 8px; padding: 16px; margin-bottom: 16px; }
.clear-scope-warning ul { margin: 0; padding-left: 20px; line-height: 1.8; }

/* Archive notice bar */
.archive-notice { background: #dbeafe; border: 1px solid #bfdbfe; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: #1e40af; }
