:root {
  --primary: #FF6B35;
  --primary-soft: rgba(255, 107, 53, 0.14);
  --primary-glow: rgba(255, 107, 53, 0.35);
  --bg: #0A0A0F;
  --bg-2: #0E0E15;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F4F5F7;
  --muted: #8B90A0;
  --muted-2: #5A6072;
  --green: #2DD470;
  --red: #FF5470;
  --yellow: #F5B301;
  --radius: 16px;
  --radius-sm: 12px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: -0.02em;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(1100px 700px at 12% -8%, rgba(255, 107, 53, 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(99, 102, 241, 0.08), transparent 55%),
    var(--bg);
}
.muted-xs { color: var(--muted-2); font-size: 11px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 16px; border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0));
  position: sticky; top: 0; height: 100vh;
}
.brand-switch { display: flex; flex-direction: column; gap: 8px; }
.brand-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-weight: 600; font-size: 14px; transition: .18s;
}
.brand-btn:hover { border-color: var(--border-strong); color: var(--text); }
.brand-btn .swatch { width: 10px; height: 10px; border-radius: 3px; background: currentColor; opacity: .5; }
.brand-btn.active { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.brand-btn.active[data-brand="ICONDENIM"] { box-shadow: inset 3px 0 0 var(--primary); }
.brand-btn.active[data-brand="ICONDENIM"] .swatch { background: var(--primary); opacity: 1; }
.brand-btn.active[data-brand="160STORE"] { box-shadow: inset 3px 0 0 var(--yellow); }
.brand-btn.active[data-brand="160STORE"] .swatch { background: var(--yellow); opacity: 1; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; flex: 1; }
.nav .tab {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 12.5px; transition: .15s;
  text-transform: uppercase; letter-spacing: .04em;
}
.nav .tab:hover { background: var(--surface); color: var(--text); }
.nav .tab:hover .ic { color: var(--text); }
.nav .tab.active { background: var(--primary-soft); color: #ffb38f; }
.nav .tab .ic { display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; color: var(--muted-2); transition: .15s; flex: 0 0 20px; }
.nav .tab.active .ic { color: var(--primary); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 14px; }
.user-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.user-row .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }

/* ---------- Toolbar ---------- */
.main { min-width: 0; }
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; position: sticky; top: 0; z-index: 20;
  background: rgba(10,10,15,0.72); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.toolbar-title { font-size: 22px; font-weight: 700; }
.toolbar-controls { display: flex; align-items: center; gap: 10px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg-btn { border: none; background: none; color: var(--muted); padding: 6px 13px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; }
.seg-btn.active { background: var(--primary); color: #1a0d06; }
.sel {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; font-family: inherit; cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ff8255); color: #1a0d06;
  border: none; border-radius: 10px; padding: 9px 16px; font-weight: 700; font-size: 13px;
  cursor: pointer; font-family: inherit; box-shadow: 0 6px 18px var(--primary-glow); transition: .15s;
}
.btn-primary:hover { transform: translateY(-1px); }

/* ---------- Content ---------- */
.content { padding: 28px; max-width: 1500px; }
.loading { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--muted); padding: 80px; }
.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.note { background: linear-gradient(135deg, rgba(245,179,1,0.10), rgba(245,179,1,0.03)); border: 1px solid rgba(245,179,1,0.25); color: #f5d488; padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; }

/* Hero */
.hero {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 18px;
  padding: 26px 28px; margin-bottom: 24px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255,107,53,0.14), rgba(255,107,53,0.02));
  border: 1px solid rgba(255,107,53,0.22); position: relative; overflow: hidden;
}
.hero::after { content:''; position:absolute; right:-60px; top:-60px; width:220px; height:220px; background: radial-gradient(circle, var(--primary-glow), transparent 70%); }
.hero .h-label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.hero .h-value { font-size: 46px; font-weight: 800; line-height: 1.05; margin-top: 6px; }
.hero .h-meta { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* Section */
.section { margin-bottom: 28px; }
.section-head { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.section-head h2 { font-size: 15px; font-weight: 700; margin: 0; text-transform: uppercase; letter-spacing: .03em; color: var(--text); }
.section-head .bar { width: 4px; height: 16px; border-radius: 2px; background: var(--primary); }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 24px; }
.cards.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.cards.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .cards.kpis { grid-template-columns: repeat(3, minmax(0,1fr)); } .cards.g4 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 760px) { .cards.kpis { grid-template-columns: repeat(2, minmax(0,1fr)); } .cards.g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }

