/* Midad Alkhair campaign tool.
   Type: Alexandria (headings) + IBM Plex Sans Arabic (text), bundled in /fonts (SIL OFL).
   Colors come from the logo: green #39B44A (decoration only) with a darker green for
   text and buttons, and the logo orange kept for the brand mark. */

@font-face { font-family: 'Alexandria'; font-weight: 500; font-display: swap; src: url(fonts/alexandria-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 600; font-display: swap; src: url(fonts/alexandria-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 700; font-display: swap; src: url(fonts/alexandria-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Alexandria'; font-weight: 500; font-display: swap; src: url(fonts/alexandria-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Alexandria'; font-weight: 600; font-display: swap; src: url(fonts/alexandria-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Alexandria'; font-weight: 700; font-display: swap; src: url(fonts/alexandria-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: 'Plex Arabic'; font-weight: 400; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 500; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 600; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Plex Arabic'; font-weight: 700; font-display: swap; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --font-head: 'Alexandria', 'Plex Arabic', Tahoma, sans-serif;
  --font-body: 'Plex Arabic', Tahoma, 'Segoe UI', sans-serif;

  --brand: #39b44a;          /* logo green: marks and accents only, too light for text */
  --brand-orange: #ee4723;   /* logo orange: brand mark only */
  --primary: #1f7a36;        /* buttons, links, selected states (5.4:1 on white) */
  --primary-hover: #19652c;
  --primary-soft: #e9f5ec;
  --primary-line: #bfe3c7;

  --page: #f4f6f5;
  --card: #ffffff;
  --subtle: #f7f9f8;
  --text: #1a2a22;
  --text-2: #3e4e46;
  --muted: #5d6b64;
  --border: #e1e7e4;
  --border-strong: #cfd8d3;

  --sidebar: #12241b;
  --sidebar-text: #d3dfd8;
  --sidebar-muted: #8fa39a;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active: rgba(57, 180, 74, .16);

  --warn: #a15c00;
  --warn-soft: #fff6e5;
  --bad: #b3261e;
  --bad-soft: #fdeceb;

  --chat-bg: #efeae2;
  --bubble: #d9fdd3;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 36, 27, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; margin: 0 0 12px; line-height: 1.45; letter-spacing: 0; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: var(--primary-soft); color: var(--primary); padding: 1px 6px; border-radius: 6px; font-size: 13px; }
bdi { unicode-bidi: isolate; }

/* Icons: inline SVG, drawn from <i data-icon> placeholders and the icon() helper. */
.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }
.i.sm { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- App shell: sidebar + content ---------- */
.app { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--sidebar); color: var(--sidebar-text); padding: 20px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; border-bottom: 1px solid rgba(255, 255, 255, .08); margin-bottom: 16px; }
.brand img { width: 44px; height: 44px; flex-shrink: 0; }
.brand-name { font-family: var(--font-head); font-weight: 600; font-size: 14.5px; line-height: 1.5; color: #fff; }
.brand-sub { font-size: 12px; color: var(--sidebar-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: none; color: var(--sidebar-text); font: inherit; font-size: 14px; font-weight: 500;
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; text-align: start; position: relative;
}
.nav button .i { color: var(--sidebar-muted); }
.nav button:hover { background: var(--sidebar-hover); }
.nav button.active { background: var(--sidebar-active); color: #fff; }
.nav button.active .i { color: var(--brand); }
.nav button.active::before {
  content: ''; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav .count {
  margin-inline-start: auto; background: rgba(255, 255, 255, .1); color: var(--sidebar-text);
  font-size: 11.5px; padding: 0 8px; border-radius: 99px; font-variant-numeric: tabular-nums;
}
.nav-label { font-size: 11.5px; color: var(--sidebar-muted); padding: 14px 12px 6px; font-weight: 500; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.account-pick { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 12px; opacity: .9; }
.account-pick select { width: 100%; }
body.role-manager .admin-only { display: none; }
.who { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; font-size: 13px; }
.who-name { opacity: .85; }
.logout-btn { width: 100%; justify-content: center; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); }
.login-logo { width: 56px; height: 56px; display: block; margin: 0 auto 8px; }
.login-card h2 { text-align: center; }
.login-card .btn { width: 100%; justify-content: center; }
.login-error { color: var(--danger, #b42318); font-size: 14px; }
.totp-qr { display: block; width: 220px; height: 220px; margin: 8px 0; background: #fff; padding: 6px; border-radius: 8px; }
.audit { max-height: 320px; overflow: auto; }
.conn { display: flex; align-items: center; gap: 10px; padding: 8px; font-size: 13px; }
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #d7a33c; flex-shrink: 0; box-shadow: 0 0 0 3px rgba(215, 163, 60, .18); }
.conn.ok .dot { background: var(--brand); box-shadow: 0 0 0 3px rgba(57, 180, 74, .2); }
.conn.bad .dot { background: #e5574f; box-shadow: 0 0 0 3px rgba(229, 87, 79, .2); }
.conn .conn-label { color: var(--sidebar-text); font-weight: 500; }
.conn .conn-number { color: var(--sidebar-muted); font-size: 12px; direction: ltr; unicode-bidi: isolate; }

.content { min-width: 0; }
.update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid #f1d7a8;
  padding: 10px 36px; font-weight: 500;
}
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 26px 36px 18px; max-width: 1240px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
main { max-width: 1240px; padding: 0 36px 60px; }
.tab { display: none; }
.tab.active { display: block; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.card > h2:first-child, .card > h3:first-child { margin-bottom: 4px; }
.card > h2 + .muted, .card > h3 + .muted { margin-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.two-col > .card { margin-bottom: 0; }
.tab > .two-col { margin-bottom: 16px; }
.section-title { font-family: var(--font-head); font-size: 14px; font-weight: 600; color: var(--text-2); margin: 20px 0 10px; }
form.card h2 { font-size: 15px; padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
form.card h2:first-child { padding-top: 0; margin-top: 0; border-top: 0; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px;
  border: 1px solid var(--border-strong); background: var(--card); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; padding: 0 14px; border-radius: var(--radius-sm); cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s;
}
.btn .i { color: var(--muted); }
.btn:hover { background: var(--subtle); border-color: var(--muted); }
.btn:focus-visible, .nav button:focus-visible, .link-btn:focus-visible { outline: 3px solid var(--primary-line); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary .i { color: #fff; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger-ghost { color: var(--bad); }
.btn.danger-ghost .i { color: var(--bad); }
.btn.danger-ghost:hover { background: var(--bad-soft); border-color: #eab4b0; }
.btn.big { width: 100%; height: 46px; font-size: 15px; font-weight: 600; }
.small-btn { height: 32px; padding: 0 12px; font-size: 13.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

input[type=text], input[type=tel], input[type=number], input[type=search], input[type=password], textarea, select {
  width: 100%; font: inherit; font-size: 14px; color: var(--text); background: var(--card);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 0 12px; height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 240px; line-height: 1.8; }
input::placeholder, textarea::placeholder { color: #93a19a; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
select { width: auto; min-width: 170px; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.field { display: block; margin-bottom: 14px; }
.field > span, .label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0 16px; }
.grid .wide { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; }
.range { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.range input { flex: 1; min-width: 0; }

/* ---------- Connect ---------- */
.connect { display: flex; justify-content: space-between; gap: 28px; align-items: center; }
#connect-status { white-space: pre-line; }
.steps { padding-inline-start: 20px; margin: 12px 0 0; color: var(--text-2); }
.steps li { margin-bottom: 6px; }
.pair-box { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.pair-title { font-family: var(--font-head); font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.pair-result { margin-top: 14px; background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: var(--radius-sm); padding: 14px 16px; }
.pair-code { font-family: var(--font-head); font-size: 30px; font-weight: 700; letter-spacing: 4px; color: var(--primary); text-align: center; }
.pair-result .steps { margin-top: 8px; font-size: 13.5px; }
.qr-box {
  width: 240px; height: 240px; flex-shrink: 0; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.qr-box img { width: 220px; height: 220px; }
.qr-box img:not([src]), .qr-box img[src=""] { display: none; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--primary); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Active campaign ---------- */
.badge { display: inline-block; padding: 2px 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; background: var(--subtle); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.running, .badge.done { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.badge.paused { background: var(--warn-soft); color: var(--warn); border-color: #f1d7a8; }
.badge.ok { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1d7a8; }
.badge.bad { background: #fde8e7; color: #b42318; border-color: #f5c2bf; }
.health-source { margin-top: 8px; }
.overview-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.ov-tile { background: var(--subtle); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.ov-value { font-size: 24px; font-weight: 700; }
.ov-label { font-size: 13px; color: var(--muted); }
.overview-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.ov-table { width: 100%; font-size: 13px; margin: 8px 0 12px; }
.ov-table td { padding: 4px 6px; border-bottom: 1px solid var(--border); }
.ov-table td:nth-child(even) { font-weight: 600; }
#tpl-count.over { color: #b42318; font-weight: 600; }
.progress { height: 8px; background: var(--subtle); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress div { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .4s; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 18px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stat { padding: 14px 16px; border-inline-start: 1px solid var(--border); }
.stat:first-child { border-inline-start: 0; }
.stat b { display: block; font-family: var(--font-head); font-size: 24px; font-weight: 600; line-height: 1.3; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.ok b { color: var(--primary); }
.stat.warn b { color: var(--warn); }
.stat.bad b { color: var(--bad); }
.run-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-weight: 500; border: 1px solid var(--primary-line); }
.run-status.waiting { background: var(--warn-soft); color: var(--warn); border-color: #f1d7a8; }
.run-status.idle { background: var(--subtle); color: var(--muted); border-color: var(--border); }
.run-status .timer { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- New campaign ---------- */
.new-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; }
.summary { background: var(--subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; }
.summary b { color: var(--primary); }
.summary p { margin: 2px 0; }
.summary .health-warning { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.summary .health-warning.warn { background: var(--warn-soft); color: var(--warn); }
.summary .health-warning.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Chat preview ---------- */
.chat { background: var(--chat-bg); border-radius: var(--radius-sm); padding: 20px; min-height: 260px; }
.small-chat { min-height: 0; padding: 14px; max-height: 340px; overflow: auto; }
.bubble {
  background: var(--bubble); border-radius: 8px; border-top-left-radius: 2px; padding: 8px 10px;
  max-width: 85%; margin-right: auto; white-space: pre-wrap; word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .08); font-size: 14px; line-height: 1.7;
}
.bubble img { display: block; max-width: 100%; border-radius: 6px; margin-bottom: 6px; }
.bubble:empty::before { content: 'لم تُكتب رسالة بعد'; color: var(--muted); }

/* ---------- Log ---------- */
.log { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow: auto; font-size: 13.5px; }
.log li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.log li:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; direction: ltr; }
.log:empty::before { content: 'لا شيء بعد'; color: var(--muted); }

/* ---------- Contacts ---------- */
.toolbar { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; flex: 1; max-width: 420px; position: relative; }
.filters .i { position: absolute; inset-inline-start: 12px; top: 11px; color: var(--muted); pointer-events: none; }
.filters input { flex: 1; padding-inline-start: 38px; }
.toolbar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.add-form { margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.country-chips { margin: 0 0 12px; }
.country-chips button, .audience button {
  display: inline-flex; align-items: center; gap: 4px; height: 32px;
  border: 1px solid var(--border-strong); background: var(--card); border-radius: 6px; padding: 0 12px;
  font: inherit; font-size: 13.5px; cursor: pointer; color: var(--text); white-space: nowrap;
}
.country-chips button:hover, .audience button:hover { border-color: var(--muted); }
.country-chips button.active, .audience button.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.country-chips button span, .audience button span { color: var(--muted); font-weight: 400; margin-inline-start: 2px; font-size: 12.5px; }
.audience { display: flex; flex-wrap: wrap; gap: 6px; }
.table-info { display: flex; justify-content: space-between; align-items: center; min-height: 40px; gap: 8px; }
.table-wrap { overflow: auto; max-height: 580px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { position: sticky; top: 0; z-index: 1; background: var(--subtle); font-size: 12.5px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.phone { direction: ltr; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
th.chk, td.chk { width: 40px; }
tbody tr:hover td { background: #fafcfb; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; background: none; cursor: pointer; color: var(--muted); border-radius: 6px; }
.icon-btn:hover { color: var(--bad); background: var(--bad-soft); }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; font-size: 13.5px; font-weight: 500; padding: 0 6px; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.more-row { display: flex; justify-content: center; }
.mix-box { border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 4px 14px 2px; margin-bottom: 14px; }
.mix-box .check-field { margin: 8px 0; }
.levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 14px; }
.levels .check-field { margin: 5px 0; }
.level-badge { display: inline-block; background: var(--subtle); border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; font-size: 11.5px; color: var(--text-2); white-space: nowrap; }
.mix-options .field { margin-bottom: 6px; }
.mix-options select, .mix-options + p { width: 100%; }
.ramp-plan { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.ramp-day { border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 13px; background: var(--subtle); text-align: center; min-width: 64px; }
.ramp-day b { display: block; font-family: var(--font-head); font-size: 15px; }
.ramp-day.today { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.ramp-day.done { opacity: .6; }
.ramp-status { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-size: 14px; }
.ramp-status.held { background: var(--warn-soft); color: var(--warn); }
.cloud-note { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary); font-size: 14px; }
.cloud-status { margin: 8px 0 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--subtle); color: var(--muted); font-size: 14px; }
.cloud-status:empty { display: none; }
select.wide-select { width: 100%; }
.cloud-status.ok { background: var(--primary-soft); color: var(--primary); }
.cloud-status.bad { background: var(--bad-soft); color: var(--bad); }
.filters select { width: auto; min-width: 190px; }
.chat-mark { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: 6px; color: var(--primary); font-size: 12px; vertical-align: middle; }
.chat-mark .i { width: 14px; height: 14px; }
.check-field { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; font-size: 14px; cursor: pointer; }
.check-field input { margin-top: 5px; flex-shrink: 0; }
.more-row .btn { margin: 12px 0; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--subtle); border: 1px solid var(--border); border-radius: 6px; padding: 2px 4px 2px 10px; direction: ltr; font-size: 13.5px; }
.chip button { display: inline-grid; place-items: center; border: 0; background: none; cursor: pointer; color: var(--muted); width: 22px; height: 22px; border-radius: 4px; }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }

.contacts-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 16px; align-items: start; }
.groups-panel { position: sticky; top: 16px; padding: 16px; }
.groups-list { list-style: none; margin: 0 0 12px; padding: 0; }
.groups-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.groups-list li:hover { background: var(--subtle); }
.groups-list li.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.groups-list li .gname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groups-list li .gcount { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.groups-list li.special { color: var(--text-2); }
.groups-list li.special.active { color: var(--primary); }
.groups-list .divider { height: 1px; background: var(--border); margin: 6px 0; padding: 0; cursor: default; }
.groups-list .empty-groups { color: var(--muted); font-size: 13px; cursor: default; }
.groups-list .empty-groups:hover { background: none; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.view-head h2 { margin: 0; font-size: 17px; }
.group-tag { display: inline-block; background: var(--subtle); border: 1px solid var(--border); color: var(--text-2); border-radius: 5px; padding: 0 8px; font-size: 12px; margin: 1px 0 1px 4px; white-space: nowrap; }
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--primary-soft); border: 1px solid var(--primary-line); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 10px;
}
.bulk-bar b { color: var(--primary); font-weight: 600; }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bulk-actions select { min-width: 160px; height: 32px; }
#group-hint { background: var(--subtle); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; margin-top: -4px; }

/* ---------- Toast & dialog ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 100px); opacity: 0;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm); font-size: 14px;
  transition: .25s; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--bad); }
dialog {
  border: 0; border-radius: 12px; padding: 24px; width: min(420px, calc(100% - 32px));
  box-shadow: 0 24px 64px rgba(0, 0, 0, .24); color: var(--text);
}
dialog::backdrop { background: rgba(18, 36, 27, .45); }
dialog h3 { margin-bottom: 14px; }

/* ---------- Stats ---------- */
.stats-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.stats-head .field { margin: 0; min-width: 300px; }
.stats-head select { width: 100%; }
.stats-head p { margin: 0 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-family: var(--font-head); font-size: 26px; font-weight: 600; line-height: 1.4; }
.kpi .sub { font-size: 12.5px; color: var(--muted); min-height: 20px; }
.funnel { display: grid; gap: 12px; margin: 14px 0; }
.funnel-row { display: grid; grid-template-columns: 72px 1fr; align-items: center; gap: 12px; }
.funnel-row .name { font-size: 13.5px; color: var(--text-2); }
.funnel-track { display: flex; align-items: center; gap: 10px; min-width: 0; }
.funnel-bar { height: 22px; background: var(--primary); border-radius: 4px 0 0 4px; min-width: 2px; }
.funnel-val { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.funnel-val b { font-weight: 600; }
.pct { color: var(--muted); font-size: 12px; margin-inline-start: 4px; }
.chart { position: relative; width: 100%; direction: ltr; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .bar { fill: var(--primary); }
.chart .hit { fill: transparent; }
.chart .bar.hover { fill: var(--brand); }
.chart-tip {
  position: fixed; z-index: 20; pointer-events: none; background: var(--card); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(18, 36, 27, .14); white-space: nowrap;
}
.chart-tip b { font-size: 15px; font-family: var(--font-head); }

/* ---------- Account health ---------- */
.health-hero { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; position: relative; overflow: hidden; }
.health-hero::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--primary); }
.health-hero.warn::before { background: #d38a12; }
.health-hero.bad::before { background: var(--bad); }
.health-hero .score { font-family: var(--font-head); font-size: 52px; font-weight: 700; line-height: 1; color: var(--primary); }
.health-hero .score small { font-size: 16px; color: var(--muted); font-weight: 500; }
.health-hero.warn .score { color: var(--warn); }
.health-hero.bad .score { color: var(--bad); }
.health-hero .verdict { flex: 1; min-width: 240px; }
.health-hero .verdict h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-size: 20px; color: var(--primary); }
.health-hero.warn .verdict h2 { color: var(--warn); }
.health-hero.bad .verdict h2 { color: var(--bad); }
.health-hero .verdict h2 .i { width: 22px; height: 22px; }
.health-hero .verdict ul { margin: 8px 0 0; padding-inline-start: 20px; color: var(--text-2); }
.health-hero .verdict li { margin-bottom: 4px; }
.indicators { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.indicator { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.indicator .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.indicator .title { font-family: var(--font-head); font-weight: 600; font-size: 14px; }
.indicator .value { font-family: var(--font-head); font-size: 20px; font-weight: 600; margin: 8px 0 2px; }
.indicator .detail { font-size: 13px; color: var(--muted); }
.indicator .advice { font-size: 13px; color: var(--text-2); margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.indicator .detail + .advice { margin-top: 12px; }
.state-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 1px 8px; white-space: nowrap; border: 1px solid transparent; }
.state-badge .i { width: 14px; height: 14px; vertical-align: -2px; }
.state-badge.ok { background: var(--primary-soft); color: var(--primary); border-color: var(--primary-line); }
.state-badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f1d7a8; }
.state-badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #eab4b0; }
.state-badge.info { background: var(--subtle); color: var(--muted); border-color: var(--border); }

/* ---------- Small screens: sidebar becomes a top bar ---------- */
@media (max-width: 1000px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contacts-layout { grid-template-columns: minmax(0, 1fr); }
  .groups-panel { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 12px 12px 0; }
  .brand { padding: 0 4px 12px; margin-bottom: 8px; }
  .brand img { width: 36px; height: 36px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 10px; scrollbar-width: none; }
  .nav button { width: auto; white-space: nowrap; padding: 8px 12px; }
  .nav button.active::before { display: none; }
  .nav-label { display: none; }
  .sidebar-foot { position: absolute; top: 14px; inset-inline-end: 12px; margin: 0; padding: 0; border: 0; }
  .sidebar { position: relative; }
  .conn .conn-number { display: none; }
  .page-head { padding: 18px 16px 12px; }
  main { padding: 0 16px 48px; }
  .two-col, .new-grid { grid-template-columns: minmax(0, 1fr); }
  .connect { flex-direction: column; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-inline-start: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .inline-form { flex-wrap: wrap; }
  .filters { max-width: none; }
}
.sender-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; }
.pick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- Send preview: the message as WhatsApp shows it ---------- */
#dlg-send { width: min(440px, calc(100% - 32px)); }
.wa-chat {
  background: #efeae2; border-radius: 10px; padding: 14px 12px; margin: 12px 0;
  max-height: 60vh; overflow: auto;
}
.wa-msg {
  background: #fff; border-radius: 8px; border-top-right-radius: 2px; padding: 4px 4px 6px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .1); font-size: 14px; line-height: 1.6; color: #111b21;
}
.wa-msg img { display: block; width: 100%; border-radius: 6px; }
.wa-noimg { background: var(--bad-soft); color: var(--bad); padding: 10px; border-radius: 6px; }
.wa-body { white-space: pre-wrap; word-break: break-word; padding: 6px 6px 0; }
.wa-footer { color: #667781; font-size: 12.5px; padding: 4px 6px 0; }
.wa-time { color: #667781; font-size: 11px; text-align: left; padding: 0 6px; }
.wa-btn {
  background: #fff; border-radius: 8px; margin-top: 3px; padding: 9px; text-align: center;
  color: #027eb5; font-size: 14px; box-shadow: 0 1px 1px rgba(0, 0, 0, .1);
}
#send-warning { margin: 0 0 8px; }
#send-warning { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
