:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17211c;
  background: #f1f5f2;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 22px clamp(18px, 4vw, 56px); background: #102a20; color: white;
}
.topbar h1 { margin: 0 0 4px; font-size: 1.35rem; }
.topbar p { margin: 0; color: #bcd2c5; font-size: .9rem; }
.layout {
  display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 22px; padding: 24px clamp(16px, 4vw, 56px) 50px;
}
.panel { background: white; border: 1px solid #dde7e0; border-radius: 18px; box-shadow: 0 12px 35px rgba(25,60,42,.06); }
.form-panel { padding: 24px; align-self: start; }
.campaigns-panel { padding: 24px; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.panel-title h2 { margin: 3px 0 0; font-size: 1.35rem; }
.eyebrow { color: #188653; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .72rem; }
.stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; font-weight: 700; font-size: .9rem; }
input, textarea {
  width: 100%; border: 1px solid #cedbd2; border-radius: 10px; padding: 11px 12px;
  background: #fbfdfb; color: #17211c; outline: none;
}
input:focus, textarea:focus { border-color: #1b9c62; box-shadow: 0 0 0 3px rgba(27,156,98,.12); }
textarea { resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-row { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-weight: 500; line-height: 1.4; }
.check-row input { margin-top: 2px; }
.primary, .ghost, .danger, .warning {
  border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 800;
}
.primary { background: #168552; color: white; }
.primary:hover { background: #106b41; }
.ghost { background: #eaf1ec; color: #214b36; }
.danger { background: #fee9e7; color: #a63029; }
.warning { background: #fff3d4; color: #805a00; }
.hint, .muted { color: #6d7f73; font-size: .82rem; margin: -6px 0 0; line-height: 1.45; }
code { background: #edf4ef; border-radius: 5px; padding: 2px 5px; }
.alert { padding: 11px 12px; border-radius: 9px; font-size: .88rem; }
.alert.success { background: #e4f7ec; color: #12613b; }
.alert.error { background: #fee9e7; color: #982d27; }
.campaign-list { display: grid; gap: 14px; }
.campaign-card { border: 1px solid #dce7df; border-radius: 14px; padding: 17px; }
.campaign-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.campaign-head h3 { margin: 0 0 5px; font-size: 1rem; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-weight: 800; font-size: .72rem; text-transform: uppercase; }
.status-running { background: #dcf6e7; color: #11643b; }
.status-paused, .status-draft { background: #eef1ef; color: #526158; }
.status-completed { background: #e4efff; color: #245c9b; }
.status-stopped { background: #fee8e5; color: #9d3029; }
.progress-track { height: 9px; background: #edf2ee; border-radius: 999px; overflow: hidden; margin: 13px 0 8px; }
.progress-bar { height: 100%; background: #18945b; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin: 12px 0; }
.stat { background: #f6f9f7; border-radius: 9px; padding: 9px; }
.stat strong { display: block; font-size: 1rem; }
.stat span { color: #718077; font-size: .68rem; text-transform: uppercase; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.actions button { padding: 8px 10px; font-size: .78rem; }
.error-text { color: #a53830; font-size: .78rem; overflow-wrap: anywhere; }
.login-body { display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #d8eee1, #f3f6f4 55%); }
.login-card { width: min(390px, 100%); padding: 34px; border-radius: 20px; background: white; box-shadow: 0 22px 60px rgba(16,42,32,.14); }
.login-card h1 { margin: 15px 0 4px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: #168552; color: white; font-size: 1.5rem; font-weight: 900; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(9,27,19,.58); z-index: 10; }
.hidden { display: none; }
.modal-card { width: min(1050px, 100%); max-height: 85vh; overflow: hidden; background: white; border-radius: 17px; padding: 20px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; }
.table-wrap { overflow: auto; max-height: 68vh; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
th, td { text-align: left; border-bottom: 1px solid #e3eae5; padding: 10px; vertical-align: top; }
th { position: sticky; top: 0; background: white; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid-2, .stats { grid-template-columns: 1fr 1fr; } .topbar { align-items: flex-start; } }

.campaign-message {
  margin: 12px 0 4px;
  border: 1px solid #dde7e0;
  border-radius: 10px;
  background: #fbfdfb;
}
.campaign-message summary {
  cursor: pointer;
  padding: 10px 12px;
  color: #214b36;
  font-size: .8rem;
  font-weight: 800;
  user-select: none;
}
.message-box {
  border-top: 1px solid #e4ece6;
  padding: 12px;
  color: #334b3e;
  font-size: .82rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: normal;
}
.message-cell {
  min-width: 260px;
  max-width: 420px;
  color: #334b3e;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.conversations-panel { grid-column: 1 / -1; padding: 24px; }
.agent-fields { display: grid; gap: 15px; padding: 16px; border: 1px solid #d7e6dc; border-radius: 12px; background: #f7fbf8; }
.agent-toggle small { display: block; color: #6d7f73; font-weight: 500; margin-top: 3px; }
.agent-badge { margin-top: 10px; padding: 8px 10px; border-radius: 9px; background: #e7f7ee; color: #14633d; font-size: .78rem; font-weight: 800; }
.webhook-note { padding: 10px 12px; border-radius: 10px; background: #f4f8f5; color: #3c5447; overflow-wrap: anywhere; font-size: .8rem; }
.conversation-list { display: grid; gap: 10px; }
.conversation-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 14px; border: 1px solid #dce7df; border-radius: 12px; }
.conversation-title { font-weight: 900; margin-bottom: 3px; }
.conversation-preview { margin: 8px 0 0; color: #3c5145; font-size: .82rem; line-height: 1.4; }
.conversation-actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.chat-modal-card { width: min(820px, 100%); }
.chat-messages { height: min(58vh, 560px); overflow-y: auto; padding: 16px 4px; display: grid; gap: 10px; background: #f4f7f5; border-radius: 12px; }
.bubble-row { display: flex; }
.bubble-row.out { justify-content: flex-end; }
.chat-bubble { max-width: 78%; padding: 10px 12px; border-radius: 14px; background: white; box-shadow: 0 3px 10px rgba(20,55,37,.06); line-height: 1.45; font-size: .88rem; overflow-wrap: anywhere; }
.bubble-row.out .chat-bubble { background: #dff4e8; }
.bubble-sender { font-size: .68rem; font-weight: 900; text-transform: uppercase; color: #5b7466; margin-bottom: 4px; }
.operator-reply { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 12px; align-items: end; }
.operator-reply textarea { min-height: 72px; }
.status-active { background: #dcf6e7; color: #11643b; }
.status-opted_out { background: #fee8e5; color: #9d3029; }
@media (max-width: 720px) {
  .conversation-card { align-items: flex-start; flex-direction: column; }
  .conversation-actions { justify-content: flex-start; }
  .operator-reply { grid-template-columns: 1fr; }
  .chat-bubble { max-width: 92%; }
}
