:root{
  --bg:#f3f5f8;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --line:#e5e7eb;
  --dark:#111827;
  --soft:#eef2ff;
  --accent:#2563eb;
  --danger-bg:#fff1f2;
  --danger:#991b1b;
  --radius:18px;
  --shadow:0 14px 40px rgba(15,23,42,.08);
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family:Arial,Helvetica,sans-serif;
  background:linear-gradient(180deg,#eef2ff 0,#f8fafc 260px,var(--bg) 100%);
  color:var(--text);
}
a{color:inherit}
.topbar{
  position:sticky;
  top:0;
  z-index:10;
  background:rgba(255,255,255,.88);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar-inner{
  max-width:1120px;
  margin:0 auto;
  padding:14px 18px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:800;
  letter-spacing:-.02em;
}
.logo{
  width:36px;
  height:36px;
  border-radius:12px;
  background:var(--dark);
  color:#fff;
  display:grid;
  place-items:center;
  font-weight:900;
}
.nav{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.nav a,.pill{
  text-decoration:none;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  padding:9px 12px;
  border-radius:999px;
  font-size:14px;
  font-weight:700;
}
.nav a.primary{
  background:var(--dark);
  border-color:var(--dark);
  color:#fff;
}
.wrap{
  max-width:1120px;
  margin:0 auto;
  padding:34px 18px;
}
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow);
}
h1{
  margin:0 0 10px;
  font-size:34px;
  line-height:1.12;
  letter-spacing:-.04em;
}
h2{
  margin:0 0 14px;
  font-size:20px;
  letter-spacing:-.02em;
}
p{line-height:1.55}
.muted{color:var(--muted);font-size:15px}
.error{
  background:var(--danger-bg);
  border:1px solid #fecdd3;
  color:var(--danger);
  padding:12px;
  border-radius:12px;
  margin:12px 0;
  font-weight:700;
}
button,.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  margin-top:18px;
  padding:12px 16px;
  border:0;
  border-radius:12px;
  background:var(--dark);
  color:#fff;
  font-size:15px;
  font-weight:800;
  cursor:pointer;
  text-decoration:none;
}
button{width:100%}
input,select,textarea{
  width:100%;
  padding:13px 14px;
  border:1px solid #d1d5db;
  border-radius:12px;
  font-size:16px;
  outline:none;
  background:#fff;
}
input:focus,select:focus,textarea:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 4px rgba(37,99,235,.12);
}
label{
  display:block;
  font-weight:800;
  margin:14px 0 7px;
  font-size:14px;
}
.hero{
  display:grid;
  grid-template-columns:1.2fr .8fr;
  gap:22px;
}
.grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:16px;
  margin-top:18px;
}
.mini,.stat{
  background:#f8fafc;
  border:1px solid var(--line);
  border-radius:16px;
  padding:16px;
}
.mini strong{display:block;margin-bottom:6px}
.dashboard{
  display:grid;
  grid-template-columns:260px 1fr;
  gap:18px;
}
.side{padding:18px}
.side .user{
  padding:14px;
  border-radius:16px;
  background:#f8fafc;
  border:1px solid var(--line);
  margin-bottom:14px;
}
.menu{
  display:grid;
  gap:8px;
}
.menu a{
  text-decoration:none;
  padding:12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-weight:800;
}
.menu a.active{
  background:var(--dark);
  color:#fff;
  border-color:var(--dark);
}
.content-grid{
  display:grid;
  grid-template-columns:repeat(2,1fr);
  gap:16px;
}
.stat .num{
  font-size:30px;
  font-weight:900;
  letter-spacing:-.04em;
  margin-top:6px;
}
.badge{
  display:inline-block;
  background:var(--soft);
  color:#3730a3;
  padding:7px 11px;
  border-radius:999px;
  font-size:13px;
  font-weight:800;
}
@media(max-width:820px){
  .topbar-inner{align-items:flex-start;flex-direction:column}
  .nav{width:100%;justify-content:flex-start}
  .hero,.dashboard{grid-template-columns:1fr}
  .grid,.content-grid{grid-template-columns:1fr}
  h1{font-size:29px}
  .wrap{padding:22px 14px}
  .card{padding:20px}
}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:760px;
  margin-top:16px;
  overflow:hidden;
  border:1px solid var(--line);
  border-radius:16px;
  background:#fff;
}
.table th,
.table td{
  padding:12px 14px;
  border-bottom:1px solid var(--line);
  text-align:left;
  vertical-align:top;
  font-size:14px;
}
.table th{
  background:#f8fafc;
  color:#374151;
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.03em;
}
.table tr:last-child td{
  border-bottom:0;
}
.table tr:hover td{
  background:#fafafa;
}

