/* ===== نظام المبيعات — التصميم ===== */
:root {
  --bg: #EEF1EE;
  --surface: #FFFFFF;
  --ink: #17302A;
  --muted: #637169;
  --line: #D9E0DB;
  --pine: #12574A;
  --pine-dark: #0B3A31;
  --pine-soft: #E3EEEA;
  --gold: #C98A1B;
  --gold-soft: #F6ECD8;
  --ok: #2F7D4F;
  --danger: #B2412F;
  --danger-soft: #F7E4E0;
  --radius-lg: 14px;
  --radius: 8px;
  --font: "IBM Plex Sans Arabic", Tahoma, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  overflow-x: clip;
}
a { color: var(--pine); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
p { margin: 0; }
code { background: var(--pine-soft); padding: 1px 6px; border-radius: 4px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[dir="ltr"] { text-align: right; unicode-bidi: plaintext; }

/* ===== الهيكل ===== */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--pine-dark);
  color: #D6E4DF;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 26px; }
.brand-mark {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--gold);
  color: var(--pine-dark);
  font-weight: 700;
  font-size: 20px;
  border-radius: 10px 10px 10px 2px;
}
.brand-mark.big { width: 64px; height: 64px; font-size: 34px; border-radius: 16px 16px 16px 4px; }
.brand-name { font-weight: 700; color: #fff; font-size: 17px; }

.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #C3D5CF;
  font-weight: 500;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset -3px 0 0 var(--gold); }
