/* Executive counting overview on "Tổng quan" (pages/dashboard-exec.js) */
.ex {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}
.ex-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ex-head p {
  margin: 2px 0 0;
}
.ex-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.ex-section {
  margin: 4px 0 12px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* Headline: progress ring + key figures */
.ex-hero {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
}
.ex-hero-ring {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  padding: 22px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  text-align: center;
}
.ex-ring-bg {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 10;
}
.ex-ring-fg {
  fill: none;
  stroke: var(--chart-1);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}
.ex-ring-txt {
  position: absolute;
  top: 22px;
  height: 132px;
  display: grid;
  align-content: center;
  justify-items: center;
}
.ex-ring-txt b {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ex-ring-txt b small {
  font-size: 18px;
  color: var(--muted);
  font-weight: 600;
}
.ex-ring-txt span {
  font-size: 12px;
  color: var(--muted);
}
.ex-ring-cap {
  display: grid;
  gap: 2px;
}
.ex-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Progress bars of the site table / site cards in the chart colour (done zones in the success colour) */
.ex .bar i {
  background: var(--chart-1);
}
.ex .bar.ok i {
  background: var(--ok);
}
.ex-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 18px 16px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  min-width: 0;
  transition: background 0.15s;
}
.ex-kpi:hover {
  background: var(--surface-2);
}
.ex-kpi:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.ex-kpi .lbl {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.ex-kpi .lbl .icon {
  width: 14px;
  height: 14px;
}
.ex-kpi .val {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.ex-kpi .val small {
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
.ex-kpi .sub {
  font-size: 12px;
  color: var(--muted);
}
.ex-kpi .bar {
  margin: 4px 0 2px;
}
.ex-kpi.bad .lbl,
.ex-kpi.bad .val {
  color: var(--bad);
}
.ex-kpi.warn .lbl,
.ex-kpi.warn .val {
  color: var(--warn);
}

/* Sites */
.ex-sites td,
.ex-sites th {
  white-space: nowrap;
}
.ex-sites td .cell-sub {
  max-width: 220px;
}
.ex-prog {
  width: 190px;
}
.ex-sites tfoot td {
  border-top: 2px solid var(--line-2);
  background: var(--surface-2);
}
.ex-bad {
  color: var(--bad);
  font-weight: 600;
}
.ex-warn {
  color: var(--warn);
  font-weight: 600;
}
.ex-off {
  color: var(--muted);
}
.ex-pending {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--line);
}
.ex-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-3);
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.ex-site-cards .item {
  display: block;
}
.ex-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}
.ex-mini b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.ex-mini .ex-bad b {
  color: var(--bad);
}

/* Damaged by site: one horizontal bar per site (value + rate as text) */
.ex-hbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}
.ex-hbar-track {
  height: 12px;
  border-radius: 4px;
  background: var(--surface-3);
  overflow: hidden;
}
.ex-hbar-track i {
  display: block;
  height: 100%;
  min-width: 2px;
  border-radius: 0 4px 4px 0;
  background: var(--chart-bad);
}

/* Item rows with photo (norm deviations, most damaged) */
.ex-seg {
  min-width: 190px;
}
.ex-norm {
  display: flex;
  flex-direction: column;
}
.ex-norm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.ex-norm-row:last-child {
  border-bottom: 0;
}
a.ex-norm-row:hover b.ellipsis {
  text-decoration: underline;
}
.ex-norm-row img,
.ex-noimg {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--surface-3);
}
.ex-noimg {
  display: grid;
  place-items: center;
  color: var(--muted);
}
.ex-noimg .icon {
  width: 16px;
  height: 16px;
}
.ex-norm-name {
  display: grid;
  min-width: 0;
}
.ex-norm-name small {
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ex-norm-row > .num {
  font-size: 15px;
  white-space: nowrap;
}

/* To do */
.ex-todo {
  display: flex;
  flex-direction: column;
}
.ex-todo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
}
.ex-todo-row:last-child {
  border-bottom: 0;
}
.ex-todo-row > b {
  min-width: 52px;
  text-align: right;
  font-size: 17px;
}
.ex-todo-row .icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.ex-todo-row:hover span {
  text-decoration: underline;
}

@media (max-width: 1023px) {
  .ex-hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .ex-hero-ring {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: auto minmax(0, 1fr);
    justify-items: start;
    text-align: left;
    padding: 16px;
  }
  .ex-hero-ring svg {
    width: 96px;
    height: 96px;
  }
  .ex-ring-txt {
    top: 16px;
    left: 16px;
    width: 96px;
    height: 96px;
  }
  .ex-ring-txt b {
    font-size: 26px;
  }
  .ex-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ex-kpi {
    padding: 14px;
  }
  .ex-kpi .val {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ex-ring-fg,
  .ex-kpi {
    transition: none;
  }
}

/* Printed report: A4 landscape, only the overview, on white */
@media print {
  .ex {
    page: paper-landscape;
    gap: 10px;
  }
  .body > .ex ~ * {
    display: none !important;
  }
  .ex .card {
    box-shadow: none !important;
    break-inside: avoid;
  }
  /* Cards one under the other: Chrome splits grid items badly across printed pages */
  .ex .dash {
    display: block;
  }
  .ex .dash > .card {
    margin-bottom: 10px;
  }
  .ex canvas {
    max-width: 100% !important;
    height: auto !important;
  }
  .ex .only-mobile {
    display: none !important;
  }
  .ex .only-desktop {
    display: table !important;
  }
  .ex-hero {
    grid-template-columns: 240px minmax(0, 1fr);
  }
  .ex-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
