/* ══════════════════════════════════════════════════════════════
   الرئيسية — غرفةُ القيادة
   ══════════════════════════════════════════════════════════════
   ‏«الصفحة الرئيسية تكون على أعلى مستوى من الاحترافية» (المالك، 2/10).
   ‏ترتيبُها قرارٌ لا زينة: الحالُ في جملة، ثمّ الأرقامُ الأربعة في شريطٍ واحد، ثمّ ما
   ‏يحتاج يدَه مرتّبا بالإلحاح، ثمّ المتاجرُ والاتجاه والمحادثات. والأحمرُ لما يوقف البيع
   ‏وحده، والأرقامُ جدوليّة، والخطُّ بولت — ولا زجاجَ ولا تدرّج. */

.hm { display: grid; gap: 22px; }
.hm-num { font-variant-numeric: tabular-nums; }
.hm-panel { border-radius: 20px; border: 1px solid var(--border-default); background: var(--surface-1); box-shadow: 0 1px 0 rgba(15, 23, 32, .03), 0 14px 34px -24px rgba(15, 23, 32, .3); }
:root[data-theme="dark"] .hm-panel { box-shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 18px 40px -26px rgba(0, 0, 0, .9); }
.hm-panel-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 18px 22px 0; }
.hm-panel-head h3 { margin: 0; font-size: 16px; color: var(--text-strong); display: flex; align-items: center; gap: 9px; }
.hm-panel-head h3 svg { width: 18px; height: 18px; }
.hm-panel-head .hm-aside { margin-inline-start: auto; font-size: 13px; font-variant-numeric: tabular-nums; }
.hm-panel-head .hm-aside b { color: var(--text-strong); font-size: 15px; }
.hm-link { border: 0; background: transparent; color: var(--text-strong); font: inherit; font-size: 13px; font-weight: var(--fw-bold); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 8px; }
.hm-link:hover { background: var(--surface-3); }
.hm-link svg { width: 15px; height: 15px; }

/* ═════════════ الرأس ═════════════ */
.hm-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.hm-date { font-size: 13px; font-weight: var(--fw-bold); letter-spacing: .03em; }
.hm-top h1 { margin: 4px 0 6px; font-size: clamp(24px, 2.4vw, 32px); line-height: 1.3; color: var(--text-strong); letter-spacing: -.01em; }
.hm-brief { margin: 0; font-size: 15px; line-height: 1.8; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.hm-brief span { display: inline-flex; align-items: center; gap: 7px; }
.hm-brief i.dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.hm-brief .bad i.dot { background: var(--danger); }
.hm-brief .ok i.dot { background: var(--success); }
.hm-brief .neutral i.dot { background: var(--text-strong); }
.hm-period { display: inline-flex; gap: 3px; padding: 4px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--border-default); }
.hm-period .period-btn { min-height: 34px; padding: 6px 14px; border-radius: 9px; font-size: 13px; font-weight: var(--fw-bold); color: var(--text-strong); }
.hm-period .period-btn.active { background: var(--text-strong); color: var(--surface-1); }

