/* Style riêng cho nhóm màn overview: Tổng quan, Tài chính, biểu đồ. */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }

/* Thanh chọn kỳ */
.ov-range { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.ov-range-label { font-size: 13px; }

/* Cần chú ý */
.ov-attention { border-left: 4px solid #e3a82b; }
.ov-attention .section-head h2 { display: flex; align-items: center; gap: 8px; }
.ov-more { margin-top: 12px; }
.ov-ok { color: var(--good); font-weight: 600; margin: 10px 0; }
.ov-alert { color: var(--danger); font-weight: 600; margin: 10px 0; }
.attention-item:hover .attention-go { color: var(--accent-strong); }

/* Biểu đồ cột */
.ov-summary { margin-bottom: 10px; color: var(--ink-2); }
.chart .axis-grid { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .axis-zero { stroke: var(--line-strong); }
.chart .axis-label { font-size: 11px; fill: var(--muted); }
.chart .bar-value { font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.chart .bar-group rect:not(.bar-hit) { transition: opacity .12s; }
.chart svg:hover .bar-group rect:not(.bar-hit) { opacity: 0.55; }
.chart svg .bar-group:hover rect:not(.bar-hit) { opacity: 1; }
.chart .bar-group:hover .bar-hit { fill: rgba(27, 26, 23, 0.04); }

.split-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: #eeeae1; margin: 12px 0 6px; }
.split-seg { display: block; height: 100%; }

/* Kênh bán */
.channel-bars { display: flex; flex-direction: column; gap: 10px; margin: 12px 0 16px; }
.channel-bar-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.channel-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-bar-stack { display: flex; flex-direction: column; gap: 4px; }
.channel-bar-row .num { display: flex; flex-direction: column; align-items: flex-end; }

/* Hiệu suất sale */
.ov-staff td .bar { margin-top: 6px; max-width: 240px; }

/* Khối nửa chiều rộng */
.ov-big { margin-bottom: 8px; }
.ov-big .stat-value { font-size: 24px; }
.ov-stage { display: grid; grid-template-columns: minmax(110px, 1fr) minmax(60px, 1.2fr) auto; gap: 12px; }
.ov-stage-label { font-weight: 500; }
.ov-flow-row { justify-content: space-between; }
.ov-subhead { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.ov-stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 6px 0 10px; }
.ov-stat-grid .stat-value { font-size: 18px; }
a.stat-box:hover { border-color: var(--line-strong); background: #fff; }
.ov-status-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ov-status { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 9px; }
.ov-status:hover { border-color: var(--line-strong); }

.ov-funnel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin-bottom: 10px; }
.ov-funnel-step { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--line); }
.ov-funnel-step:first-child { border-radius: 10px 0 0 10px; }
.ov-funnel-step:last-child { border-radius: 0 10px 10px 0; background: var(--good-bg); }
.ov-funnel-step + .ov-funnel-step { border-left: 0; }

.ov-product { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(60px, 1fr) auto; gap: 12px; }
.ov-product-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Radar khách hàng */
.ov-radar-sum { margin-bottom: 10px; }
.radar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.radar-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; background: var(--surface-2); }
.radar-spent { font-size: 18px; font-weight: 800; }
.radar-foot { margin-top: 6px; }

/* Tài chính */
.fin-card.is-highlight { border-left: 4px solid var(--accent-strong); }
.pl-table tr.pl-head td { font-weight: 700; }
.pl-table tr.pl-minus td:first-child { padding-left: 24px; }
.pl-table tr.pl-total td { font-weight: 800; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
.cash-strong { font-weight: 800; background: var(--surface-2); padding-left: 8px; padding-right: 8px; border-radius: 8px; }

@media (max-width: 860px) {
  .channel-bar-row { grid-template-columns: minmax(0, 1fr) auto; }
  .channel-bar-stack { grid-column: 1 / -1; grid-row: 2; }
  .ov-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-funnel { grid-template-columns: minmax(0, 1fr); }
  .ov-funnel-step, .ov-funnel-step:first-child, .ov-funnel-step:last-child { border-radius: 0; border-left: 1px solid var(--line); }
  .ov-funnel-step + .ov-funnel-step { border-top: 0; }
  .ov-stage, .ov-product { grid-template-columns: minmax(0, 1fr) auto; }
  .ov-stage .bar, .ov-product .bar { grid-column: 1 / -1; grid-row: 2; }
}

/* ---------- Đợt 7: popover "i" dùng chung (js/explain.js) ---------- */
.xp { position: relative; display: inline-block; vertical-align: middle; }
.xp > summary { list-style: none; }
.xp > summary::-webkit-details-marker { display: none; }
.xp-btn {
  width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer;
  font-size: 11px; font-weight: 700; font-style: italic; color: var(--muted); border: 1px solid var(--line-strong); background: var(--surface);
}
.xp-btn:hover, .xp[open] > .xp-btn { color: var(--ink); border-color: var(--ink-2); }
.xp-btn:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.xp-pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: -8px; width: min(340px, 86vw);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgba(27, 26, 23, 0.16);
  padding: 12px 14px; font-size: 13px; font-weight: 400; color: var(--ink); text-align: left; white-space: normal; text-transform: none; letter-spacing: 0;
}
.xp-right .xp-pop { left: auto; right: -8px; }
.xp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.xp-close { border: 0; background: none; font-size: 18px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 2px; }
.xp-sec h4 { margin: 10px 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.xp-sec p { margin: 0; color: var(--ink-2); }
.xp-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.xp-table td { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.xp-table td.num { text-align: right; white-space: nowrap; padding-left: 10px; }
.xp-table tr.xp-minus td { color: var(--ink-2); }
.xp-table tr.xp-total td { font-weight: 700; border-bottom: 1px solid var(--line-strong); }
.xp-table tr.xp-sub td { color: var(--muted); font-size: 12px; }

/* ---------- Tổng quan: thẻ KPI + sparkline ---------- */
.ov-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ov-kpi .kpi-head > .ellipsis { min-width: 0; }
.ov-kpi .kpi-value a:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.ov-spark { display: flex; flex-direction: column; gap: 2px; }
.ov-spark .spark { width: 100%; height: 34px; overflow: visible; }
.ov-spark .spark:focus-visible { outline: 2px solid var(--accent-strong); outline-offset: 2px; border-radius: 4px; }
.spark-pt circle { fill: transparent; }
.spark-pt.is-on circle { fill: var(--accent-strong); }
.spark-pt:hover circle { fill: var(--ink); }
.spark-tip:empty { display: none; }

/* Chọn kỳ + tùy chọn */
.chips-scroll { overflow-x: auto; scrollbar-width: none; }
.chips-scroll::-webkit-scrollbar { display: none; }
.chips-scroll .chips { flex-wrap: nowrap; width: max-content; }
.ov-custom { align-items: center; }
.ov-custom input[type=date] { width: auto; padding: 5px 8px; }

/* Tab trong khối */
.ov-tabs { margin-bottom: 10px; }
.ov-compare { font-weight: 600; margin: 4px 0 8px; }
.chart .avg-line { stroke: var(--ink-2); stroke-dasharray: 5 5; stroke-width: 1.2; }
.chart .avg-label { font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.chart .bar-group { cursor: pointer; outline: none; }
.chart .bar-group:focus-visible .bar-hit, .chart .bar-group.is-selected .bar-hit { fill: rgba(63, 143, 58, 0.12); }
.chart .bar-group:focus-visible rect:not(.bar-hit) { opacity: 1; }

/* Panel chi tiết inline (đơn ngày, nguồn, trạng thái, sản phẩm) */
.ov-panel { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.ov-panel h3 { margin: 0; font-size: 15px; }
.ov-panel .ov-stat-grid { margin-top: 10px; }
.ov-stat-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ov-day-order { justify-content: space-between; }
.ov-day-order .num { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }

button.list-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; font: inherit; color: inherit; }
button.list-row:hover, button.list-row.is-active { background: var(--surface-2); }
.ov-source { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(60px, 1.2fr) auto; gap: 12px; }
button.ov-status { background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
button.ov-status.is-active { border-color: var(--ink-2); background: var(--surface-2); }
.ov-quick { margin-top: 12px; }
.ov-staff-bar { display: block; margin-top: 6px; max-width: 240px; }
.ov-staff-bar .split-bar { margin: 0; height: 8px; }
.attention-tag { font-weight: 700; }
.attention-tag.danger { color: var(--danger); }
.attention-tag.warn { color: var(--warn); }

/* Kế hoạch hôm nay */
.ov-plan { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.ov-plan-item + .ov-plan-item { border-top: 1px solid var(--line); }
.ov-plan-item > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; }
.ov-plan-item > summary::-webkit-details-marker { display: none; }
.ov-plan-item > summary:hover { background: var(--surface-2); }
.ov-plan-n { font-size: 22px; font-weight: 800; min-width: 34px; text-align: right; }
.ov-plan-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ov-plan-go { color: var(--muted); transition: transform .15s; }
.ov-plan-item[open] .ov-plan-go { transform: rotate(90deg); }
.ov-plan-body { padding: 0 12px 12px 58px; }
.ov-plan-list { margin: 4px 0 8px; padding-left: 18px; }
.ov-plan-list li { margin: 2px 0; }

/* Radar dạng danh sách */
ul.radar-grid { list-style: none; margin: 0; padding: 0; }

/* Thêm chỉ số: sức khỏe + AI */
.ov-more-metrics > summary { cursor: pointer; padding: 2px 0; }
.ov-more-metrics[open] > summary { margin-bottom: 12px; }
.ov-health h3, .ov-ai h3 { margin: 0; font-size: 16px; }
.ov-health-score { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.ov-health-score strong { font-size: 26px; }
.ov-pillars { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ov-pillar { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.ov-pillar > summary { list-style: none; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 10px; align-items: center; padding: 8px 10px; cursor: pointer; }
.ov-pillar > summary::-webkit-details-marker { display: none; }
.ov-pillar-score { font-weight: 800; }
.ov-pillar-comment { grid-column: 1 / -1; }
.ov-pillar-body { padding: 0 10px 10px; color: var(--ink-2); }
.ov-pillar-body p { margin: 4px 0; }

@media (max-width: 860px) {
  .ov-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-kpi .kpi-value { font-size: 20px; }
  .ov-stat-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-source { grid-template-columns: minmax(0, 1fr) auto; }
  .ov-source .bar { grid-column: 1 / -1; grid-row: 2; }
  .ov-plan-body { padding-left: 12px; }
  .xp-pop { position: fixed; left: 12px !important; right: 12px !important; top: auto; bottom: 84px; width: auto; max-height: 60vh; overflow: auto; }
}