.nav-with-badge{
  position:relative;
}
.notice-badge{
  position:absolute;
  top:-7px;
  right:-7px;
  min-width:19px;
  height:19px;
  padding:0 5px;
  border-radius:999px;
  background:#dc2626;
  color:#fff;
  font-size:11px;
  line-height:19px;
  text-align:center;
  font-weight:900;
  box-shadow:0 0 0 2px #fff;
}

.impersonate-bar{
  border-color:#facc15;
  background:#fefce8;
  color:#713f12;
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
}
.impersonate-bar .btn{
  margin:0;
}

.service-topline{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
  margin-bottom:14px;
}
.service-breadcrumb{
  margin:0;
  font-size:13px;
}
.btn-small{
  padding:7px 10px;
  font-size:13px;
  border-radius:10px;
}

.service-toggle-wrap{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  align-items:center;
}
.service-toggle-form{
  margin:0;
}
.service-toggle-btn{
  margin:0;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  line-height:1.1;
  font-weight:800;
  border:1px solid transparent;
  cursor:pointer;
  white-space:nowrap;
}
.service-toggle-btn.is-on{
  background:#dcfce7;
  border-color:#86efac;
  color:#166534;
}
.service-toggle-btn.is-off{
  background:#fee2e2;
  border-color:#fecaca;
  color:#991b1b;
}

.table-action-btn{
  margin:0;
  padding:7px 10px;
  border-radius:10px;
  font-size:12px;
  line-height:1.15;
  font-weight:800;
  white-space:nowrap;
}

/* SMS Chat */
.sms-chat-box{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:18px;
}
.sms-bubble{
  max-width:820px;
  padding:13px 15px;
  border:1px solid var(--line);
  border-radius:16px;
  background:#fff;
}
.sms-bubble-ok{
  border-left:5px solid #22c55e;
}
.sms-bubble-waiting{
  border-left:5px solid #ef4444;
  background:#fff7f7;
}
.sms-bubble-meta{
  font-size:12px;
  color:#64748b;
  margin-bottom:7px;
}
.sms-bubble-text{
  font-size:15px;
  line-height:1.5;
  white-space:normal;
}
@media (max-width:720px){
  .sms-bubble{
    max-width:100%;
  }
}

/* SMS operational inbox */
.sms-work-layout{
  display:grid;
  grid-template-columns:360px 1fr;
  gap:18px;
  margin-top:18px;
}
.sms-user-list,
.sms-chat-preview{
  border:1px solid var(--line);
  border-radius:18px;
  background:#fff;
  overflow:hidden;
}
.sms-user-list-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  background:#f8fafc;
}
.sms-user-item{
  display:block;
  padding:13px 16px;
  border-bottom:1px solid var(--line);
  color:inherit;
  text-decoration:none;
}
.sms-user-item:hover{
  background:#f8fafc;
}
.sms-user-main{
  display:flex;
  justify-content:space-between;
  gap:10px;
  align-items:center;
}
.sms-user-main span{
  font-size:13px;
  color:#64748b;
  text-transform:uppercase;
  font-weight:700;
}
.sms-user-meta{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-top:5px;
  font-size:12px;
  color:#64748b;
}
.sms-user-badge,
.sms-user-badge-ok{
  display:inline-block;
  margin-top:8px;
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
}
.sms-user-badge{
  background:#fee2e2;
  color:#991b1b;
}
.sms-user-badge-ok{
  background:#dcfce7;
  color:#166534;
}
.sms-chat-preview{
  min-height:520px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:22px;
  background:#f8fafc;
}
.sms-chat-empty{
  text-align:center;
  max-width:360px;
}
@media (max-width:900px){
  .sms-work-layout{
    grid-template-columns:1fr;
  }
  .sms-chat-preview{
    display:none;
  }
}

