/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius); padding: 18px 20px;
  transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-tertiary); margin-bottom: 8px; font-weight: 500; }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 500; letter-spacing: -1px; }
.stat-card[data-type="active"] .stat-value { color: var(--status-in-progress); }
.stat-card[data-type="pending"] .stat-value { color: var(--status-pending); }
.stat-card[data-type="waiting"] .stat-value { color: var(--status-waiting); }
.stat-card[data-type="completed"] .stat-value { color: var(--status-completed); }
.stat-card[data-type="failed"] .stat-value { color: var(--status-failed); }

/* Tables */
.table-section-header { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 12px; letter-spacing: 0.1px; }
.table-wrap { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 10px 16px; font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 1px; color: var(--text-tertiary);
  background: var(--bg-elevated); border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border-subtle); cursor: pointer; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 12px 16px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
tbody td:first-child { color: var(--text-primary); font-weight: 500; }

/* Status badge */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 500;
  letter-spacing: 0.3px;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.badge-completed { background: var(--status-completed-bg); color: var(--status-completed); }
.badge-completed::before { background: var(--status-completed); }
.badge-waiting_reply { background: var(--status-waiting-bg); color: var(--status-waiting); }
.badge-waiting_reply::before { background: var(--status-waiting); }
.badge-in_progress { background: var(--status-in-progress-bg); color: var(--status-in-progress); }
.badge-in_progress::before { background: var(--status-in-progress); }
.badge-pending { background: var(--status-pending-bg); color: var(--status-pending); }
.badge-pending::before { background: var(--status-pending); }
.badge-failed { background: var(--status-failed-bg); color: var(--status-failed); }
.badge-failed::before { background: var(--status-failed); }
.badge-waiting_follow_up { background: var(--status-waiting-bg); color: var(--status-waiting); }
.badge-waiting_follow_up::before { background: var(--status-waiting); }
.badge-retry_pending { background: var(--status-pending-bg); color: var(--status-pending); }
.badge-retry_pending::before { background: var(--status-pending); }
.badge-active { background: var(--status-completed-bg); color: var(--status-completed); }
.badge-active::before { background: var(--status-completed); }
.badge-expiring { background: var(--status-waiting-bg); color: var(--status-waiting); }
.badge-expiring::before { background: var(--status-waiting); }
.badge-expired { background: var(--status-failed-bg); color: var(--status-failed); }
.badge-expired::before { background: var(--status-failed); }
.badge-cancelled { background: var(--status-failed-bg); color: var(--status-failed); }
.badge-cancelled::before { background: var(--status-failed); }
.badge-not_renewing { background: var(--status-waiting-bg); color: var(--status-waiting); }
.badge-not_renewing::before { background: var(--status-waiting); }

/* Filters */
.filters { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.filter-input, .filter-select {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-primary);
  font-family: var(--font-body); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.filter-input::placeholder { color: var(--text-tertiary); }
.filter-input:focus, .filter-select:focus { border-color: var(--accent); }
.filter-select { cursor: pointer; }
.filter-select option { background: var(--bg-elevated); color: var(--text-primary); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg-elevated); border-top: 1px solid var(--border-subtle); }
.pagination-info { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }
.pagination-btns { display: flex; gap: 6px; }
.btn-page {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 14px; color: var(--text-secondary); font-size: 12px; cursor: pointer;
  font-family: var(--font-body); transition: all 0.15s;
}
.btn-page:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.btn-page:disabled { opacity: 0.3; cursor: not-allowed; }

