:root {
  --bg-1: #f6f5f1;
  --bg-2: #ebe7dc;
  --ink: #202019;
  --muted: #666453;
  --accent: #d85e2a;
  --accent-2: #1f495d;
  --card: #fffdf8;
  --ok: #1d7f45;
  --no: #9a2f26;
  --line: rgba(32, 32, 25, 0.18);
  --shadow: 0 18px 40px rgba(31, 73, 93, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 20%, #fffaf0, transparent 35%),
    radial-gradient(circle at 80% 10%, #d7e5ea, transparent 42%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  position: relative;
  overflow-x: hidden;
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

.bg-shape-a {
  width: 420px;
  height: 420px;
  background: rgba(216, 94, 42, 0.16);
  top: -120px;
  left: -140px;
}

.bg-shape-b {
  width: 360px;
  height: 360px;
  background: rgba(31, 73, 93, 0.15);
  right: -100px;
  bottom: -110px;
}

.app-shell {
  max-width: 1100px;
  margin: 32px auto;
  padding: 0 18px 32px;
  position: relative;
  z-index: 1;
  animation: rise 400ms ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.call-topbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.topbar-title-wrap {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--muted);
}

h1, h2, h3 {
  margin: 0;
  font-family: "Archivo", sans-serif;
}

h1 {
  font-size: 1.5rem;
}

.badge {
  margin-top: 10px;
  display: inline-block;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f7e1d8;
  color: #6e2d13;
  font-weight: 600;
  font-size: 0.88rem;
}

.detail-tabs {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-tab {
  border: 1px solid #d4d0c1;
  background: #f5f2e8;
  color: #2f332a;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.detail-tab.active {
  background: #1f495d;
  border-color: #1f495d;
  color: #fff;
}

.detail-panel {
  margin-top: 8px;
}

.customer-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.customer-grid article {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.history-table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ddd7c9;
  border-radius: 12px;
  overflow: hidden;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid #eee8da;
  font-size: 0.9rem;
}

.history-table th {
  background: #f9f6ed;
  color: #585640;
  font-weight: 700;
}

.history-table tbody tr:last-child td {
  border-bottom: 0;
}

.history-subsection {
  margin-top: 18px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
}

.subsection-title {
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.history-table .tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.tag-opportunity {
  background: #e4f0fb;
  color: #164a6a;
}

.tag-lead {
  background: #f3edf8;
  color: #5c2d7a;
}

.tag-won {
  background: #e7f5ec;
  color: var(--ok);
}

.tag-lost {
  background: #fce9e7;
  color: var(--no);
}

.tag-open {
  background: #fef6e4;
  color: #7a5500;
}

.label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.value {
  margin: 5px 0 0;
  font-weight: 700;
}

.branch-picker {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 10px;
}

.big-action,
.action-btn {
  border: 0;
  border-radius: 12px;
  background: var(--accent-2);
  color: #fff;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.big-action {
  padding: 16px;
  font-size: 1rem;
}

.action-btn {
  padding: 12px 15px;
}

.big-action:hover,
.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 22px rgba(31, 73, 93, 0.25);
}

.big-action.active {
  background: var(--accent);
}

.panel {
  margin-top: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost {
  background: #ece9df;
  color: #2f332a;
}

.small {
  font-size: 0.9rem;
}

.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

.status-banner {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  background: #e8f1f7;
  border: 1px solid #b8d0df;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 15, 0.5);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 20;
}

.modal {
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 50px rgba(10, 12, 15, 0.32);
  padding: 18px;
  position: relative;
}

.close-modal {
  position: absolute;
  right: 10px;
  top: 8px;
  border: 0;
  border-radius: 8px;
  width: 30px;
  height: 30px;
  background: #f2efe4;
  cursor: pointer;
  font-weight: 700;
}

.modal-note {
  color: var(--muted);
  margin: 6px 0 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
select {
  font: inherit;
  border: 1px solid #cfcbbc;
  border-radius: 10px;
  padding: 10px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-2);
}

.availability-box {
  margin: 12px 0;
  border-radius: 10px;
  padding: 10px;
  font-weight: 700;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 10px 0 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

.dot.available {
  background: #dceee4;
  border: 1px solid #8fc2a3;
}

.dot.booked {
  background: #fce9e7;
  border: 1px solid #e6a49d;
}

.dot.selected {
  background: #e8f1f7;
  border: 1px solid #8db5ce;
}

.hourly-calendar {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}

.time-slot {
  border: 1px solid #b6c3cb;
  border-radius: 10px;
  padding: 10px;
  background: #f4f9fb;
  color: #1e4158;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.time-slot:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(30, 65, 88, 0.2);
}

.time-slot.booked {
  background: #fce9e7;
  color: #912a21;
  border-color: #e6a49d;
  cursor: not-allowed;
  box-shadow: none;
}

.time-slot.selected {
  background: #e9f3f8;
  color: #173749;
  border-color: #6ea0bf;
  box-shadow: 0 0 0 2px rgba(110, 160, 191, 0.26);
}

.availability-ok {
  background: #e7f5ec;
  color: var(--ok);
  border: 1px solid #a7d9b9;
}

.availability-no {
  background: #fce9e7;
  color: var(--no);
  border: 1px solid #e6a49d;
}

.lead-summary {
  border: 1px solid #ddd7c9;
  border-radius: 10px;
  background: #fcfbf6;
  padding: 12px;
  margin: 12px 0 16px;
}

.sms-preview {
  border: 1px solid #ddd7c9;
  border-radius: 12px;
  background: linear-gradient(180deg, #fffdf8, #f7f4ec);
  padding: 14px;
  margin: 12px 0 16px;
  white-space: pre-line;
  line-height: 1.6;
}

.outcome-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

@media (max-width: 860px) {
  .customer-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    margin-top: 20px;
  }

  .customer-grid,
  .branch-picker {
    grid-template-columns: 1fr;
  }

  .panel-actions,
  .outcome-actions {
    flex-direction: column;
  }

  .big-action,
  .action-btn {
    width: 100%;
  }

  .hourly-calendar {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

/* ═══════════════════════════════════════════
   Agent Copilot Sidebar
═══════════════════════════════════════════ */

/* ── Toggle button (fixed FAB) ── */
.copilot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 800;
  background: linear-gradient(135deg, #1f495d 0%, #0f2a3c 100%);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 11px 22px 11px 16px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 6px 28px rgba(15, 42, 60, 0.45);
  display: flex;
  align-items: center;
  gap: 9px;
  transition: right 320ms cubic-bezier(.4,0,.2,1),
              box-shadow 180ms ease,
              transform 180ms ease;
}

.copilot-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(15, 42, 60, 0.55);
}

.copilot-toggle-icon {
  font-size: 1.1rem;
  color: #7ecbea;
}

body.copilot-open .copilot-toggle {
  right: 384px;
}

/* ── Sidebar panel ── */
.copilot-sidebar {
  position: fixed;
  right: -380px;
  top: 0;
  width: 360px;
  height: 100vh;
  background: #0f2536;
  color: #dde9f0;
  display: flex;
  flex-direction: column;
  z-index: 850;
  transition: right 320ms cubic-bezier(.4,0,.2,1);
  box-shadow: -10px 0 50px rgba(0, 0, 0, 0.35);
}

.copilot-sidebar.open {
  right: 0;
}

body.copilot-open {
  padding-right: 360px;
  transition: padding-right 320ms cubic-bezier(.4,0,.2,1);
}

/* ── Header ── */
.copilot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.copilot-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copilot-icon {
  font-size: 1.1rem;
  color: #7ecbea;
}

.copilot-title {
  font-weight: 700;
  font-size: 1rem;
  color: #e8f4fa;
}

.copilot-listening {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.73rem;
  font-weight: 600;
  color: #4dbb85;
  margin-left: 4px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background: #4dbb85;
  border-radius: 50%;
  flex-shrink: 0;
  animation: copilotPulse 1.6s ease-in-out infinite;
}

@keyframes copilotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.6); }
}

.copilot-close {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: #a0bece;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms;
}

.copilot-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ── Live Insights label ── */
.copilot-feed-label {
  padding: 10px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
}

/* ── Insight feed ── */
.copilot-feed {
  flex: 1;
  overflow-y: auto;
  padding: 6px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #1f495d transparent;
}

.copilot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 0;
  color: rgba(255,255,255,0.3);
  font-size: 0.88rem;
}

.copilot-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #4a9cbd;
  border-radius: 50%;
  animation: copilotSpin 900ms linear infinite;
}

@keyframes copilotSpin {
  to { transform: rotate(360deg); }
}

.insight-card {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-left: 3px solid var(--insight-color, #4a9cbd);
  border-radius: 10px;
  padding: 10px 13px;
  animation: insightIn 420ms ease-out;
}

@keyframes insightIn {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0);    }
}

.insight-tag {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--insight-color, #4a9cbd);
}

.insight-text {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #c8dce8;
}

/* ── Chat section ── */
.copilot-chat {
  border-top: 1px solid rgba(255,255,255,0.09);
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.chat-messages {
  max-height: 165px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: #1f495d transparent;
}

.chat-msg {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.45;
  max-width: 93%;
  word-break: break-word;
}

.chat-msg.user {
  background: #1f495d;
  color: #e0f1fa;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
}

.chat-msg.bot {
  background: rgba(255,255,255,0.09);
  color: #c8dce8;
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}

.chat-msg.typing {
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.35);
  font-style: italic;
  font-size: 0.82rem;
}

.chat-quick-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  color: #9ec8dd;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.79rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 150ms, color 150ms;
}

.quick-btn:hover {
  background: rgba(255,255,255,0.16);
  color: #e0f1fa;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  color: #e8f4fa;
  font-family: inherit;
  font-size: 0.86rem;
  padding: 9px 16px;
  outline: none;
  transition: border-color 150ms, background 150ms;
}

.chat-input::placeholder {
  color: rgba(255,255,255,0.28);
}

.chat-input:focus {
  border-color: #4a9cbd;
  background: rgba(255,255,255,0.12);
}

.chat-send {
  background: #1f495d;
  border: 0;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms, transform 120ms;
}

.chat-send:hover {
  background: #2d6b84;
  transform: scale(1.07);
}
