/* SITE — Báo cáo quản trị (theme kem + đỏ UEB, gần báo cáo Power BI) */
:root {
  --bg: #faf7f2;
  --bg-elevated: #ffffff;
  --surface: #f2ebe2;
  --border: rgba(139, 21, 56, 0.18);
  --text: #2b1812;
  --text-muted: #5c4d47;
  --accent: #8b1538;
  --accent-bright: #a61d42;
  --accent-dim: rgba(139, 21, 56, 0.12);
  --chart-gold: #d4a017;
  --chart-terracotta: #9c4c3a;
  --success: #2f6f4e;
  --warning: #c9972e;
  --font: "Be Vietnam Pro", "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  --shadow: 0 10px 40px -12px rgba(43, 24, 18, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: linear-gradient(180deg, #fffefc 0%, var(--bg) 45%, #f5efe6 100%);
  color: var(--text);
  line-height: 1.5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* —— Navbar —— */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 254, 252, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.logos {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.logos img {
  height: 44px;
  width: auto;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px 4px;
}

.logos img:first-child {
  max-height: 48px;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: clamp(0.85rem, 2.5vw, 1rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.brand-text .sub {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-controls label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.segment-select {
  appearance: none;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 2.25rem 0.5rem 0.85rem;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235c4d47' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
}

.segment-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--accent);
}

a.btn-ghost {
  text-decoration: none;
  display: inline-block;
}

.btn-ghost[hidden] {
  display: none !important;
}

/* —— Main —— */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.view {
  display: none;
  animation: fadeIn 0.35s ease;
}

.view.is-active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-title {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.view-desc {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* —— Landing tiles —— */
.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  min-height: calc(100vh - 180px);
  align-items: stretch;
}

@media (max-width: 768px) {
  .tile-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

.tile {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(165deg, #ffffff 0%, #faf6f0 100%);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
  overflow: hidden;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, var(--accent-dim), transparent 50%);
  pointer-events: none;
}

.tile:hover,
.tile:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(139, 21, 56, 0.35);
  box-shadow: var(--shadow), 0 0 0 1px rgba(139, 21, 56, 0.12);
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.tile-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 220px;
}

.tile-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: var(--accent-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.tile h2 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tile p {
  margin: 0.65rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  flex: 1;
}

.tile-cta {
  margin-top: 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.tile-cta span {
  transition: transform 0.2s ease;
}

.tile:hover .tile-cta span {
  transform: translateX(4px);
}

/* —— Dashboard layout —— */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}

.kpi-card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}

.kpi-card .value {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.kpi-card .hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.embed-panel {
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.embed-panel strong {
  display: block;
  margin-bottom: 0.5rem;
}

.embed-panel p {
  margin: 0;
  color: var(--text-muted);
  max-width: 480px;
  font-size: 0.9rem;
}

/* —— Đào tạo: xem PDF —— */
.dao-pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.dao-pdf-toolbar .dao-pdf-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.dao-pdf-toolbar .dao-pdf-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Tràn ngang viewport (khít chiều trang) */
.dao-pdf-fullbleed {
  width: 100vw;
  position: relative;
  left: 50%;
  right: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  margin-bottom: 0.35rem;
}

.dao-pdf-fullbleed .dao-pdf-js-wrap {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.dao-pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 0.5rem 1.25rem;
  background: #fffefc;
}

.dao-pdf-page-canvas {
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 14px rgba(43, 24, 18, 0.07);
}

.dao-pdf-loading,
.dao-pdf-error {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  margin: 0;
}

.dao-pdf-iframe-fallback {
  width: 100%;
  min-height: 75vh;
  border: 0;
  display: block;
  background: #fff;
}

.dao-pdf-iframe-fallback[hidden] {
  display: none !important;
}

.dao-pdf-fallback {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background: var(--surface);
}

.dao-pdf-fallback a {
  font-weight: 600;
}

.table-placeholder {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.875rem;
}

.table-placeholder th,
.table-placeholder td {
  border: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  text-align: left;
}

.table-placeholder th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-placeholder tbody tr:nth-child(even) {
  background: rgba(139, 21, 56, 0.04);
}

/* —— Tuyển sinh: ngữ cảnh kỳ báo cáo —— */
.ts-period-banner {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(139, 21, 56, 0.22);
  background: rgba(139, 21, 56, 0.06);
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.ts-period-banner strong {
  color: var(--text);
  font-weight: 600;
}

.ts-100do-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.ts-100do-toolbar label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0;
}

.ts-100do-toolbar .segment-select {
  min-width: min(100%, 280px);
}

/* —— Tuyển sinh: bảng dữ liệu —— */
.ts-section {
  margin-bottom: 2.25rem;
}

.ts-section h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.ts-section .ts-note {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tvts-subhead {
  margin: 1.35rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

.tvts-note-small {
  font-size: 0.8rem;
  margin-top: -0.15rem;
}

.tvts-compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

.tvts-compare-table th,
.tvts-compare-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  text-align: left;
}

.tvts-compare-table thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.tvts-compare-table tbody tr:nth-child(even) {
  background: rgba(139, 21, 56, 0.04);
}

.tvts-compare-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.tvts-table-scroll-wrap {
  max-height: min(480px, 55vh);
  overflow: auto;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.tvts-dialog-table-wrap {
  max-height: min(48vh, 520px);
  margin-top: 0.75rem;
}

.tvts-dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(960px, 96vw);
  width: 100%;
  background: var(--bg-elevated);
  color: var(--text);
  box-shadow: 0 16px 48px rgba(43, 24, 18, 0.22);
}

.tvts-dialog::backdrop {
  background: rgba(43, 24, 18, 0.45);
}

.tvts-dialog-panel {
  padding: 1rem 1.15rem 1.2rem;
  max-height: min(92vh, 880px);
  overflow: auto;
}

.tvts-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.tvts-dialog-head h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--accent);
}

.tvts-dialog-close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.tvts-dialog-close:hover {
  color: var(--accent);
  border-color: rgba(139, 21, 56, 0.35);
}

.tvts-dialog-chart {
  height: min(360px, 38vh);
  min-height: 240px;
  margin-bottom: 0.25rem;
}

.tvts-link-btn {
  margin-left: 0.35rem;
  vertical-align: baseline;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th,
.data-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.65rem;
  vertical-align: middle;
}

.data-table thead th {
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.data-table tbody th {
  font-weight: 600;
  text-align: left;
  background: rgba(242, 235, 226, 0.95);
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr:nth-child(even):not(.row-total) {
  background: rgba(139, 21, 56, 0.04);
}

.data-table tr.row-total td,
.data-table tr.row-total th {
  background: rgba(139, 21, 56, 0.1);
  font-weight: 700;
  border-top-width: 2px;
}

.data-table .cell-empty {
  color: var(--text-muted);
}

.chart-plan {
  margin-top: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 0;
  overflow: hidden;
}

.chart-plan summary {
  padding: 0.85rem 1rem;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.chart-plan summary::-webkit-details-marker {
  display: none;
}

.chart-plan summary::after {
  content: " ▼";
  font-size: 0.7rem;
  color: var(--text-muted);
}

.chart-plan[open] summary::after {
  content: " ▲";
}

.chart-plan .plan-body {
  padding: 0 1rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.875rem;
}

.chart-plan .plan-body ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.chart-plan .plan-body li {
  margin-bottom: 0.45rem;
}

.chart-plan .plan-body strong {
  color: var(--text);
}

/* —— ECharts containers —— */
.chart-wrap {
  width: 100%;
  height: min(420px, 55vh);
  min-height: 280px;
  margin-bottom: 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
}

.chart-wrap.chart-wrap-tall {
  height: min(480px, 62vh);
  min-height: 360px;
}

.chart-wrap.chart-wrap-compact {
  height: min(288px, 36vh);
  min-height: 240px;
  margin-bottom: 0.75rem;
}

.chart-wrap.chart-wrap-extra-tall {
  height: min(560px, 70vh);
  min-height: 400px;
}

.chart-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  align-items: stretch;
}

@media (max-width: 900px) {
  .chart-grid-2 {
    grid-template-columns: 1fr;
  }
  .chart-wrap {
    height: 360px;
  }
  .chart-wrap.chart-wrap-tall {
    height: min(420px, 58vh);
    min-height: 340px;
  }
  .chart-wrap.chart-wrap-compact {
    height: 260px;
    min-height: 220px;
  }
  .chart-wrap.chart-wrap-extra-tall {
    height: min(480px, 62vh);
    min-height: 360px;
  }
}

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--accent-dim);
  color: var(--accent-bright);
  font-weight: 600;
}

.view-desc code {
  font-size: 0.85em;
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}
