/* Tổng quan doanh số – dashboard biểu đồ */
.revenue-dashboard { --dash-grid: #e8edf3; --dash-base: #cfd7e2; --dash-axis: #7b879a; display: grid; gap: 16px; min-width: 0; }
.dash-head { display: grid; gap: 4px; }
.dash-meta { min-height: 18px; }
.dash-cache { min-height: 28px; }
.dash-head h1 { font-size: var(--text-heading); }
.dash-meta, .dash-sub { color: var(--muted); font-size: var(--text-caption); line-height: 1.5; }

/* Bộ lọc: một hàng phía trên mọi biểu đồ */
.dash-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px 12px; }
.dash-field { display: grid; gap: 4px; font-size: var(--text-caption); color: var(--muted); }
.dash-field input, .dash-field select { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-small); }
.dash-field select { max-width: 200px; }
.dash-seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: #e9edf3; }
.dash-seg button { border: 0; background: none; color: var(--muted); font: inherit; font-size: var(--text-small); font-weight: 600; padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.dash-seg button:hover { color: var(--ink); }
.dash-seg button[aria-pressed=true] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px #0f1d331f; }
.dash-seg.is-small button { font-size: var(--text-caption); padding: 5px 10px; }

.dash-content { display: grid; gap: 16px; transition: opacity .15s; }
.dash-content.is-loading { opacity: .5; pointer-events: none; }

/* Chỉ số: một số chính (hero) + các ô phụ */
.dash-kpis { display: grid; grid-template-columns: minmax(0, 2fr) repeat(5, minmax(0, 1fr)); gap: 12px; }
.dash-tile { display: grid; align-content: start; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.dash-tile-label { font-size: var(--text-caption); color: var(--muted); }
.dash-tile strong { font-size: var(--text-heading); font-weight: 700; color: var(--ink); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-tile-sub { font-size: var(--text-caption); color: var(--muted); }
.dash-tile.is-hero { align-content: center; background: linear-gradient(135deg, #fff, var(--blue-50)); }
.dash-tile.is-hero strong { font-size: var(--text-heading); letter-spacing: -.02em; }
.dash-tile.is-hero .dash-tile-label { font-size: var(--text-small); font-weight: 600; color: var(--ink); }

/* Lưới biểu đồ */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.dash-card { display: grid; align-content: start; gap: 12px; min-width: 0; }
.dash-card.is-wide { grid-column: 1 / -1; }
.dash-card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.dash-card-head h2 { font-size: var(--text-body); margin: 0; }
.dash-card-head .dash-seg, .dash-mini { margin-left: auto; }
.dash-mini { width: auto; max-width: 140px; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; font-size: var(--text-caption); }
.dash-plot { min-width: 0; }
.dash-plot svg { display: block; overflow: visible; font-family: var(--font); fill: currentColor; stroke: none; stroke-width: 0; }
.dash-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--text-caption); color: var(--muted); }
.dash-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dash-legend i { width: 10px; height: 10px; border-radius: 3px; }

line.dash-gridline { stroke: var(--dash-grid); stroke-width: 1; }
line.dash-base { stroke: var(--dash-base); stroke-width: 1; }
line.dash-cross { stroke: var(--dash-axis); stroke-width: 1; pointer-events: none; }
text.dash-axis { fill: var(--dash-axis); font-size: var(--text-caption); font-variant-numeric: tabular-nums; }
text.dash-label { fill: var(--ink); font-size: var(--text-caption); font-weight: 600; }
.dash-plot svg text { pointer-events: none; }
text.dash-empty { fill: var(--muted); font-size: var(--text-small); }
text.dash-name { fill: var(--ink); font-size: var(--text-small); }
rect.dash-track { fill: #f1f4f8; }
path.dash-line { fill: none; stroke: #2a78d6; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
path.dash-area { fill: #2a78d6; fill-opacity: .1; stroke: none; }
circle.dash-dot { fill: #2a78d6; stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.dash-plot g { transition: opacity .12s; }
.dash-plot svg:has(g.is-on) g:not(.is-on) path { opacity: .55; }
.dash-hit { cursor: pointer; outline: none; }
.dash-hit:focus-visible { stroke: var(--ink); stroke-width: 1; }

/* Tooltip: giá trị trước, nhãn sau */
.dash-tip { position: fixed; z-index: 80; pointer-events: none; min-width: 150px; max-width: 280px; padding: 9px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: var(--text-caption); }
.dash-tip-title { color: var(--muted); margin-bottom: 4px; }
.dash-tip-row { display: grid; grid-template-columns: 12px auto 1fr; align-items: center; gap: 8px; }
.dash-tip-row i { width: 12px; height: 2px; border-radius: 1px; }
.dash-tip-row strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-tip-row span { color: var(--muted); }

/* Bảng số liệu (thu gọn) */
.dash-table summary, .dash-how summary { cursor: pointer; font-size: var(--text-caption); color: var(--muted); font-weight: 600; }
.dash-table[open] summary { margin-bottom: 8px; }
.revenue-table-scroll { overflow: auto; }
.revenue-table-scroll table { width: 100%; border-collapse: collapse; font-size: var(--text-small); }
.revenue-table-scroll th, .revenue-table-scroll td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
.revenue-table-scroll th { color: var(--muted); font-weight: 600; font-size: var(--text-caption); }
.dash-how p { margin-top: 8px; font-size: var(--text-caption); color: var(--muted); line-height: 1.6; }

/* Khách lâu chưa chăm sóc */
.dash-stale { list-style: none; margin: 0; padding: 0; display: grid; max-height: 360px; overflow: auto; }
.dash-stale li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: var(--text-small); }
.dash-stale a { color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-stale a:hover { color: var(--blue); text-decoration: underline; }
.dash-pill { flex: none; font-size: var(--text-caption); color: var(--muted); background: #f1f4f8; border-radius: 99px; padding: 2px 8px; font-variant-numeric: tabular-nums; }
.dash-pill.is-never { color: var(--amber); background: var(--amber-50); }
.revenue-pager { display: flex; align-items: center; gap: 10px; font-size: var(--text-small); color: var(--muted); }

@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-tile.is-hero { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dash-tile.is-hero strong { font-size: var(--text-heading); }
  .dash-tile strong { font-size: var(--text-heading); }
  .dash-seg { width: 100%; } .dash-seg button { flex: 1; padding: 7px 4px; }
  .dash-card-head .dash-seg { margin-left: 0; }
  .dash-field { flex: 1 1 130px; } .dash-field input, .dash-field select { width: 100%; max-width: none; }
}

/* ---- Điểm KPI Sale: danh sách người (Manager), biểu đồ tròn + bảng chi tiết. */
.dash-kpi { display: grid; gap: 16px; }
.dash-kpi > [aria-busy="true"] { min-height: 330px; }
@media (max-width: 760px) {
  .dash-meta { min-height: 36px; }
  .dash-cache { min-height: 46px; }
  .dash-kpi > [aria-busy="true"] { min-height: 650px; }
}
.dash-report-card { min-width: 0; border-top: 1px solid var(--line); padding-top: 16px; }
.dash-report-card > h3 { margin: 0 0 10px; font-size: var(--text-body); }
.dash-report-body { display: grid; gap: 10px; min-height: 120px; }
.dash-report-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.dash-report-stats .dash-tile { padding: 12px; }
.dash-report-stats .dash-tile strong { font-size: 16px; white-space: normal; overflow-wrap: anywhere; }
.dash-report-details > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.dash-report-details .report-score-card { margin: 0; }
.dash-report-links { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { .dash-report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-kpi-main { display: grid; grid-template-columns: minmax(220px, 260px) minmax(0, 1fr); gap: 20px; align-items: start; }
.dash-kpi-chart { display: grid; justify-items: center; gap: 8px; }
.dash-kpi-name { margin: 0; font-weight: 600; }
.dash-donut path { stroke: #fff; stroke-width: 1.5; }
.dash-donut text { stroke: none; }
.dash-donut .dash-hit { outline: none; }
.dash-donut .dash-hit:focus-visible path { stroke: #1d2b24; stroke-width: 2; }
.dash-donut .dash-donut-value { font-size: 28px; font-weight: 700; fill: var(--ink, #1d2b24); }
.dash-donut .dash-donut-label { font-size: 12px; font-weight: 400; fill: var(--muted, #6b7a72); }
.dash-donut .dash-donut-missing { fill: var(--dash-track, #e3e9e6); }
.dash-donut g.is-on path, .dash-donut g:focus path { opacity: .82; }
.dash-kpi-table { width: 100%; border-collapse: collapse; }
.dash-kpi-table th, .dash-kpi-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line, #e3e9e6); }
.dash-kpi-table th:not(:first-child), .dash-kpi-table td:not(:first-child) { text-align: right; }
.dash-kpi-table td strong { display: block; font-weight: 600; }
.dash-kpi-table td small { display: block; color: var(--muted, #6b7a72); font-size: 12px; }
#view-dashboard .dash-kpi-table { display: table !important; min-width: 0 !important; }
#view-dashboard .dash-kpi-table tr { display: table-row !important; }
#view-dashboard .dash-kpi-table :is(td, th) { display: table-cell !important; white-space: normal !important; }
.dash-kpi-table tr.is-total td { font-weight: 700; border-bottom: 0; }
.dash-kpi-key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }
.dash-kpi-notes { margin: 10px 0 0; padding-left: 18px; color: var(--muted, #6b7a72); font-size: var(--text-small, 13px); display: grid; gap: 4px; }
.dash-kpi-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.dash-kpi-person { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name value" "bar bar"; gap: 6px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line, #e3e9e6); border-radius: 8px; background: transparent; cursor: pointer; text-align: left; font: inherit; color: inherit; min-height: 44px; }
.dash-kpi-person[aria-pressed="true"] { border-color: #2a78d6; box-shadow: inset 0 0 0 1px #2a78d6; }
.dash-kpi-person-name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-kpi-person strong { grid-area: value; }
.dash-report-person-points { font-size:var(--text-caption);max-width:130px;text-align:right; }
.dash-report-person-summary { grid-area:bar;color:var(--muted);font-size:var(--text-caption);line-height:1.5; }
.dash-kpi-card.is-reports-only .dash-report-card > h3 { display:none; }
.dash-kpi-card.is-reports-only .dash-report-body[aria-busy="true"] { min-height:600px; }
.dash-kpi-card.is-reports-only .is-details-collapsed .dash-report-body[aria-busy="true"] { min-height:230px; }
@media(max-width:760px) {
  .dash-kpi-card.is-reports-only .dash-report-body[aria-busy="true"] { min-height:900px; }
  .dash-kpi-card.is-reports-only .is-details-collapsed .dash-report-body[aria-busy="true"] { min-height:380px; }
  .dash-kpi-card.is-reports-only .report-score-heading { flex-direction:column;align-items:flex-start; }
}
.dash-kpi-bar { grid-area: bar; height: 6px; border-radius: 3px; background: var(--dash-track, #e3e9e6); overflow: hidden; }
.dash-kpi-bar i { display: block; height: 100%; border-radius: 3px; }
.dash-kpi-bar i.is-high { background: #1a9e77; } .dash-kpi-bar i.is-low { background: #eb6834; } .dash-kpi-bar i.is-poor { background: #d92d20; }
.dash-kpi-score.is-high { color: #127a5b; fill: #127a5b; }
.dash-kpi-score.is-low { color: #9a4d00; fill: #9a4d00; }
.dash-kpi-score.is-poor { color: #b42318; fill: #b42318; }
.dash-kpi-card.is-loading .dash-kpi { opacity: .55; }
.dash-kpi-card .dash-mini { min-width: 110px; }
@media (max-width: 760px) { .dash-kpi-main { grid-template-columns: minmax(0, 1fr); } .dash-kpi-table th, .dash-kpi-table td { padding: 8px 6px; font-size: 13px; } }

/* Doanh số cửa hàng (NVBH / CHT): DS chung, chỉ tiêu, mốc thưởng, DS từng người */
.dash-store { display: grid; gap: 20px; }
.dash-store-one { display: grid; gap: 12px; min-width: 0; }
.dash-store-one + .dash-store-one { padding-top: 16px; border-top: 1px solid var(--line); }
.dash-store-name { margin: 0; font-size: var(--text-body, 15px); font-weight: 700; }
.dash-store-sub { margin: 4px 0 0; font-size: var(--text-small, 13px); font-weight: 600; color: var(--ink); }
.dash-store-tiles { grid-template-columns: minmax(0, 2fr) repeat(auto-fit, minmax(140px, 1fr)); }
.dash-store-bar { position: relative; height: 12px; margin: 6px 0 4px; border-radius: 6px; background: var(--dash-track, #e3e9e6); }
.dash-store-bar > i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: #eb6834; }
.dash-store-bar > i.is-on { background: #1a9e77; }
.dash-store-mark { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink, #1f2a37); border-radius: 1px; }
.dash-store-mark.is-done { background: #1a9e77; }
.dash-store-tiers tr.is-done td { color: #127a5b; font-weight: 600; }
.dash-store-people tr.is-me td { background: var(--blue-50, #eef5fd); }
.dash-store-people .dash-pill { margin-left: 6px; }
#view-dashboard .dash-store-tiers, #view-dashboard .dash-store-people { min-width: 560px !important; }
#view-dashboard .dash-store-tiers :is(td, th):not(:first-child), #view-dashboard .dash-store-people :is(td, th):not(:first-child) { white-space: nowrap !important; }
@media (max-width: 760px) {
  .dash-store-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.dash-kpi-drilldown{display:block;width:100%;text-align:right;border:0;background:transparent;color:#0065cc;padding:4px;cursor:pointer;border-radius:5px;font:inherit}
.dash-kpi-drilldown:hover{background:#eff6ff}.dash-kpi-drilldown:focus-visible{outline:2px solid #006fee}
.dash-kpi-popup{width:min(1100px,94vw);max-height:88dvh;padding:20px;border:1px solid #dce3eb;border-radius:14px;color:#172336;background:#fff;box-sizing:border-box}
.dash-kpi-popup::backdrop{background:#15253d66}.dash-kpi-popup header{display:flex;align-items:center;justify-content:space-between;gap:16px}.dash-kpi-popup h2{font-size:18px;margin:0}
.dash-kpi-detail-summary{padding:12px;background:#eff6ff;border-radius:8px}.dash-kpi-detail-warning{padding:10px;background:#fff7ed;color:#92400e;border-radius:8px}
.dash-kpi-detail-table{overflow:auto;max-height:55dvh}.dash-kpi-detail-table table{width:100%;border-collapse:collapse}.dash-kpi-detail-table td,.dash-kpi-detail-table th{padding:10px;border-bottom:1px solid #e2e8f0;text-align:left;vertical-align:top}.dash-kpi-detail-table th{background:#f4f7fa;position:sticky;top:0}.dash-kpi-detail-table td:nth-child(4){text-align:right;white-space:nowrap}.dash-kpi-detail-table td:nth-child(2){min-width:170px;max-width:350px;overflow-wrap:anywhere}
.dash-kpi-detail-pages{display:flex;align-items:center;justify-content:center;gap:14px;margin-top:14px}@media(max-width:600px){.dash-kpi-popup{padding:12px}.dash-kpi-popup h2{font-size:16px}}
.dash-kpi-detail-table table{display:table!important;min-width:660px}
.dash-kpi-detail-table tr{display:table-row!important}
.dash-kpi-detail-table :is(th,td){display:table-cell!important}
.dash-kpi-detail-table a{color:#0065cc;text-decoration:underline}

.dash-export{display:flex;flex-wrap:wrap;gap:8px;align-items:center;flex-basis:100%;border:1px solid var(--line,#dce4ec);border-radius:8px;background:var(--surface,#fff);padding:12px}.dash-export [role="status"]{font-size:12px;flex-basis:100%}
