/*
 * لوحة الإحصائيات (حساب الزبون ولوحة الأدمن): لون واحد (كحلي KONTAKTI)، شبكة خفيفة، أعمدة رفيعة.
 * بتتأقلم مع عرض المكان اللي هي فيه (container query)، مش مع عرض الشاشة.
 */
.st {
  --st-ink: #1e3a5f;
  --st-ink-strong: #001f3f;
  --st-track: #e4e8d8;
  container-type: inline-size;
  transition: opacity 0.2s ease;
}

.st.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

.st > * + * {
  margin-top: 14px;
}

/* ---------- الفلتر ---------- */
.st-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.st-range {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--st-track);
}

.st-range button {
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.st-range button:hover {
  color: var(--navy);
}

.st-range button[aria-checked="true"] {
  background: #f6f7ed;
  color: var(--navy);
  box-shadow: 0 1px 2px rgba(0, 31, 63, 0.12);
}

.st-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.st-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16a34a;
  animation: st-live 2s ease-out infinite;
}

@keyframes st-live {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.45); }
  100% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
}

/* ---------- الملاحظات ---------- */
.st-notes {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* الفراغ بين الفلتر والملاحظات (القاعدة فوق بتصفّر الهامش، فبيلزق الصندوق بالفلتر) */
.st > .st-notes {
  margin-top: 16px;
}

.st-notes li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--brand-soft);
  font-size: 0.92rem;
  color: var(--ink-2);
}

.st-notes li > i {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: var(--navy);
  color: #f6f7ed;
  font-size: 0.85rem;
}

.st-notes b {
  color: var(--navy);
}

/* ---------- الأرقام الأربعة ---------- */
.st-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@container (min-width: 620px) {
  .st-tiles {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.st-tile {
  position: relative;
  display: grid;
  gap: 2px;
  align-content: start;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--field, #eef0e3);
  border: 1px solid var(--line);
  overflow: hidden;
}

.st-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.st-value {
  font-family: "Manrope", var(--font);
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--navy);
  direction: ltr;
  text-align: right;
}

.st-tile-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 6px;
  min-height: 1.3em;
  font-size: 0.74rem;
  color: var(--muted);
}

.st-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  color: var(--muted);
}

.st-delta i {
  font-size: 0.85em;
}

.st-delta.is-up {
  color: #157347;
}

.st-delta.is-down {
  color: #b42318;
}

.st-spark {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 8px;
  overflow: visible;
}

