/* ──────────────────────────────────────────────
 * Executive View — "Báo cáo Lãnh đạo" (Plan 086 Sprint 164)
 *
 * File riêng để không đụng css/index.css (file lớn, nhiều agent hay sửa song song).
 * BẮT BUỘC dùng CSS token có sẵn (--primary, --accent, --surface, --text...) để tự
 * thích ứng đúng cả light/dark và cả 3 brand theme (Anthropic/Google/Microsoft).
 * KHÔNG hardcode mã màu hex cho màu thương hiệu.
 * ────────────────────────────────────────────── */

.exec {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-bottom: 32px;
}

/* ── Tone palette dùng chung (traffic-light) ─────────────────────── */
.exec-kpi--success, .exec-tone--success, .exec-pill--success, .exec-exception--success {
  --exec-tone: var(--success);
  --exec-tone-bg: var(--success-glow);
}
.exec-kpi--warning, .exec-tone--warning, .exec-pill--warning, .exec-exception--warning {
  --exec-tone: var(--warning);
  --exec-tone-bg: var(--warning-glow);
}
.exec-kpi--danger, .exec-tone--danger, .exec-pill--danger, .exec-exception--danger {
  --exec-tone: var(--danger);
  --exec-tone-bg: var(--danger-glow);
}
.exec-kpi--info, .exec-tone--info, .exec-pill--info, .exec-exception--info {
  --exec-tone: var(--info);
  --exec-tone-bg: var(--info-glow);
}
.exec-kpi--neutral, .exec-tone--neutral, .exec-pill--neutral, .exec-exception--neutral {
  --exec-tone: var(--text-muted);
  --exec-tone-bg: var(--surface-3);
}

.exec-tone {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: var(--radius-pill);
  background: var(--exec-tone, var(--text-muted));
}

.exec-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--primary);
}

/* ── Header ──────────────────────────────────────────────────────── */
.exec-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.exec-header__title {
  margin: 0;
  font-size: var(--text-3xl);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
}

.exec-header__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.exec-header__meta strong { color: var(--text-primary); font-weight: var(--font-weight-semibold); }

.exec-header__source {
  margin-top: 4px;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.exec-header__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ── Section shell ───────────────────────────────────────────────── */
.exec-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.exec-section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.exec-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.exec-section__hint {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── KPI hero row ────────────────────────────────────────────────── */
.exec-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.exec-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--exec-tone, var(--text-muted));
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.exec-kpi:hover { transform: translateY(-1px); border-color: var(--border-strong); }

.exec-kpi__dot {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--exec-tone, var(--text-muted));
  box-shadow: 0 0 0 4px var(--exec-tone-bg, transparent);
}

.exec-kpi__value {
  font-size: var(--text-4xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
  word-break: break-word;
}

.exec-kpi__label {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-secondary);
}

.exec-kpi__hint {
  font-size: var(--text-xs);
  line-height: 1.5;
  color: var(--text-muted);
}

/* ── Pipeline funnel ─────────────────────────────────────────────── */
.exec-funnel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exec-funnel__row {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr minmax(150px, auto);
  align-items: center;
  gap: 12px;
}

.exec-funnel__label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.exec-funnel__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.exec-funnel__chip {
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: var(--radius-xs);
}

.exec-funnel__bar {
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.exec-funnel__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width var(--transition);
}

.exec-funnel__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.exec-funnel__meta strong { font-size: var(--text-sm); color: var(--text-primary); }

/* ── Google Partner Funding ──────────────────────────────────────── */
.exec-fund-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exec-fund-summary__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.exec-fund-summary__item strong { color: var(--text-primary); }

.exec-fund-summary__count {
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
}

.exec-fund-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.exec-fund-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.exec-fund-card:hover { border-color: var(--primary); background: var(--surface-3); }

.exec-fund-card.is-open {
  border-color: var(--primary);
  box-shadow: inset 0 -2px 0 0 var(--primary);
}

.exec-fund-card.is-open .exec-fund-card__caret { transform: rotate(180deg); }

