/* ============================================================
   نيبوكود للمراسلة — ورقة الأنماط الرئيسية
   نظام تصميم فاتح: خلفية رمادية مزرقة خفيفة، أسطح بيضاء،
   كحلي للنصوص، أزرق كوبالت للأفعال، أخضر واتساب للحالات الإيجابية.
   ============================================================ */

:root {
  --page: #EEF1F6;
  --surface: #FFFFFF;
  --surface-2: #F6F8FB;
  --surface-3: #EDF0F5;
  --line: #E3E8F0;
  --line-2: #D3DAE5;
  --ink: #12223D;
  --ink-2: #41506A;
  --ink-3: #7A869C;
  --cobalt: #2443C9;
  --cobalt-2: #1B35A6;
  --cobalt-soft: #E8ECFB;
  --saffron: #F2B33D;
  --saffron-soft: #FDF3DC;
  --green: #1E9E6A;
  --green-soft: #E3F5EC;
  --red: #D64545;
  --red-soft: #FBE7E7;
  --wa-bg: #E5DDD5;
  --wa-out: #DCF8C6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(18, 34, 61, .05), 0 4px 16px rgba(18, 34, 61, .06);
  --shadow-lg: 0 8px 32px rgba(18, 34, 61, .14);
  --sidebar-w: 248px;
  --font: "Alexandria", "Segoe UI", Tahoma, sans-serif;
  --font-display: "Reem Kufi", "Alexandria", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.3; letter-spacing: 0; }