/* SMS inbox compact overrides */
.sms-work-layout{
  grid-template-columns:330px 1fr;
  align-items:start;
}
.sms-user-list{
  max-height:620px;
  overflow:auto;
}
.sms-user-item{
  padding:10px 13px;
}
.sms-user-line{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.sms-user-time{
  margin-top:3px;
  font-size:11px;
  color:#64748b;
  font-weight:500;
}
.sms-user-count,
.sms-user-count-ok{
  flex:0 0 auto;
  min-width:28px;
  height:28px;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:13px;
  font-weight:900;
}
.sms-user-count{
  background:#ef4444;
  color:#fff;
}
.sms-user-count-ok{
  background:#dcfce7;
  color:#166534;
}
.sms-user-meta{
  margin-top:4px;
}
.sms-user-item.has-unanswered{
  background:#fffafa;
}
.sms-user-item.has-unanswered:hover{
  background:#fff1f2;
}
.sms-user-item.is-clear{
  background:#ffffff;
}
@media (max-width:900px){
  .sms-user-list{
    max-height:none;
  }
}

.sms-user-item.is-active{
  background:#eef6ff;
  box-shadow:inset 4px 0 0 #2563eb;
}
.sms-chat-preview{
  align-items:stretch;
  justify-content:flex-start;
  overflow:auto;
}
.sms-chat-panel-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid var(--line);
  background:#fff;
}
.sms-reply-panel-compact{
  margin:14px;
}
.sms-chat-box-embed{
  padding:0 14px 16px;
}
.sms-row{
  display:flex;
  width:100%;
}
.sms-row-in{
  justify-content:flex-start;
}
.sms-bubble-in{
  background:#fff;
  border-radius:18px 18px 18px 6px;
  border:1px solid var(--line);
}
.sms-status{
  display:inline-block;
  padding:2px 7px;
  border-radius:999px;
  font-size:11px;
  font-weight:800;
}
.sms-status-ok{
  background:#dcfce7;
  color:#166534;
}
.sms-status-wait{
  background:#fee2e2;
  color:#991b1b;
}

/* SMS right chat panel fixed reply + scroll messages */
.sms-chat-preview{
  height:620px;
  min-height:620px;
  display:flex;
  flex-direction:column;
  align-items:stretch;
  justify-content:flex-start;
  padding:0;
  overflow:hidden;
  background:#f8fafc;
}
.sms-chat-panel-head{
  flex:0 0 auto;
}
.sms-reply-panel-compact{
  flex:0 0 auto;
  margin:12px;
  padding:12px;
  border:1px solid var(--line);
  border-radius:16px;
  background:#fff;
}
.sms-reply-panel-compact textarea{
  min-height:82px;
  resize:vertical;
}
.sms-reply-panel-compact .sms-reply-actions{
  margin-top:8px;
}
.sms-chat-box-embed{
  flex:1 1 auto;
  overflow:auto;
  padding:0 12px 14px;
  margin:0;
}
.sms-chat-box-embed .sms-bubble{
  max-width:86%;
}
.sms-chat-box-embed .sms-bubble-meta{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  align-items:center;
}
@media (max-width:900px){
  .sms-chat-preview{
    height:auto;
    min-height:0;
  }
}

/* SMS inbox active user + right static block polish */
.sms-user-item.is-active{
  background:#dbeafe !important;
  box-shadow:inset 5px 0 0 #2563eb;
}
.sms-user-item.is-active strong{
  color:#0f172a;
}
.sms-user-item.is-active .sms-user-time{
  color:#1d4ed8;
}
.sms-chat-panel-head{
  background:#eef6ff;
  border-bottom:1px solid #bfdbfe;
  padding:12px 14px;
}
.sms-chat-head-main{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  width:100%;
}
.sms-chat-head-main strong{
  font-size:18px;
}
.sms-chat-head-stats{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  align-items:center;
}
.sms-head-pill{
  display:inline-flex;
  align-items:center;
  padding:5px 9px;
  border-radius:999px;
  background:#ffffff;
  border:1px solid #bfdbfe;
  color:#1e3a8a;
  font-size:12px;
  font-weight:800;
}
.sms-head-pill-wait{
  background:#fee2e2;
  border-color:#fecaca;
  color:#991b1b;
}
.sms-reply-panel-compact{
  background:#f8fbff;
  border-color:#bfdbfe;
}

.sms-user-item.is-active .sms-user-time{
  color:#64748b !important;
}

.sms-row-out{
  justify-content:flex-end;
}
.sms-bubble-out{
  background:#e0f2fe;
  border:1px solid #bae6fd;
  border-radius:18px 18px 6px 18px;
}
.sms-bubble-out .sms-bubble-meta{
  justify-content:flex-end;
}

