/* ════════════════════════════════════════════════════════════════════
   EXECUTIVE DASHBOARD — "Tổng quan hoạt động trong ngày" (/dashboard/executive)
   CSS tập trung (rule: 100% CSS ở wwwroot/css, không scoped/inline).
   Dark, executive, số lớn dễ đọc. Prefix .exec-*.
   Tokens: var(--ag-*) + var(--mud-palette-*); màu mờ qua rgba(var(--ag-fg-rgb), a).
   ════════════════════════════════════════════════════════════════════ */

/* ── Ambient background ─────────────────────────────────────────── */
.exec-ambient {
    position: fixed;
    inset: 0;
    z-index: -1;   /* nền trang trí SAU nội dung — khỏi tạo stacking-context riêng cho .exec-page */
    pointer-events: none;
    background:
        radial-gradient(38% 48% at 8% 12%, rgba(56, 189, 248, .13), transparent 70%),
        radial-gradient(34% 44% at 92% 8%, rgba(167, 139, 250, .11), transparent 70%),
        radial-gradient(42% 52% at 70% 95%, rgba(52, 211, 153, .09), transparent 70%),
        radial-gradient(30% 40% at 35% 60%, rgba(251, 191, 36, .05), transparent 70%);
}
.exec-page { position: relative; padding-bottom: 24px; }

/* ── Header ──────────────────────────────────────────────────────── */
.exec-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 20px;
    margin-bottom: 20px;
}
.exec-brand { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.exec-brand__logo {
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .14em;
    color: #34d399;
    text-transform: uppercase;
}
.exec-title {
    margin: 0;
    font-size: clamp(1.25rem, 1rem + 1.4vw, 2rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: .01em;
    color: var(--mud-palette-text-primary);
    text-shadow: 0 2px 18px rgba(0, 0, 0, .35);
}
.exec-header__right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
}
.exec-datepicker { max-width: 168px; }
.exec-daterow { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.exec-daterow__day {
    font-size: .92rem;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
    font-variant-numeric: tabular-nums;
}
.exec-daterow__upd { font-size: .72rem; color: rgba(var(--ag-fg-rgb), .5); }
.exec-refresh { border: 1px solid rgba(var(--ag-fg-rgb), .14); border-radius: 12px; }

/* ── Glass card (chung) ──────────────────────────────────────────── */
.exec-card {
    position: relative;
    padding: 18px;
    border-radius: 16px;
    background: linear-gradient(150deg, rgba(var(--ag-fg-rgb), .07), rgba(var(--ag-fg-rgb), .015) 60%);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid rgba(var(--ag-fg-rgb), .12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255, 255, 255, .10);
    transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease;
}
.exec-card__title {
    margin: 0 0 14px;
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(var(--ag-fg-rgb), .72);
}
.exec-card__titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.exec-card__titlebar .exec-card__title { margin: 0; }
.exec-badge {
    flex: 0 0 auto;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    color: #fbbf24;
    background: rgba(251, 191, 36, .14);
    border: 1px solid rgba(251, 191, 36, .35);
}
.exec-empty {
    padding: 22px 8px;
    text-align: center;
    font-size: .82rem;
    color: rgba(var(--ag-fg-rgb), .45);
}

/* ── Rows layout (grid) ──────────────────────────────────────────── */
.exec-rows { display: flex; flex-direction: column; }
.exec-row { display: grid; gap: 16px; margin-bottom: 16px; }
.exec-row--3 { grid-template-columns: repeat(3, 1fr); }
.exec-row--4 { grid-template-columns: repeat(4, 1fr); }
/* Hàng cuối: Timeline (trái, nội dung ngắn) + Alerts (phải, cao hơn). align-items:start
   để card Timeline CO theo nội dung, KHÔNG bị kéo cao tạo hộp trống lớn ở dưới. */
.exec-row--2 { grid-template-columns: 1.4fr 1fr; align-items: start; }

/* ── HÀNG 1: 4 KPI lớn ───────────────────────────────────────────── */
.exec-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.exec-kpi {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 20px 18px 24px;
    border-radius: 16px;
    text-align: left;
    cursor: pointer;
    background: linear-gradient(150deg, rgba(var(--ag-fg-rgb), .08), rgba(var(--ag-fg-rgb), .015) 62%);
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    border: 1px solid rgba(var(--ag-fg-rgb), .12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .14);
    overflow: hidden;
    transition: transform .2s cubic-bezier(.2, .8, .2, 1), box-shadow .2s ease;
    color: inherit;
    font: inherit;
}
.exec-kpi:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .2); }
.exec-kpi:focus-visible { outline: 2px solid rgba(56, 189, 248, .7); outline-offset: 2px; }