/* ═════════════ شريطُ الأرقام ═════════════ */
.hm-strip { display: grid; grid-template-columns: 1.35fr 1fr 1fr 1fr; overflow: hidden; }
.hm-kpi { position: relative; display: grid; align-content: start; gap: 8px; padding: 20px 22px 18px; text-align: start; border: 0; background: transparent; color: inherit; font: inherit; min-width: 0; }
.hm-kpi + .hm-kpi { border-inline-start: 1px solid var(--border-subtle); }
button.hm-kpi { cursor: pointer; transition: background .15s; }
button.hm-kpi:hover { background: var(--surface-3); }
button.hm-kpi:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hm-kpi-label { font-size: 13px; font-weight: var(--fw-bold); display: flex; align-items: center; gap: 7px; }
.hm-kpi-label svg { width: 16px; height: 16px; }
.hm-kpi-value { font-size: clamp(26px, 2.5vw, 34px); line-height: 1.1; font-weight: var(--fw-bold); color: var(--text-strong); font-variant-numeric: tabular-nums; letter-spacing: -.01em; white-space: nowrap; }
.hm-kpi-value small { font-size: .55em; margin-inline-start: 4px; }
.hm-kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; min-height: 22px; }
.hm-chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; border: 1px solid var(--border-default); }
.hm-chip.up { color: var(--success-text); border-color: color-mix(in srgb, var(--success) 45%, transparent); background: var(--success-soft); }
.hm-chip.down { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, transparent); background: var(--danger-soft); }
.hm-chip.warn { color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 45%, transparent); background: var(--warning-soft); }
.hm-spark { position: absolute; inset-inline-end: 20px; top: 22px; width: 120px; height: 38px; }
.hm-spark path.line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.hm-spark path.area { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.hm-spark circle { fill: var(--accent); stroke: var(--surface-1); stroke-width: 2; }
.hm-kpi.locked .hm-kpi-value { color: var(--text-strong); opacity: .45; }

/* ═════════════ محتاج تدخلك ═════════════ */
.hm-attn { overflow: hidden; }
.hm-attn[data-urgent="1"] { border-color: color-mix(in srgb, var(--danger) 45%, var(--border-default)); }
.hm-attn .hm-panel-head { padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); align-items: center; }
.hm-count { min-width: 26px; height: 26px; padding: 0 8px; border-radius: 8px; display: inline-grid; place-items: center; font-size: 13px; font-weight: var(--fw-bold); background: var(--danger); color: #fff; font-variant-numeric: tabular-nums; }
.hm-count.calm { background: var(--surface-3); color: var(--text-strong); }
.hm-group-title { margin: 0; padding: 12px 22px 6px; font-size: 12px; font-weight: var(--fw-bold); letter-spacing: .05em; display: flex; align-items: center; gap: 8px; }
.hm-group-title i.dot { width: 8px; height: 8px; border-radius: 2px; }
.hm-group-title.urgent i.dot { background: var(--danger); }
.hm-group-title.watch i.dot { background: var(--warning); }
.hm-alert {
  width: 100%; display: grid; grid-template-columns: 4px 38px minmax(0, 1fr) auto; gap: 14px; align-items: center; text-align: start;
  padding: 11px 22px 11px 18px; border: 0; border-top: 1px solid var(--border-hairline); background: transparent; color: inherit; font: inherit; cursor: pointer;
  transition: background .15s;
}
.hm-group-title + .hm-alert { border-top: 0; }
.hm-alert:hover { background: var(--surface-3); }
.hm-alert:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
a.hm-alert { text-decoration: none; }   /* ‏سطرٌ وجهتُه خارجيّة (إصدارُ مكتبة) وصلةٌ لا زرّ — بلا خطٍّ تحته */
.hm-alert::before { content: ''; width: 4px; height: 30px; border-radius: 2px; background: var(--hm-tone); }
.hm-alert[data-tone="error"] { --hm-tone: var(--danger); --hm-soft: var(--danger-soft); }
.hm-alert[data-tone="warn"] { --hm-tone: var(--warning); --hm-soft: var(--warning-soft); }
.hm-alert[data-tone="info"] { --hm-tone: var(--info); --hm-soft: var(--info-soft); }
.hm-alert-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--hm-soft); color: var(--hm-tone); }
.hm-alert-ic svg { width: 19px; height: 19px; }
.hm-alert-txt { display: grid; gap: 2px; min-width: 0; }
.hm-alert-txt b { font-size: 14.5px; line-height: 1.55; color: var(--text-strong); overflow-wrap: anywhere; }
.hm-alert-txt small { font-size: 12.5px; line-height: 1.6; }
.hm-alert-go { display: inline-flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 9px; border: 1px solid var(--border-default); font-size: 12.5px; font-weight: var(--fw-bold); white-space: nowrap; }
.hm-alert:hover .hm-alert-go { background: var(--text-strong); border-color: var(--text-strong); color: var(--surface-1); }
.hm-alert-go svg { width: 14px; height: 14px; }
.hm-calm { display: flex; align-items: center; gap: 14px; padding: 18px 22px; }
.hm-calm span.mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--success-soft); color: var(--success-text); flex: none; }
.hm-calm span.mark svg { width: 20px; height: 20px; }
.hm-calm b { font-size: 15px; color: var(--text-strong); display: block; }
.hm-calm small { font-size: 13px; }

/* ═════════════ الشبكة ═════════════ */
.hm-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.hm > *, .hm-grid > * { min-width: 0; }

