/* CareOS v2 — Main stylesheet */

:root {
  --primary: #00377b;
  --primary-light: #004a9e;
  --accent: #10b981;
  --accent-light: #059669;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #3b82f6;
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-header: #001f44;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: .2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

/* ── Header ───────────────────────────────────────────────── */

header {
  background: var(--bg-header);
  color: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  overflow: hidden;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.header-left h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.header-left .version {
  font-size: 11px;
  background: var(--accent);
  color: #fff;
  padding: 1px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

#global-trunk-select,
#global-org-select {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.user-info {
  font-size: 13px;
  opacity: .85;
}

.btn-logout {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition);
}

.btn-logout:hover { background: rgba(255,255,255,.2); }

/* ── Container & Tabs ─────────────────────────────────────── */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 40px;
  overflow-x: hidden;
}

.tab-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.tab-nav::after {
  content: '';
  min-width: 1px;
  flex-shrink: 0;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-btn svg { width: 16px; height: 16px; }

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

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ── KPI Grid ─────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

.kpi-card .kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Tables ───────────────────────────────────────────────── */

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.table-card table {
  min-width: 600px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}

tbody tr {
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background var(--transition);
}

tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 10px 14px;
  font-size: 13px;
}

/* ── Badges ───────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f8fafc; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  padding: 6px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

.btn:disabled, .btn.btn-loading {
  opacity: .6;
  pointer-events: none;
}

/* ── Forms ────────────────────────────────────────────────── */

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font);
  transition: border-color var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}

.form-group.has-error input,
.form-group.has-error select {
  border-color: var(--danger);
}

.form-group.has-success input,
.form-group.has-success select {
  border-color: var(--success);
}

.form-group .error-msg {
  color: var(--danger);
  font-size: 11px;
  margin-top: 2px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Modals ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95) translateY(12px);
  transition: transform .25s;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal.wide { max-width: 1000px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  transition: background var(--transition);
}

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

.modal-body { padding: 20px; }

.modal-info {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.modal-info .info-item label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
}

.modal-info .info-item span {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-all;
}

.modal-info .info-item {
  min-width: 0;
  overflow: hidden;
}

/* ── Login overlay ────────────────────────────────────────── */

.login-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--bg-header) 0%, #003366 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-overlay.hidden { display: none; }

.login-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  max-width: 90vw;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-box h2 {
  font-size: 22px;
  margin-bottom: 6px;
  color: var(--primary);
}

.login-box .subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-box input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}

.login-box input:focus { border-color: var(--primary); }

.login-box .btn-login {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.login-box .btn-login:hover { background: var(--primary-light); }

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  display: none;
}

/* ── Pipeline / CRM ───────────────────────────────────────── */

.pipeline-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.pipeline-card {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}

.pipeline-card:hover { border-color: var(--primary); }
.pipeline-card.active { border-color: var(--primary); background: #eef4ff; }

.pipeline-card .count {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

.pipeline-card .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ── Campaign cards ───────────────────────────────────────── */

.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.campaign-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition);
}

.campaign-card:hover { box-shadow: var(--shadow-lg); }

.campaign-card .campaign-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.campaign-card .campaign-stats {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── WhatsApp ─────────────────────────────────────────────── */

.wa-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  min-height: 500px;
}

.wa-conversations {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow-y: auto;
  max-height: 70vh;
}

.wa-conv-item {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background var(--transition);
}

.wa-conv-item:hover, .wa-conv-item.active { background: #eef4ff; }

.wa-conv-item .wa-name { font-weight: 600; font-size: 13px; }
.wa-conv-item .wa-preview { font-size: 12px; color: var(--text-muted); }

.wa-chat {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

.wa-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  max-height: 60vh;
}

.wa-msg {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.wa-msg.user {
  background: #dcfce7;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.wa-msg.assistant {
  background: #f1f5f9;
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

/* ── Timeline ─────────────────────────────────────────────── */

.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding-bottom: 16px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
}

.timeline-item.voice::before { background: var(--accent); }
.timeline-item.whatsapp::before { background: #25d366; }
.timeline-item.email::before { background: var(--info); }
.timeline-item.campaign::before { background: var(--warning); }

.timeline-item .tl-time {
  font-size: 11px;
  color: var(--text-muted);
}

.timeline-item .tl-content {
  font-size: 13px;
  margin-top: 2px;
}

/* ── Charts ───────────────────────────────────────────────── */

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.chart-card h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Toast ────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
  max-width: 350px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
.toast.info { background: var(--info); }

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

/* ── Filter bar ───────────────────────────────────────────── */

.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--primary);
}

/* ── Pagination ───────────────────────────────────────────── */

.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 16px;
}

