:root {
  --navy: #0b1220;
  --navy-2: #151d2c;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e4e9f2;
  --text: #122033;
  --muted: #6b7890;
  --teal: #00c2a8;
  --danger: #e11d48;
  --warn: #d97706;
  --ok: #047857;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", sans-serif;
}
.hidden { display: none !important; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-card, .modal-card {
  width: min(440px, 100%);
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(11, 18, 32, 0.08);
}
.brand {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 1px;
}
.brand b { color: #7eb6ff; font-weight: 800; }
.brand span { color: var(--teal); }
aside .brand { color: #fff; }
aside .brand b { color: #9cc7ff; }
aside .brand span { color: var(--teal); }
.sub, .aside-sub, label, .hint, .eyebrow { color: var(--muted); }
.aside-sub { margin-top: 0; }
label, input, select, button { display: block; width: 100%; }
input, select {
  margin: 8px 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font: inherit;
}
input:focus, select:focus {
  outline: 2px solid rgba(0, 194, 168, 0.35);
  border-color: var(--teal);
}
input.invalid { border-color: var(--danger); }
button { font: inherit; cursor: pointer; border: 0; }
.primary, .ghost, .nav-btn {
  padding: 14px 16px;
  border-radius: 14px;
  font-weight: 700;
}
.primary { background: var(--teal); color: #06241f; }
.primary:disabled { opacity: 0.55; cursor: not-allowed; }
.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
aside .ghost { color: #fff; border-color: #2a364c; }
.error { color: var(--danger); margin: 0 0 12px; }
.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #d1fae5;
  color: var(--ok);
  font-weight: 700;
}
.notice.warn { background: #fef3c7; color: var(--warn); }
tr.highlight td { background: #ecfdf5; }
.hint { margin: -8px 0 14px; font-size: 13px; }
.hint.ok { color: var(--ok); }
.hint.bad { color: var(--danger); }
#app-view { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
aside {
  margin: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--navy);
  color: #fff;
  border-radius: 22px;
}
nav { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.nav-label {
  margin: 12px 4px 0;
  font-size: 12px;
  color: #8b97ad;
  font-weight: 700;
}
.nav-btn { text-align: right; background: var(--navy-2); color: #fff; }
.nav-btn.active { background: var(--teal); color: #06241f; }
main { padding: 36px 40px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 4px 0 0; }
.eyebrow { margin: 0; font-size: 13px; font-weight: 700; }
.section-title { margin: 0 0 14px; font-size: 18px; }
.toolbar { margin-bottom: 16px; }
.toolbar input { max-width: 360px; margin: 0; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat {
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 24px rgba(11, 18, 32, 0.04);
  min-height: 118px;
}
.stat span { color: var(--muted); font-size: 14px; display: block; }
.stat b { display: block; font-size: 40px; margin-top: 10px; color: var(--navy); line-height: 1; }
.stat.teal { border-top: 4px solid var(--teal); }
.stat.warn { border-top: 4px solid var(--warn); }
.stat.danger { border-top: 4px solid var(--danger); }
.stat.teal b { color: var(--ok); }
.stat.warn b { color: var(--warn); }
.stat.danger b { color: var(--danger); }
.stat.live {
  border-top: 4px solid var(--ok);
  background: linear-gradient(180deg, #ecfdf5 0%, #fff 42%);
}
.stat.live b { color: var(--ok); }
.stat.live span { display: flex; align-items: center; gap: 8px; }
.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(4, 120, 87, 0.55);
  animation: live-pulse 1.6s ease-out infinite;
}
@keyframes live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(4, 120, 87, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(4, 120, 87, 0); }
  100% { box-shadow: 0 0 0 0 rgba(4, 120, 87, 0); }
}
.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 22px 0; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(11, 18, 32, 0.04);
}
.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 40px; gap: 10px; align-items: center; }
.bar-row span { color: var(--muted); font-size: 14px; }
.bar-row b { text-align: left; color: var(--navy); }
.bar-track { height: 10px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 999px; min-width: 0; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }
.bar-fill.muted { background: #94a3b8; }
.row-between, .row { display: flex; gap: 12px; align-items: center; }
.row-between { justify-content: space-between; }
.row button { width: auto; flex: 1; }
.table-wrap {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: right; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 13px; background: #f8fafc; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.ACTIVE { background: #d1fae5; color: var(--ok); }
.EXPIRED { background: #fef3c7; color: var(--warn); }
.SUSPENDED { background: #ffe4e6; color: var(--danger); }
.DISABLED { background: #e5e7eb; color: #4b5563; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions button {
  width: auto;
  padding: 8px 10px;
  font-size: 13px;
  background: #eef2f7;
  color: var(--text);
  border-radius: 10px;
}
.check { display: flex; align-items: center; gap: 10px; margin: 8px 0; color: var(--text); }
.check input { width: auto; margin: 0; }
.apps-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 16px; }
.banner-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }
.banner-card { background: #f8fafc; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.banner-card img { width: 100%; height: 96px; object-fit: cover; display: block; cursor: zoom-in; }
.banner-card p { margin: 8px 10px 0; font-size: 13px; color: var(--muted); }
.banner-card button { width: calc(100% - 20px); margin: 8px 10px 10px; }
.banner-preview {
  background: rgba(11, 18, 32, 0.82);
  z-index: 40;
  padding: 28px 16px;
}
.banner-preview img {
  max-width: min(1100px, 94vw);
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  object-fit: contain;
}
.banner-preview-close {
  position: absolute;
  top: 18px;
  left: 18px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: var(--navy);
  font-size: 28px;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}
.wa-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 68vh;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
}
.wa-list {
  background: #fff;
  border-left: 1px solid var(--line);
  overflow: auto;
}
.wa-list-head {
  padding: 16px 18px;
  font-weight: 800;
  border-bottom: 1px solid var(--line);
}
.thread-item {
  width: 100%;
  text-align: right;
  padding: 12px 16px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #f1f5f9;
}
.thread-item.active { background: #e7f8f4; }
.thread-item small { color: var(--muted); font-weight: 500; }
.wa-preview { color: var(--muted); font-size: 13px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.wa-unread {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}
.wa-chat { display: flex; flex-direction: column; background: #efeae2; min-height: 68vh; }
.wa-chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  background: #f0f2f5;
  border-bottom: 1px solid var(--line);
}
.wa-chat-head .section-title { margin: 0; }
.danger-btn { color: var(--danger); border-color: #fecdd3; width: auto; }
.nav-badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  margin-inline-start: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  align-items: center;
  justify-content: center;
}
.nav-badge.hidden { display: none; }
.ok-btn { color: #0f766e; border-color: #99f6e4; }
.wa-msgs {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  direction: ltr;
}
.wa-row { display: flex; }
.wa-row.mine { justify-content: flex-end; }
.wa-row.theirs { justify-content: flex-start; }
.wa-bubble {
  max-width: 72%;
  padding: 8px 10px 6px;
  border-radius: 12px;
  direction: rtl;
  text-align: right;
  box-shadow: 0 1px 1px rgba(11, 18, 32, 0.08);
}
.wa-bubble.mine { background: #d9fdd3; border-bottom-right-radius: 4px; }
.wa-bubble.theirs { background: #fff; border-bottom-left-radius: 4px; }
.wa-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  color: #667781;
  font-size: 11px;
}
.ticks { letter-spacing: -2px; font-weight: 700; }
.ticks.unread { color: #8696a0; }
.ticks.read { color: #53bdeb; }
.wa-composer, .wa-pass {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #f0f2f5;
}
.wa-composer input, .wa-pass input { margin: 0; }
.wa-composer button, .wa-pass button { width: auto; }
@media (max-width: 900px) {
  .wa-shell { grid-template-columns: 1fr; }
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
@media (max-width: 1100px) {
  .stats, .dash-split { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  #app-view { grid-template-columns: 1fr; }
  aside { margin: 12px; }
  main { padding: 20px; }
  .stats, .dash-split { grid-template-columns: 1fr; }
}
