/* ==========================================================================
   لوحة المؤشرات — تابات وبطاقات تملأ الشاشة بلا تمرير
   ========================================================================== */
.dash {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 0.7rem;
}

/* ---------- شريط العنوان والتابات والفترة ---------- */
.dash__bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.dash__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1.02rem;
  font-weight: 700;
  white-space: nowrap;
}
.dash__title i { color: var(--brand-600); font-size: 1.15rem; }

.dash__tabs {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.dash__tabs::-webkit-scrollbar { display: none; }

.dash__tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: 7px;
  white-space: nowrap;
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
}
.dash__tab:hover { background: color-mix(in srgb, var(--brand-500) 9%, transparent); color: var(--brand-600); }
.dash__tab.is-active {
  background: var(--chrome-900);
  color: #fff;
}

.dash__period {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.dash__range { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.dash__scale {
  display: flex;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
}
.dash__scale-btn {
  padding: 0.32rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-inline-start: 1px solid var(--card-border);
}
.dash__scale-btn:first-child { border-inline-start: 0; }
.dash__scale-btn:hover { background: color-mix(in srgb, var(--brand-500) 8%, transparent); color: var(--brand-600); }
.dash__scale-btn.is-active { background: var(--chrome-900); color: #fff; }

/* ---------- اللوحة الواحدة: صف مؤشرات + صفّي بطاقات ---------- */
.dash__panel { display: none; }
.dash__panel.is-active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.7rem;
  flex: 1;
  min-height: 0;
}

.dash__kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.6rem;
}

.dash__row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  min-height: 0;
}

/* ---------- مؤشر مختصر ---------- */
.dash-kpi {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  box-shadow: var(--shadow-card);
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.dash-kpi::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 3px;
  background: var(--accent, var(--brand-500));
}
.dash-kpi__icon {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 1rem;
  background: color-mix(in srgb, var(--accent, var(--brand-500)) 12%, transparent);
  color: var(--accent, var(--brand-500));
}
.dash-kpi__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.dash-kpi__label {
  font-size: 0.7rem; color: var(--text-muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-kpi__value {
  font-size: 1.02rem; font-weight: 700; color: var(--accent, var(--brand-600));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-kpi__hint {
  font-size: 0.65rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- بطاقة ---------- */
.dash-card {
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  min-height: 0;
  overflow: hidden;
}
.dash-card__head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--card-border);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--brand-500) 4%, var(--card-bg));
}
.dash-card__head i { color: var(--brand-600); font-size: 0.95rem; }
.dash-card__hint {
  margin-inline-start: auto;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.08rem 0.4rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--gold-500) 22%, transparent);
  color: #8a6100;
}
[data-bs-theme="dark"] .dash-card__hint { color: var(--gold-300); }

.dash-card__body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.35rem 0.55rem;
}

/* ---------- جدول داخل بطاقة ---------- */
.dash-table { width: 100%; font-size: 0.78rem; border-collapse: collapse; }
.dash-table th {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.2rem 0.35rem;
  text-align: start;
  border-bottom: 1px solid var(--card-border);
}
.dash-table td {
  padding: 0.28rem 0.35rem;
  border-bottom: 1px dashed var(--card-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-table td.num, .dash-table th:not(:first-child) { text-align: start; }
.dash-table tr:last-child td { border-bottom: 0; }
.dash-table tr.is-key td {
  background: color-mix(in srgb, var(--gold-500) 12%, transparent);
  font-weight: 700;
}
.dash-table tr.is-total td {
  background: color-mix(in srgb, var(--brand-500) 12%, transparent);
  font-weight: 700;
  border-top: 1px solid var(--brand-500);
}
.dash-table--bars td:first-child { max-width: 90px; }

/* ---------- مربعات صغيرة ---------- */
.dash-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  height: 100%;
  align-content: center;
  padding: 0.3rem;
}
.dash-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.6rem 0.3rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-strong);
  transition: border-color var(--transition-speed) ease;
}
.dash-tile:hover { border-color: var(--brand-500); color: var(--brand-600); }
.dash-tile__num { font-size: 1.4rem; font-weight: 700; color: var(--brand-600); line-height: 1; }
.dash-tile__label { font-size: 0.7rem; color: var(--text-muted); }

/* ---------- ملاحظات ---------- */
.dash-notes { display: flex; flex-direction: column; gap: 0.4rem; padding: 0.3rem; }
.dash-note {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-muted);
}
.dash-note i { color: var(--brand-600); margin-top: 0.1rem; flex-shrink: 0; }
.dash-note strong { color: var(--text-strong); }
.dash-note--warn i { color: #b8860b; }
[data-bs-theme="dark"] .dash-note--warn i { color: var(--gold-400); }

/* ---------- لوحة فارغة ---------- */
.dash-blank {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
}
.dash-blank i { font-size: 1.5rem; opacity: 0.35; }

/* ---------- شاشات أضيق ---------- */
@media (max-width: 1399.98px) {
  .dash__kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash__panel.is-active { grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr); }
}

@media (max-width: 991.98px) {
  .dash { height: auto; }
  .dash__panel.is-active { grid-template-rows: none; }
  .dash__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__row { grid-template-columns: 1fr; }
  .dash-card { min-height: 160px; }
  .dash__bar { gap: 0.5rem; }
  .dash__title { width: 100%; }
}