/* Accent bar trái + halo theo màu modifier */
.exec-kpi__accent {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--exec-accent, #38bdf8);
    box-shadow: 0 0 18px 2px var(--exec-accent, #38bdf8);
}
.exec-kpi::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(70% 90% at 100% 0%, var(--exec-accent-soft, transparent), transparent 60%);
    pointer-events: none;
}
.exec-kpi--green { --exec-accent: #34d399; --exec-accent-soft: rgba(52, 211, 153, .12); }
.exec-kpi--red   { --exec-accent: #f87171; --exec-accent-soft: rgba(248, 113, 113, .12); }
.exec-kpi--gold  { --exec-accent: #fbbf24; --exec-accent-soft: rgba(251, 191, 36, .12); }
.exec-kpi--blue  { --exec-accent: #38bdf8; --exec-accent-soft: rgba(56, 189, 248, .12); }

.exec-kpi__head { display: flex; align-items: center; gap: 8px; }
.exec-kpi__icon { color: var(--exec-accent, #38bdf8); font-size: 1.25rem; }
.exec-kpi__label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: rgba(var(--ag-fg-rgb), .62);
}
.exec-kpi__value {
    font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.15rem);
    font-weight: 800;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
    color: var(--mud-palette-text-primary);
}
.exec-kpi__sub { font-size: .76rem; font-weight: 600; color: rgba(var(--ag-fg-rgb), .6); }
.exec-kpi__delta { font-size: .76rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── HÀNG 1B: KPI vận hành (strip gọn, thấp hơn KPI tài chính) ── */
.exec-ops {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.exec-ops-tile {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 16px;
    border-radius: 14px;
    background: linear-gradient(150deg, rgba(var(--ag-fg-rgb), .06), rgba(var(--ag-fg-rgb), .015) 60%);
    border: 1px solid rgba(var(--ag-fg-rgb), .1);
    border-left: 3px solid rgba(var(--ag-fg-rgb), .28);
}
.exec-ops-tile__label { font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: rgba(var(--ag-fg-rgb), .6); }
.exec-ops-tile__value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; color: var(--mud-palette-text-primary); }
.exec-ops-tile__sep { font-size: .95rem; font-weight: 700; color: rgba(var(--ag-fg-rgb), .45); }
.exec-ops-tile__sub { font-size: .72rem; font-weight: 600; color: rgba(var(--ag-fg-rgb), .55); }
.exec-ops-tile.is-good { border-left-color: #34d399; }
.exec-ops-tile.is-good .exec-ops-tile__value { color: #34d399; }
.exec-ops-tile.is-warn { border-left-color: #fbbf24; }
.exec-ops-tile.is-warn .exec-ops-tile__value { color: #fbbf24; }
.exec-ops-tile.is-bad  { border-left-color: #f87171; }
.exec-ops-tile.is-bad  .exec-ops-tile__value { color: #f87171; }

/* sắc thái delta dùng chung */
.up      { color: #34d399; }
.down    { color: #f87171; }
.neutral { color: #fbbf24; }
.zero    { color: rgba(var(--ag-fg-rgb), .5); }
.exec-kpi__delta.up { color: #34d399; }
.exec-kpi__delta.down { color: #f87171; }
.exec-kpi__delta.neutral { color: #fbbf24; }

/* ── HÀNG 2A: Tiền đang nằm ở đâu (2×2) ──────────────────────────── */
.exec-pos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.exec-pos-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 14px 14px 18px;
    border-radius: 12px;
    text-align: left;
    background: rgba(var(--ag-fg-rgb), .035);
    border: 1px solid rgba(var(--ag-fg-rgb), .10);
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.exec-pos-card:hover { background: rgba(var(--ag-fg-rgb), .07); transform: translateY(-1px); }
.exec-pos-card:focus-visible { outline: 2px solid rgba(56, 189, 248, .7); outline-offset: 2px; }
.exec-pos-card::before {
    content: "";
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--exec-pos, #38bdf8);
}
.exec-pos-card--red    { --exec-pos: #f87171; }
.exec-pos-card--amber  { --exec-pos: #fb923c; }
.exec-pos-card--yellow { --exec-pos: #fbbf24; }
.exec-pos-card--blue   { --exec-pos: #38bdf8; }
.exec-pos-card__label {
    font-size: .72rem;
    font-weight: 600;
    color: rgba(var(--ag-fg-rgb), .6);
}
.exec-pos-card__value {
    font-size: 1.18rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--mud-palette-text-primary);
}
.exec-pos-card__note { font-size: .68rem; color: rgba(var(--ag-fg-rgb), .55); }
.exec-pos-card__note--muted { font-style: italic; }
.exec-pos-card__delta { font-size: .68rem; font-weight: 700; }
.exec-pos-card__delta.up { color: #34d399; }
.exec-pos-card__delta.down { color: #f87171; }
.exec-pos-card__delta.neutral { color: rgba(var(--ag-fg-rgb), .5); }

/* ── HÀNG 2B: Sự vụ hôm nay ──────────────────────────────────────── */
.exec-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.exec-event-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 6px;
    border-bottom: 1px solid rgba(var(--ag-fg-rgb), .06);
}
.exec-event-row.is-link { cursor: pointer; border-radius: 8px; transition: background .12s ease; }
.exec-event-row.is-link:hover { background: rgba(var(--ag-fg-rgb), .05); }
.exec-event__icon { flex: 0 0 auto; }
.exec-event__icon.sev-critical { color: #f87171; }
.exec-event__icon.sev-warning  { color: #fb923c; }
.exec-event__icon.sev-info     { color: #38bdf8; }
.exec-event__title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .84rem;
    color: var(--mud-palette-text-primary);
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}
.exec-event__amount { font-weight: 700; color: #fbbf24; font-variant-numeric: tabular-nums; }
.exec-event__time {
    flex: 0 0 auto;
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
    color: rgba(var(--ag-fg-rgb), .5);
}
.exec-link-all {
    margin-top: 10px;
    padding: 0;
    border: none;
    background: transparent;
    color: #7dd3fc;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.exec-link-all:hover { color: #bae6fd; }
.exec-link-all:focus-visible { outline: 2px solid rgba(56, 189, 248, .6); outline-offset: 2px; border-radius: 4px; }

/* ── HÀNG 2C: Thu chi trong ngày ─────────────────────────────────── */
.exec-thuchi { width: 100%; border-collapse: collapse; }
.exec-thuchi td { padding: 9px 4px; font-size: .85rem; color: var(--mud-palette-text-primary); }
.exec-thuchi__amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exec-thuchi__amt.up { color: #34d399; }
.exec-thuchi__amt.down { color: #f87171; }
.exec-thuchi__amt.zero { color: rgba(var(--ag-fg-rgb), .5); }
.exec-thuchi__total td { border-top: 1px solid rgba(var(--ag-fg-rgb), .18); padding-top: 12px; font-weight: 800; }
.exec-thuchi__amt.strong { font-size: 1.05rem; }
/* Khoản trừ (giá vốn / tiền chi): tông muted để đọc như phép trừ, không chói. */
.exec-thuchi__amt.out { color: rgba(var(--ag-fg-rgb), .55); }
/* Nhãn phụ "tạm tính" cạnh tiêu đề card. */
.exec-card__note {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: none;
    color: rgba(var(--ag-fg-rgb), .55);
    background: rgba(var(--ag-fg-rgb), .08);
}
/* Chip "Biên LN x%" gắn cạnh dòng Lợi nhuận gộp. */
.exec-thuchi__chip {
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.exec-thuchi__chip.up { color: #34d399; background: rgba(52, 211, 153, .14); }
.exec-thuchi__chip.down { color: #f87171; background: rgba(248, 113, 113, .14); }
/* Dải phân tách "TIỀN MẶT TRONG NGÀY" giữa khối kế toán và khối tiền mặt. */
.exec-thuchi__section td {
    padding-top: 14px;
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(var(--ag-fg-rgb), .45);
}

/* ── HÀNG 3: mini-line footer ────────────────────────────────────── */
.exec-trend-foot {
    margin-top: 6px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-variant-numeric: tabular-nums;
}
.exec-trend-foot__word { font-size: .78rem; font-weight: 700; }
.exec-trend-foot__val { font-size: .82rem; font-weight: 800; }
.exec-trend-foot.up { color: #34d399; }
.exec-trend-foot.down { color: #f87171; }
.exec-trend-foot.neutral { color: rgba(var(--ag-fg-rgb), .55); }

/* ── HÀNG 3: Top NCC / KH ────────────────────────────────────────── */
.exec-top__head { font-size: .68rem; color: rgba(var(--ag-fg-rgb), .45); text-transform: uppercase; letter-spacing: .04em; }
.exec-top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.exec-top-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 2px;
    border-bottom: 1px solid rgba(var(--ag-fg-rgb), .06);
}
.exec-top__rank {
    flex: 0 0 auto;
    width: 18px;
    font-size: .78rem;
    font-weight: 800;
    color: rgba(var(--ag-fg-rgb), .4);
    text-align: center;
}
.exec-top__avatar {
    flex: 0 0 auto;
    width: 28px; height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 800;
    color: #0b1220;
    background: linear-gradient(140deg, #7dd3fc, #38bdf8);
}
.exec-top__name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .84rem;
    color: var(--mud-palette-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.exec-top__vip { color: #fbbf24; font-size: 1rem; }
.exec-top__amt {
    flex: 0 0 auto;
    font-size: .85rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #fbbf24;
    white-space: nowrap;
}

/* ── HÀNG 4: Timeline ────────────────────────────────────────────── */
.exec-timeline {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    overflow-x: auto;
    padding: 4px 2px 10px;
}
.exec-tl-node {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 84px;
    text-align: center;
}
.exec-tl-node__dot {
    width: 38px; height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #7dd3fc;
    background: rgba(56, 189, 248, .12);
    border: 1px solid rgba(56, 189, 248, .35);
}
.exec-tl-node__time { font-size: .74rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--mud-palette-text-primary); }
.exec-tl-node__label { font-size: .68rem; color: rgba(var(--ag-fg-rgb), .6); line-height: 1.2; }
.exec-tl-arrow {
    flex: 0 0 auto;
    align-self: center;
    margin-top: 8px;
    font-size: 1.1rem;
    color: rgba(var(--ag-fg-rgb), .35);
}

/* ── HÀNG 4: Cảnh báo — ưu tiên thị giác cao nhất ────────────────── */
.exec-alerts-wrap { padding: 0; background: none; border: none; box-shadow: none; }
.exec-alerts {
    height: 100%;
    padding: 18px;
    border-radius: 16px;
    background: rgba(127, 29, 29, .35);
    border: 1px solid rgba(248, 113, 113, .5);
    box-shadow: 0 8px 28px rgba(127, 29, 29, .4), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.exec-alerts__head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.exec-alerts__icon { color: #fca5a5; font-size: 1.4rem; }
.exec-alerts__title {
    margin: 0;
    font-size: .86rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fecaca;
}
.exec-alerts__ok { padding: 14px 4px; font-size: .85rem; color: #fca5a5; }
.exec-alerts__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.exec-alert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 4px;
    border-bottom: 1px solid rgba(248, 113, 113, .18);
}
.exec-alert-row.is-link { cursor: pointer; border-radius: 8px; transition: background .12s ease; }
.exec-alert-row.is-link:hover { background: rgba(248, 113, 113, .1); }
.exec-alert-row__bullet {
    flex: 0 0 auto;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #f87171;
    box-shadow: 0 0 10px 1px rgba(248, 113, 113, .8);
}
.exec-alert-row__title { flex: 1 1 auto; min-width: 0; font-size: .86rem; font-weight: 600; color: #fee2e2; }
.exec-alert-row__amt { flex: 0 0 auto; font-size: .85rem; font-weight: 800; font-variant-numeric: tabular-nums; color: #fecaca; }

/* ── TV mode (màn treo tường) ────────────────────────────────────── */
.exec-page--tv .exec-title { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.6rem); }
.exec-page--tv .exec-kpi__value { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.8rem); }
.exec-page--tv .exec-card { padding: 22px; }
.exec-page--tv .exec-kpi { padding: 22px 24px 22px 28px; }

@media (min-width: 2000px) {
    .exec-page { padding: 8px 20px 28px; }
    .exec-kpi__value { font-size: 2.6rem; }
    .exec-card__title { font-size: .92rem; }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1100px) {
    .exec-kpis { grid-template-columns: repeat(2, 1fr); }
    .exec-ops { grid-template-columns: repeat(2, 1fr); }
    .exec-row--3 { grid-template-columns: 1fr; }
    .exec-row--4 { grid-template-columns: repeat(2, 1fr); }
    .exec-row--2 { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
    .exec-kpis { grid-template-columns: 1fr; }
    .exec-ops { grid-template-columns: repeat(2, 1fr); }
    .exec-row--4 { grid-template-columns: 1fr; }
    .exec-pos-grid { grid-template-columns: 1fr; }
    .exec-kpi__value { font-size: 1.7rem; }
    .exec-timeline { padding-bottom: 14px; }
}

@media (max-width: 600px) {
    .exec-header { align-items: flex-start; }
    .exec-daterow { align-items: flex-start; }
    /* Đưa panel "CẦN GIÁM ĐỐC XỬ LÝ" lên gần đầu trên mobile (ưu tiên xử lý). */
    .exec-row--2 { display: flex; flex-direction: column; }
    .exec-alerts-wrap { order: -1; }
}
