* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f9fafb; color: #1f2937; min-height: 100vh; }

.header { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); color: white; padding: 20px 24px; cursor: default; }
.header-inner { max-width: 960px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; }
.header .logo { font-size: 14px; opacity: 0.85; }
.header .title { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.header .user-info { display: flex; align-items: center; gap: 12px; }
.header .client-name { font-size: 14px; opacity: 0.9; }
.btn-logout { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3); color: white; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-logout:hover { background: rgba(255,255,255,0.25); }

.container { max-width: 960px; margin: 0 auto; padding: 24px; }

/* Login */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 40px; width: 100%; max-width: 400px; }
.login-card h2 { font-size: 24px; margin-bottom: 8px; }
.login-card p { color: #6b7280; font-size: 14px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: #374151; }
.form-group input, .form-group textarea { width: 100%; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 0.15s; font-family: inherit; }
.form-group input:focus, .form-group textarea:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-group select { width: 100%; padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 14px; background: white; }
.form-group textarea { resize: vertical; min-height: 60px; }
.btn-primary { width: 100%; padding: 10px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 12px; display: none; }

/* Tab Navigation */
.tab-nav { display: flex; gap: 4px; margin-bottom: 16px; background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 4px; overflow-x: auto; }
.tab-btn { flex: 1; padding: 10px 16px; background: transparent; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; color: #6b7280; transition: all 0.15s; white-space: nowrap; }
.tab-btn:hover { color: #374151; background: #f3f4f6; }
.tab-btn.active { background: #2563eb; color: white; }
.tab-btn-cta:not(.active) { color: #059669; font-weight: 600; position: relative; background: #ecfdf5; }
.tab-btn-cta:not(.active)::after { content: ''; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: #059669; border-radius: 50%; animation: ctaPulse 2s infinite; }
@keyframes ctaPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Cards */
.card { background: white; border-radius: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); padding: 24px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h3 { font-size: 16px; font-weight: 600; }
.btn-add { background: #2563eb; color: white; border: none; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-add:hover { background: #1d4ed8; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px; border-bottom: 2px solid #e5e7eb; }
td { padding: 12px; border-bottom: 1px solid #f3f4f6; font-size: 14px; vertical-align: middle; }
tr:hover { background: #f9fafb; }

.badge-active { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; background: #dcfce7; color: #166534; }
.badge-inactive { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; background: #fee2e2; color: #991b1b; }

.btn-edit { background: none; border: 1px solid #e5e7eb; padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; color: #374151; }
.btn-edit:hover { background: #f3f4f6; }
.btn-toggle { background: none; border: 1px solid #e5e7eb; padding: 4px 10px; border-radius: 6px; font-size: 12px; cursor: pointer; color: #374151; }
.btn-toggle:hover { background: #f3f4f6; }
.btn-delete { color: #dc2626 !important; border-color: #fecaca !important; }
.btn-delete:hover { background: #fef2f2 !important; }
.actions { display: flex; gap: 6px; }

.col-description { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Schedule display */
.schedule-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.schedule-row.inactive { opacity: 0.4; }
.day-toggle { display: flex; align-items: center; gap: 6px; min-width: 60px; }
.day-toggle input[type=checkbox] { width: 16px; height: 16px; }
.time-inputs { display: flex; align-items: center; gap: 8px; }
.time-inputs select { padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 6px; font-size: 13px; }
.time-inputs span { color: #9ca3af; font-size: 13px; }

/* Business Hours Form */
.form-section { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #f3f4f6; }
.form-section:last-child { border-bottom: none; margin-bottom: 0; }
.form-section h3 { font-size: 14px; font-weight: 600; color: #374151; margin-bottom: 12px; }
.form-row { margin-bottom: 12px; }
.form-row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-section select { padding: 10px 12px; border: 1px solid #e5e7eb; border-radius: 8px; font-size: 14px; background: white; width: 100%; }
.form-actions { margin-top: 20px; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); z-index: 100; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal { background: white; border-radius: 12px; padding: 28px; width: 90%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.btn-cancel { padding: 8px 16px; border: 1px solid #e5e7eb; background: white; border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-cancel:hover { background: #f3f4f6; }
.btn-save { padding: 8px 16px; background: #2563eb; color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.btn-save:hover { background: #1d4ed8; }

.checkbox-group { display: flex; align-items: center; gap: 8px; }
.checkbox-group input[type=checkbox] { width: 16px; height: 16px; }

.loading { text-align: center; padding: 40px; color: #6b7280; }
.empty-state { text-align: center; padding: 40px; color: #9ca3af; }

.footer { text-align: center; padding: 24px; color: #9ca3af; font-size: 12px; }
.footer a { color: #9ca3af; text-decoration: none; }
.footer a:hover { color: #6b7280; text-decoration: underline; }

.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 20px; border-radius: 8px; font-size: 14px; color: white; z-index: 200; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.show { opacity: 1; }

/* Audio player in calls table */
.col-audio audio { vertical-align: middle; }

@media (max-width: 700px) {
  .container { padding: 16px; }
  .header { padding: 16px; }
  table { font-size: 13px; }
  th, td { padding: 8px 6px; }
  .col-schedule { display: none; }
  .col-description { display: none; }
  .col-turns { display: none; }
  .col-audio { display: none; }
  .tab-btn { padding: 8px 8px; font-size: 12px; }
  .form-row-2col { grid-template-columns: 1fr; }
}
/* Call detail expandable */
.call-detail-row td { padding: 0 !important; border-bottom: 1px solid #e5e7eb; }
.call-detail-row.hidden { display: none; }
.call-detail-content { padding: 12px 16px; }
.call-summary-card { border-left: 3px solid #2563eb; padding: 10px 14px; margin-bottom: 10px; background: #eff6ff; border-radius: 0 8px 8px 0; font-size: 13px; line-height: 1.5; }
.call-transcript-box { max-height: 200px; overflow-y: auto; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 10px 14px; font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.call-row-clickable { cursor: pointer; }
.call-row-clickable:hover { background: #f0f6ff !important; }
.expand-icon { display: inline-block; width: 16px; font-size: 10px; color: #6b7280; transition: transform 0.15s; }
.expand-icon.open { transform: rotate(90deg); }

/* Analytics */
.analytics-controls { display: flex; gap: 8px; margin-bottom: 16px; }
.range-btn { padding: 6px 14px; border: 1px solid #e5e7eb; background: white; border-radius: 6px; font-size: 13px; cursor: pointer; color: #374151; }
.range-btn:hover { background: #f3f4f6; }
.range-btn.active { background: #2563eb; color: white; border-color: #2563eb; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: white; border-radius: 10px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: #1f2937; }
.stat-label { font-size: 12px; color: #6b7280; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.chart-section { margin-bottom: 20px; }
.chart-section h4 { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: #374151; }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding: 0 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; }
.bar { background: #2563eb; border-radius: 3px 3px 0 0; min-height: 2px; width: 100%; transition: height 0.3s; }
.bar-label { font-size: 9px; color: #9ca3af; margin-top: 4px; writing-mode: vertical-rl; transform: rotate(180deg); max-height: 40px; overflow: hidden; }
.stacked-bar-container { display: flex; height: 28px; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.stacked-segment { height: 100%; transition: width 0.3s; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.peak-table { width: 100%; border-collapse: collapse; }
.peak-table td { padding: 4px 8px; font-size: 12px; border-bottom: 1px solid #f3f4f6; }
.peak-bar { background: #dbeafe; border-radius: 3px; height: 14px; }
.wow-card { display: flex; align-items: center; gap: 12px; padding: 16px; background: white; border-radius: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.wow-arrow { font-size: 24px; }
.wow-up { color: #16a34a; }
.wow-down { color: #dc2626; }
.wow-flat { color: #6b7280; }
.wow-text { font-size: 14px; color: #374151; }
.wow-pct { font-weight: 700; font-size: 20px; }
.top-callers-list { font-size: 13px; }
.top-callers-list .caller-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f3f4f6; }
@media (max-width: 700px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .analytics-controls { flex-wrap: wrap; }
}