.nav svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.me { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 16px 18px; }
.me-link { display: flex; align-items: center; gap: 10px; color: #fff; margin-bottom: 8px; }
.me-link:hover { text-decoration: none; }
.me-link small { display: block; color: #9DB5AD; font-size: 12px; }
.me .link-btn { color: #9DB5AD; font-size: 13px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pine); color: #fff; font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 22px 32px 18px;
}
.topbar h1 { font-size: 26px; font-weight: 700; flex: 1; min-width: 0; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.menu-btn svg { width: 26px; height: 26px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; }
.content { padding: 0 32px 40px; display: flex; flex-direction: column; gap: 20px; }
.backdrop { display: none; }

/* ===== عناصر عامة ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--pine); color: #fff; }
.btn-primary:hover { background: var(--pine-dark); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--pine-soft); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--pine); cursor: pointer; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}
.panel.narrow { max-width: 760px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { font-size: 17px; font-weight: 600; }
.h-sm { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.lead { max-width: 70ch; }
.muted { color: var(--muted); }
.strong { font-weight: 600; }
.d-block { display: block; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 22px 8px !important; }
.stack-gap { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.alert { margin: 0 32px 14px; padding: 11px 16px; border-radius: var(--radius); font-weight: 500; transition: opacity .4s; }
.panel .alert, .auth-form .alert { margin: 0 0 14px; }
.alert-success { background: var(--pine-soft); color: var(--pine-dark); }
.alert-error { background: var(--danger-soft); color: #7D2A1D; }
.alert.fade { opacity: 0; }

/* ===== الأرقام العلوية ===== */
.figures {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.figures > div { padding: 18px 22px; border-inline-start: 1px solid var(--line); }
.figures > div:first-child { border-inline-start: 0; }
.figures small { display: block; color: var(--muted); font-size: 13px; }
.figures strong { display: block; font-size: 24px; font-weight: 700; margin: 2px 0; font-variant-numeric: tabular-nums; }
.figures em { font-style: normal; color: var(--muted); font-size: 13px; }

/* ===== بطاقة التارجت (العنصر المميز) ===== */
.target-hero {
  background: var(--pine-dark);
  color: #E8F0ED;
  border-radius: var(--radius-lg);
  padding: 26px 28px 22px;
  display: grid;
  gap: 18px;
}
.target-text small { color: #A9C1B9; font-size: 14px; }
.target-text strong { display: block; font-size: 56px; line-height: 1.05; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.target-text p { color: #C9D9D3; }
.target-text a { color: var(--gold); }
.target-track { height: 14px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; }
.target-track span { display: block; height: 100%; background: var(--gold); border-radius: 99px; animation: grow .9s cubic-bezier(.2,.7,.2,1) both; transform-origin: right; }
@keyframes grow { from { transform: scaleX(0); } }
.target-meta { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 28px; color: #C9D9D3; font-size: 14px; }
.target-meta strong { color: #fff; font-size: 16px; }
.target-hero .dot.ok { color: #9FD8B5; }
.target-hero .dot.ok::before { background: #9FD8B5; }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: right; font-weight: 500; font-size: 13px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 12px 10px; border-bottom: 1px solid #EDF1EE; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #F8FAF9; }
.row-off td { opacity: .6; }
.row-actions { white-space: nowrap; text-align: left; }
.row-actions > * { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 12px; vertical-align: middle; }
.clients-table tr[data-href] { cursor: pointer; }
.clients-table tr[data-href]:hover { background: color-mix(in srgb, var(--pine) 4%, white); }
.status-inline select { width: auto; min-width: 110px; padding: 5px 28px 5px 8px; border-color: var(--c); color: var(--c); font-weight: 600; }
.whatsapp-link { display: inline-flex; vertical-align: middle; color: var(--pine); }
.whatsapp-link svg { width: 17px; height: 17px; fill: currentColor; }
.bulk-bar { display: none; position: sticky; top: 8px; z-index: 20; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; margin-bottom: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.bulk-bar.visible { display: flex; }
.bulk-bar select { width: auto; min-width: 150px; }
.follow-overdue { color: var(--danger); font-weight: 600; }
.follow-today { color: var(--gold); font-weight: 600; }

/* ===== تحليلات المبيعات ===== */
.period-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.period-tabs a { padding: 7px 13px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 14px; }
.period-tabs a.active { background: var(--pine); border-color: var(--pine); color: #fff; }
.custom-dates { display: none; gap: 8px; }
.custom-dates.visible { display: flex; }
.sales-kpis { margin-bottom: 20px; }
.change { display: inline-flex !important; gap: 4px; font-weight: 600; }
.change.up { color: var(--ok); }
.change.down { color: var(--danger); }
.change.neutral { color: var(--muted); }
.sales-chart-panel { overflow: hidden; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i, .payment-panel i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-legend .paid, .payment-panel .paid { background: var(--ok); }
.chart-legend .partial, .payment-panel .partial { background: var(--gold); }
.chart-legend .unpaid, .payment-panel .unpaid { background: var(--danger); }
.chart-legend .previous { width: 18px; height: 0; border-top: 2px dashed var(--muted); }
.sales-chart-scroll { width: 100%; max-width: 100%; overflow-x: auto; overflow-y: hidden; position: relative; }
.sales-chart { width: 100%; height: auto; display: block; font-family: inherit; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-y, .axis-x { fill: var(--muted); font-size: 11px; text-anchor: end; }
.axis-x { text-anchor: middle; }
.bar-paid { fill: var(--ok); }.bar-partial { fill: var(--gold); }.bar-unpaid { fill: var(--danger); }
.sale-bar { cursor: help; }.sale-bar:hover { opacity: .8; }
.previous-line { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 5; }
.chart-tooltip { display: none; position: fixed; z-index: 100; max-width: 280px; padding: 8px 10px; color: #fff; background: var(--pine-dark); border-radius: 6px; font-size: 12px; pointer-events: none; }
.chart-tooltip.visible { display: block; }
.chart-empty { text-align: center; padding: 44px 20px; }.chart-empty p { color: var(--muted); margin-bottom: 12px; }
.analytics-grid { margin-top: 20px; }
.analytics-bars { list-style: none; margin: 0; padding: 0; }
.analytics-bars li { display: grid; grid-template-columns: minmax(130px,1.2fr) minmax(100px,1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.analytics-bars li:last-child { border-bottom: 0; }
.analytics-bars small { display: block; color: var(--muted); font-size: 12px; }
.analytics-track { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.analytics-track span { display: block; height: 100%; background: var(--pine); }
.analytics-bars .tcell { grid-column: 1 / -1; }
.danger-text { color: var(--danger); }
.donut-layout { display: grid; grid-template-columns: 150px 1fr; gap: 20px; align-items: center; }
.donut { width: 150px; transform: rotate(-90deg); }
.donut-bg, .donut-segment { fill: none; stroke-width: 14; }.donut-bg { stroke: var(--line); }.donut-segment { transform-origin: 60px 60px; }
.donut-segment.paid { stroke: var(--ok); }.donut-segment.partial { stroke: var(--gold); }.donut-segment.unpaid { stroke: var(--danger); }
.donut-value, .donut-label { text-anchor: middle; transform: rotate(90deg); transform-origin: 60px 60px; fill: var(--pine-dark); font-size: 14px; font-weight: 700; }
.donut-label { font-size: 9px; font-weight: 400; fill: var(--muted); }
.donut-layout ul { list-style: none; margin: 0; padding: 0; }.donut-layout li a { display: flex; gap: 8px; align-items: center; padding: 7px 0; }.donut-layout li span { flex: 1; }.donut-layout li small { display: block; color: var(--muted); }
.target-compact { min-height: 0; padding: 22px; }.target-compact .target-text strong { font-size: 38px; }
.payment-select { width: auto; min-width: 115px; padding: 5px 28px 5px 8px; font-weight: 600; }.payment-select.pay-paid { color: var(--ok); }.payment-select.pay-partial { color: var(--gold); }.payment-select.pay-unpaid { color: var(--danger); }
.sales-log { margin-top: 20px; }.sales-log tfoot th, .sales-log tfoot td { border-top: 1px solid var(--line); background: color-mix(in srgb, var(--pine) 4%, white); }
.w-target { min-width: 170px; }
.w-order { width: 76px; }
.w-color { width: 70px; }

.tcell { display: flex; align-items: center; gap: 10px; }
.tbar { flex: 1; height: 8px; background: #E7ECE9; border-radius: 99px; overflow: hidden; min-width: 90px; }
.tbar span { display: block; height: 100%; border-radius: 99px; }
.tbar.low span { background: var(--danger); }
.tbar.mid span { background: var(--gold); }
.tbar.done span { background: var(--ok); }
.tpct { font-weight: 600; min-width: 40px; font-variant-numeric: tabular-nums; }

.badge {
  --c: var(--pine);
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 13px; font-weight: 500;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, white);
  white-space: nowrap;
}
.badge-none { --c: #7A8580; }
.pay { font-size: 13px; font-weight: 500; white-space: nowrap; }
.pay::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-inline-end: 6px; vertical-align: middle; }
.pay-paid { color: var(--ok); } .pay-paid::before { background: var(--ok); }
.pay-partial { color: #9A6710; } .pay-partial::before { background: var(--gold); }
.pay-unpaid { color: var(--danger); } .pay-unpaid::before { background: var(--danger); }
.dot { font-size: 13px; white-space: nowrap; }
.dot::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-inline-end: 6px; vertical-align: middle; }
.dot.ok { color: var(--ok); } .dot.ok::before { background: var(--ok); }
.dot.off { color: var(--muted); } .dot.off::before { background: #A9B3AE; }
.tag { font-size: 12px; background: var(--pine-soft); color: var(--pine-dark); padding: 2px 8px; border-radius: 4px; white-space: nowrap; }

.pager { display: flex; gap: 4px; justify-content: center; padding-top: 16px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 34px; padding: 4px 8px; text-align: center; border-radius: 6px; }
.pager a { border: 1px solid var(--line); }
.pager .current { background: var(--pine); color: #fff; }
.pager .gap { color: var(--muted); }

/* ===== النماذج ===== */
input, select, textarea {
  font: inherit; color: var(--ink);
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #C9D2CC;
  border-radius: var(--radius);
  background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px rgba(18,87,74,.15); }
input[disabled] { background: #F2F4F3; color: var(--muted); }
input[type="color"] { padding: 3px; height: 40px; width: 56px; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--pine); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 5px; font-weight: 500; font-size: 14px; }
label.inline { flex-direction: row; align-items: center; gap: 8px; white-space: nowrap; }
label.check { flex-direction: row; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; padding-top: 6px; }
.inline-form { display: flex; gap: 8px; }
.row-form { display: grid; grid-template-columns: 76px 1fr 56px auto; gap: 10px; align-items: center; }
.stages-table .row-form { grid-template-columns: 76px 1fr 56px; }
select.sm { width: auto; padding: 4px 8px; font-size: 13px; }

.seg { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { font-weight: 500; font-size: 14px; margin-bottom: 6px; padding: 0; }
.seg label { flex-direction: row; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { padding: 8px 16px; border: 1px solid #C9D2CC; border-radius: var(--radius); background: #fff; }
.seg input:checked + span { background: var(--pine); border-color: var(--pine); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type="search"] { flex: 1 1 260px; }
.filters select { width: auto; min-width: 150px; }
.filters input[type="date"] { width: auto; }

/* ===== مراحل ===== */
.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.stages a, .stage-row { display: grid; grid-template-columns: 130px 1fr 36px; gap: 12px; align-items: center; padding: 6px 4px; border-radius: 6px; color: var(--ink); }
.stages a:hover { background: #F4F7F5; text-decoration: none; }
.stage-name { display: flex; align-items: center; gap: 8px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-name i { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.stage-bar { height: 10px; background: #EEF2EF; border-radius: 99px; overflow: hidden; }
.stage-bar span { display: block; height: 100%; border-radius: 99px; }
.stage-count { text-align: left; font-weight: 600; font-variant-numeric: tabular-nums; }

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.bars li { display: grid; grid-template-columns: 70px 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.bars-label { color: var(--muted); font-variant-numeric: tabular-nums; }
.bars-track { height: 12px; background: #EEF2EF; border-radius: 4px; overflow: hidden; }
.bars-track span { display: block; height: 100%; background: var(--pine); }
.bars-val { font-variant-numeric: tabular-nums; white-space: nowrap; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid #EDF1EE; }
.list li:last-child { border-bottom: 0; }
.list small { margin-inline-start: auto; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 20px 14px 0; border-right: 2px solid var(--line); margin-right: 5px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; right: -6px; top: 7px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--pine); }
.timeline p { font-size: 14px; }
.timeline time { font-size: 12px; color: var(--muted); }

/* ===== ملف العميل ===== */
.client-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 20px; align-items: start; }
.client-card-head { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.details { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; }
.stages-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.stages-pick button {
  --c: var(--pine);
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 99px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--c) 35%, white);
  background: #fff; color: var(--c);
}
.stages-pick button:hover { background: color-mix(in srgb, var(--c) 10%, white); }
.stages-pick button.on { background: var(--c); color: #fff; border-color: var(--c); }
.danger-zone { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--line); }
.note-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { padding: 12px 14px; background: color-mix(in srgb, var(--ink) 4%, var(--surface)); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; color: var(--ink); }
.notes li p { color: var(--ink); margin-top: 4px; }
.note-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 4px; }
.note-meta strong { color: var(--ink); }
.note-meta time { color: var(--muted); }

/* ===== صفحة الدخول ===== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-wrap {
  width: 100%; max-width: 860px;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border-radius: 18px; overflow: hidden;
  border: 1px solid var(--line);
}
.auth-wrap.single { max-width: 460px; grid-template-columns: 1fr; }
.auth-side { background: var(--pine-dark); color: #C9D9D3; padding: 48px 40px; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; min-height: 420px; }
.auth-side h2 { color: #fff; font-size: 30px; margin-top: 18px; }
.auth-form { padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; }
.auth-form h1 { font-size: 24px; margin-bottom: 22px; }
.auth-form p { margin-bottom: 14px; }

/* ===== الجوال ===== */
@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .client-layout { grid-template-columns: 1fr; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures > div:nth-child(3) { border-inline-start: 0; }
  .figures > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; right: 0; z-index: 50; transform: translateX(100%); transition: transform .25s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(10,25,21,.45); z-index: 40; }
  .menu-btn { display: block; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 21px; }
  .topbar-actions { width: 100%; }
  .content { padding: 0 16px 32px; }
  .alert { margin: 0 16px 12px; }
  .panel { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .target-text strong { font-size: 44px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { min-height: 0; padding: 28px; }
  .auth-form { padding: 28px; }
  .row-form { grid-template-columns: 64px 1fr 50px; }
  .row-form .btn { grid-column: 1 / -1; }
}
@media (max-width: 520px) {
  .figures { grid-template-columns: 1fr; }
  .figures > div { border-inline-start: 0 !important; }
  .figures > div + div { border-top: 1px solid var(--line); }
  .stages a, .stage-row { grid-template-columns: 100px 1fr 30px; }
  .analytics-filters > * { width: 100%; }
  .custom-dates.visible { width: 100%; flex-direction: column; }
  .donut-layout { grid-template-columns: 1fr; justify-items: center; }
  .donut-layout ul { width: 100%; }
  .analytics-bars li { grid-template-columns: minmax(120px,1fr) auto; }
  .analytics-track { grid-column: 1 / -1; grid-row: 2; }
  .sales-chart { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== أزرار الإجراءات الموحدة ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: middle;
  transition: background .15s;
  box-sizing: border-box;
}
.act:hover { text-decoration: none; }
.act:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.act svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.act-view {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}
.act-view:hover {
  background: var(--pine-soft);
}

.act-edit {
  color: var(--pine);
  background: var(--pine-soft);
  border-color: transparent;
}
.act-edit:hover {
  background: color-mix(in srgb, var(--pine) 24%, white);
}

.act-delete {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}
.act-delete:hover {
  background: var(--danger);
  color: #fff;
}

.act-toggle-off {
  color: var(--gold);
  background: var(--gold-soft);
  border-color: transparent;
}
.act-toggle-off:hover {
  background: color-mix(in srgb, var(--gold) 24%, white);
}

.act-toggle-on {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
  border-color: transparent;
}
.act-toggle-on:hover {
  background: color-mix(in srgb, var(--ok) 22%, transparent);
}

.act-save {
  color: var(--pine);
  background: var(--pine-soft);
  border-color: transparent;
}
.act-save:hover {
  background: color-mix(in srgb, var(--pine) 24%, white);
}

.act-whatsapp {
  color: #1F8F55;
  background: color-mix(in srgb, #1F8F55 12%, transparent);
  border-color: transparent;
}
.act-whatsapp:hover {
  background: color-mix(in srgb, #1F8F55 22%, transparent);
}

.act-call {
  color: var(--pine);
  background: var(--pine-soft);
  border-color: transparent;
}
.act-call:hover {
  background: color-mix(in srgb, var(--pine) 24%, white);
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: nowrap;
}
.actions form {
  display: inline-flex;
  margin: 0;
  padding: 0;
  border: 0;
}

th.col-actions, td.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: left;
}
.table th:last-child {
  text-align: left;
}

@media (max-width: 860px) {
  .actions .act {
    min-width: 36px;
    min-height: 36px;
    padding: 0 8px;
    justify-content: center;
  }
  .actions .act span:not(.sr-only) {
    display: none;
  }
}

/* ===== نافذة التأكيد (Modal Dialog) ===== */
.confirm-dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  padding: 24px;
  max-width: 440px;
  width: calc(100% - 32px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
}
.confirm-dialog::backdrop {
  background: rgba(10, 25, 21, 0.55);
  backdrop-filter: blur(2px);
}
.confirm-dialog h3 {
  font-size: 18px;
  margin-bottom: 8px;
}
.confirm-dialog p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== تبويبات الإعدادات ===== */
.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.settings-tabs a {
  padding: 8px 18px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  transition: all .15s;
}
.settings-tabs a:hover {
  background: var(--pine-soft);
  text-decoration: none;
}
.settings-tabs a.active {
  background: var(--pine);
  border-color: var(--pine);
  color: #fff;
}

/* ===== مفتاح التبديل (CSS Toggle) ===== */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  font-weight: 500;
  font-size: 14px;
}
.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}
.toggle-track {
  width: 46px;
  height: 24px;
  background: var(--line);
  border-radius: 99px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.toggle input:checked + .toggle-track {
  background: var(--pine);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(-22px);
}
.toggle input:focus-visible + .toggle-track {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ===== الشعار والصور الرمزية ===== */
.brand-logo {
  max-width: 110px;
  max-height: 38px;
  object-fit: contain;
}
.brand-logo.big {
  max-width: 180px;
  max-height: 64px;
  object-fit: contain;
}
.avatar-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.avatar-img.lg {
  width: 72px;
  height: 72px;
}
.avatar-img.sm {
  width: 28px;
  height: 28px;
}
.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ===== معاينة العملة ومؤشر قوة كلمة المرور ===== */
.format-preview {
  background: var(--pine-soft);
  color: var(--pine-dark);
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pw-strength {
  height: 6px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}
.pw-strength span {
  display: block;
  height: 100%;
  width: 0;
  transition: width .25s, background .25s;
}
.pw-strength.weak span { width: 33%; background: var(--danger); }
.pw-strength.medium span { width: 66%; background: var(--gold); }
.pw-strength.strong span { width: 100%; background: var(--ok); }

/* ===== الوضع الداكن (Dark Theme) ===== */
[data-theme="dark"] {
  --bg: #101916;
  --surface: #172420;
  --ink: #EDF3F0;
  --muted: #8FA29A;
  --line: #263832;
  --pine: #289981;
  --pine-dark: #0B1613;
  --pine-soft: #1D332C;
  --gold: #DFA030;
  --gold-soft: #382B14;
  --ok: #38A169;
  --danger: #D64532;
  --danger-soft: #381B17;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
[data-theme="dark"] .table tbody tr:hover td { background: #1C2D27; }
[data-theme="dark"] .table td { border-bottom-color: var(--line); }
[data-theme="dark"] .seg span { background: var(--surface); border-color: var(--line); color: var(--ink); }
[data-theme="dark"] .tbar { background: #253731; }
[data-theme="dark"] .act-view { background: var(--surface); border-color: var(--line); color: var(--ink); }

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"], html:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #101916;
    --surface: #172420;
    --ink: #EDF3F0;
    --muted: #8FA29A;
    --line: #263832;
    --pine: #289981;
    --pine-dark: #0B1613;
    --pine-soft: #1D332C;
    --gold: #DFA030;
    --gold-soft: #382B14;
    --ok: #38A169;
    --danger: #D64532;
    --danger-soft: #381B17;
  }
  :root[data-theme="system"] input,
  :root[data-theme="system"] select,
  :root[data-theme="system"] textarea,
  html:not([data-theme="light"]):not([data-theme="dark"]) input,
  html:not([data-theme="light"]):not([data-theme="dark"]) select,
  html:not([data-theme="light"]):not([data-theme="dark"]) textarea {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line);
  }
  :root[data-theme="system"] .table tbody tr:hover td,
  html:not([data-theme="light"]):not([data-theme="dark"]) .table tbody tr:hover td { background: #1C2D27; }
  :root[data-theme="system"] .table td,
  html:not([data-theme="light"]):not([data-theme="dark"]) .table td { border-bottom-color: var(--line); }
  :root[data-theme="system"] .seg span,
  html:not([data-theme="light"]):not([data-theme="dark"]) .seg span { background: var(--surface); border-color: var(--line); color: var(--ink); }
  :root[data-theme="system"] .tbar,
  html:not([data-theme="light"]):not([data-theme="dark"]) .tbar { background: #253731; }
  :root[data-theme="system"] .act-view,
  html:not([data-theme="light"]):not([data-theme="dark"]) .act-view { background: var(--surface); border-color: var(--line); color: var(--ink); }
}

/* ===== نظام الإشعارات ===== */
.notif-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.notif-btn {
  position: relative;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
}
.notif-btn:hover { background: var(--pine-soft); color: var(--pine); }
.notif-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notif-btn.has-unread { color: var(--pine); }

.notif-badge {
  position: absolute;
  top: 0; left: 0;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  transform: translate(30%, -30%);
  animation: notif-pop .25s ease;
}
.notif-badge[hidden] {
  display: none !important;
}
@keyframes notif-pop {
  0%   { transform: translate(30%, -30%) scale(0); }
  70%  { transform: translate(30%, -30%) scale(1.2); }
  100% { transform: translate(30%, -30%) scale(1); }
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: auto;
  width: 360px;
  max-width: min(360px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notif-slide .18s ease;
}
.notif-panel[hidden] {
  display: none !important;
}
html[dir="rtl"] .notif-panel,
[dir="rtl"] .notif-panel {
  left: 0;
  right: auto;
}
html[dir="ltr"] .notif-panel,
[dir="ltr"] .notif-panel {
  left: auto;
  right: 0;
}
@keyframes notif-slide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.notif-panel-head h3 { font-size: 15px; font-weight: 600; margin: 0; }
.notif-read-all {
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  color: var(--pine);
  padding: 4px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.notif-read-all:hover { background: var(--pine-soft); }

.notif-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 380px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: background .12s;
  align-items: flex-start;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--pine-soft); }
.notif-item.unread { background: #EBF4F0; }
.notif-item.unread:hover { background: #D8EDE6; }

.notif-item-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--pine-soft);
  color: var(--pine);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.notif-item.unread .notif-item-icon { background: var(--pine); color: #fff; }
.notif-item-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.notif-item-text  { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-item-time  { font-size: 11px; color: var(--muted); margin-top: 3px; }

.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--pine);
  flex-shrink: 0;
  margin-top: 5px;
  align-self: flex-start;
}

.notif-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}
.notif-empty svg { width: 40px; height: 40px; stroke: var(--line); fill: none; stroke-width: 1.5; display: block; margin: 0 auto 10px; }

.notif-panel-foot {
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  text-align: center;
}
.notif-panel-foot a { font-size: 13px; color: var(--pine); }

/* صفحة الإشعارات الكاملة */
.notif-page-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: flex-start;
}
.notif-page-item:last-child { border-bottom: 0; }
.notif-page-item.unread .notif-item-title { color: var(--pine); }
.notif-page-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--pine-soft);
  color: var(--pine);
  font-weight: 600;
}

/* Dark mode للإشعارات */
[data-theme="dark"] .notif-panel,
[data-theme="dark"] .notif-item { background: #1A2B25; }
[data-theme="dark"] .notif-item:hover { background: #1F3329; }
[data-theme="dark"] .notif-item.unread { background: #1D2F28; }
[data-theme="dark"] .notif-item.unread:hover { background: #223A31; }
[data-theme="dark"] .notif-btn:hover { background: rgba(255,255,255,.07); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) .notif-panel,
  html:not([data-theme="light"]):not([data-theme="dark"]) .notif-item { background: #1A2B25; }
  html:not([data-theme="light"]):not([data-theme="dark"]) .notif-item.unread { background: #1D2F28; }
}