.st-spark path {
  fill: none;
  stroke: var(--slate);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.st-spark circle {
  fill: var(--st-ink-strong);
  stroke: var(--field, #eef0e3);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

/* ---------- البطاقات ---------- */
.st-card {
  margin: 0;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f6f7ed;
}

.st-card h4,
.st-chart figcaption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
}

.st-card h4 small,
.st-chart figcaption small {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- الزيارات كل يوم ---------- */
.st-plot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  height: 190px;
}

.st-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: left;
  transform: translateY(-0.5em);
  margin-bottom: -1em;
}

.st-area {
  position: relative;
}

.st-grid {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.st-grid i {
  height: 1px;
  background: var(--line);
}

.st-cols {
  position: absolute;
  inset: 0;
  display: flex;
  gap: 2px;
  align-items: stretch; /* RTL: الأقدم عاليمين والأحدث عاليسار، متل اتجاه القراءة */
}

.st-col {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.st-col:hover,
.st-col.is-on {
  background: var(--st-track);
}

.st-bar {
  display: block;
  width: 100%;
  max-width: 24px;
  border-radius: 4px 4px 0 0;
  background: var(--st-ink);
  transition: height 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.st-cols.is-dense .st-bar {
  border-radius: 2px 2px 0 0;
}

.st-col.is-on .st-bar,
.st-col:hover .st-bar {
  background: var(--st-ink-strong);
}

.st-xaxis {
  position: relative;
  container-type: inline-size;
  height: 20px;
  margin-top: 6px;
  margin-inline-start: 36px;
  font-size: 0.72rem;
  color: var(--muted);
}

.st-xaxis span {
  position: absolute;
  right: calc(var(--at) * 100%);
  transform: translateX(50%);
  white-space: nowrap;
}

.st-xaxis b {
  font-weight: inherit;
}

.st-x-short {
  display: none;
}

/* رسم ضيق (موبايل): التواريخ القصيرة، لحتى ما يركبوا فوق بعض */
@container (max-width: 520px) {
  .st-x-long {
    display: none;
  }

  .st-x-short {
    display: inline;
  }
}

/* ضيق كتير: بس أول وآخر تاريخ */
@container (max-width: 200px) {
  .st-xaxis span:not(:first-child):not(:last-child) {
    display: none;
  }
}

.st-xaxis span:first-child {
  right: 0;
  transform: none;
}

.st-xaxis span:last-child {
  right: auto;
  left: 0;
  transform: none;
}

.st-tip {
  position: absolute;
  top: -8px;
  z-index: 5;
  display: grid;
  gap: 2px;
  min-width: 150px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--navy);
  color: rgba(246, 247, 237, 0.78);
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: 0 10px 24px -12px rgba(0, 31, 63, 0.6);
  pointer-events: none;
  transform: translateY(-100%);
}

.st-tip b {
  margin-bottom: 2px;
  color: #f6f7ed;
  font-size: 0.82rem;
}

.st-tip strong {
  color: #f6f7ed;
  font-family: "Manrope", var(--font);
}

/* ---------- اللوحات الصغيرة ---------- */
.st-panels {
  display: grid;
  gap: 12px;
}

@container (min-width: 620px) {
  .st-panels {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .st-wide {
    grid-column: 1 / -1;
  }
}

.st-bars {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.st-bars li {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.st-bars-ico {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--st-track);
  color: var(--navy);
  font-size: 0.85rem;
}

.st-flag {
  font-size: 1.1rem;
  line-height: 1;
}

.st-bars-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.st-bars-text {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 0.86rem;
}

.st-bars-text b {
  font-weight: 600;
  white-space: nowrap;
}

.st-bars-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.75rem;
}

.st-bars-track {
  height: 6px;
  border-radius: 3px;
  background: var(--st-track);
  overflow: hidden;
}

.st-bars-track span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--st-ink);
}

.st-bars-val {
  display: grid;
  justify-items: end;
  min-width: 42px;
  line-height: 1.25;
}

.st-bars-val b {
  font-family: "Manrope", var(--font);
  font-weight: 600;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.st-bars-val small {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

/* ---------- أوقات الذروة ---------- */
.st-hm {
  display: grid;
  grid-template-columns: auto repeat(8, minmax(0, 1fr));
  gap: 3px;
  align-items: center;
}

.st-hm-day {
  padding-inline-end: 8px;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.st-hm-hour {
  font-size: 0.68rem;
  color: var(--muted);
  text-align: center;
}

.st-cell {
  display: block;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  cursor: default;
  transition: transform 0.12s ease;
}

button.st-cell:hover,
button.st-cell:focus-visible {
  transform: scale(1.12);
  outline: 2px solid var(--navy);
  outline-offset: 1px;
}

/* درجات الكحلي: من شبه فاضي لغامق (الأفتح = صفر) */
.st-cell.s0 { background: #eef0e3; }
.st-cell.s1 { background: #d6dee8; }
.st-cell.s2 { background: #a9bbd0; }
.st-cell.s3 { background: #7896b5; }
.st-cell.s4 { background: #3f5f86; }
.st-cell.s5 { background: #001f3f; }

.st-hm-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 12px;
  font-size: 0.72rem;
  color: var(--muted);
}

.st-hm-legend .st-cell {
  width: 16px;
  height: 12px;
  border-radius: 3px;
}

.st-hm-legend span {
  margin-inline: 4px;
}

.st-hm-tip {
  top: 0;
  transform: none;
  min-width: 0;
  white-space: nowrap;
}

/* ---------- عام ---------- */
.st-empty {
  margin: 0;
  padding: 18px 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.st-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
}

.st-foot i {
  flex: none;
}

@media (prefers-reduced-motion: reduce) {
  .st-live-dot {
    animation: none;
  }

  .st-bar,
  .st-cell {
    transition: none;
  }
}

/* الإنجليزي: الأيام من اليسار (الأقدم) لليمين (اليوم)، فالتواريخ تحت كمان */
[dir="ltr"] .st-xaxis span {
  right: auto;
  left: calc(var(--at) * 100%);
  transform: translateX(-50%);
}

[dir="ltr"] .st-xaxis span:first-child {
  left: 0;
  right: auto;
  transform: none;
}

[dir="ltr"] .st-xaxis span:last-child {
  left: auto;
  right: 0;
  transform: none;
}
