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

: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); }
/* تلميح الموظف الجديد في صفحة الدخول + رابط العودة للصفحة العامة */
.auth-hint { display: flex; gap: .55rem; align-items: flex-start; margin-top: 1.1rem; padding: .7rem .85rem; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); font-size: .86rem; line-height: 1.7; }
.auth-hint .icon { color: var(--green); margin-top: .2rem; }
.auth-hint b { color: var(--ink); }
.auth-back { margin: .9rem 0 0; text-align: center; font-size: .86rem; }
.auth-back a { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-3); }
.auth-back a:hover { color: var(--cobalt); }

/* ---------- صندوق المحادثات ---------- */
.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; position: relative; }
.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: static; }
.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; }


/* =====================================================================
   المحادثة الاحترافية: الوسائط، الصوت، المرفقات، التفاعلات
   ===================================================================== */
.composer-inner { position: relative; }
.msg { transition: box-shadow .2s; }
.msg:focus { outline: none; }
.msg.has-media { padding: .25rem .25rem .3rem; }
.msg.has-media .msg-text, .msg.has-media .msg-meta, .msg.has-media .quote, .msg.has-media .msg-error { margin-inline: .45rem; }
.msg.has-media .msg-text { margin-top: .3rem; }
.msg.sticker { background: transparent !important; box-shadow: none; padding: 0; }
.msg.sticker .msg-meta { background: rgba(255,255,255,.85); border-radius: 999px; padding: 0 .45rem; width: fit-content; margin-inline-start: auto; }
.msg.has-reactions { margin-bottom: 1rem; }
.msg.flash { animation: nb-flash 1.5s ease; }
@keyframes nb-flash { 0%, 45% { box-shadow: 0 0 0 3px rgba(36, 67, 201, .45); } 100% { box-shadow: 0 1px 1px rgba(0,0,0,.05); } }
.msg-text a { color: var(--cobalt); text-decoration: underline; word-break: break-all; }
.msg-text code { font-size: .85em; background: rgba(0,0,0,.06); }