/* Slide-out panel */
.panel-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 100; opacity: 0; pointer-events: none; transition: opacity 0.25s ease; }
.panel-overlay.open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--panel-w);
  background: var(--bg-surface); border-left: 1px solid var(--border-subtle);
  z-index: 101; transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel.open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border-subtle); flex-shrink: 0;
}
.panel-title { font-size: 15px; font-weight: 500; }
.btn-close {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); transition: all 0.15s;
}
.btn-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.panel-body { flex: 1; overflow-y: auto; padding: 24px; }
.panel-section { margin-bottom: 24px; }
.panel-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--text-tertiary); margin-bottom: 12px; font-weight: 500; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-item {}
.detail-label { font-size: 11px; color: var(--text-tertiary); margin-bottom: 2px; }
.detail-value { font-size: 13px; color: var(--text-primary); }

/* Communication timeline */
.timeline { display: flex; flex-direction: column; gap: 16px; }
.timeline-item { position: relative; padding-left: 20px; }
.timeline-item::before { content: ''; position: absolute; left: 4px; top: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.timeline-item.outbound::before { background: var(--accent); }
.timeline-item.inbound::before { background: var(--status-completed); }
.timeline-item::after { content: ''; position: absolute; left: 7px; top: 20px; bottom: -12px; width: 1px; background: var(--border-subtle); }
.timeline-item:last-child::after { display: none; }
.timeline-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.timeline-direction { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.timeline-direction.outbound { color: var(--accent); }
.timeline-direction.inbound { color: var(--status-completed); }
.timeline-date { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); }
.timeline-subject { font-size: 13px; color: var(--text-primary); font-weight: 500; margin-bottom: 2px; }
.timeline-body { font-size: 12px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; max-height: 120px; overflow-y: auto; }
.timeline-addresses { font-size: 11px; color: var(--text-tertiary); font-family: var(--font-mono); margin-bottom: 4px; }

/* Settings */
.settings-section { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); overflow: hidden; }
.settings-header { padding: 16px 20px; border-bottom: 1px solid var(--border-subtle); }
.settings-title { font-size: 14px; font-weight: 500; }
.settings-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.settings-body { padding: 16px 20px; }
.domain-add { display: flex; gap: 8px; margin-bottom: 16px; }
.domain-add .filter-select { width: auto; }
.domain-input {
  flex: 1; background: var(--bg-base); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-primary);
  font-family: var(--font-body); font-size: 13px; outline: none;
}
.domain-input:focus { border-color: var(--accent); }
.btn-add {
  background: var(--accent); color: white; border: none; border-radius: var(--radius-sm);
  padding: 8px 18px; font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: var(--font-body); transition: opacity 0.15s;
}
.btn-add:hover { opacity: 0.85; }
.domain-list { display: flex; flex-direction: column; gap: 4px; }
.domain-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: var(--radius-sm); background: var(--bg-base);
  border: 1px solid var(--border-subtle);
}
.domain-name { font-family: var(--font-mono); font-size: 13px; color: var(--text-primary); }
.btn-remove {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  padding: 2px 6px; border-radius: 3px; font-size: 12px; transition: all 0.15s;
}
.btn-remove:hover { color: var(--status-failed); background: var(--status-failed-bg); }

/* Mono date cells */
.td-mono { font-family: var(--font-mono); font-size: 12px; }

/* Empty state */
.empty-state { padding: 48px 24px; text-align: center; color: var(--text-tertiary); font-size: 13px; }