.sms-chat-mobile-card{
  padding:0;
  overflow:hidden;
}
.sms-chat-mobile-card .sms-chat-preview{
  height:auto;
  min-height:620px;
  border:0;
  border-radius:0;
}

/* SMS chat standalone mobile page */
.sms-chat-mobile-card{
  display:block;
}
.sms-chat-mobile-card .sms-chat-panel-head,
.sms-chat-mobile-card .sms-reply-panel-compact,
.sms-chat-mobile-card .sms-chat-box-embed{
  display:block;
}
.sms-chat-mobile-card .sms-chat-box-embed{
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
  padding:12px;
}
.sms-chat-mobile-card .sms-row{
  display:flex;
}
.sms-chat-mobile-card .sms-row-in{
  justify-content:flex-start;
}
.sms-chat-mobile-card .sms-row-out{
  justify-content:flex-end;
}
.sms-chat-mobile-card .sms-bubble{
  display:block;
  max-width:92%;
}
@media (max-width:900px){
  .sms-chat-mobile-card .sms-chat-box-embed{
    display:block !important;
  }
}

/* FINAL mobile fix for SMS work page */
@media (max-width:900px){
  .sms-work-layout{
    display:block !important;
    grid-template-columns:1fr !important;
  }

  .sms-user-list{
    width:100% !important;
    max-height:none !important;
    overflow:visible !important;
  }

  .sms-chat-preview{
    display:none !important;
  }

  .sms-user-item{
    width:100% !important;
  }
}

/* Standalone SMS chat page must always show messages */
.sms-chat-mobile-card .sms-chat-panel-head,
.sms-chat-mobile-card .sms-reply-panel-compact,
.sms-chat-mobile-card .sms-chat-box-embed{
  display:block !important;
}

.sms-chat-mobile-card .sms-chat-box-embed{
  height:auto !important;
  max-height:none !important;
  overflow:visible !important;
  padding:12px !important;
}

.sms-chat-mobile-card .sms-row{
  display:flex !important;
}

.sms-chat-mobile-card .sms-row-in{
  justify-content:flex-start !important;
}

.sms-chat-mobile-card .sms-row-out{
  justify-content:flex-end !important;
}

.sms-chat-mobile-card .sms-bubble{
  max-width:94% !important;
}

.sms-chat-standalone{
  display:flex !important;
  height:auto !important;
  min-height:620px !important;
  border:0 !important;
  border-radius:0 !important;
}
.sms-chat-standalone .sms-chat-box-embed{
  display:block !important;
  flex:1 1 auto !important;
  overflow:visible !important;
}

/* SMS stats keyword table */
.stats-keyword-table{
  max-width:620px;
}

.stats-keyword-table .table{
  min-width:0;
}

.stats-keyword-table th,
.stats-keyword-table td{
  white-space:nowrap;
}

.stats-keyword-table th:nth-child(1),
.stats-keyword-table td:nth-child(1){
  width:38%;
}

.stats-keyword-table th:nth-child(n+2),
.stats-keyword-table td:nth-child(n+2){
  text-align:right;
}

