:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", sans-serif;
  color: #192436;
  background: #f2f5f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --blue: #1769aa;
  --blue-dark: #0f4d82;
  --line: #dce3ec;
  --muted: #637188;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; }

.page-shell { width: min(920px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 40px; }
.page-header { margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; color: #133f69; font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.brand span { color: #78879b; font-size: 10px; letter-spacing: .1em; }
h1 { margin: 0; font-size: clamp(25px, 5vw, 38px); letter-spacing: -.035em; }
.lede { max-width: 720px; margin: 10px 0 0; color: var(--muted); line-height: 1.55; }

.demo-banner { display: flex; gap: 14px; align-items: flex-start; padding: 17px 19px; margin: 20px 0; color: #583d00; background: #fff6d9; border: 1px solid #eed991; border-radius: 12px; }
.demo-banner strong { font-size: 14px; letter-spacing: .055em; }
.demo-banner p { margin: 5px 0 0; font-size: 13px; line-height: 1.5; }
.demo-dot { width: 11px; height: 11px; margin-top: 3px; border-radius: 50%; background: #e2a500; box-shadow: 0 0 0 4px #f6e7ae; flex: 0 0 auto; }

.panel { padding: 22px; margin-top: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 4px 18px #1a35520a; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
label { display: block; margin-bottom: 8px; color: #34435a; font-size: 13px; font-weight: 700; }
select, textarea { width: 100%; padding: 12px 13px; color: #192436; background: #fff; border: 1px solid #c9d3e0; border-radius: 9px; font: inherit; }
select:focus, textarea:focus { outline: 3px solid #1769aa30; border-color: var(--blue); }
select:disabled, textarea:disabled { color: #7b8798; background: #f3f5f8; }
.local-pill, .turn-counter { padding: 6px 9px; color: #52647d; background: #f0f4f8; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.heading-pills { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.engine-pill { padding: 6px 9px; color: #155b3d; background: #edf8f1; border-radius: 99px; font-size: 11px; font-weight: 700; }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.setup-actions { margin-top: 15px; }
.button { min-height: 42px; padding: 9px 14px; border: 1px solid transparent; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.button:focus-visible { outline: 3px solid #1769aa55; outline-offset: 2px; }
.button:disabled { opacity: .48; cursor: not-allowed; }
.button-primary { color: #fff; background: var(--blue); }
.button-primary:hover:not(:disabled) { background: var(--blue-dark); }
.button-secondary { color: #33445b; background: #fff; border-color: #cbd5e1; }
.button-secondary:hover:not(:disabled) { background: #f5f7fa; }

.decision-status { padding: 12px 14px; margin: 0 0 14px; border: 1px solid #d9e1eb; border-radius: 9px; color: #53647a; background: #f7f9fc; font-size: 13px; line-height: 1.45; }
.decision-allowed { color: #155b3d; background: #edf8f1; border-color: #b9dfc7; }
.decision-denied { color: #812e2e; background: #fff0f0; border-color: #edc2c2; }
.decision-unavailable { color: #694f12; background: #fff8e6; border-color: #ead69e; }
.message-list { display: flex; flex-direction: column; gap: 10px; min-height: 150px; max-height: 380px; overflow-y: auto; padding: 12px; margin-bottom: 14px; background: #f7f9fc; border: 1px solid #e1e7ef; border-radius: 10px; }
.empty-state { margin: auto; color: #8290a3; font-size: 13px; text-align: center; }
.message { max-width: min(82%, 640px); padding: 11px 13px; border-radius: 11px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-user { align-self: flex-end; color: #fff; background: #28689c; border-bottom-right-radius: 3px; }
.message-assistant { align-self: flex-start; color: #253349; background: #fff; border: 1px solid #e0e6ee; border-bottom-left-radius: 3px; }
.message-form textarea { resize: vertical; min-height: 76px; }
.form-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 10px; }
.form-footer > span { color: #718096; font-size: 12px; }
.page-footer { padding: 18px 4px 0; color: #78869a; font-size: 11px; line-height: 1.5; }
.page-footer p { margin: 5px 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.hidden { display: none !important; }

.voice-section { padding: 14px 16px; margin-bottom: 16px; background: #f0f4f9; border: 1px solid #d3dde8; border-radius: 12px; }
.voice-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.button-voice { color: #fff; background: #127253; border-color: #0f5c43; }
.button-voice:hover:not(:disabled) { background: #0c4d37; }
.button-danger { color: #fff; background: #c53030; border-color: #9b2c2c; }
.button-danger:hover:not(:disabled) { background: #9b2c2c; }
.voice-status { font-size: 12px; font-weight: 600; color: #4a5568; }
.voice-status-active { color: #127253; }
.call-timer { font-family: monospace; font-size: 13px; font-weight: 700; color: #155b3d; background: #edf8f1; padding: 4px 8px; border-radius: 6px; }
.voice-call-details { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e2e8f0; font-size: 11px; color: #718096; display: flex; flex-direction: column; gap: 8px; }
.voice-indicators { display: flex; justify-content: space-between; align-items: center; }
.voice-speaker-state { font-weight: 600; color: #2b6cb0; }
.voice-speaker-state.agent-speaking { color: #127253; }
.voice-speaker-state.user-speaking { color: #b7791f; }
.ambience-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12px; color: #4a5568; }
.ambience-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.ambience-toggle input { cursor: pointer; }
.ambience-controls input[type="range"] { width: 100px; }

.customer-lead-card { margin-top: 12px; padding: 12px; background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 9px; }
.card-header { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; color: #1e293b; }
.card-icon { font-size: 14px; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; }
.card-item { display: flex; gap: 4px; }
.card-item-wide { grid-column: span 2; }
.card-label { font-weight: 600; color: #64748b; }
.card-val { color: #0f172a; font-weight: 500; }

/* Modale de Compte-Rendu Post-Appel */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-card, .admin-dialog {
  max-width: 660px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 12px;
}
.modal-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #155b3d;
  background: #edf8f1;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 4px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}
.modal-meta {
  font-size: 12px;
  color: #64748b;
  margin: 4px 0 0;
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  color: #94a3b8;
  padding: 2px 8px;
  border-radius: 6px;
  transition: color 0.15s;
}
.modal-close:hover {
  color: #1e293b;
  background: #f1f5f9;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  color: #1e40af;
  font-size: 13px;
}
.banner-content {
  flex: 1;
}
.calendar-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.button-gcal {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.button-gcal:hover {
  background: #f0f7ff;
}
.button-ics {
  display: inline-flex;
  align-items: center;
  background: #1e40af;
  color: #ffffff;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.button-ics:hover {
  background: #1d4ed8;
}
.banner-icon {
  font-size: 18px;
}
.modal-section {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 12px 14px;
  background: #f8fafc;
}
.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 12px;
}
.modal-field {
  font-size: 13px;
  display: flex;
  gap: 6px;
}
.field-label {
  font-weight: 600;
  color: #64748b;
}
.field-value {
  font-weight: 500;
  color: #0f172a;
}
.modal-list {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
}
.modal-list li {
  margin-bottom: 4px;
}
.transcript-details {
  font-size: 13px;
}
.transcript-summary {
  font-weight: 600;
  cursor: pointer;
  color: #2563eb;
  padding: 2px 0;
}
.transcript-summary:hover {
  text-decoration: underline;
}
.modal-transcript-content {
  max-height: 180px;
  overflow-y: auto;
  margin-top: 10px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.transcript-bubble {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
}
.transcript-bubble.caller {
  background: #eff6ff;
  color: #1e3a8a;
  align-self: flex-start;
}
.transcript-bubble.agent {
  background: #f1f5f9;
  color: #0f172a;
  align-self: flex-start;
}
.email-section {
  background: #f0fdf4;
  border-color: #bbf7d0;
}
.email-form {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.email-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
}
.modal-email-status {
  font-size: 12px;
  margin-top: 6px;
  font-weight: 600;
}
.modal-email-status.success {
  color: #15803d;
}
.modal-email-status.error {
  color: #b91c1c;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

/* CRM Activity & Journal */
.activity-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.kpi-card {
  padding: 16px 20px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}
.kpi-label {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}
.kpi-value {
  color: #0f172a;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.activity-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}
.activity-filter-btn {
  padding: 7px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.activity-filter-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.activity-filter-btn.is-active {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 700;
}

.activity-crm-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.crm-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.02);
  transition: border-color .15s ease;
}
.crm-card:hover {
  border-color: #cbd5e1;
}
.crm-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.crm-card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.crm-card-icon {
  font-size: 18px;
}
.crm-card-name {
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
}
.crm-card-phone {
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.crm-card-phone:hover {
  text-decoration: underline;
}
.crm-card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.crm-badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
.crm-badge-urgent {
  background: #fde8e8;
  color: #c53030;
  border: 1px solid #feb2b2;
}
.crm-badge-normal {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}
.crm-badge-rdv {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.crm-badge-rappel {
  background: #fffaf0;
  color: #7b341e;
  border: 1px solid #feebc8;
}

.crm-appointment-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
}
.crm-appointment-info {
  color: #166534;
  font-size: 12px;
  font-weight: 700;
}
.crm-calendar-actions {
  display: flex;
  gap: 8px;
}
.crm-btn-gcal {
  padding: 5px 10px;
  border: 1px solid #86efac;
  border-radius: 6px;
  background: #fff;
  color: #166534;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.crm-btn-gcal:hover {
  background: #dcfce7;
}
.crm-btn-ics {
  padding: 5px 10px;
  border: 1px solid #86efac;
  border-radius: 6px;
  background: #166534;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}
.crm-btn-ics:hover {
  background: #14532d;
}

.crm-drawer-toggle {
  background: transparent;
  border: 0;
  padding: 4px 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  align-self: flex-start;
}
.crm-drawer-toggle:hover {
  text-decoration: underline;
}

.crm-details-drawer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.crm-details-section h4 {
  margin: 0 0 6px;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.crm-details-section ul {
  margin: 0;
  padding-left: 18px;
  color: #475569;
  font-size: 12px;
  line-height: 1.6;
}
.crm-transcript-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.crm-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.5;
}
.crm-bubble-caller {
  align-self: flex-start;
  background: #eff6ff;
  color: #1e3a8a;
}
.crm-bubble-agent {
  align-self: flex-end;
  background: #f0fdf4;
  color: #14532d;
}

@media (max-width: 600px) {
  .page-shell { width: min(100% - 20px, 920px); padding-top: 20px; }
  .panel { padding: 16px; }
  .panel-heading { align-items: flex-start; }
  .setup-actions .button { flex: 1 1 100%; }
  .form-footer { align-items: flex-end; }
  .form-footer .actions { justify-content: flex-end; }
  .button { padding-inline: 11px; }
}