h1 { font-size: 1.55rem; }
h1:focus, h1:focus-visible { outline: none; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .5rem; }
a { color: var(--cobalt); text-decoration: none; }
a:hover { text-decoration: underline; }
img, video { max-width: 100%; }
code, .mono { font-family: var(--mono); font-size: .9em; }
code { background: var(--surface-3); padding: .05em .35em; border-radius: 4px; direction: ltr; unicode-bidi: embed; }
mark { background: var(--saffron-soft); color: #8A5A00; border-radius: 3px; padding: 0 .15em; }
small { font-size: .82em; }
.small { font-size: .85rem; }
.muted { color: var(--ink-3); }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.row.gap, .gap { gap: .5rem; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.center { align-self: center; }
.pad { padding: 1rem 1.25rem; }
.text-bad { color: var(--red); }
.rot180 { transform: rotate(180deg); }
.icon { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
::selection { background: var(--cobalt-soft); }

/* ---------- حقول الإدخال ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--ink-3); cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: #A5AEBF; }
textarea { resize: vertical; min-height: 2.6rem; }
select { appearance: none; -webkit-appearance: none; padding-inline-end: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237A869C' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left .7rem center; }
input[type="checkbox"] { width: 1.05rem; height: 1.05rem; accent-color: var(--cobalt); cursor: pointer; }
input[type="range"] { width: 100%; accent-color: var(--cobalt); }
input[type="color"] { width: 2.2rem; height: 2.2rem; padding: 0; border: 1px solid var(--line-2); border-radius: 6px; background: none; cursor: pointer; }
.select-sm, .input-sm { padding: .35rem .6rem !important; font-size: .88rem; width: auto !important; }
.select-sm { padding-inline-end: 1.8rem !important; }
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .9rem; }
.field > span, .field > label { font-size: .86rem; font-weight: 500; color: var(--ink-2); }
.field small { color: var(--ink-3); }
.field.inline { flex-direction: row; align-items: center; gap: .6rem; margin: 0; }
.field.inline > span { white-space: nowrap; }
.field-foot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.check, .check-row { display: flex; align-items: flex-start; gap: .55rem; cursor: pointer; margin: .4rem 0 .8rem; font-size: .92rem; }
.check input, .check-row input { margin-top: .2rem; }
.check.small { font-size: .84rem; margin: .3rem 0; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .5rem; }
.form-error, .form-alert.bad { background: var(--red-soft); color: #9A2B2B; border: 1px solid #F3C5C5; border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .9rem; margin: .5rem 0; }
.form-alert.ok { background: var(--green-soft); color: #176B48; border: 1px solid #BDE6D1; border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .9rem; margin: .5rem 0; display: flex; gap: .4rem; align-items: center; }
.form-alert.bad { display: flex; gap: .4rem; align-items: center; }
.validation-message { color: var(--red); font-size: .82rem; }
.hint { font-size: .82rem; color: var(--ink-3); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .55rem 1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: var(--surface-3); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s; text-decoration: none !important; line-height: 1.3;
}
.btn:hover { background: #E2E7EF; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--cobalt); color: #fff; }
.btn-primary:hover { background: var(--cobalt-2); }
.btn-primary.danger { background: var(--red); }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--red); }
.btn-ghost.danger:hover { background: var(--red-soft); }
.btn-sm { padding: .35rem .7rem; font-size: .86rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.active { background: var(--cobalt-soft); color: var(--cobalt); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.icon-btn.disabled, .icon-btn:disabled { opacity: .4; pointer-events: none; }
.icon-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.link { font-size: .88rem; }
.link-btn { background: none; border: 0; color: var(--cobalt); cursor: pointer; font-size: .85rem; padding: 0; }
.back-link { display: inline-flex; align-items: center; gap: .25rem; font-size: .85rem; color: var(--ink-3); margin-bottom: .25rem; }
.back-link:hover { color: var(--cobalt); text-decoration: none; }

/* ---------- الهيكل العام ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .65rem; padding: 1.1rem 1.1rem .9rem; color: var(--ink); text-decoration: none !important; }
.brand img { border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-family: var(--font-display); font-size: 1.15rem; letter-spacing: .01em; direction: ltr; text-align: start; }
.brand-text small { color: var(--ink-3); font-size: .74rem; }
.brand-lg img { border-radius: 12px; }
.brand-lg .brand-text b { font-size: 1.45rem; }
.tenant-chip {
  margin: 0 .9rem .6rem; padding: .45rem .7rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
  font-size: .84rem; font-weight: 500; display: flex; align-items: center; gap: .45rem; color: var(--ink-2); overflow: hidden;
}
.tenant-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; padding: .25rem .6rem; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: .65rem; padding: .55rem .7rem; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; font-size: .93rem; text-decoration: none !important; position: relative;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--cobalt-soft); color: var(--cobalt); }
.nav a.active::before { content: ""; position: absolute; inset-inline-start: -0.6rem; top: 20%; height: 60%; width: 3px; border-radius: 3px; background: var(--cobalt); }
.nav-badge { margin-inline-start: auto; background: var(--green); color: #fff; font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 0 .45rem; min-width: 1.35rem; text-align: center; line-height: 1.35rem; font-style: normal; }
.nav-sep { font-size: .72rem; color: var(--ink-3); font-weight: 600; letter-spacing: .04em; padding: .9rem .7rem .3rem; }
.sidebar-foot { border-top: 1px solid var(--line); padding: .7rem .9rem; display: flex; align-items: center; gap: .4rem; }
.user-row { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; color: var(--ink); text-decoration: none !important; padding: .3rem; border-radius: var(--radius-sm); }
.user-row:hover { background: var(--surface-2); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.user-meta b { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { color: var(--ink-3); font-size: .74rem; }
.logout-form { margin: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; display: flex; align-items: center; gap: .5rem; padding: 0 1.5rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-spacer { flex: 1; }
.menu-toggle { display: none; }
.content { padding: 1.5rem; max-width: 1400px; width: 100%; margin: 0 auto; flex: 1; }
.nav-scrim { display: none; }
.alerts-wrap { position: relative; }
.dot-badge { position: absolute; top: 4px; inset-inline-start: 4px; background: var(--red); color: #fff; font-size: .66rem; font-weight: 600; font-style: normal; border-radius: 999px; min-width: 1.1rem; height: 1.1rem; line-height: 1.1rem; text-align: center; padding: 0 .25rem; }
.alerts-panel { position: absolute; top: calc(100% + .5rem); inset-inline-start: 0; width: 360px; max-width: 90vw; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 50; max-height: 70vh; overflow-y: auto; }
.alerts-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.alerts-empty { padding: 1.5rem; text-align: center; color: var(--ink-3); font-size: .9rem; }
.alert-row { padding: .7rem 1rem; border-bottom: 1px solid var(--line); border-inline-start: 3px solid var(--line-2); font-size: .88rem; }
.alert-row.sev-warn { border-inline-start-color: var(--saffron); }
.alert-row.sev-bad { border-inline-start-color: var(--red); }
.alert-row.sev-info { border-inline-start-color: var(--cobalt); }
.alert-row p { color: var(--ink-2); margin: .15rem 0; }
.alert-row small { color: var(--ink-3); }

/* ---------- الرؤوس والبطاقات ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.page-head p { margin: .2rem 0 0; font-size: .92rem; }
.head-actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.card-head h2 { display: flex; align-items: center; gap: .5rem; }
.table-card { padding: 0; overflow: hidden; }
.table-card .card-head { padding: 1rem 1.25rem 0; }
.table-card .pad { padding: 1.25rem; }
.sec-title { margin: 1.25rem 0 .6rem; font-size: .95rem; }
.sec-title:first-child { margin-top: 0; }
.page-loading, .page-center { display: flex; align-items: center; justify-content: center; min-height: 50vh; color: var(--ink-3); }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 1.25rem; }
.grid-main .card { margin: 0; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
.grid-2 .card { margin: 0; }
.callout { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; border-radius: var(--radius); background: var(--cobalt-soft); border: 1px solid #CDD5F5; color: var(--ink); margin-bottom: 1.25rem; }
.callout > .icon { color: var(--cobalt); }
.callout > div { flex: 1; }
.callout b { display: block; margin-bottom: .15rem; }
.callout p { margin: 0; color: var(--ink-2); font-size: .92rem; }
.callout.warn { background: var(--saffron-soft); border-color: #F3DFAE; }
.callout.warn > .icon { color: #B57A00; }
.callout.soft { background: var(--surface-2); border-color: var(--line); }
.callout.soft > .icon { color: var(--ink-3); }
.callout.small { padding: .6rem .9rem; font-size: .88rem; margin: .5rem 0 1rem; }
.callout ul { margin: .3rem 0 0; padding-inline-start: 1.1rem; font-size: .9rem; }

/* ---------- المؤشرات ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: .15rem; color: var(--ink); text-decoration: none !important; box-shadow: var(--shadow); min-width: 0; }
a.stat:hover { border-color: var(--line-2); }
.stat-label { font-size: .8rem; color: var(--ink-3); font-weight: 500; }
.stat b { font-size: 1.65rem; font-family: var(--font-display); font-weight: 600; line-height: 1.2; }
.stat small { color: var(--ink-3); }
.mini-stats { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0 1rem; }
.mini-stats > div { flex: 1; min-width: 90px; background: var(--surface-2); border-radius: var(--radius-sm); padding: .7rem .8rem; display: flex; flex-direction: column; }
.mini-stats b { font-size: 1.2rem; font-family: var(--font-display); }
.mini-stats span { font-size: .78rem; color: var(--ink-3); }
.pill { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); line-height: 1.5; }
.pill-ok { background: var(--green-soft); color: #176B48; }
.pill-warn { background: var(--saffron-soft); color: #8A5A00; }
.pill-bad { background: var(--red-soft); color: #9A2B2B; }
.pill-info { background: var(--cobalt-soft); color: var(--cobalt-2); }
.pill-muted { background: var(--surface-3); color: var(--ink-3); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; display: inline-block; }
.status-dot.ok { background: var(--green); }
.status-dot.warn { background: var(--saffron); }
.status-dot.bad { background: var(--red); }
.status-dot.info { background: var(--cobalt); }
.status-dot.big { width: 14px; height: 14px; }
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; display: flex; margin: .3rem 0; }
.progress-bar { height: 100%; background: var(--green); transition: width .4s; }
.progress-bar.bad { background: var(--red); }
.progress.big { height: 14px; margin: .5rem 0 1rem; }
.legend { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--ink-3); }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-start: .5rem; }
.sw-in { background: var(--cobalt); }
.sw-out { background: var(--green); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 190px; padding-top: .5rem; }
.bars.tall { height: 240px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-stack { flex: 1; width: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; border-bottom: 1px solid var(--line); }
.bar { width: 100%; border-radius: 4px 4px 2px 2px; min-height: 2px; transition: height .4s; }
.bar-in { background: var(--cobalt); opacity: .9; }
.bar-out { background: var(--green); opacity: .85; }
.bar-label { font-size: .7rem; color: var(--ink-3); margin-top: .35rem; white-space: nowrap; height: 1rem; }
.bar-col::after { content: ""; display: block; height: 1rem; margin-top: .35rem; }
.bar-col:has(.bar-label)::after { display: none; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: .8rem; padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row b { display: block; font-size: .92rem; }
.list-row small { color: var(--ink-3); display: block; }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: flex; align-items: center; gap: .8rem; padding: .4rem 0; font-size: .9rem; }
.rank li > span { width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-bar { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.rank-bar i { display: block; height: 100%; background: var(--cobalt); border-radius: 999px; }
.rank em { font-style: normal; font-weight: 600; min-width: 2.5rem; text-align: end; }
.heat { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; margin: .5rem 0; }
.heat-cell { aspect-ratio: 1; border-radius: 6px; background: rgba(36, 67, 201, calc(.08 + var(--a, 0) * .85)); display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--ink-2); }
.heat-cell[style*="--a:1"] span, .heat-cell[style*="--a:0.9"] span, .heat-cell[style*="--a:0.8"] span { color: #fff; }
.reasons { margin-top: 1rem; font-size: .9rem; }
.reasons ul { list-style: none; margin: .4rem 0 0; padding: 0; }
.reasons li { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.reasons em { font-style: normal; font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; font-size: .9rem; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.kv.review { font-size: 1rem; gap: .6rem 1.2rem; margin-bottom: 1rem; }

/* ---------- الجداول ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: start; font-weight: 600; font-size: .78rem; color: var(--ink-3); padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: .7rem 1.25rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FAFBFD; }
.table.compact th, .table.compact td { padding: .45rem .75rem; }
.table.hours td { padding: .4rem .5rem; border-bottom: 0; }
.table.hours input[type="time"] { width: 120px; }
.row-muted td { opacity: .55; }
.row-bad td { background: #FFF7F7; }
.w-check { width: 2.5rem; }
.w-progress { min-width: 160px; }
.cell-person { display: flex; align-items: center; gap: .6rem; }
.cell-person small { display: block; }
.row-actions { white-space: nowrap; text-align: end; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.25rem; border-top: 1px solid var(--line); font-size: .88rem; }
.toolbar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .search { max-width: 340px; }
.bulk { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; background: var(--cobalt-soft); border-radius: var(--radius-sm); padding: .35rem .6rem; font-size: .86rem; }
.search { position: relative; display: flex; align-items: center; flex: 1; min-width: 180px; }
.search .icon { position: absolute; inset-inline-start: .7rem; color: var(--ink-3); pointer-events: none; }
.search input { padding-inline-start: 2.2rem !important; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: .25rem .75rem; font-size: .84rem; cursor: pointer; display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-2); }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip em { font-style: normal; font-size: .74rem; background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .4rem; }
.chip.on em { background: rgba(255,255,255,.2); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .7rem .9rem; cursor: pointer; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: .4rem; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--cobalt); border-bottom-color: var(--cobalt); }
.tabs em { font-style: normal; font-size: .74rem; background: var(--surface-3); border-radius: 999px; padding: 0 .4rem; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: .75rem; }
.seg button { border: 0; background: var(--surface); padding: .45rem .9rem; cursor: pointer; color: var(--ink-2); font-size: .88rem; border-inline-end: 1px solid var(--line); }
.seg button:last-child { border-inline-end: 0; }
.seg button:hover { background: var(--surface-2); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on.ok { background: var(--green); }
.seg button.on.bad { background: var(--red); }
.seg-cat { width: 100%; }
.seg-cat button { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; padding: .6rem .9rem; text-align: start; }
.seg-cat button small { font-size: .74rem; opacity: .8; }
.tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.tags.big { gap: .45rem; margin: .5rem 0 1rem; }
.tags.small .tag { font-size: .72rem; padding: 0 .45rem; }
.tag { --lc: var(--cobalt); display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--line-2); border-radius: 999px; padding: .05rem .55rem; font-size: .78rem; background: var(--surface); color: var(--ink-2); cursor: default; }
button.tag { cursor: pointer; }
button.tag:hover { border-color: var(--lc); }
.tag.on { background: color-mix(in srgb, var(--lc) 12%, white); border-color: color-mix(in srgb, var(--lc) 40%, white); color: color-mix(in srgb, var(--lc) 80%, black); }
.tag-x { border: 0; background: none; cursor: pointer; padding: 0 .1rem; color: inherit; opacity: .6; }
.tag-x:hover { opacity: 1; }
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .86rem; color: var(--ink-2); }
.switch input { appearance: none; width: 2.4rem; height: 1.35rem; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(-1.05rem); }

/* ---------- الحالة الفارغة ---------- */
.empty { text-align: center; padding: 2.5rem 1.5rem; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.empty-icon { width: 60px; height: 60px; border-radius: 18px; background: var(--cobalt-soft); color: var(--cobalt); display: flex; align-items: center; justify-content: center; margin-bottom: .5rem; }
.empty h3 { font-size: 1.1rem; }
.empty p { max-width: 420px; color: var(--ink-3); font-size: .92rem; }
.empty .btn { margin-top: .5rem; }
.how { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; text-align: start; width: 100%; }
.how > div { display: flex; gap: .6rem; align-items: flex-start; }
.how span { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 600; font-size: .8rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.how b { display: block; font-size: .88rem; }
.how small { color: var(--ink-3); }

/* ---------- الصورة الرمزية ---------- */
.avatar { --av-bg: var(--cobalt); display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--av-bg); color: #fff; font-weight: 600; flex-shrink: 0; letter-spacing: 0; }

/* ---------- التنبيهات المنبثقة ---------- */
.toast-host { position: fixed; bottom: 1.25rem; inset-inline-start: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; max-width: 380px; }
.toast { display: flex; align-items: center; gap: .6rem; background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; cursor: pointer; animation: toast-in .25s ease-out; }
.toast-ok { background: #176B48; }
.toast-bad { background: #9A2B2B; }
.toast-warn { background: #8A5A00; }
.toast-info { background: var(--ink); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- النوافذ ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(18, 34, 61, .45); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 1rem; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease-out; }
.modal-wide { max-width: 900px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--line); }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: .6rem; margin-top: 1rem; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
.cred-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem 1rem; margin: .75rem 0; }
.cred-box > div { display: flex; gap: 1rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.cred-box > div:last-child { border-bottom: 0; }
.cred-box span { color: var(--ink-3); min-width: 110px; }
.cred-box code { background: var(--surface); border: 1px solid var(--line); padding: .25rem .6rem; border-radius: 6px; word-break: break-all; user-select: all; }
.code-sample, .code { background: #1A2540; color: #E6ECF5; border-radius: var(--radius-sm); padding: .9rem 1rem; font-family: var(--mono); font-size: .8rem; line-height: 1.6; overflow-x: auto; direction: ltr; text-align: left; margin: .5rem 0 1rem; white-space: pre; }
.file-drop { display: flex; flex-direction: column; align-items: center; gap: .35rem; border: 2px dashed var(--line-2); border-radius: var(--radius); padding: 1.25rem; cursor: pointer; position: relative; color: var(--ink-2); margin: .5rem 0; }
.file-drop:hover { border-color: var(--cobalt); background: var(--surface-2); }
.file-drop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-result { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .75rem; font-size: .9rem; }
.import-result details { width: 100%; }
.import-result ul { font-size: .82rem; color: var(--red); margin: .3rem 0 0; }

/* ---------- صفحات الدخول ---------- */
.auth-shell { display: flex; min-height: 100vh; }
.auth-side { width: 44%; background: linear-gradient(160deg, #15275A 0%, #2443C9 65%, #3A63E8 100%); color: #fff; padding: 2rem 2.5rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.14), transparent 70%); bottom: -200px; inset-inline-start: -150px; }
.auth-side .brand { color: #fff; padding: 0; }
.auth-side .brand-text small { color: rgba(255,255,255,.75); }
.auth-pitch { position: relative; z-index: 1; max-width: 460px; }
.auth-pitch h2 { font-size: 2rem; margin-bottom: .75rem; line-height: 1.35; }
.auth-pitch p { color: rgba(255,255,255,.85); font-size: 1rem; margin-bottom: 1.25rem; }
.auth-pitch ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.auth-pitch li { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }
.auth-pitch li .icon { color: #9FE3C4; }
.auth-foot { font-size: .8rem; color: rgba(255,255,255,.65); position: relative; z-index: 1; }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1.5rem; }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: .25rem; }
.auth-card > .muted { margin-bottom: 1.25rem; font-size: .92rem; }
.auth-card .btn-block { margin-top: .5rem; padding: .7rem; }
.auth-card .grid-2 { gap: 0 1rem; margin: 0; }
.auth-switch { margin-top: 1.25rem; text-align: center; font-size: .9rem; color: var(--ink-2); }

/* ---------- صندوق المحادثات ---------- */
.inbox { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 56px - 3rem); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin: -0.25rem 0 0; }
.inbox-list { border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--surface); }
.inbox-list-head { display: flex; gap: .5rem; padding: .85rem .85rem .5rem; flex-wrap: wrap; }
.inbox-list-head .search { min-width: 160px; }
.inbox-list .chips { padding: 0 .85rem .6rem; border-bottom: 1px solid var(--line); }
.inbox-list .chip { padding: .15rem .6rem; font-size: .8rem; }
.conv-list { flex: 1; overflow-y: auto; min-height: 0; }
.conv { display: flex; gap: .7rem; padding: .75rem .85rem; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none !important; transition: background .1s; }
.conv:hover { background: var(--surface-2); }
.conv.active { background: var(--cobalt-soft); }
.conv-body { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.conv-name { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-top time { font-size: .74rem; color: var(--ink-3); white-space: nowrap; }
.conv-bottom { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.conv-preview { font-size: .84rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv.unread .conv-preview { color: var(--ink-2); font-weight: 500; }
.conv.unread .conv-name { font-weight: 700; }
.unread-badge { font-style: normal; background: var(--green); color: #fff; font-size: .72rem; font-weight: 600; border-radius: 999px; min-width: 1.3rem; height: 1.3rem; line-height: 1.3rem; text-align: center; padding: 0 .35rem; flex-shrink: 0; }
.conv-meta { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }
.meta-chip { --lc: var(--cobalt); display: inline-flex; align-items: center; gap: .2rem; font-size: .7rem; color: var(--ink-3); background: var(--surface-3); border-radius: 4px; padding: 0 .4rem; }
.meta-chip.warn { background: var(--saffron-soft); color: #8A5A00; }
.meta-chip.label { background: color-mix(in srgb, var(--lc) 14%, white); color: color-mix(in srgb, var(--lc) 75%, black); }
.inbox-thread { min-width: 0; display: flex; flex-direction: column; min-height: 0; background: var(--surface-2); }
.thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.thread { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread-head { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.thread-head .back-link { display: none; margin: 0; }
.thread-head b { display: block; font-size: .95rem; }
.thread-head small { color: var(--ink-3); display: block; font-size: .78rem; }
.thread-actions { display: flex; align-items: center; gap: .35rem; }
.thread-split { display: flex; flex: 1; min-height: 0; }
.thread-main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Ccircle cx='20' cy='20' r='1.2' fill='%23D7DEE9'/%3E%3Ccircle cx='80' cy='60' r='1.2' fill='%23D7DEE9'/%3E%3Ccircle cx='40' cy='100' r='1.2' fill='%23D7DEE9'/%3E%3C/svg%3E"); }
.messages > :first-child { margin-top: auto; }
.day-sep { align-self: center; margin: .6rem 0 .4rem; }
.day-sep span { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .7rem; font-size: .74rem; color: var(--ink-3); }
.msg { max-width: min(68%, 560px); background: var(--surface); border-radius: 14px; padding: .5rem .75rem .35rem; box-shadow: 0 1px 1px rgba(0,0,0,.05); position: relative; font-size: .93rem; }
.msg.in { align-self: flex-start; border-start-start-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--wa-out); border-start-end-radius: 4px; }
.msg.failed { border: 1px solid #F3C5C5; background: #FFF4F4; }
.msg-text { white-space: pre-wrap; word-wrap: break-word; line-height: 1.55; }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: .35rem; font-size: .7rem; color: var(--ink-3); margin-top: .15rem; }
.msg-meta time { font-variant-numeric: tabular-nums; }
.ticks { display: inline-flex; }
.tick-read { color: #2F8DE4; }
.tick-failed { color: var(--red); }
.msg-error { font-size: .76rem; color: var(--red); margin-top: .25rem; }
.quote { border-inline-start: 3px solid var(--cobalt); background: rgba(0,0,0,.04); border-radius: 6px; padding: .3rem .6rem; font-size: .8rem; color: var(--ink-2); margin-bottom: .35rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.msg-img { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; margin-bottom: .25rem; }
.msg-video { max-width: 100%; max-height: 320px; border-radius: 10px; display: block; }
.msg-sticker { width: 140px; height: 140px; object-fit: contain; }
.media-missing { display: flex; align-items: center; gap: .4rem; color: var(--ink-3); font-size: .85rem; padding: .3rem 0; }
.doc { display: flex; align-items: center; gap: .6rem; background: rgba(0,0,0,.04); border-radius: 8px; padding: .5rem .7rem; color: var(--ink); text-decoration: none !important; }
.doc span { display: flex; flex-direction: column; font-size: .88rem; }
.doc small { color: var(--ink-3); }
.tpl-tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; color: var(--ink-3); background: rgba(0,0,0,.05); border-radius: 4px; padding: 0 .4rem; margin-bottom: .25rem; }
.reaction { font-size: 1.3rem; }
.note-msg { align-self: center; max-width: 80%; display: flex; gap: .5rem; align-items: flex-start; background: var(--saffron-soft); border: 1px dashed #E9CB7A; border-radius: 10px; padding: .5rem .8rem; font-size: .85rem; color: #6B4A00; margin: .25rem 0; }
.note-msg small { color: #9A7320; display: block; font-size: .72rem; }
.note-text { white-space: pre-wrap; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: .6rem .9rem; position: relative; }
.composer.note-mode { background: var(--saffron-soft); }
.composer-row { display: flex; align-items: flex-end; gap: .5rem; }
.composer-tools { display: flex; gap: .15rem; align-items: center; padding-bottom: .15rem; }
.composer textarea { resize: none; max-height: 160px; min-height: 2.6rem; border-radius: 14px; }
.send-btn { width: 2.7rem; height: 2.7rem; padding: 0; border-radius: 50%; flex-shrink: 0; }
.window-banner { display: flex; align-items: center; gap: .6rem; background: var(--saffron-soft); border: 1px solid #F3DFAE; color: #6B4A00; border-radius: var(--radius-sm); padding: .5rem .8rem; font-size: .86rem; margin-bottom: .6rem; }
.window-banner span { flex: 1; }
.window-banner.soft { background: var(--surface-2); border-color: var(--line); color: var(--ink-3); padding: .3rem .7rem; font-size: .78rem; }
.quick-pop { position: absolute; bottom: calc(100% - .25rem); inset-inline-start: 4rem; inset-inline-end: 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 10; }
.quick-pop button { display: flex; gap: .6rem; width: 100%; border: 0; background: none; padding: .55rem .9rem; text-align: start; cursor: pointer; font-size: .88rem; border-bottom: 1px solid var(--line); }
.quick-pop button:last-child { border-bottom: 0; }
.quick-pop button:hover { background: var(--surface-2); }
.quick-pop button b { color: var(--cobalt); font-family: var(--mono); font-size: .8rem; white-space: nowrap; }
.quick-pop button span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-panel { width: 300px; border-inline-start: 1px solid var(--line); background: var(--surface); overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.panel-sec > label:first-child, .panel-sec label:not(.check) { display: block; font-size: .78rem; color: var(--ink-3); font-weight: 600; margin-bottom: .35rem; }
.panel-sec .seg { width: 100%; margin: 0; }
.panel-sec .seg button { flex: 1; font-size: .8rem; padding: .35rem .3rem; }
.panel-sec input, .panel-sec textarea { font-size: .88rem; }
.panel-sec .tags { margin-bottom: .4rem; }

/* ---------- معاينة واتساب ---------- */
.wa-preview { background: var(--wa-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Ccircle cx='20' cy='20' r='1' fill='%23cbc2b8'/%3E%3Ccircle cx='60' cy='50' r='1' fill='%23cbc2b8'/%3E%3C/svg%3E"); border-radius: 14px; padding: 1.25rem 1rem; }
.wa-screen { max-width: 340px; margin: 0 auto; }
.wa-bubble { background: #fff; border-radius: 10px; border-start-start-radius: 2px; padding: .5rem .7rem .3rem; box-shadow: 0 1px 1px rgba(0,0,0,.1); font-size: .9rem; color: #111; }
.wa-media { display: flex; flex-direction: column; align-items: center; gap: .25rem; background: #EEE; border-radius: 8px; height: 120px; justify-content: center; color: #777; font-size: .8rem; margin-bottom: .4rem; }
.wa-header { font-weight: 700; margin-bottom: .25rem; }
.wa-body { white-space: pre-wrap; line-height: 1.5; }
.wa-body .ph { color: #9AA3B2; }
.wa-footer { color: #888; font-size: .78rem; margin-top: .3rem; }
.wa-time { text-align: end; font-size: .7rem; color: #999; display: flex; justify-content: flex-end; align-items: center; gap: .2rem; margin-top: .15rem; }
.wa-time .icon { color: #53BDEB; }
.wa-buttons { display: flex; flex-direction: column; gap: 3px; margin-top: 3px; }
.wa-btn { background: #fff; border-radius: 8px; text-align: center; padding: .45rem; color: #00A5F4; font-size: .88rem; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: .3rem; }
.wa-list { background: #fff; border-radius: 8px; margin-top: 6px; overflow: hidden; }
.wa-list-row { padding: .45rem .7rem; border-bottom: 1px solid #EEE; display: flex; flex-direction: column; font-size: .86rem; }
.wa-list-row:last-child { border-bottom: 0; }
.wa-list-row small { color: #777; }

/* ---------- القوالب ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1rem; }
.tpl-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, transform .1s; text-align: start; display: flex; flex-direction: column; gap: .5rem; font: inherit; color: inherit; }
.tpl-card:hover { border-color: var(--cobalt); transform: translateY(-1px); }
.tpl-card.rejected { border-color: #F3C5C5; }
.tpl-card.on { border-color: var(--cobalt); box-shadow: 0 0 0 3px var(--cobalt-soft); }
.tpl-card.small { padding: .75rem .9rem; gap: .3rem; }
.tpl-card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.tpl-card-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.tpl-card-body { font-size: .88rem; color: var(--ink-2); white-space: pre-wrap; line-height: 1.5; max-height: 6.5em; overflow: hidden; }
.tpl-card-meta { display: flex; gap: .6rem; flex-wrap: wrap; font-size: .76rem; color: var(--ink-3); }
.tpl-reject { font-size: .8rem; color: var(--red); }
.tpl-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tpl-send { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 1.5rem; }
.hint-row { margin-bottom: .75rem; }
.builder { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1.25rem; align-items: start; }
.builder-form { margin: 0; }
.builder-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.sticky { position: sticky; top: calc(56px + 1.5rem); }
.tips { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; margin-top: 1rem; font-size: .86rem; }
.tips ul { margin: .4rem 0 0; padding-inline-start: 1.1rem; color: var(--ink-2); }
.examples { background: var(--surface-2); border-radius: var(--radius-sm); padding: .75rem .9rem; display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.examples .field.inline span { min-width: 3rem; }
.btn-row { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.btn-row select { width: 130px; flex-shrink: 0; }

/* ---------- الحملات ---------- */
.wizard-steps { display: flex; list-style: none; margin: 0 0 1.25rem; padding: 0; gap: .25rem; counter-reset: step; overflow-x: auto; }
.wizard-steps li { flex: 1; display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; background: var(--surface); border: 1px solid var(--line); font-size: .86rem; color: var(--ink-3); white-space: nowrap; cursor: default; }
.wizard-steps li:first-child { border-start-start-radius: var(--radius); border-end-start-radius: var(--radius); }
.wizard-steps li:last-child { border-start-end-radius: var(--radius); border-end-end-radius: var(--radius); }
.wizard-steps li span { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; font-size: .76rem; font-weight: 600; flex-shrink: 0; }
.wizard-steps li.on { color: var(--ink); font-weight: 600; border-color: var(--cobalt); }
.wizard-steps li.on span { background: var(--cobalt); color: #fff; }
.wizard-steps li.done { color: var(--ink-2); cursor: pointer; }
.wizard-steps li.done span { background: var(--green); color: #fff; }
.wizard { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; }
.wizard-body { margin: 0; min-height: 420px; display: flex; flex-direction: column; }
.wizard-body h2 { margin-bottom: 1rem; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: auto; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.radio-cards { display: flex; flex-direction: column; gap: .5rem; }
.radio-card { display: flex; align-items: center; gap: .8rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: .7rem .9rem; background: var(--surface); cursor: pointer; text-align: start; font: inherit; color: inherit; }
.radio-card:hover { border-color: var(--cobalt); }
.radio-card.on { border-color: var(--cobalt); background: var(--cobalt-soft); }
.radio-card.disabled { opacity: .55; }
.radio-card b { display: block; }
.radio-card small { display: block; color: var(--ink-3); }
.var-row { display: grid; grid-template-columns: 3.5rem 180px 1fr; gap: .6rem; align-items: center; margin-bottom: .6rem; }
.var-label { font-weight: 600; color: var(--cobalt); }
.audience-box { display: flex; align-items: center; gap: .8rem; background: var(--green-soft); border: 1px solid #BDE6D1; border-radius: var(--radius-sm); padding: .8rem 1rem; margin: .5rem 0 1rem; flex-wrap: wrap; }
.audience-box .icon { color: var(--green); }
.audience-box b { font-size: 1.3rem; }
.test-send .row { gap: .5rem; }

/* ---------- الأرقام ---------- */
.waba-card .card-head h2 { font-size: 1.05rem; }
.phones { display: flex; flex-direction: column; gap: .6rem; }
.phone-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 1rem; align-items: center; padding: .9rem 1rem; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.phone-main b { font-size: 1.05rem; display: block; }
.phone-edit { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.phone-edit input:not([type="checkbox"]) { width: 150px; }
.phone-edit .check { margin: 0; }
.phone-actions { display: flex; gap: .2rem; }
.info-card h3 { margin-bottom: 1rem; }
.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.info-grid > div { display: flex; gap: .6rem; align-items: flex-start; }
.info-grid .icon { color: var(--cobalt); margin-top: .15rem; }
.info-grid b { display: block; font-size: .9rem; }
.info-grid small { color: var(--ink-3); }

/* ---------- الأتمتة ---------- */
.rule-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.rule-item { display: flex; align-items: center; gap: .8rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.rule-item.off { opacity: .6; }
.rule-order { display: flex; flex-direction: column; }
.rule-order .icon-btn { width: 1.6rem; height: 1.3rem; }
.rule-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--cobalt-soft); color: var(--cobalt); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rule-item b { display: block; font-size: .95rem; }
.rule-item .tags { margin: .2rem 0; }
.rule-meta { display: flex; align-items: center; gap: .5rem; }
.rule-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; }
.rule-editor-preview .wa-preview { position: sticky; top: 0; }
.options-editor { background: var(--surface-2); border-radius: var(--radius-sm); padding: .9rem; margin-bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.option-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem; display: flex; flex-direction: column; gap: .4rem; }
.option-card input, .option-card textarea { font-size: .88rem; }

/* ---------- الفريق والإعدادات ---------- */
.roles-help { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.roles-help > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .86rem; }
.roles-help b { display: block; }
.roles-help small { color: var(--ink-3); }
.labels-grid { display: flex; flex-direction: column; gap: .5rem; max-width: 520px; }
.label-row { display: flex; gap: .5rem; align-items: center; }
.label-row.new { margin-top: .5rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.plan-box { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.plan-box h2 { font-size: 1.5rem; }
.plan-status { display: flex; flex-direction: column; align-items: flex-end; gap: .3rem; }
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.plan-card { margin: 0; display: flex; flex-direction: column; }
.plan-card.off { opacity: .6; }
.price { font-family: var(--font-display); margin: .25rem 0 .5rem; }
.price b { font-size: 2rem; }
.price span { color: var(--ink-3); font-size: .85rem; }
.plan-features { list-style: none; margin: .5rem 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .4rem; font-size: .9rem; }
.plan-features li { display: flex; align-items: center; gap: .5rem; }
.plan-features .icon { color: var(--green); }
.docs { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.docs-nav { position: sticky; top: calc(56px + 1.5rem); display: flex; flex-direction: column; gap: .15rem; }
.docs-nav a { padding: .45rem .7rem; border-radius: var(--radius-sm); color: var(--ink-2); font-size: .9rem; }
.docs-nav a:hover { background: var(--surface); text-decoration: none; }
.docs-body .card h2 { margin-bottom: .5rem; }
.docs-body .card p { font-size: .92rem; }

/* ---------- الاستجابة ---------- */
@media (max-width: 1200px) {
  .stats-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: 1fr; }
  .grid-main > .card:first-child { grid-row: auto; }
  .builder, .wizard { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .info-grid, .how { grid-template-columns: repeat(2, 1fr); }
  .contact-panel { width: 260px; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; z-index: 100; transform: translateX(100%); transition: transform .2s; box-shadow: none; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .nav-open .nav-scrim { display: block; position: fixed; inset: 0; background: rgba(18,34,61,.4); z-index: 90; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 1rem; }
  .stats, .stats-6, .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .tpl-send, .rule-editor { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr; }
  .docs-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .auth-side { display: none; }
  .inbox { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 56px - 2rem); }
  .inbox.no-selection .inbox-thread { display: none; }
  .inbox:not(.no-selection) .inbox-list { display: none; }
  .thread-head .back-link { display: inline-flex; }
  .contact-panel { position: absolute; inset: 0; width: auto; z-index: 5; }
  .thread-split { position: relative; }
  .phone-row { grid-template-columns: auto 1fr; }
  .phone-edit, .phone-actions { grid-column: span 2; }
  .roles-help { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .var-row { grid-template-columns: 3rem 1fr; }
  .var-row > :last-child { grid-column: span 2; }
  .msg { max-width: 85%; }
  .page-head { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 600px) {
  .stats, .stats-6, .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .heat { grid-template-columns: repeat(8, 1fr); }
  .table th, .table td { padding: .55rem .75rem; }
  .how, .info-grid { grid-template-columns: 1fr; }
  .modal { border-radius: 12px; }
  .wizard-steps li { padding: .5rem; }
  .wizard-steps li:not(.on) { flex: 0; }
  .wizard-steps li:not(.on) { font-size: 0; gap: 0; }
  .wizard-steps li:not(.on) span { font-size: .76rem; }
}
@media print {
  .sidebar, .topbar, .head-actions, .toast-host { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* شريط الاشتراك أعلى المحتوى */
.sub-banner { margin-bottom: 1rem; padding: .6rem 1rem; font-size: .9rem; }
.sub-banner > div { flex: 1; }
