:root {
  --bg: #f3f6f5;
  --card: #ffffff;
  --ink: #15201c;
  --muted: #68756f;
  --line: #e2e8e5;
  --brand: #0f7a5a;
  --brand-2: #0b5e45;
  --wa: #1fa855;
  --wa-bg: #e5f7ec;
  --wa-line: #9fdcb5;
  --call: #2563eb;
  --call-bg: #e7efff;
  --call-line: #a9c2fb;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 40, 30, .06), 0 4px 14px rgba(16, 40, 30, .05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 "Tajawal", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--brand); text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0 0 2px; font-weight: 800; }
h2 { font-size: 1.15rem; margin: 0; }
h3 { font-size: 1.05rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.clamp1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }
.inline { display: inline; margin: 0; }
[hidden] { display: none !important; }

/* header */
.top { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.top-in { max-width: 1100px; margin: auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 800; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.logo { background: #fff; color: var(--brand); width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; margin-inline-start: auto; align-items: center; }
.top nav a, .top nav .link { color: #e2f4ec; padding: 6px 10px; border-radius: 8px; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; }
.top nav a.on, .top nav a:hover, .top nav .link:hover { background: rgba(255,255,255,.16); color: #fff; }
.who { max-width: 1100px; margin: auto; padding: 0 16px 6px; font-size: .8rem; color: #bfe6d6; }

.wrap { max-width: 1100px; margin: auto; padding: 20px 16px 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
.back { font-size: .9rem; display: inline-block; margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: #c5d0cb; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); }
.btn.big { padding: 13px 18px; font-size: 1.05rem; width: 100%; }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f0f3f2; }
.btn.wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn.wa:hover { filter: brightness(.95); }
.btn.call { background: var(--call); border-color: var(--call); color: #fff; }
.btn.call:hover { filter: brightness(.95); }

/* forms */
.form { max-width: 720px; }
.narrow { max-width: 420px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; padding: 10px 12px; border: 1px solid #cfd8d4; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,122,90,.25); border-color: var(--brand); }
textarea { resize: vertical; }
.hint { font-weight: 400; font-size: .85rem; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #e9f8f0; border-color: #b6e5cb; color: #0d5a3c; }
.flash.err { background: #fdecea; border-color: #f4c1bb; color: #8a2419; }

.pill { display: inline-block; font-size: .8rem; padding: 2px 10px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--wa-bg); color: #137a3c; }
.pill.gray { background: #eef1f0; color: var(--muted); }

/* login */
.login { min-height: 90vh; display: grid; place-items: center; }
.login-card { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 32px 26px; width: 100%; max-width: 380px; text-align: center; border: 1px solid var(--line); }
.login-card form { text-align: start; margin-top: 18px; }
.login-logo { width: 58px; height: 58px; border-radius: 16px; background: var(--brand); color: #fff; font-size: 30px; display: grid; place-items: center; margin: 0 auto 12px; }

/* home */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.group-card { color: var(--ink); display: block; transition: transform .1s, box-shadow .1s; margin: 0; }
.group-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(16,40,30,.1); }
.gc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.gc-foot { display: flex; justify-content: space-between; font-size: .85rem; margin-top: 8px; }
.bar { height: 8px; background: #edf1ef; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--wa); border-radius: 99px; }
.mini-stats { display: flex; gap: 10px; }
.mini-stats div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; text-align: center; min-width: 96px; }
.mini-stats b { display: block; font-size: 1.3rem; }
.mini-stats span { font-size: .8rem; color: var(--muted); }

/* group page */
.msg-preview summary { cursor: pointer; font-weight: 700; }
.msg-preview p { margin: 10px 0 0; background: #f6f8f7; padding: 12px; border-radius: 10px; white-space: normal; }
.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.tabs { display: flex; gap: 4px; background: #e6ecea; padding: 4px; border-radius: 12px; overflow-x: auto; }
.tabs a { padding: 7px 12px; border-radius: 9px; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: .92rem; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.tabs small { background: rgba(0,0,0,.06); border-radius: 99px; padding: 0 7px; margin-inline-start: 4px; font-size: .75rem; }
.search input { min-width: 240px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.contact { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 12px 14px;
  border-inline-start: 5px solid transparent; transition: background .2s, border-color .2s; }
.c-name { font-weight: 700; font-size: 1.05rem; }
.c-phone { color: var(--muted); font-size: .92rem; text-align: right; unicode-bidi: plaintext; }
.c-status { font-size: .82rem; font-weight: 600; }
.c-status:empty { display: none; }
.c-btns { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
/* contacted via WhatsApp = green card, via call = blue card */
.contact.is-sent.kind-wa { background: var(--wa-bg); border-color: var(--wa-line); border-inline-start-color: var(--wa); }
.contact.is-sent.kind-wa .c-status { color: #137a3c; }
.contact.is-sent.kind-call { background: var(--call-bg); border-color: var(--call-line); border-inline-start-color: var(--call); }
.contact.is-sent.kind-call .c-status { color: #1d4ed8; }
.contact.is-sent .btn.wa, .contact.is-sent .btn.call { opacity: .75; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 18px; }

.empty { text-align: center; padding: 50px 16px; background: #fff; border-radius: var(--radius); border: 1px dashed #cfd8d4; }

/* tables */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 700; background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
tr.off td { opacity: .55; }
.ltr-cell { text-align: right; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.stat { margin: 0; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: var(--brand); }
.stat span { font-weight: 700; display: block; }
.stat small { color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 8px; flex-shrink: 0; }
.dot.wa { background: var(--wa); }
.dot.call { background: var(--call); }
.danger-zone { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-zone h3 { width: 100%; }

@media (max-width: 720px) {
  .stats, .two-col, .row2 { grid-template-columns: 1fr; }
  .search, .search input { width: 100%; min-width: 0; }
  .contact { flex-direction: column; align-items: stretch; }
  .c-btns { width: 100%; }
  .c-btns .btn.wa, .c-btns .btn.call { flex: 1; padding: 12px; font-size: 1rem; }
  .top nav { margin-inline-start: 0; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  h1 { font-size: 1.3rem; }
  .clamp1 { max-width: 180px; }
}