.exec-fund-card__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.exec-fund-card__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.exec-fund-card__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.exec-fund-card__toggle:hover { background: var(--surface); color: var(--text-primary); }

.exec-fund-card__caret {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.exec-fund-card__total {
  font-size: var(--text-2xl);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--text-primary);
  word-break: break-word;
}

.exec-fund-card__meta,
.exec-fund-card__empty {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.exec-fund-card__statuses {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
}

.exec-fund-status {
  display: grid;
  grid-template-columns: 8px 1fr auto auto;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.exec-fund-status__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exec-fund-status__amount { font-weight: var(--font-weight-semibold); color: var(--text-primary); }

.exec-fund-status__count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  text-align: center;
}

.exec-fund-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.exec-fund-detail__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.exec-fund-detail__head h4 {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.exec-fund-detail__count { font-size: var(--text-xs); color: var(--text-muted); }

/* ── Tables ──────────────────────────────────────────────────────── */
.exec-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.exec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.exec-table th,
.exec-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.exec-table th {
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--letter-spacing-wide);
  color: var(--text-muted);
}

.exec-table td { color: var(--text-secondary); }
.exec-table tbody tr:last-child td { border-bottom: none; }
.exec-table tbody tr:hover td { background: var(--surface-3); }
.exec-table td:first-child { color: var(--text-primary); font-weight: var(--font-weight-medium); }
.exec-table__num { text-align: right; font-variant-numeric: tabular-nums; }

.exec-pill {
  display: inline-block;
  padding: 2px 10px;
  border: 1px solid var(--exec-tone, var(--text-muted));
  border-radius: var(--radius-pill);
  background: var(--exec-tone-bg, transparent);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-medium);
  color: var(--exec-tone, var(--text-muted));
}

/* ── Exceptions ──────────────────────────────────────────────────── */
.exec-exceptions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.exec-exception {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--exec-tone, var(--text-muted));
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.exec-exception__label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.exec-exception__count {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--exec-tone-bg, var(--surface-3));
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--exec-tone, var(--text-primary));
}

/* ── Empty state ─────────────────────────────────────────────────── */
.exec-empty { padding: 28px 16px; }

.exec-empty__icon {
  width: 36px;
  height: 36px;
  margin-bottom: 12px;
  color: var(--text-muted);
  opacity: 0.7;
}

.exec-empty p {
  max-width: 460px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* ── Skeleton (Sprint 149 pattern) ───────────────────────────────── */
.exec-skeleton { animation: exec-pulse 1.5s ease-in-out infinite; }

.exec-skeleton__box {
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.exec-skeleton__box--header { height: 88px; margin-bottom: 4px; }
.exec-skeleton__box--tile   { height: 118px; }
.exec-skeleton__box--panel  { height: 220px; }
.exec-skeleton__box--line   { height: 34px; }

.exec-skeleton .exec-kpis,
.exec-skeleton .exec-fund-grid { margin: 0; }

.exec-skeleton__lines { display: grid; gap: 10px; }

@keyframes exec-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .exec { gap: 16px; }
  .exec-header,
  .exec-section { padding: 16px; }
  .exec-header__actions { width: 100%; }
  .exec-header__actions .btn { flex: 1 1 auto; justify-content: center; }
  .exec-header__title { font-size: var(--text-2xl); }
  .exec-kpi__value { font-size: var(--text-3xl); }
  .exec-funnel__row {
    grid-template-columns: 1fr;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .exec-funnel__row:last-child { border-bottom: none; padding-bottom: 0; }
  .exec-funnel__meta { flex-direction: row; align-items: center; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .exec-skeleton { animation: none; }
  .exec-kpi,
  .exec-funnel__fill,
  .exec-fund-card,
  .exec-fund-card__caret { transition: none; }
}

/* ── Print / xuất PDF (Sprint 165 tái dùng) ──────────────────────── */
@media print {
  .exec { gap: 14px; }
  .exec-header__actions { display: none; }
  .exec-header,
  .exec-section,
  .exec-kpi,
  .exec-fund-card { break-inside: avoid; page-break-inside: avoid; }
  .exec-table th,
  .exec-table td { white-space: normal; }
}