/* SMS chat compact header */
.sms-chat-head-clean{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

.sms-chat-head-left{
  min-width:0;
}

.sms-chat-head-meta{
  margin-top:3px;
  font-size:12px;
  line-height:1.35;
  color:#667085;
  display:flex;
  gap:5px;
  flex-wrap:wrap;
}

.sms-chat-head-note{
  margin-top:3px;
  font-size:12px;
  line-height:1.35;
  color:#667085;
}

.sms-chat-head-clean .sms-chat-head-stats{
  flex-shrink:0;
  display:flex;
  gap:6px;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
}

/* SMS chat header keyword/meta pills */
.sms-chat-meta-pill{
  display:inline-flex;
  align-items:center;
  gap:3px;
  padding:2px 7px;
  border:1px solid #d7e3f4;
  background:#ffffff;
  border-radius:999px;
  font-size:11px;
  line-height:1.25;
  color:#475467;
  white-space:nowrap;
}

.sms-chat-head-meta{
  margin-top:4px;
  gap:5px;
}

/* SMS chat header plain compact meta */
.sms-chat-head-meta-plain{
  margin-top:1px !important;
  display:block !important;
  font-size:10px !important;
  line-height:1.15 !important;
  color:#667085 !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

.sms-chat-head-meta-plain span{
  display:inline !important;
  padding:0 !important;
  border:0 !important;
  background:transparent !important;
  border-radius:0 !important;
  font-size:10px !important;
  line-height:1.15 !important;
  color:#667085 !important;
  white-space:nowrap !important;
}

.sms-chat-head-meta-plain strong{
  font-weight:600 !important;
  color:#475467 !important;
}

/* Stats table compact two-line headers */
.stats-keyword-table th .th-two{
  display:inline-block;
  font-size:12px;
  line-height:1.15;
  white-space:normal;
}

/* Operators page toolbar */
.operators-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
  margin:14px 0 18px;
}
.operators-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.op-tab{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:8px 12px;
  border:1px solid #d0d5dd;
  border-radius:999px;
  background:#fff;
  color:#101828;
  font-weight:700;
  font-size:13px;
  text-decoration:none;
}
.op-tab.is-active{
  background:#101323;
  border-color:#101323;
  color:#fff;
}

/* Operators table compact columns */
.table .col-operator{
  font-size:13px;
  line-height:1.2;
  min-width:180px;
}
.table .col-operator strong{
  font-size:13px;
}
.table .col-services{
  font-size:12px;
  min-width:150px;
}
.table .col-services .service-toggle-btn{
  font-size:12px;
  padding:5px 9px;
  line-height:1.15;
  white-space:nowrap;
}
.table .col-services .service-toggle-wrap{
  gap:5px;
}

/* Operator tab counters */
.op-tab-count{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 6px;
  margin-left:6px;
  border-radius:999px;
  background:#eef2f6;
  color:#101828;
  font-size:12px;
  font-weight:800;
}
.op-tab.is-active .op-tab-count{
  background:#fff;
  color:#101323;
}
.op-tab-count.is-alert{
  background:#ef4444;
  color:#fff;
  animation:opPulse 1.4s ease-in-out infinite;
}
@keyframes opPulse{
  0%,100%{transform:scale(1);opacity:1}
  50%{transform:scale(1.08);opacity:.78}
}

/* Softer operator tab counters override */
.op-tab-count{
  min-width:18px;
  height:18px;
  padding:0 6px;
  margin-left:5px;
  border-radius:999px;
  background:#f3f4f6;
  border:1px solid #e5e7eb;
  color:#475467;
  font-size:11px;
  font-weight:700;
  line-height:18px;
}
.op-tab.is-active .op-tab-count{
  background:#ffffff;
  border-color:#ffffff;
  color:#101323;
}
.op-tab-count.is-alert{
  background:#ef4444;
  border-color:#ef4444;
  color:#ffffff;
  animation:opPulse 1.4s ease-in-out infinite;
}

/* Operator verification indicators */
.verify-pill{
  display:inline-flex;
  align-items:center;
  margin-left:6px;
  padding:2px 6px;
  border-radius:999px;
  font-size:10px;
  font-weight:700;
  vertical-align:middle;
}
.verify-pill.is-ok{
  background:#ecfdf3;
  color:#067647;
  border:1px solid #abefc6;
}
.verify-pill.is-bad{
  background:#fef3f2;
  color:#b42318;
  border:1px solid #fecdca;
}

/* Quieter operator warnings */
.operator-warnings{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:3px;
  font-size:10px;
  line-height:1.2;
}
.operator-warnings span{
  color:#b42318;
  background:#fff1f0;
  border:1px solid #ffd6d1;
  border-radius:999px;
  padding:1px 5px;
}

/* Compact contact verification bubbles */
.contact-bubbles{
  display:flex;
  gap:6px;
  flex-wrap:wrap;
  margin-top:5px;
}
.contact-bubble{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:2px 7px;
  border-radius:999px;
  font-size:10px;
  line-height:1.2;
  font-weight:700;
  border:1px solid transparent;
  cursor:default;
}
.contact-bubble.is-ok{
  background:#ecfdf3;
  border-color:#a6f4c5;
  color:#027a48;
}
.contact-bubble.is-bad{
  background:#fef3f2;
  border-color:#fecdca;
  color:#b42318;
}

/* Top navigation alignment tweak */
.topbar-inner{
  max-width:1120px;
  margin:0 auto;
  padding:0 18px;
}

.nav{
  gap:7px;
}

.nav a,.pill{
  padding:8px 11px;
  line-height:1;
  white-space:nowrap;
}