/* Loading */
.loading { display: flex; align-items: center; justify-content: center; height: 200px; color: var(--text-tertiary); font-size: 13px; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page.active .stat-card { animation: fadeIn 0.3s ease both; }
.page.active .stat-card:nth-child(2) { animation-delay: 0.04s; }
.page.active .stat-card:nth-child(3) { animation-delay: 0.08s; }
.page.active .stat-card:nth-child(4) { animation-delay: 0.12s; }
.page.active .stat-card:nth-child(5) { animation-delay: 0.16s; }
.page.active .table-wrap { animation: fadeIn 0.35s ease 0.1s both; }

/* Analytics stat card types */
.stat-card[data-type="info"] .stat-value { color: var(--accent); }
.stat-card[data-type="success"] .stat-value { color: var(--status-completed); }
.stat-card[data-type="danger"] .stat-value { color: var(--status-failed); }
.stat-row { display: flex; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-row .stat-card { flex: 1; min-width: 140px; }

/* Analytics sections */
.analytics-section { background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.analytics-section h3 { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.8px; }

/* SVG charts */
.chart-empty { color: var(--text-tertiary); font-size: 13px; padding: 40px; text-align: center; }
.chart-label { font-size: 10px; fill: var(--text-tertiary); font-family: var(--font-mono); }
.chart-value { font-size: 11px; fill: var(--text-secondary); font-family: var(--font-mono); }
.bar-chart, .line-chart { display: block; }

/* Sigma color classes */
.sigma-excellent { color: var(--status-completed); }
.sigma-good { color: #34d399; }
.sigma-fair { color: var(--status-waiting); }
.sigma-poor { color: #fb923c; }
.sigma-critical { color: var(--status-failed); }
.sigma-none { color: var(--text-tertiary); }

/* Wizard form */
.wizard-form { max-width: 600px; }
.form-section { margin-bottom: 20px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.8px; }
.form-input { width: 100%; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; color: var(--text-primary); font-size: 13px; font-family: var(--font-body); }
.form-input:focus { outline: none; border-color: var(--accent); }
textarea.form-input { resize: vertical; }
.form-checkbox { display: flex; align-items: center; gap: 8px; }
.form-checkbox label { margin: 0; font-size: 13px; color: var(--text-secondary); cursor: pointer; text-transform: none; letter-spacing: normal; }
.form-error { background: var(--status-failed-bg); color: var(--status-failed); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.form-success { background: var(--status-completed-bg); color: var(--status-completed); padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); padding: 10px 24px; font-size: 13px; font-weight: 500; cursor: pointer; transition: opacity 0.15s; }
.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Operator hub */
.operator-tab-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sort-toggle { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.3px; }
.sort-toggle-arrow { font-size: 13px; }
.operator-type-indicator { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.8px; }
.badge-restarted {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 10px; font-size: 10px; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase;
  background: rgba(96,165,250,0.12); color: var(--status-in-progress);
}
.segmented-control { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.segmented-btn {
  background: var(--bg-surface); border: none; border-right: 1px solid var(--border);
  padding: 6px 14px; color: var(--text-tertiary); font-size: 11px; font-weight: 500;
  font-family: var(--font-body); cursor: pointer; transition: all 0.15s;
  letter-spacing: 0.3px;
}
.segmented-btn:last-child { border-right: none; }
.segmented-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.segmented-btn.active { background: var(--accent-dim); color: var(--accent); }

/* Vendor chips */
.vendor-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.vendor-chip { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 16px; padding: 6px 14px; font-size: 12px; color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.vendor-chip:hover { border-color: var(--accent); color: var(--text-primary); }
.vendor-chip.selected { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* Button-as-link resets (for accessible <button> replacing <a onClick>) */
.channel-toggle,
.channel-help-toggle {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent); font-size: 12px; cursor: pointer;
  font-family: var(--font-body); text-decoration: underline;
  text-underline-offset: 2px;
}
.channel-toggle:hover,
.channel-help-toggle:hover { color: var(--text-primary); }
.channel-help { margin-top: 8px; }
.channel-help-toggle { font-size: 11px; color: var(--text-tertiary); }

/* Error / warning / selected in channel selector */
.channel-error { color: var(--status-failed); font-size: 12px; margin-top: 4px; }
.channel-warning { color: var(--status-waiting); font-size: 12px; margin-top: 4px; }
.channel-selected { color: var(--status-completed); font-size: 12px; margin-top: 4px; }

/* Channel dropdown */
.channel-dropdown { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 200px; overflow-y: auto; margin-top: 4px; }
.channel-option { padding: 8px 12px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.channel-option:hover, .channel-option:focus { background: var(--bg-hover); color: var(--text-primary); outline: none; }
.channel-option.selected { color: var(--accent); }
