:root {
  --bg: #06120e;
  --deep: #071b14;
  --panel: rgba(246, 241, 225, 0.92);
  --panel-dark: rgba(6, 18, 14, 0.82);
  --phone: #101915;
  --screen: #efe8d6;
  --line: rgba(6, 18, 14, 0.12);
  --text: #112119;
  --muted: #6e796f;
  --white: #fffdf6;
  --green: #20c063;
  --green-dark: #075e54;
  --bubble-out: #d9fdd3;
  --bubble-in: #ffffff;
  --amber: #ffb443;
  --danger: #f04b41;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --body: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --display: "Archivo Black", Impact, sans-serif;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: var(--body);
  background:
    radial-gradient(circle at 12% 12%, rgba(32, 192, 99, 0.32), transparent 28rem),
    radial-gradient(circle at 88% 6%, rgba(255, 180, 67, 0.18), transparent 28rem),
    linear-gradient(135deg, #03100c 0%, #082018 46%, #020806 100%);
}

.mesh {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(255,255,255,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.08) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(circle at center, black, transparent 76%);
}

.workspace {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.intro {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--white);
}

.eyebrow, .panel-kicker {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow { color: #8df4b8; }

h1 {
  max-width: 920px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(40px, 7vw, 88px);
  line-height: 0.92;
  letter-spacing: -0.075em;
  text-transform: uppercase;
}

.intro-copy {
  max-width: 820px;
  margin: 0;
  color: rgba(255, 253, 246, 0.72);
  font-size: 17px;
  line-height: 1.55;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 470px) 1fr;
  gap: 22px;
  align-items: start;
}

.phone-wrap {
  position: sticky;
  top: 18px;
  display: grid;
  place-items: center;
}

.phone {
  position: relative;
  width: min(100%, 430px);
  height: 780px;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  overflow: hidden;
  border: 12px solid #050907;
  border-radius: 46px;
  background: var(--screen);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,0.18);
}

.phone::before {
  content: "";
  position: absolute;
  top: 9px;
  left: 50%;
  z-index: 3;
  width: 110px;
  height: 25px;
  transform: translateX(-50%);
  border-radius: 0 0 18px 18px;
  background: #050907;
}

.phone-glass {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,0.14), transparent 34%, transparent 66%, rgba(255,255,255,0.06));
  z-index: 2;
}

.wa-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 86px;
  padding: 26px 16px 14px;
  background: linear-gradient(135deg, #075e54, #06483f);
  color: white;
}

.icon-button, .wa-actions span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  color: white;
  font-weight: 900;
}

.avatar-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(135deg, #20c063, #ffb443);
  color: #062016;
  font-weight: 900;
}

.wa-title { flex: 1; min-width: 0; }
.wa-title strong { display: block; font-size: 17px; line-height: 1.1; }
.wa-title span { display: block; margin-top: 4px; color: rgba(255,255,255,0.72); font-size: 12px; }
.wa-actions { display: flex; gap: 5px; }
.wa-actions span { width: 6px; height: 6px; padding: 0; }

.wa-status-strip {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: #0b2f28;
}
.wa-status-strip span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.82);
  font: 700 10px var(--mono);
  text-transform: uppercase;
}
.wa-status-strip .locked { background: rgba(240,75,65,0.22); color: #ffd6d2; }
.wa-status-strip .open { background: rgba(32,192,99,0.2); color: #c9ffe0; }

.chat-surface {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 12px 20px;
  overflow-y: auto;
  background:
    linear-gradient(rgba(239,232,214,0.88), rgba(239,232,214,0.9)),
    radial-gradient(circle at 20% 20%, rgba(7,94,84,0.14) 0 6px, transparent 7px),
    radial-gradient(circle at 80% 50%, rgba(7,94,84,0.12) 0 5px, transparent 6px);
  background-size: auto, 52px 52px, 46px 46px;
}

.day-marker, .system-note {
  align-self: center;
  max-width: 88%;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.7);
  color: #59645b;
  font-size: 11px;
  box-shadow: 0 3px 12px rgba(0,0,0,0.06);
}
.system-note { background: #fff3cd; color: #705519; text-align: center; }

.message {
  position: relative;
  max-width: 82%;
  padding: 9px 10px 7px;
  border-radius: 14px;
  color: #111b14;
  font-size: 14px;
  line-height: 1.36;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  animation: pop 160ms ease-out both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(7px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.customer { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.message.business { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.message.agent { align-self: flex-start; background: #e7fff0; border: 1px solid rgba(32,192,99,0.22); border-bottom-left-radius: 4px; }
.message strong { display: block; margin-bottom: 4px; font-size: 11px; color: #075e54; }
.message small { display: block; margin-top: 5px; color: rgba(17,27,20,0.48); text-align: right; font-size: 10px; }

.typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: white;
}
.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8b988f;
  animation: blink 1s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 120ms; }
.typing span:nth-child(3) { animation-delay: 240ms; }
@keyframes blink { 50% { transform: translateY(-3px); opacity: 0.45; } }

.quick-replies {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  background: #f7f2e5;
  border-top: 1px solid rgba(0,0,0,0.05);
}
.quick-replies button {
  flex: 0 0 auto;
  border: 1px solid rgba(7,94,84,0.18);
  border-radius: 999px;
  background: white;
  color: #075e54;
  padding: 8px 11px;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 11px;
  background: #ebe3d1;
}
.composer input {
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 13px 16px;
  font: 600 14px var(--body);
  outline: none;
  background: white;
}
.composer button, .takeover, .ghost, .mini-actions button {
  border: 0;
  cursor: pointer;
  font-family: var(--body);
  font-weight: 900;
}
.composer button {
  border-radius: 999px;
  padding: 0 16px;
  background: var(--green-dark);
  color: white;
}

.control-panel { display: grid; gap: 14px; }
.card {
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 28px;
  padding: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.operator-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  background: linear-gradient(135deg, rgba(255,253,246,0.96), rgba(216,255,224,0.94));
}
.panel-kicker { color: #087255; }
h2 { margin: 7px 0 8px; font-size: 34px; line-height: 1; letter-spacing: -0.07em; }
.operator-card p:not(.panel-kicker) { margin: 0; color: var(--muted); line-height: 1.5; }
.takeover, .ghost, .mini-actions button {
  min-height: 46px;
  border-radius: 999px;
  padding: 0 18px;
}
.takeover { background: var(--danger); color: white; }
.ghost { grid-column: 2; background: #0b2118; color: white; }

.ids-card label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.ids-card input {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  font: 700 15px var(--mono);
  outline: none;
}
.mini-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.mini-actions button { background: #10261c; color: white; }

.state-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.state-grid div {
  min-height: 94px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(7,94,84,0.08);
}
.state-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.state-grid strong {
  display: block;
  margin-top: 12px;
  font: 900 18px var(--body);
  letter-spacing: -0.05em;
  word-break: break-word;
}
.is-danger { color: var(--danger); }
.is-ok { color: #087255; }

pre {
  max-height: 280px;
  overflow: auto;
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  background: #07120e;
  color: #d8ffe1;
  font: 500 12px/1.55 var(--mono);
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .phone-wrap { position: static; }
  .phone { height: min(780px, 82vh); }
  .operator-card { grid-template-columns: 1fr; }
  .ghost { grid-column: auto; }
  .state-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .workspace { width: min(100% - 16px, 1240px); padding-top: 16px; }
  .phone { border-width: 7px; border-radius: 34px; height: 76vh; }
  .state-grid, .mini-actions { grid-template-columns: 1fr; }
}