/* أزرار سريعة فوق الرسالة */
.msg-actions {
  position: absolute; top: -14px; inset-inline-end: 8px; display: flex; gap: 1px; padding: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .12s; z-index: 3;
}
.msg:hover .msg-actions, .msg:focus .msg-actions, .msg:focus-within .msg-actions { opacity: 1; pointer-events: auto; }
.msg-actions button, .msg-actions a {
  width: 28px; height: 28px; border-radius: 50%; border: 0; background: none; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none !important;
}
.msg-actions button:hover, .msg-actions a:hover, .msg-actions .on { background: var(--surface-3); color: var(--cobalt); }
.react-pop {
  position: absolute; bottom: calc(100% + 18px); inset-inline-end: 0; display: flex; gap: 2px; padding: .3rem .4rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 4; animation: pop .14s ease-out;
}
.react-pop button { font-size: 1.35rem; width: 2.3rem; height: 2.3rem; border: 0; background: none; border-radius: 50%; cursor: pointer; transition: transform .12s; line-height: 1; }
.react-pop button:hover { transform: scale(1.22); background: var(--surface-2); }
.react-pop button.on { background: var(--cobalt-soft); }
.msg-reactions {
  position: absolute; bottom: -13px; inset-inline-start: 10px; display: flex; gap: 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 .35rem; font-size: .92rem; line-height: 1.55; box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.msg.out .msg-reactions { inset-inline-start: auto; inset-inline-end: 10px; }
/* الرسائل الواردة: أزرار الرسالة وقائمة التفاعل تمتد نحو وسط المحادثة — لا نحو حافتها.
   (كانت على الرسائل القصيرة مثل «تم» تتجاوز حافة المحادثة فيختفي زر «رد» تحت قائمة المحادثات
   على الكمبيوتر أو خارج الشاشة على الجوال، فيضغط المستخدم ولا يحدث شيء) */
.msg.in .msg-actions { inset-inline-end: auto; inset-inline-start: 8px; }
.msg.in .react-pop { inset-inline-end: auto; inset-inline-start: 0; }

/* لوحة بيانات العميل: عمود جانبي على الكمبيوتر، وطبقة كاملة على الجوال (تبدأ مغلقة) */
.only-mobile { display: none !important; }
.panel-back { align-self: flex-start; }
@media (min-width: 961px) {
  .contact-panel:not(.desk-open) { display: none; }
}
@media (max-width: 960px) {
  .only-desktop { display: none !important; }
  .only-mobile { display: inline-flex !important; }
  .contact-panel:not(.mob-open) { display: none; }
}

/* الاقتباس */
.quote { display: flex; align-items: stretch; gap: .5rem; width: 100%; text-align: start; font: inherit; cursor: pointer; white-space: normal; }
button.quote:hover { background: rgba(0,0,0,.07); }
.quote-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.quote-body b { color: var(--cobalt); font-size: .78rem; }
.quote-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote img { width: 42px; height: 42px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }

/* الصور والفيديو */
.media-img { display: block; padding: 0; border: 0; background: none; cursor: zoom-in; width: 100%; border-radius: 10px; overflow: hidden; }
.media-img img { display: block; width: 100%; max-width: 330px; max-height: 360px; min-height: 60px; object-fit: cover; border-radius: 10px; background: var(--surface-3); }
.msg-video { width: 330px; max-width: 100%; max-height: 360px; border-radius: 10px; display: block; background: #000; }
.media-missing .btn { margin-inline-start: auto; }

/* مشغّل الصوت */
.vp { display: flex; align-items: center; gap: .6rem; width: 290px; max-width: 100%; padding: .2rem .1rem; }
.vp-play {
  width: 38px; height: 38px; border-radius: 50%; border: 0; flex-shrink: 0; cursor: pointer;
  background: var(--cobalt); color: #fff; display: inline-flex; align-items: center; justify-content: center; transition: transform .1s;
}
.vp-play:active { transform: scale(.94); }
.msg.out .vp-play { background: #1E9E6A; }
.vp .i-pause { display: none; }
.vp.playing .i-play { display: none; }
.vp.playing .i-pause { display: inline; }
.vp.error .vp-play { background: var(--red); }
.vp-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
.vp-bar { position: relative; height: 4px; border-radius: 4px; background: rgba(18, 34, 61, .14); cursor: pointer; margin: .45rem 0 0; }
.vp-bar::before { content: ""; position: absolute; inset: -8px 0; }
.vp-bar i { position: absolute; inset-block: 0; inset-inline-start: 0; width: 0; border-radius: 4px; background: var(--cobalt); }
.msg.out .vp-bar i { background: #1E9E6A; }
.vp-bar b { position: absolute; top: 50%; inset-inline-start: 0; width: 12px; height: 12px; margin-top: -6px; margin-inline-start: -6px; border-radius: 50%; background: var(--cobalt); box-shadow: 0 0 0 2px var(--surface); }
.msg.out .vp-bar b { background: #1E9E6A; box-shadow: 0 0 0 2px var(--wa-out); }
.vp-row { display: flex; align-items: center; gap: .5rem; font-size: .74rem; color: var(--ink-3); }
.vp-time { font-variant-numeric: tabular-nums; }
.vp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vp-speed { margin-inline-start: auto; border: 0; background: rgba(18, 34, 61, .08); color: var(--ink-2); font-size: .72rem; font-weight: 600; border-radius: 999px; padding: 0 .45rem; cursor: pointer; line-height: 1.5; }
.vp-badge { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); color: var(--ink-3); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.vp.voice .vp-badge { background: var(--cobalt-soft); color: var(--cobalt); }
.vp audio { display: none; }

/* المستندات */
.doc-card { display: flex; align-items: center; gap: .65rem; background: rgba(18, 34, 61, .05); border-radius: 10px; padding: .55rem .6rem; min-width: 240px; max-width: 330px; }
.doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-info b { font-size: .88rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-info small { color: var(--ink-3); font-size: .74rem; }
.doc-card .icon-btn { width: 2rem; height: 2rem; flex-shrink: 0; }
.doc-ico {
  width: 38px; height: 46px; border-radius: 5px 12px 5px 5px; flex-shrink: 0; display: inline-flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px; font-size: .58rem; font-weight: 700; letter-spacing: .02em; color: #fff; background: #7A869C; direction: ltr;
}
.doc-ico.pdf { background: #D64545; }
.doc-ico.word { background: #2B579A; }
.doc-ico.excel { background: #1E7B45; }
.doc-ico.ppt { background: #C4501E; }
.doc-ico.sm { width: 26px; height: 32px; font-size: .48rem; padding-bottom: 4px; border-radius: 4px 8px 4px 4px; }
.doc-ico.lg { width: 74px; height: 92px; font-size: .9rem; padding-bottom: 12px; border-radius: 8px 22px 8px 8px; }

/* الموقع */
.loc-card { display: flex; flex-direction: column; width: 290px; max-width: 100%; border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none !important; }
.loc-map {
  height: 118px; display: flex; align-items: center; justify-content: center; color: #D64545;
  background:
    linear-gradient(115deg, transparent 46%, rgba(255,255,255,.95) 46%, rgba(255,255,255,.95) 50%, transparent 50%),
    linear-gradient(25deg, transparent 60%, rgba(255,214,120,.9) 60%, rgba(255,214,120,.9) 63%, transparent 63%),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(255,255,255,.55) 22px 24px),
    repeating-linear-gradient(90deg, transparent 0 30px, rgba(255,255,255,.55) 30px 32px),
    #DDE8D5;
}
.loc-map .icon { filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); fill: #fff; }
.loc-info { display: flex; flex-direction: column; padding: .5rem .65rem; gap: .1rem; }
.loc-info b { font-size: .88rem; }
.loc-info small { color: var(--ink-3); font-size: .75rem; }
.loc-card:hover .loc-info b { color: var(--cobalt); }
.loc-card.preview { width: 100%; margin-top: .25rem; }

/* بطاقة جهة اتصال */
.vcard { display: flex; align-items: center; gap: .6rem; background: rgba(18, 34, 61, .05); border-radius: 10px; padding: .5rem .6rem; min-width: 230px; margin-bottom: .3rem; }
.vcard-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vcard-info b { font-size: .9rem; }
.vcard-info span { font-size: .78rem; color: var(--ink-2); text-align: start; }

/* الرسائل التفاعلية */
.ia-head { font-weight: 600; margin-bottom: .2rem; }
.ia-foot { font-size: .76rem; color: var(--ink-3); margin-top: .2rem; }
.ia-buttons { display: flex; flex-direction: column; margin: .45rem -.75rem -.1rem; border-top: 1px solid rgba(18, 34, 61, .1); }
.ia-buttons span { display: flex; align-items: center; justify-content: center; gap: .3rem; padding: .4rem; color: var(--cobalt); font-size: .86rem; font-weight: 500; border-bottom: 1px solid rgba(18, 34, 61, .08); }
.ia-buttons span:last-child { border-bottom: 0; }
.ia-reply { display: inline-flex; align-items: center; gap: .25rem; font-size: .72rem; color: var(--ink-3); background: rgba(18, 34, 61, .06); border-radius: 4px; padding: 0 .4rem; margin-bottom: .2rem; }
.msg-error { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.msg-error .link-btn { display: inline-flex; align-items: center; gap: .2rem; font-size: .76rem; font-weight: 600; }

/* إفلات الملفات على المحادثة */
.thread-main.dropping::after {
  content: "أفلت الملفات هنا لإرسالها"; position: absolute; inset: 12px; z-index: 40; pointer-events: none;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1.05rem; color: var(--cobalt);
  border: 2px dashed var(--cobalt); border-radius: 18px; background: rgba(232, 236, 251, .93);
}

/* المحرر */
.reply-bar { display: flex; align-items: center; gap: .6rem; background: var(--surface-2); border-inline-start: 3px solid var(--cobalt); border-radius: 8px; padding: .4rem .5rem .4rem .7rem; margin-bottom: .5rem; color: var(--ink-2); }
.reply-body { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: .82rem; }
.reply-body b { color: var(--cobalt); font-size: .78rem; }
.reply-body span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; }
.pop-backdrop { position: fixed; inset: 0; z-index: 15; }
/* صف الكتابة فوق الخلفية أثناء فتح القوائم: «إرسال» يرسل مباشرة بدل أن تُغلق القائمة فقط بأول ضغطة */
.composer-row.over-pop { position: relative; z-index: 16; }
.emoji-pop, .attach-menu {
  position: absolute; bottom: calc(100% + .35rem); inset-inline-start: 0; z-index: 16; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .14s ease-out;
}
.emoji-pop { width: min(360px, calc(100vw - 2rem)); overflow: hidden; }
.emoji-tabs { display: flex; gap: 2px; padding: .35rem; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.emoji-tabs button { flex: 1; border: 0; background: none; font-size: 1.15rem; padding: .25rem 0; border-radius: 8px; cursor: pointer; filter: grayscale(.6); opacity: .75; }
.emoji-tabs button.on, .emoji-tabs button:hover { background: var(--surface); filter: none; opacity: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: .4rem; max-height: 230px; overflow-y: auto; }
.emoji-grid button { border: 0; background: none; font-size: 1.4rem; line-height: 1; padding: .3rem 0; border-radius: 8px; cursor: pointer; }
.emoji-grid button:hover { background: var(--surface-3); }
.attach-menu { padding: .35rem; min-width: 210px; display: flex; flex-direction: column; }
.attach-menu button { display: flex; align-items: center; gap: .7rem; border: 0; background: none; padding: .45rem .55rem; border-radius: 9px; cursor: pointer; font: inherit; font-size: .9rem; color: var(--ink); text-align: start; }
.attach-menu button:hover { background: var(--surface-2); }
.am-ico { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.am-ico.img { background: #7C5CE0; }
.am-ico.doc { background: #2B7BD6; }
.am-ico.aud { background: #E0663A; }
.am-ico.loc { background: #1E9E6A; }
.am-ico.con { background: #2493B5; }
.mic-btn { background: var(--green); }
.mic-btn:hover { background: #17855A; }
.char-count { text-align: end; font-size: .72rem; color: var(--ink-3); margin-top: .2rem; font-variant-numeric: tabular-nums; }
.char-count.over { color: var(--red); font-weight: 600; }

/* شريط التسجيل */
.rec-bar { display: flex; align-items: center; gap: .6rem; min-height: 2.7rem; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: rec-pulse 1.1s ease-in-out infinite; flex-shrink: 0; }
@keyframes rec-pulse { 50% { opacity: .25; } }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); min-width: 3rem; }
.rec-level { flex: 1; height: 30px; display: flex; align-items: center; gap: 3px; overflow: hidden; direction: ltr; }
.rec-level i { flex: 1; max-width: 4px; min-width: 2px; height: 12%; border-radius: 3px; background: var(--cobalt); opacity: .8; transition: height .08s linear; }
.rec-preview { flex: 1; width: auto; }
.rec-sending { flex: 1; display: inline-flex; align-items: center; gap: .5rem; color: var(--ink-3); font-size: .88rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--cobalt); animation: nb-spin .8s linear infinite; display: inline-block; }
@keyframes nb-spin { to { transform: rotate(360deg); } }

/* نافذة المرفقات (تغطي المحادثة) */
.attach-panel { position: absolute; inset: 0; z-index: 25; background: var(--surface-2); display: flex; flex-direction: column; animation: fade .15s; }
.ap-head { display: flex; align-items: center; gap: .6rem; padding: .6rem .9rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.ap-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
.ap-head .muted { margin-inline-start: auto; font-size: .82rem; }
.ap-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .8rem; padding: 1.25rem; }
.ap-stage > img, .ap-stage > video {
  max-width: 100%; max-height: calc(100% - 3rem); object-fit: contain; border-radius: 10px; box-shadow: var(--shadow);
  background: repeating-conic-gradient(#E9EDF3 0% 25%, #fff 0% 50%) 50% / 18px 18px;
}
.ap-file { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; max-width: 80%; }
.ap-file b { word-break: break-all; }
.ap-file small { color: var(--ink-3); }
.ap-progress { width: min(320px, 90%); display: flex; flex-direction: column; gap: .35rem; align-items: center; font-size: .82rem; color: var(--ink-3); }
.ap-bar { width: 100%; height: 5px; border-radius: 5px; background: var(--line); overflow: hidden; }
.ap-bar i { display: block; height: 100%; background: var(--cobalt); transition: width .2s; }
.ap-msg { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .7rem; max-width: 90%; }
.ap-msg.bad { color: #9A2B2B; background: var(--red-soft); border-color: #F3C5C5; }
.ap-caption { padding: 0 1rem .6rem; display: flex; justify-content: center; }
.ap-caption input { max-width: 620px; border-radius: 12px; background: var(--surface); }
.ap-foot { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; background: var(--surface); border-top: 1px solid var(--line); }
.ap-thumbs { flex: 1; display: flex; gap: .5rem; overflow-x: auto; padding: .3rem .1rem; }
.ap-thumb {
  position: relative; width: 56px; height: 56px; border-radius: 10px; flex-shrink: 0; cursor: pointer; overflow: visible;
  background: var(--surface-3); border: 2px solid transparent; display: flex; align-items: center; justify-content: center; color: var(--ink-3);
}
.ap-thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.ap-thumb.on { border-color: var(--cobalt); }
.ap-thumb.failed { border-color: var(--red); }
.ap-ext { font-size: .62rem; font-weight: 700; direction: ltr; }
.ap-ring {
  position: absolute; inset: 0; border-radius: 8px; background: rgba(18, 34, 61, .45);
  mask: radial-gradient(circle at center, transparent 9px, #000 10px); -webkit-mask: radial-gradient(circle at center, transparent 9px, #000 10px);
}
.ap-ring::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 1%), rgba(255,255,255,.3) 0);
  -webkit-mask: radial-gradient(circle, transparent 7px, #000 8px); mask: radial-gradient(circle, transparent 7px, #000 8px);
}
.ap-bad { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(214, 69, 69, .55); color: #fff; border-radius: 8px; }
.ap-x {
  position: absolute; top: -7px; inset-inline-end: -7px; width: 20px; height: 20px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--ink); color: #fff; display: none; align-items: center; justify-content: center; padding: 0;
}
.ap-thumb:hover .ap-x, .ap-thumb.on .ap-x { display: inline-flex; }
.ap-add { width: 56px; height: 56px; border-radius: 10px; border: 2px dashed var(--line-2); background: none; color: var(--ink-3); cursor: pointer; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.ap-add:hover { border-color: var(--cobalt); color: var(--cobalt); }

/* اختيار جهة اتصال */
.pick-list { display: flex; flex-direction: column; gap: 2px; margin: -.3rem 0 .8rem; border: 1px solid var(--line); border-radius: 10px; padding: .25rem; max-height: 220px; overflow-y: auto; }
.pick-list button { display: flex; align-items: center; gap: .6rem; border: 0; background: none; padding: .4rem .5rem; border-radius: 8px; cursor: pointer; font: inherit; text-align: start; }
.pick-list button:hover { background: var(--surface-2); }
.pick-list span { display: flex; flex-direction: column; min-width: 0; }
.pick-list b { font-size: .88rem; font-weight: 500; }
.pick-list small { color: var(--ink-3); font-size: .76rem; text-align: start; }

/* وسائط المحادثة في لوحة العميل */
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: .4rem; }
.media-grid > * { position: relative; aspect-ratio: 1; border-radius: 6px; overflow: hidden; border: 0; padding: 0; background: var(--surface-3); cursor: pointer; display: block; }
.media-grid img, .media-grid video { width: 100%; height: 100%; object-fit: cover; display: block; }
.mg-video .icon { position: absolute; left: 50%; top: 50%; margin: -9px 0 0 -9px; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.media-doc { display: flex; align-items: center; gap: .5rem; padding: .3rem .2rem; font-size: .82rem; color: var(--ink-2); text-decoration: none !important; border-radius: 6px; }
.media-doc:hover { background: var(--surface-2); color: var(--cobalt); }
.media-doc span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* عارض الصور */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 16, 30, .92); display: flex; align-items: center; justify-content: center; animation: fade .15s; }
.lightbox img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lb-bar { position: absolute; top: 0; inset-inline: 0; display: flex; justify-content: flex-end; gap: .5rem; padding: .8rem 1rem; }
.lb-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none !important; }
.lb-btn:hover { background: rgba(255,255,255,.24); }

@media (max-width: 960px) {
  .msg-video, .media-img img, .vp, .loc-card, .doc-card { width: 100%; max-width: 280px; min-width: 0; }
  .msg-actions { opacity: 0; }
  .emoji-grid { grid-template-columns: repeat(7, 1fr); }
  .ap-stage { padding: .75rem; }
}

/* وسائط ترويسة القالب */
.hm-picker { display: flex; flex-direction: column; gap: .35rem; }
.hm-row { display: flex; gap: .5rem; }
.hm-row input { flex: 1; min-width: 0; }
.hm-ok { color: var(--green); display: inline-flex; align-items: center; gap: .3rem; }
.hm-error { color: var(--red); display: inline-flex; align-items: center; gap: .3rem; }
.hm-thumb { max-width: 160px; max-height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* المحادثة على الجوال */
@media (max-width: 600px) {
  .thread-head { flex-wrap: wrap; row-gap: .45rem; padding: .5rem .75rem; }
  .thread-head .grow b, .thread-head .grow small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .thread-actions { order: 3; width: 100%; }
  .thread-actions .select-sm { flex: 1; width: auto !important; }
  .messages { padding: .75rem .6rem; }
  .composer { padding: .5rem .55rem; }
  .composer-row { gap: .3rem; }
  .composer-tools { gap: 0; }
  .composer-tools .icon-btn { width: 2rem; height: 2rem; }
  .send-btn { width: 2.5rem; height: 2.5rem; }
  .ap-foot { padding: .6rem; gap: .5rem; }
}
.wa-media-img { display: block; width: 100%; max-height: 180px; object-fit: cover; border-radius: 6px; margin-bottom: .35rem; }

/* ============================================================
   تجهيز الصفحة التفاعلية، انقطاع الاتصال، الأخطاء غير المتوقعة
   ============================================================ */

/* شريط تحميل رفيع أعلى الصفحة حتى تتصل الأزرار بالخادم */
#nb-boot-bar { display: none; }
html.nb-boot #nb-boot-bar {
  display: block; position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 3000;
  overflow: hidden; background: rgba(36, 67, 201, .12); pointer-events: none;
}
html.nb-boot #nb-boot-bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 38%; left: -38%;
  background: linear-gradient(90deg, transparent, var(--cobalt), transparent);
  animation: nb-boot-slide 1.1s ease-in-out infinite;
}
@keyframes nb-boot-slide { to { left: 100%; } }
html.nb-boot .main button:not([type="submit"]), html.nb-boot .modal button { cursor: progress; }
/* تعذّر التحميل نهائياً: نوقف شريط التحميل (رسالة التحديث تبقى ظاهرة) */
html.nb-failed #nb-boot-bar { display: none; }

/* تنبيه صغير أعلى الصفحة: «لحظة… نجهّز الصفحة» أو «تعذّر التحميل» مع زر تحديث */
#nb-boot-note {
  position: fixed; top: .9rem; left: 50%; z-index: 3001; transform: translate(-50%, -12px);
  display: flex; align-items: center; gap: .6rem; max-width: calc(100vw - 2rem);
  background: var(--ink); color: #fff; padding: .55rem .95rem; border-radius: 999px;
  box-shadow: var(--shadow-lg); font: 500 .88rem/1.4 var(--font);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#nb-boot-note.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#nb-boot-note.is-bad { background: #9A2B2B; }
#nb-boot-note .nbn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--saffron); flex-shrink: 0; animation: rec-pulse 1s ease-in-out infinite; }
#nb-boot-note.is-bad .nbn-dot { background: #fff; animation: none; }
#nb-boot-note .nbn-reload {
  display: none; background: #fff; color: var(--ink); border: 0; border-radius: 999px;
  padding: .22rem .75rem; font-size: .82rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#nb-boot-note.with-reload .nbn-reload { display: inline-block; }

/* نافذة انقطاع الاتصال (يتحكم Blazor بأصناف الحالة عليها) */
.nb-rc { border: 0; padding: 0; margin: auto; background: transparent; width: min(420px, calc(100vw - 2rem)); max-width: none; color: var(--ink); overflow: visible; }
.nb-rc::backdrop { background: rgba(18, 34, 61, .5); }
.nb-rc, .nb-rc-card { border-radius: 16px; }
.nb-rc:focus, .nb-rc:focus-visible { outline: none; }
.nb-rc .btn:focus-visible { outline: 3px solid rgba(36, 67, 201, .3); outline-offset: 2px; }
/* أثناء محاولة إعادة الاتصال لا نُظهر شريط «حدث خطأ» (قد يرفعه Blazor لمحاولة فاشلة عابرة) */
html:has(#components-reconnect-modal[open]) #blazor-error-ui { display: none !important; }
/* تأخير نصف ثانية قبل الظهور: انقطاع لحظي يمر بدون وميض (لكن الضغطات تُحجب فوراً) */
.nb-rc[open] { animation: nb-rc-in .22s ease-out .5s both; }
.nb-rc[open]::backdrop { animation: fade .22s ease-out .5s both; }
@keyframes nb-rc-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.nb-rc-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 1.6rem 1.5rem 1.3rem; text-align: center; font-family: var(--font); }
.nb-rc-visual { width: 52px; height: 52px; margin: 0 auto .9rem; position: relative; }
.nb-rc-spin { position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--cobalt-soft); border-top-color: var(--cobalt); animation: nb-spin .8s linear infinite; }
.nb-rc-icon { display: none; position: absolute; inset: 0; border-radius: 50%; background: var(--saffron-soft); color: #B57A00; font: 700 1.45rem/52px var(--font); }
.nb-rc-title { font-size: 1.08rem; margin-bottom: .35rem; }
.nb-rc-msg { color: var(--ink-2); font-size: .92rem; margin: 0 0 1.05rem; }
.nb-rc-actions { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; }
.nb-rc-actions [data-act] { display: none; }
.nb-rc.components-reconnect-failed .nb-rc-spin, .nb-rc.components-reconnect-paused .nb-rc-spin { display: none; }
.nb-rc.components-reconnect-failed .nb-rc-icon, .nb-rc.components-reconnect-paused .nb-rc-icon { display: block; }
.nb-rc.components-reconnect-failed [data-act="retry"],
.nb-rc.components-reconnect-failed [data-act="reload"],
.nb-rc.components-reconnect-paused [data-act="resume"],
.nb-rc.components-reconnect-paused [data-act="reload"],
.nb-rc[data-long] [data-act="reload"] { display: inline-flex; }
.nb-rc[data-busy] .nb-rc-spin { display: block; }
.nb-rc[data-busy] .nb-rc-icon,
.nb-rc[data-busy] [data-act="retry"],
.nb-rc[data-busy] [data-act="resume"] { display: none; }

/* شريط «حدث خطأ غير متوقع» — يظهره Blazor تلقائياً إذا توقف اتصال الصفحة بسبب خطأ */
#blazor-error-ui {
  display: none; position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 3002;
  width: min(520px, calc(100vw - 2rem)); background: var(--surface); color: var(--ink);
  border: 1px solid #F1C6C6; border-inline-start: 4px solid var(--red); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: .85rem 1rem .85rem 2.6rem; font-size: .92rem;
}
#blazor-error-ui .beu-text { display: block; margin-bottom: .6rem; }
#blazor-error-ui .beu-text b { color: var(--red); }
#blazor-error-ui .dismiss { position: absolute; top: .45rem; left: .55rem; cursor: pointer; color: var(--ink-3); font-size: .95rem; padding: .15rem .4rem; border-radius: 6px; text-decoration: none; }
#blazor-error-ui .dismiss:hover { background: var(--surface-3); color: var(--ink); }

/* بطاقة الخطأ داخل الصفحة (حاجز الأخطاء في MainLayout) */
.error-card { display: flex; gap: 1rem; align-items: flex-start; border-color: #F1C6C6; background: #FFFBFB; }
.error-card-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--red-soft); color: var(--red); display: grid; place-items: center; flex-shrink: 0; }
.error-card h3 { margin-bottom: .3rem; }
.error-card p { margin-bottom: .85rem; }

/* زر بشكل رابط داخل فقرة نصية */
.link-btn.inline { font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* قفزات فهرس دليل المطورين: لا يختفي عنوان القسم تحت الشريط العلوي */
.docs-body > section[id] { scroll-margin-top: 72px; }

@media (prefers-reduced-motion: reduce) {
  html.nb-boot #nb-boot-bar::after, .nb-rc-spin, #nb-boot-note .nbn-dot { animation-duration: 2.4s; }
  .nb-rc[open], .nb-rc[open]::backdrop { animation-delay: .3s; animation-duration: .01s; }
}

/* سبب تعطيل زر الحفظ/التالي — بجانب الزر حتى لا يبدو أنه لا يستجيب */
.action-hint { color: #8A5A00; font-size: .84rem; line-height: 1.4; align-self: center; margin-inline-end: auto; }
.wizard-nav .action-hint { margin-inline-start: auto; margin-inline-end: .75rem; }
.builder-actions { display: flex; align-items: center; gap: .6rem; }

/* =====================================================================
   الاشتراك والدفع (1.4.0): اختيار الباقة والمدة، ملخص الدفع، الإيصال، المدفوعات
   ===================================================================== */
.callout.ok { background: var(--green-soft); border-color: #BFE6D2; }
.callout.ok > .icon { color: var(--green); }
.callout.bad { background: var(--red-soft); border-color: #F2C9C9; }
.callout.bad > .icon { color: var(--red); }
.callout b.inline { display: inline; margin: 0; }
.text-warn { color: #B57A00; }
.nowrap { white-space: nowrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll .table { min-width: 640px; }
.spinner.light { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }

.bill-result { align-items: flex-start; }
.bill-result > .btn { align-self: center; }
.bill-result p b { display: inline; }
.bill-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.25rem; align-items: start; margin-bottom: 1.25rem; }
.bill-main > .card:last-child, .bill-main > .callout:last-child { margin-bottom: 0; }
.bill-side { position: sticky; top: calc(56px + 1rem); }
.bill-side .card { margin: 0; }

.bill-current-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.bill-current-head h2 { font-size: 1.3rem; margin-top: .15rem; }
.bill-ends { display: flex; align-items: center; gap: .45rem; margin: .75rem 0 .25rem; font-size: .95rem; color: var(--ink-2); }
.bill-ends b { color: var(--ink); }
.bill-ends.text-bad, .bill-ends.text-bad b { color: var(--red); }

.bill-step-head { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.bill-step { width: 26px; height: 26px; border-radius: 8px; background: var(--ink); color: #fff; display: inline-grid; place-items: center; font-size: .85rem; font-weight: 700; font-family: var(--font-display); flex-shrink: 0; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .75rem; }
.pick { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: .45rem; text-align: start; padding: 1rem 1.05rem; border: 1.5px solid var(--line-2); border-radius: var(--radius); background: var(--surface); cursor: pointer; font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s, background .15s; }
.pick:hover:not(:disabled) { border-color: var(--cobalt); }
.pick.on { border-color: var(--cobalt); background: #F7F9FF; box-shadow: 0 0 0 3px rgba(36, 67, 201, .12); }
.pick.off { cursor: not-allowed; background: var(--surface-2); }
.pick.off > :not(.pick-why) { opacity: .55; }
.pick-head { display: flex; align-items: center; gap: .45rem; }
.pick-head b { font-family: var(--font-display); font-size: 1.05rem; }
.pick-radio { margin-inline-start: auto; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); flex-shrink: 0; transition: border .15s; }
.pick.on .pick-radio { border: 5px solid var(--cobalt); }
.pick-price { font-size: .9rem; color: var(--ink-2); }
.pick-price b { font-size: 1.45rem; font-family: var(--font-display); color: var(--ink); }
.pick-price small { display: block; color: var(--ink-3); font-size: .78rem; }
.pick-feats { display: flex; flex-direction: column; gap: .15rem; font-size: .82rem; color: var(--ink-2); }
.pick-feats span { display: inline-flex; align-items: center; gap: .35rem; }
.pick-save { font-size: .78rem; font-weight: 600; color: #176B48; }
.pick-why { font-size: .78rem; color: var(--red); line-height: 1.5; }

.bill-options { display: grid; grid-template-columns: auto 1fr; gap: .5rem 2rem; align-items: start; }
.bill-months { margin: 0; }
.bill-months button { padding: .5rem 1rem; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; }
.bill-months .save { font-style: normal; font-size: .7rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; background: var(--green-soft); color: #176B48; }
.bill-months button.on .save { background: rgba(255, 255, 255, .18); color: #fff; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; width: fit-content; background: var(--surface); }
.stepper button { width: 40px; height: 38px; border: 0; background: var(--surface); font-size: 1.2rem; cursor: pointer; color: var(--ink); }
.stepper button:hover:not(:disabled) { background: var(--surface-2); }
.stepper button:disabled { color: var(--ink-3); cursor: not-allowed; opacity: .5; }
.stepper output { min-width: 52px; text-align: center; font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; border-inline: 1px solid var(--line); line-height: 38px; }

.bill-summary h2 { font-size: 1.05rem; }
.bill-lines { margin: 0 0 .75rem; display: flex; flex-direction: column; gap: .55rem; font-size: .9rem; }
.bill-lines > div { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.bill-lines dt { color: var(--ink-2); }
.bill-lines dt small { display: block; color: var(--ink-3); font-size: .78rem; margin-top: .1rem; }
.bill-lines dd { margin: 0; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bill-lines .disc dd { color: #176B48; }
.bill-total { display: flex; justify-content: space-between; align-items: baseline; padding: .8rem 0; border-top: 1px dashed var(--line-2); border-bottom: 1px dashed var(--line-2); margin-bottom: .75rem; }
.bill-total span { font-weight: 600; }
.bill-total b { font-family: var(--font-display); font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.bill-total b small { font-size: .9rem; color: var(--ink-3); font-family: var(--font); }
.bill-until { display: flex; align-items: center; gap: .4rem; font-size: .86rem; color: var(--ink-2); margin-bottom: 1rem; }
.bill-methods { margin-bottom: 1rem; }
.btn-pay { padding: .75rem 1rem; font-size: 1rem; font-weight: 600; justify-content: center; }
.bill-secure { display: flex; gap: .4rem; align-items: flex-start; font-size: .78rem; color: var(--ink-3); margin: .65rem 0 0; line-height: 1.6; }
.bill-secure .icon { margin-top: .2rem; }
.bank-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .8rem; margin-bottom: .75rem; }
.bank-box > div { display: flex; align-items: center; gap: .6rem; padding: .4rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.bank-box > div:last-child { border-bottom: 0; }
.bank-box span { color: var(--ink-3); min-width: 72px; }
.bank-box code { flex: 1; background: var(--surface); border: 1px solid var(--line); padding: .2rem .5rem; border-radius: 6px; word-break: break-all; user-select: all; font-size: .82rem; }
/* اختيار ملف الإيصال: مساحة واضحة بدل زر المتصفح الافتراضي (الحقل الحقيقي شفاف فوقها — يعمل بالنقر والسحب ولوحة المفاتيح) */
.receipt-drop { position: relative; display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem; border: 1.5px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink-2); cursor: pointer; transition: border-color .15s, background .15s; }
.receipt-drop:hover { border-color: var(--cobalt); background: #F7F9FF; }
.receipt-drop:focus-within { outline: 2px solid var(--cobalt); outline-offset: 2px; }
.receipt-drop input[type=file] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.receipt-drop > .icon { flex-shrink: 0; color: var(--cobalt); }
.receipt-drop > span { display: flex; flex-direction: column; min-width: 0; }
.receipt-drop b { font-size: .9rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-drop small { font-size: .76rem; color: var(--ink-3); }
.receipt-drop.has-file { border-style: solid; border-color: #BFE6D2; background: var(--green-soft); }
.receipt-drop.has-file > .icon { color: var(--green); }
.bill-note { display: flex; gap: .4rem; align-items: flex-start; font-size: .8rem; color: var(--ink-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .65rem; margin: -.4rem 0 1rem; line-height: 1.6; }
.bill-note .icon { margin-top: .2rem; flex-shrink: 0; color: var(--cobalt); }
.bill-result-meta { display: flex; flex-wrap: wrap; gap: .2rem 1rem; margin: .3rem 0 0; font-size: .8rem; color: var(--ink-2); }
.table small.mono { white-space: nowrap; }
.rd-card { display: block; font-size: .8rem; color: var(--ink-2); margin-top: .1rem; }
.plan-actions { margin: .5rem 0 1rem; }

.stat-btn { font: inherit; text-align: start; cursor: pointer; }
.stat-btn:hover { border-color: var(--cobalt); }
.stat-btn.on { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(36, 67, 201, .12); }

/* إيصال الدفع — يُطبع أو يُحفظ PDF من المتصفح */
.receipt-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 820px; margin: 0 auto 1rem; }
.receipt-doc { max-width: 820px; margin: 0 auto 2rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 2.25rem 2.5rem; box-shadow: var(--shadow); }
.rd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.5rem; padding-bottom: 1.25rem; border-bottom: 2px solid var(--ink); }
.rd-brand { display: flex; align-items: center; gap: .75rem; }
.rd-brand b { display: block; font-family: var(--font-display); font-size: 1.15rem; }
.rd-brand span { font-size: .82rem; color: var(--ink-3); }
.rd-title { text-align: end; }
.rd-title h1 { font-size: 1.6rem; }
.rd-title span { font-size: .8rem; color: var(--ink-3); }
.rd-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem 1.5rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.rd-meta span { display: block; font-size: .76rem; color: var(--ink-3); }
.rd-meta b { font-size: .92rem; }
.rd-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; padding: 1.1rem 0; }
.rd-parties h3 { font-size: .8rem; color: var(--ink-3); font-family: var(--font); font-weight: 600; margin-bottom: .3rem; }
.rd-parties p { margin: 0 0 .15rem; font-size: .9rem; }
.rd-ltr { text-align: end; }
.rd-table { width: 100%; border-collapse: collapse; margin: .5rem 0 1rem; font-size: .9rem; }
.rd-table th { text-align: start; background: var(--surface-2); color: var(--ink-3); font-size: .76rem; font-weight: 600; padding: .6rem .75rem; border-bottom: 1px solid var(--line); }
.rd-table td { padding: .8rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.rd-table td small { display: block; color: var(--ink-3); font-size: .78rem; margin-top: .15rem; }
.rd-table td:last-child, .rd-table th:last-child { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rd-totals { width: min(100%, 340px); margin-block: 0; margin-inline-start: auto; margin-inline-end: 0; display: flex; flex-direction: column; gap: .45rem; font-size: .9rem; }
.rd-totals > div { display: flex; justify-content: space-between; gap: 1rem; }
.rd-totals dt { color: var(--ink-2); }
.rd-totals dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rd-grand { padding-top: .6rem; border-top: 2px solid var(--ink); font-weight: 700; font-size: 1.05rem; }
.rd-grand dt { color: var(--ink) !important; }
.rd-grand dd small { font-weight: 500; color: var(--ink-3); }
.rd-test { margin: 1rem 0 0; padding: .5rem .75rem; border-radius: var(--radius-sm); background: var(--saffron-soft); color: #8A5A00; font-size: .85rem; }
.rd-foot { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--ink-3); }
.rd-foot p { margin: 0 0 .25rem; }

@media (max-width: 1100px) {
  .bill-layout { grid-template-columns: minmax(0, 1fr); }
  .bill-side { position: static; }
}
@media (max-width: 600px) {
  .bill-options { grid-template-columns: minmax(0, 1fr); }
  .bill-months { display: flex; width: 100%; }
  .bill-months button { flex: 1; padding: .5rem .3rem; }
  .bill-current-head { flex-direction: column; gap: .4rem; }
  .receipt-doc { padding: 1.25rem 1rem; }
  .rd-head { flex-direction: column; gap: .75rem; }
  .rd-title { text-align: start; }
  .rd-parties { grid-template-columns: 1fr; gap: .75rem; }
  .rd-table th:nth-child(3), .rd-table td:nth-child(3) { display: none; }
}
@page { size: A4; margin: 14mm; }
@media print {
  .no-print, .sub-banner, .receipt-actions { display: none !important; }
  .receipt-doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  body { background: #fff; }
}

/* أزرار تصفية كثيرة على شاشة ضيقة: تُمرَّر أفقياً بدل أن تُقص */
.seg-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg-scroll button { white-space: nowrap; flex-shrink: 0; }
/* شبكة أمان للجداول القديمة على الجوال: تمرير أفقي بدل قص الأعمدة */
@media (max-width: 960px) {
  .table-card { overflow-x: auto; }
}