/* ── الاتجاه ── */
.hm-chart { padding: 0 22px 20px; }
.hm-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 14px 0 18px; border-radius: 14px; border: 1px solid var(--border-subtle); overflow: hidden; }
.hm-metrics div { padding: 10px 14px; display: grid; gap: 2px; }
.hm-metrics div + div { border-inline-start: 1px solid var(--border-subtle); }
.hm-metrics span { font-size: 12px; font-weight: var(--fw-bold); }
.hm-metrics b { font-size: 17px; color: var(--text-strong); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-bars { position: relative; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; align-items: end; height: 170px; padding-top: 18px; border-bottom: 1px solid var(--border-default); direction: ltr; }
.hm-bars::before { content: attr(data-max); position: absolute; top: 0; left: 0; font-size: 11px; font-weight: var(--fw-bold); color: var(--text-strong); opacity: .7; direction: rtl; }
.hm-bars::after { content: ''; position: absolute; left: 0; right: 0; top: 18px; border-top: 1px dashed var(--border-subtle); pointer-events: none; }
.hm-bar { position: relative; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.hm-bar i { display: block; width: 100%; min-height: 3px; border-radius: 5px 5px 2px 2px; background: color-mix(in srgb, var(--accent) 55%, var(--surface-3)); transition: background .15s; }
.hm-bar.zero i { background: var(--border-default); }
.hm-bar.today i { background: var(--accent); }
.hm-bar:hover i { background: var(--text-strong); }
.hm-bar .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); padding: 6px 9px; border-radius: 8px; background: var(--text-strong); color: var(--surface-1); font-size: 11.5px; font-weight: var(--fw-bold); white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 2; direction: rtl; }
.hm-bar:hover .tip { opacity: 1; }
.hm-bar.edge-l .tip { left: 0; transform: none; }
.hm-bar.edge-r .tip { left: auto; right: 0; transform: none; }
.hm-xlabels { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; margin-top: 7px; direction: ltr; font-size: 11px; font-weight: var(--fw-bold); text-align: center; }
.hm-xlabels span { white-space: nowrap; overflow: hidden; unicode-bidi: isolate; }
.hm-xlabels span:last-child { overflow: visible; direction: rtl; text-align: end; }
.hm-dist { margin-top: 20px; display: grid; gap: 10px; }
.hm-dist-title { font-size: 13px; font-weight: var(--fw-bold); color: var(--text-strong); }
.hm-dist-bar { display: flex; gap: 3px; height: 12px; border-radius: 6px; overflow: hidden; }
.hm-dist-bar i { display: block; height: 100%; min-width: 3px; }
.hm-dist-legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.hm-dist-legend div { display: grid; gap: 1px; padding-inline-start: 10px; border-inline-start: 3px solid var(--c); }
.hm-dist-legend b { font-size: 16px; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.hm-dist-legend span { font-size: 12px; }
.hm-empty { display: grid; justify-items: center; gap: 8px; padding: 34px 16px; text-align: center; font-size: 13.5px; }
.hm-empty svg { width: 26px; height: 26px; }

/* ── المحادثات ── */
.hm-list { display: grid; padding: 8px 10px 12px; }
.hm-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; border: 0; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; }
.hm-row:hover { background: var(--surface-3); }
.hm-avatar { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-3); border: 1px solid var(--border-default); font-size: 13px; font-weight: var(--fw-bold); color: var(--text-strong); }
.hm-row b { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hm-row small { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.hm-row time { font-size: 12px; font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.hm-tag { display: inline-flex; padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: var(--fw-bold); border: 1px solid var(--border-default); }
.hm-tag.warn { border-color: color-mix(in srgb, var(--warning) 55%, transparent); color: var(--warning-text); background: var(--warning-soft); }
.hm-tag.ok { border-color: color-mix(in srgb, var(--success) 55%, transparent); color: var(--success-text); background: var(--success-soft); }
.hm-tag.bad { border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger-text); background: var(--danger-soft); }
.hm-tag.info { border-color: color-mix(in srgb, var(--info) 55%, transparent); color: var(--info-text); background: var(--info-soft); }

/* ── الجداول ── */
.hm-table-wrap { overflow-x: auto; padding: 10px 6px 8px; }
.hm-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.hm-table th { text-align: start; font-size: 12px; font-weight: var(--fw-bold); padding: 8px 16px; border-bottom: 1px solid var(--border-default); white-space: nowrap; }
.hm-table td { padding: 12px 16px; border-bottom: 1px solid var(--border-hairline); white-space: nowrap; color: var(--text-strong); }
.hm-table tr:last-child td { border-bottom: 0; }
.hm-table .num { font-variant-numeric: tabular-nums; }
.hm-table tbody tr:hover td { background: var(--surface-3); }
.hm-table .store-key { display: block; font-size: 11px; font-weight: var(--fw-semibold); opacity: .7; direction: ltr; text-align: start; }
.hm-table tr.store-quiet td:first-child { box-shadow: inset -3px 0 0 var(--warning); }
.hm-table .store-silent { color: var(--warning-text); font-weight: var(--fw-bold); }
.hm-table .store-why { display: block; font-size: 11.5px; color: var(--danger-text); max-width: 280px; white-space: normal; line-height: 1.5; margin-top: 2px; }

/* ═════════════ الشاشات الصغيرة ═════════════ */
@media (max-width: 1180px) {
  .hm-strip { grid-template-columns: 1fr 1fr; }
  .hm-kpi:nth-child(3) { border-inline-start: 0; }
  .hm-kpi:nth-child(n+3) { border-top: 1px solid var(--border-subtle); }
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .hm { gap: 16px; }
  .hm-strip { grid-template-columns: minmax(0, 1fr); }
  .hm-kpi + .hm-kpi { border-inline-start: 0; border-top: 1px solid var(--border-subtle); }
  .hm-spark { width: 96px; }
  .hm-alert { grid-template-columns: 4px 34px minmax(0, 1fr); padding: 11px 14px 11px 12px; gap: 10px; }
  .hm-alert-go { display: none; }
  .hm-alert-ic { width: 34px; height: 34px; }
  .hm-panel-head { padding: 16px 16px 0; }
  .hm-group-title { padding: 12px 16px 6px; }
  .hm-chart { padding: 0 16px 16px; }
  .hm-bars { height: 140px; gap: 3px; }
  .hm-xlabels { gap: 3px; font-size: 10px; }
  .hm-dist-legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-metrics b { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) { .hm * { transition: none !important; } }