/* CHI TIET NAM (bang rong) */
.detail-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 0 6px; margin-bottom: 24px; }
.detail-head { display: flex; align-items: baseline; gap: 14px; padding: 0 20px 14px; }
.detail-head h3 { margin: 0; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; position: relative; padding-left: 12px; }
.detail-head h3::before { content: ''; position: absolute; left: 0; top: 2px; width: 4px; height: 15px; border-radius: 2px; background: var(--primary); }
.detail-note { color: var(--muted-2); font-size: 12px; margin-left: auto; padding-right: 20px; }
.detail-scroll { overflow: auto; max-height: 72vh; }
table.detail { border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; }
table.detail th, table.detail td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
/* Hang tieu de dinh top khi cuon doc */
table.detail th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; background: var(--bg-2); position: sticky; top: 0; z-index: 4; }
table.detail td.right, table.detail th.right { text-align: right; }
table.detail .sticky { position: sticky; left: 0; z-index: 3; background: #14151c; text-align: left; width: 168px; min-width: 168px; max-width: 168px; box-shadow: 1px 0 0 var(--border); }
table.detail th.sticky { z-index: 6; }
/* Cot cung ky (T-1) ghim cố định ngay sau cot HANG MUC khi re ngang */
table.detail .pin { position: sticky; left: 168px; z-index: 3; }
table.detail th.pin { z-index: 6; }
table.detail tr.hdr td { color: var(--primary); font-weight: 700; font-size: 14px; background: rgba(255,107,53,0.06); }
table.detail tr.hdr td.sticky { background: #1c150f; color: var(--primary); }
table.detail td.hl, table.detail th.hl { background: #2a1b10; color: #ffb38f; font-weight: 600; }
table.detail th.hl { background: #2a1b10; }
table.detail tr.hdr td.hl { color: var(--primary); background: #34200f; }
table.detail td.pin, table.detail th.pin { background: #1a1d27; box-shadow: inset 2px 0 0 var(--border-strong), 1px 0 0 var(--border); }
table.detail tr.hdr td.pin { background: #1f2330; }
table.detail tbody tr:hover td:not(.sticky):not(.hl) { background: var(--surface); }

.sortic { color: var(--muted); font-size: 11px; margin-left: 5px; opacity: .85; }
th:hover .sortic { color: var(--primary); opacity: 1; }
.table-box th { cursor: pointer; user-select: none; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; transition: .18s; position: relative; overflow: hidden;
}
.card:hover { border-color: var(--border-strong); background: var(--surface-2); transform: translateY(-2px); }
.card .label { color: var(--muted); font-size: 12.5px; font-weight: 500; margin-bottom: 8px; }
.card .value { font-size: 25px; font-weight: 700; letter-spacing: -0.03em; }
.card .row2 { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.delta { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; display: inline-flex; align-items: center; gap: 3px; }
.delta.up { color: var(--green); background: rgba(45,212,112,0.12); }
.delta.down { color: var(--red); background: rgba(255,84,112,0.12); }
.delta.flat { color: var(--muted); background: var(--surface); }
.sub { color: var(--muted-2); font-size: 12px; }
.progress { height: 6px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #ff9466); border-radius: 4px; }

/* KPI cards (có target) */
.card.kpi { background: linear-gradient(160deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02)); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head .label { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.card.kpi .value { font-size: 28px; }
.card-sub { color: var(--muted-2); font-size: 12px; margin-top: 6px; }
.ach { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.ach.up { color: var(--green); background: rgba(45,212,112,0.14); }
.ach.warn { color: var(--yellow); background: rgba(245,179,1,0.14); }
.ach.down { color: var(--red); background: rgba(255,84,112,0.14); }

.compare { text-align: right; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; font-weight: 500; }
.cdot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }
td .d-up { color: var(--green); font-weight: 700; }
td .d-down { color: var(--red); font-weight: 700; }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 24px; }
.charts.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-box.wide { grid-column: 1 / -1; }
.chart-sub { color: var(--muted-2); font-size: 12px; margin: -8px 0 12px; }
@media (max-width: 1100px) { .charts { grid-template-columns: minmax(0, 1fr); } }
.chart-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.chart-box .cv { position: relative; height: 290px; }

/* Tables */
.table-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 24px; overflow-x: auto; }
/* Tieu de dong nhat (gach cam + font giong nhau) cho chart, table, detail */
.chart-box h3, .table-box h3, .detail-head h3 {
  margin: 0 0 14px; font-size: 14px; font-weight: 700; color: var(--text);
  text-transform: uppercase; letter-spacing: .03em; position: relative; padding-left: 13px;
}
.chart-box h3::before, .table-box h3::before, .detail-head h3::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 15px; border-radius: 2px; background: var(--primary);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { text-align: left; color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
th:hover { color: var(--text); }
th.right, td.right { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: .1s; }
tbody tr:hover td { background: var(--surface); }
tbody tr:last-child td { border-bottom: none; }
td a { color: var(--primary); text-decoration: none; font-weight: 600; }
td a:hover { text-decoration: underline; }

/* Subtabs / segmented filters */
.subtabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 18px; align-items: center; }
.subtab { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 13px; font-weight: 500; transition: .15s; }
.subtab:hover { border-color: var(--border-strong); color: var(--text); }
.subtab.active { background: var(--primary); color: #1a0d06; border-color: var(--primary); font-weight: 600; }

@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; }
}

/* ONLINE - VẬN HÀNH */
.optoggle { display: inline-flex; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 5px; margin-bottom: 20px; }
.optab { border: none; background: none; color: var(--muted); font-weight: 700; font-size: 13px; padding: 8px 22px; border-radius: 9px; cursor: pointer; font-family: inherit; letter-spacing: .03em; }
.optab.active { background: linear-gradient(135deg, var(--primary), #ff8255); color: #1a0d06; box-shadow: 0 4px 14px var(--primary-glow); }

.vh-grid { display: grid; gap: 16px; margin-bottom: 26px; }
.vh-grid.g2 { grid-template-columns: repeat(2, 1fr); }
.vh-grid.g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1200px) { .vh-grid.g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .vh-grid.g2, .vh-grid.g4 { grid-template-columns: 1fr; } }

.vh-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.vh-card.big { padding: 20px 24px; }
.vh-title { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.vh-body { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center; }
@media (max-width: 600px) { .vh-body { grid-template-columns: 1fr; } }
.vh-donut { position: relative; width: 210px; height: 210px; margin: 0 auto; }
.vh-donut.sm { width: 175px; height: 175px; margin: 8px auto 12px; }
.vh-chead { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 4px; }
.vh-chead b { font-weight: 600; }
.vh-cdot { width: 11px; height: 11px; border-radius: 3px; }
.vh-chead .share { margin-left: auto; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }

.vh-legend { display: flex; flex-direction: column; gap: 2px; }
.leg-row { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; font-size: 13.5px; }
.vh-legend.sm .leg-row { padding: 5px 6px; font-size: 12.5px; gap: 7px; }
.leg-row.sub { background: rgba(220,38,38,0.10); }
.leg-dot { width: 11px; height: 11px; border-radius: 3px; }
.leg-name { color: var(--muted); }
.leg-row.sub .leg-name { color: #f87171; }
.leg-val { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.leg-pct { color: var(--muted); font-size: 12px; min-width: 56px; text-align: right; }
.leg-row.sub .leg-pct { color: #f87171; }

.op-filters { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.op-filters label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.op-filters .sel { min-width: 200px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.sku-search-wrap { display: inline-flex; align-items: center; gap: 6px; }
.sku-search-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.sku-input { min-width: 160px; max-width: 200px; }
.sku-btn { padding: 8px 14px; font-size: 13px; }
.sku-clear { padding: 7px 11px; font-size: 13px; color: var(--muted); cursor: pointer; }
.sku-clear:hover { color: var(--text); }

/* SẢN PHẨM */
.cat-nav { display: flex; align-items: center; gap: 10px; }
.cat-arrow { background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 34px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.cat-arrow:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.cat-arrow:disabled { opacity: .35; cursor: default; }
.cat-pg { color: var(--muted); font-size: 12px; min-width: 32px; text-align: center; }
.cat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 26px; }
@media (max-width: 1300px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
.cat-card { position: relative; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow: hidden;
  background: linear-gradient(150deg, color-mix(in srgb, var(--cc) 14%, transparent), rgba(255,255,255,0.02)); }
.cat-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--cc); }
.cc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cc-rank { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--cc); text-transform: uppercase; }
.cc-dot { width: 9px; height: 9px; border-radius: 2px; }
.cc-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.cc-rev { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.cc-yoy { margin: 7px 0 10px; font-size: 12px; }
.cc-foot { display: flex; align-items: baseline; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 8px; font-size: 12px; color: var(--muted); }
.cc-foot b { color: var(--text); font-weight: 700; }
.cc-qty { color: var(--muted-2); font-variant-numeric: tabular-nums; }
.cc-target { color: var(--muted-2); font-size: 11px; margin-top: 5px; }
.cb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cb-head h3 { margin: 0; }

.abc-cards { grid-template-columns: repeat(3, 1fr); }
/* Mau nhom A/B/C da the hien qua badge goc phai; khong dung vien canh (giu card sach) */

/* ============ RESPONSIVE (tablet / mobile) ============ */
/* Chong tran ngang toan trang: clip o root (giu sticky), grid co lai duoc 0 */
html, body { max-width: 100%; overflow-x: hidden; }
.app { max-width: 100%; overflow-x: clip; }
.main, .content { min-width: 0; max-width: 100%; }
.chart-box, .table-box, .card, .detail-box { min-width: 0; }
.chart-box .cv canvas { max-width: 100% !important; }
/* Tablet & nho hon: sidebar -> thanh tren cung, tab cuon ngang */
@media (max-width: 920px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; flex-direction: row; flex-wrap: wrap;
    align-items: center; gap: 10px 14px; padding: 12px 14px;
    border-right: none; border-bottom: 1px solid var(--border); min-width: 0;
  }

  .brand-switch { flex-direction: row; gap: 6px; }
  .brand-btn { padding: 8px 12px; }
  .nav { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 4px; margin-top: 0; order: 5; flex-basis: 100%; min-width: 0; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .nav .tab { white-space: nowrap; flex: 0 0 auto; padding: 9px 12px; }
  .sidebar-foot { display: none; }
  .toolbar { padding: 12px 14px; flex-wrap: wrap; gap: 10px; }
  .toolbar-title { font-size: 18px; }
  .toolbar-controls { flex-wrap: wrap; }
  .content { padding: 16px 14px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards.kpis, .cards.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { padding: 20px; }
  .hero .h-value { font-size: 34px; }
}
/* Dien thoai: KPI 2 card / hang (card thu gon padding + chu cho vua) */
@media (max-width: 540px) {
  body { font-size: 14px; }
  .cards, .cards.kpis, .cards.g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .card { padding: 13px 13px; }
  .card .value, .card.kpi .value { font-size: 19px; }
  .card .label, .card-head .label { font-size: 10.5px; }
  .card-sub { font-size: 11px; }
  .delta { font-size: 11px; padding: 2px 6px; }
  .toolbar-title { font-size: 16px; }
  .content { padding: 12px 10px; }
  .seg-btn { padding: 6px 10px; font-size: 12px; }
  .chart-box, .table-box { padding: 14px; }
  .chart-box .cv { height: 250px; }
}

/* ================================================================
   THEME "CAL" — giao diện SÁNG theo DESIGN-cal.md (kiểu Cal.com).
   Scope toàn bộ trong html.theme-cal — KHÔNG ảnh hưởng theme tối mặc định.
   Nguyên tắc: canvas trắng, card #f5f5f5 bo 12px, action layer ĐEN đơn sắc,
   pill-in-pill cho segmented control, shadow nhẹ, không glow/gradient.
   ================================================================ */
html.theme-cal { color-scheme: light; }
html.theme-cal body {
  --primary: #2563eb;
  --primary-soft: #e3edfd;
  --primary-glow: rgba(37, 99, 235, 0.22);
  --bg: #f5f8fd;
  --bg-2: #eef4fc;
  --surface: #ffffff;
  --surface-2: #f2f6fc;
  --border: #eef2f7;
  --border-strong: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --green: #16a34a;
  --red: #ef4444;
  --yellow: #f59e0b;
  --radius: 14px;
  --radius-sm: 10px;
}
/* Canvas trắng phẳng — bỏ radial glow nền của theme tối */
html.theme-cal body::before { background: var(--bg); }

/* ---- Sidebar: trắng + hairline ---- */
html.theme-cal .sidebar { background: var(--bg); }
html.theme-cal .brand-btn { background: #ffffff; }
html.theme-cal .brand-btn.active { background: var(--surface); }
html.theme-cal .nav .tab.active { background: var(--primary-soft); color: #111111; }
html.theme-cal .user-row .dot { box-shadow: none; }

/* ---- Toolbar: trắng mờ; tiêu đề tracking âm kiểu display Cal ---- */
html.theme-cal .toolbar { background: rgba(255, 255, 255, 0.85); }
html.theme-cal .toolbar-title { letter-spacing: -0.5px; }

/* ---- Segmented control = nav-pill-group (pill-in-pill đặc trưng Cal) ---- */
html.theme-cal .seg { background: #f3f4f6; border: none; border-radius: 9999px; padding: 4px; }
html.theme-cal .seg-btn { border-radius: 9999px; }
html.theme-cal .seg-btn.active { background: #ffffff; color: #111111; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
html.theme-cal .sel { background: #ffffff; }

/* ---- Nút chính: đen #111, bo 8px, shadow nhẹ (không gradient/glow) ---- */
html.theme-cal .btn-primary { background: #111111; color: #ffffff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); border-radius: 8px; font-weight: 600; }
html.theme-cal .btn-primary:active { background: #242424; }

/* ---- Note / cảnh báo: amber sáng ---- */
html.theme-cal .note { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---- Hero: card xám nhạt kiểu feature-card, bỏ glow ---- */
html.theme-cal .hero { background: var(--surface); border-color: var(--border); }
html.theme-cal .hero::after { display: none; }
html.theme-cal .hero .h-value { letter-spacing: -1px; }

/* ---- Cards / chart / table: card xám #f5f5f5, hover nổi shadow nhẹ ---- */
html.theme-cal .card:hover { background: #f0f1f3; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); }
html.theme-cal .card.kpi { background: var(--surface); }
html.theme-cal .delta.up { background: rgba(16, 185, 129, 0.12); }
html.theme-cal .delta.down { background: rgba(239, 68, 68, 0.10); }
html.theme-cal .ach.up { background: rgba(16, 185, 129, 0.14); }
html.theme-cal .ach.warn { background: rgba(245, 158, 11, 0.16); color: #b45309; }
html.theme-cal .ach.down { background: rgba(239, 68, 68, 0.12); }
html.theme-cal .progress { background: #e5e7eb; }
html.theme-cal .progress > i { background: #111111; }

/* ---- Bảng CHI TIẾT NĂM: nền sticky/highlight bản sáng ---- */
html.theme-cal table.detail .sticky { background: #ffffff; }
html.theme-cal table.detail tr.hdr td { background: rgba(17, 17, 17, 0.04); }
html.theme-cal table.detail tr.hdr td.sticky { background: #f3f4f6; color: #111111; }
html.theme-cal table.detail td.hl, html.theme-cal table.detail th.hl { background: #f3f4f6; color: #111111; }
html.theme-cal table.detail tr.hdr td.hl { background: #e5e7eb; color: #111111; }
html.theme-cal table.detail td.pin, html.theme-cal table.detail th.pin { background: #f8f9fa; }
html.theme-cal table.detail tr.hdr td.pin { background: #eef0f3; }

/* ---- Subtab / optoggle: active đen chữ trắng (action layer đơn sắc) ---- */
html.theme-cal .subtab { background: #ffffff; }
html.theme-cal .subtab.active { background: #111111; color: #ffffff; border-color: #111111; }
html.theme-cal .optoggle { background: #f3f4f6; border: none; border-radius: 9999px; }
html.theme-cal .optab { border-radius: 9999px; }
html.theme-cal .optab.active { background: #ffffff; color: #111111; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }

/* ---- Vận hành: legend hoàn bom bản sáng ---- */
html.theme-cal .leg-row.sub { background: rgba(239, 68, 68, 0.08); }
html.theme-cal .leg-row.sub .leg-name, html.theme-cal .leg-row.sub .leg-pct { color: #b91c1c; }

/* ---- Sản phẩm: cat-card pha màu danh mục trên nền trắng ---- */
html.theme-cal .cat-card { background: linear-gradient(150deg, color-mix(in srgb, var(--cc) 9%, #ffffff), #ffffff); }
html.theme-cal .cat-arrow { background: #ffffff; }

/* ================================================================
   BRAND SWITCH = LOGO BANNER (thay text bằng logo, áp cho cả 2 theme)
   ================================================================ */
.brand-btn { padding: 5px; justify-content: center; }
.brand-logo { display: block; width: 100%; height: auto; border-radius: 8px; }
/* Inactive: dịu màu để nổi brand đang chọn; hover sáng dần */
.brand-btn:not(.active) .brand-logo { opacity: .42; filter: grayscale(.45); transition: .18s; }
.brand-btn:not(.active):hover .brand-logo { opacity: .75; filter: grayscale(.15); }
.brand-btn.active .brand-logo { opacity: 1; filter: none; }
/* Viền active theo màu brand, đậm hơn inset bar cũ */
.brand-btn.active[data-brand="ICONDENIM"] { box-shadow: inset 0 0 0 2px var(--primary); }
.brand-btn.active[data-brand="160STORE"] { box-shadow: inset 0 0 0 2px var(--yellow); }
/* Mobile: sidebar thành thanh ngang -> logo thu gọn theo chiều cao */
@media (max-width: 920px) {
  .brand-btn { padding: 3px; width: auto; }
  .brand-logo { width: auto; height: 34px; }
}

/* ================================================================
   BLOCK BẢNG DẠNG TAB (TOP 10 POS/SKU) — pill toggle cạnh tiêu đề
   ================================================================ */
.tt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tt-head h3 { margin: 0; }
.tt-toggle { margin-bottom: 0; padding: 4px; }
.tt-toggle .optab { padding: 7px 16px; font-size: 12px; }
@media (max-width: 540px) { .tt-toggle .optab { padding: 6px 10px; font-size: 11px; } }

/* ================================================================
   NHÂN SỰ — sơ đồ tổ chức (cây 2 cấp: DMM -> nhóm -> thành viên)
   ================================================================ */
.org-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 22px 20px; margin-bottom: 24px; overflow-x: auto; }
.org-wrap { min-width: 760px; }
.org-node { border: 1px solid var(--border-strong); border-radius: 12px; background: var(--bg-2); padding: 10px 14px; text-align: center; }
.on-name { font-weight: 700; font-size: 14px; color: var(--text); line-height: 1.3; }
.on-role { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.3; }

/* Cấp 1: DMM ở giữa + đường xuống */
.org-top { display: flex; justify-content: center; padding-bottom: 26px; position: relative; }
.org-top::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 1px; height: 26px; background: var(--border-strong); }
.org-node.root { min-width: 250px; border-color: #6366F1; background: color-mix(in srgb, #6366F1 9%, var(--surface)); }
.org-node.root .on-name { font-size: 15.5px; }
.org-node.root .on-role { color: #6366F1; font-weight: 600; }

/* Cấp 2: các nhóm, nối bằng thanh ngang + đường rẽ xuống */
.org-branches { display: flex; align-items: flex-start; gap: 14px; }
.org-branch { flex: 1 1 0; min-width: 160px; position: relative; padding-top: 26px; }
.org-branch::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: var(--border-strong); }
.org-branch:first-child::before { left: 50%; }
.org-branch:last-child::before { right: 50%; }
.org-branch:only-child::before { display: none; }
.org-branch::after { content: ''; position: absolute; top: 0; left: 50%; width: 1px; height: 26px; background: var(--border-strong); }
.org-node.lead .on-name { font-size: 14.5px; }

/* Cấp 3: thành viên — cột dọc bên trái + nhánh ngang vào từng ô */
.org-children { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.org-child { position: relative; padding-left: 20px; }
.org-child::before { content: ''; position: absolute; left: 6px; top: -10px; bottom: 0; width: 1px; background: var(--border-strong); }
.org-child:first-child::before { top: -16px; }
.org-child:last-child::before { bottom: 50%; }
.org-child::after { content: ''; position: absolute; left: 6px; top: 50%; width: 14px; height: 1px; background: var(--border-strong); }

/* Trạng thái nhân sự */
.org-node.st-new { border-color: #10b981; background: color-mix(in srgb, #10b981 10%, var(--surface)); }
.org-node.st-pending { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 11%, var(--surface)); }
.org-node.st-hiring { border-color: #ef4444; border-style: dashed; background: color-mix(in srgb, #ef4444 7%, var(--surface)); }
.org-node.st-hiring .on-name, .org-node.st-hiring .on-role { color: #dc2626; }

.org-legend { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 22px; padding-top: 15px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.org-legend .lg { display: inline-flex; align-items: center; gap: 8px; }
.org-legend .sw { width: 15px; height: 15px; border-radius: 5px; border: 1px solid; flex: none; }
.org-legend .sw.st-new { border-color: #10b981; background: color-mix(in srgb, #10b981 16%, transparent); }
.org-legend .sw.st-pending { border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 16%, transparent); }
.org-legend .sw.st-hiring { border-color: #ef4444; border-style: dashed; background: color-mix(in srgb, #ef4444 10%, transparent); }

/* Hẹp: xếp các nhóm theo chiều dọc, bỏ đường nối ngang */
@media (max-width: 900px) {
  .org-wrap { min-width: 0; }
  .org-branches { flex-direction: column; gap: 24px; }
  .org-branch { padding-top: 0; min-width: 0; }
  .org-branch::before, .org-branch::after { display: none; }
}

/* ================================================================
   SOFTFIRE — retheme sáng sạch (override cuối, sau theme-cal).
   Canvas xanh nhạt · card trắng shadow mềm · accent xanh #2563eb.
   ================================================================ */
html.theme-cal body, html.theme-cal body::before { background: #eef3fb; }

/* Sidebar trắng ngả xanh + hairline; nav chữ thường, active xanh */
html.theme-cal .sidebar { background: #fbfdff; border-right: 1px solid #eef2f7; }
html.theme-cal .nav .tab { text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 500; }
html.theme-cal .nav .tab.active { background: #e3edfd; color: #1d4ed8; font-weight: 600; }
html.theme-cal .nav .tab.active .ic { color: #2563eb; }
html.theme-cal .toolbar { background: rgba(255,255,255,0.92); border-bottom: 1px solid #eef2f7; }

/* Card / chart / table / detail / vh / hero: trắng + shadow mềm SoftFire */
html.theme-cal .card, html.theme-cal .chart-box, html.theme-cal .table-box,
html.theme-cal .detail-box, html.theme-cal .vh-card, html.theme-cal .hero {
  background: #ffffff; border-color: #eef2f7; box-shadow: 0 1px 3px rgba(15,23,42,0.05);
}
html.theme-cal .card { transition: box-shadow .18s, transform .18s; }
html.theme-cal .card:hover { background: #ffffff; box-shadow: 0 8px 22px rgba(15,23,42,0.10); transform: translateY(-2px); }
html.theme-cal .card.kpi { background: #ffffff; }
html.theme-cal .hero::after { display: none; }

/* Tiêu đề section kiểu SoftFire: chữ thường, bỏ gạch accent bên trái */
html.theme-cal .section-head h2, html.theme-cal .chart-box h3,
html.theme-cal .table-box h3, html.theme-cal .detail-head h3 {
  text-transform: none; letter-spacing: -0.01em; font-size: 15px; padding-left: 0;
}
html.theme-cal .section-head .bar,
html.theme-cal .chart-box h3::before, html.theme-cal .table-box h3::before,
html.theme-cal .detail-head h3::before { display: none; }

/* Nút / segmented / subtab / optoggle: accent xanh, pill bo tròn */
html.theme-cal .btn-primary { background: #2563eb; color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,0.25); border-radius: 9px; font-weight: 600; }
html.theme-cal .btn-primary:hover { background: #1d4ed8; transform: none; }
html.theme-cal .seg { background: #f2f5f9; border: none; border-radius: 999px; padding: 4px; }
html.theme-cal .seg-btn { border-radius: 999px; }
html.theme-cal .seg-btn.active { background: #fff; color: #0f172a; box-shadow: 0 1px 2px rgba(15,23,42,0.10); }
html.theme-cal .sel { background: #fff; border-color: #e6ebf2; border-radius: 9px; }
html.theme-cal .subtab { background: #fff; border-color: #e6ebf2; }
html.theme-cal .subtab.active { background: #2563eb; color: #fff; border-color: #2563eb; }
html.theme-cal .optoggle { background: #f2f5f9; border: none; border-radius: 999px; }
html.theme-cal .optab.active { background: #fff; color: #0f172a; box-shadow: 0 1px 2px rgba(15,23,42,0.10); }

/* Progress + accent xanh */
html.theme-cal .progress { background: #e8eef6; }
html.theme-cal .progress > i { background: #2563eb; }

/* Bảng CHI TIẾT NĂM: header/pin/highlight tông xanh nhạt */
html.theme-cal table.detail th { background: #f5f8fd; color: #64748b; }
html.theme-cal table.detail .sticky { background: #fff; }
html.theme-cal table.detail tr.hdr td { background: rgba(37,99,235,0.05); color: #1d4ed8; }
html.theme-cal table.detail tr.hdr td.sticky { background: #eef4fc; color: #1d4ed8; }
html.theme-cal table.detail td.hl, html.theme-cal table.detail th.hl { background: #e3edfd; color: #1d4ed8; }
html.theme-cal table.detail tr.hdr td.hl { background: #dbe7fb; color: #1d4ed8; }
html.theme-cal table.detail td.pin, html.theme-cal table.detail th.pin { background: #f5f8fd; }
html.theme-cal table.detail tr.hdr td.pin { background: #eaf0fa; }

/* ===== Section "Khách mới · Khách cũ" (tab Tổng hợp) ===== */
.section.kk { margin-top: 4px; }
.kk-sub { color: var(--muted-2); font-size: 12px; margin: -8px 0 14px; }
.kk-badge {
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; line-height: 1.5;
}
.kk-badge.info { color: var(--muted-2); background: color-mix(in srgb, var(--muted-2) 14%, transparent); }
.kk-badge.warn { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 16%, transparent); }
.kk-empty {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; color: var(--muted-2); font-size: 13px;
}
/* Bảng E: dòng nhóm kênh đậm, 2 dòng con thụt lề, dòng TỔNG gạch trên */
.kk-table tbody tr.kk-group td { font-weight: 700; }
.kk-table tbody tr.kk-sub-row td:first-child { padding-left: 28px; color: var(--muted-2); }
.kk-table tbody tr.kk-total td { font-weight: 700; border-top: 2px solid var(--border); }
.kk-table td.kk-dim { color: var(--muted-2); }
.kk-note { color: var(--muted-2); margin-left: 3px; font-weight: 400; }
.kk-foot { margin-top: 10px; color: var(--muted-2); font-size: 11px; line-height: 1.5; }