.pagination .btn { min-width: 36px; justify-content: center; }

/* ── Org selector ─────────────────────────────────────────── */

.org-selector {
  display: flex;
  align-items: center;
  gap: 8px;
}

.org-selector select {
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.1);
  color: #fff;
  font-size: 13px;
  outline: none;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
  .pipeline-grid { grid-template-columns: repeat(3, 1fr); }
  .wa-layout { grid-template-columns: 1fr; }
  .wa-conversations { max-height: 250px; }
  .campaign-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
  header { padding: 0 12px; gap: 8px; }
  .header-left h1 { font-size: 15px; }
  .header-left img { height: 22px !important; }
  .header-left .version { font-size: 10px; padding: 1px 5px; }
  .container { padding: 0 10px 24px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-card { padding: 12px; }
  .kpi-card .kpi-value { font-size: 22px; }
  .pipeline-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .pipeline-card { padding: 8px; }
  .pipeline-card .count { font-size: 18px; }
  .form-row { grid-template-columns: 1fr; }
  .modal { width: 96%; max-width: none; max-height: 95vh; }
  .modal.wide { max-width: none; }
  .modal-body { padding: 14px; }
  .modal-header { padding: 12px 14px; }
  .modal-info { grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 14px; }
  .live-badge, .user-info { display: none; }
  .header-right { gap: 8px; }
  .header-right select { font-size: 12px; padding: 4px 8px; max-width: 120px; }
  .btn-logout { padding: 4px 10px; font-size: 12px; }
  .campaign-grid { grid-template-columns: 1fr; }
  .filter-bar { gap: 8px; }
  .filter-bar select, .filter-bar input { font-size: 12px; padding: 6px 10px; }
  .tab-btn { padding: 8px 12px; font-size: 12px; }
  .tab-btn svg { width: 14px; height: 14px; }
  thead th { padding: 8px 10px; font-size: 11px; }
  tbody td { padding: 8px 10px; font-size: 12px; }
  .wa-msg { max-width: 85%; }
  .wizard-steps { gap: 2px; }
  .wizard-step { font-size: 11px; padding: 6px 2px; }
  #toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  header { height: 48px; }
  .header-left h1 { display: none; }
  .header-left .version { display: none; }
  .container { padding: 0 8px 20px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card .kpi-value { font-size: 20px; }
  .pipeline-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .pipeline-card .count { font-size: 16px; }
  .pipeline-card .label { font-size: 10px; }
  .modal-info { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .header-right .org-selector { display: none; }
  .header-right select { max-width: 100px; }
  .tab-label { display: none; }
  .tab-nav { gap: 0; }
  .tab-btn { padding: 8px 10px; }
  .login-box { padding: 24px 20px; }
  .btn { padding: 7px 12px; font-size: 12px; }
  h2 { font-size: 18px; }
  h3 { font-size: 16px; }
  .flex-between { flex-wrap: wrap; gap: 8px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar input, .filter-bar select { width: 100%; min-width: 0 !important; }
  .campaign-card .campaign-name { font-size: 14px; }
  .tab-content { overflow-x: hidden; }
}

/* ── Empty state ──────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; opacity: .5; margin-bottom: 12px; }
.empty-state h4 { font-size: 16px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* ── Utility ──────────────────────────────────────────────── */

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Wizard steps ─────────────────────────────────────────── */

.wizard-steps {
  display: flex; gap: 4px; border-bottom: 2px solid var(--border); padding-bottom: 12px;
}
.wizard-step {
  flex: 1; text-align: center; padding: 8px 4px; font-size: 13px;
  color: var(--text-muted); border-radius: 6px 6px 0 0; position: relative;
}
.wizard-step .step-num {
  display: inline-block; width: 22px; height: 22px; line-height: 22px;
  border-radius: 50%; background: var(--border); font-size: 12px; font-weight: 600;
  margin-right: 4px;
}
.wizard-step.active { color: var(--primary); font-weight: 600; }
.wizard-step.active .step-num { background: var(--primary); color: #fff; }
.wizard-step.done { color: var(--success); cursor: pointer; }
.wizard-step.done .step-num { background: var(--success); color: #fff; }
.wizard-step.done:hover { background: var(--hover-bg); }

/* ── Details/summary styling ──────────────────────────────── */

details { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; }
details summary { cursor: pointer; user-select: none; }
details[open] summary { margin-bottom: 8px; }

/* ── Template option ──────────────────────────────────────── */

.template-option:has(input:checked) { border-color: var(--primary) !important; background: rgba(0,55,123,.05); }

/* ── QA Badges ───────────────────────────────────────────── */

.badge-qa-verified { background: #d1fae5; color: #065f46; }
.badge-qa-flagged { background: #fee2e2; color: #991b1b; }
.badge-qa-needs_review { background: #fef3c7; color: #92400e; }
.badge-qa-none { background: #f1f5f9; color: #94a3b8; }
.badge-qa-pending { background: #dbeafe; color: #1e40af; }
.badge-qa-approved { background: #d1fae5; color: #065f46; }
.badge-qa-rejected { background: #fee2e2; color: #991b1b; }

/* ── Performance badges ──────────────────────────────────── */

.perf-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 4px;
}

.perf-good { background: #d1fae5; color: #065f46; }
.perf-warn { background: #fef3c7; color: #92400e; }
.perf-bad { background: #fee2e2; color: #991b1b; }

/* ── Table search / filter bar ───────────────────────────── */

.table-search {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.table-search input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  flex: 1;
  min-width: 180px;
}

.table-search input:focus { border-color: var(--primary); }

.table-search select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}

/* ── Field summary grid ──────────────────────────────────── */

.field-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.field-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}

.field-summary-card h5 {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.summary-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 12px;
}

.summary-bar .bar-track {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.summary-bar .bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
}

.summary-bar .bar-fill.green { background: var(--success); }
.summary-bar .bar-fill.red { background: var(--danger); }
.summary-bar .bar-fill.blue { background: var(--info); }
.summary-bar .bar-fill.yellow { background: var(--warning); }

.summary-tag {
  display: inline-block;
  padding: 2px 8px;
  margin: 2px;
  border-radius: 10px;
  font-size: 11px;
  background: #f1f5f9;
  color: var(--text);
}

/* ── Replay container ────────────────────────────────────── */

.replay-container {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: #fafbfc;
  margin-top: 12px;
}

.replay-step {
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  opacity: 0.4;
  transition: opacity .3s ease, transform .3s ease;
}

.replay-step.active {
  opacity: 1;
  transform: scale(1.01);
}

.replay-bot {
  background: #f1f5f9;
  margin-right: 15%;
  border-bottom-left-radius: 4px;
}

.replay-user {
  background: #dcfce7;
  margin-left: 15%;
  border-bottom-right-radius: 4px;
}

.replay-extraction {
  background: #eff6ff;
  margin-left: 10%;
  margin-right: 10%;
  border-left: 3px solid var(--info);
  font-size: 12px;
}

.replay-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.replay-nav button {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}

.replay-nav button:hover { background: #f1f5f9; }
.replay-nav button:disabled { opacity: .4; cursor: default; }
.replay-nav .replay-counter { font-size: 12px; color: var(--text-muted); }

/* ── Audit log ───────────────────────────────────────────── */

.audit-log-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 12px;
}

.audit-log-item:last-child { border-bottom: none; }

.audit-log-item .audit-action {
  font-weight: 600;
  color: var(--primary);
  min-width: 80px;
}

.audit-log-item .audit-time {
  color: var(--text-muted);
  min-width: 120px;
}

/* ── Callout ─────────────────────────────────────────────── */

.callout {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 8px;
}

.callout-warning {
  background: #fef3c7;
  border-left: 3px solid var(--warning);
  color: #92400e;
}

.callout-info {
  background: #eff6ff;
  border-left: 3px solid var(--info);
  color: #1e40af;
}

.callout-danger {
  background: #fef2f2;
  border-left: 3px solid var(--danger);
  color: #991b1b;
}
