/* ==========================================================================
   Giao diện chung của Cổng báo cáo (bản làm mới)
   Dùng cho trang đăng nhập, Tổng quan, Quản lý tài khoản và khung 3 báo cáo.
   Bên trong từng báo cáo có khối "GIAO DIỆN MỚI" riêng, cùng bộ màu này.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e4e9f0;
  --line-strong: #cfd8e3;
  --ink: #101c2b;
  --ink-2: #344456;
  --muted: #687789;
  --brand: #173b5f;
  --brand-700: #102d49;
  --brand-50: #eef3f9;
  --focus: #2f6fed;

  --nvl: #c2622d;
  --nvl-50: #fdf1e9;
  --be-day: #0f766e;
  --be-day-50: #e8f6f4;
  --vtkph: #c0392b;
  --vtkph-50: #fdecea;
  --ppt: #6d4bd1;
  --ppt-50: #f1edfc;

  --danger: #d92d20;
  --danger-ink: #912018;
  --danger-50: #fef3f2;
  --warn: #dc6803;
  --warn-ink: #93370d;
  --warn-50: #fffaeb;
  --ok: #079455;
  --ok-ink: #05603a;
  --ok-50: #ecfdf3;
  --info: #1570ef;
  --info-50: #eff8ff;

  --topbar-bg: rgba(243, 245, 249, 0.86);
  --line-hover: #b4c0ce;
  --chip-bg: #eef2f6;
  --grid: #edf1f5;
  --row-hover: #fafbfd;
  --sk-1: #edf1f5;
  --sk-2: #f6f8fb;
  --danger-line: #f6cfcb;
  --danger-100: #fee4e2;
  --ok-line: #abefc6;
  --info-line: #b2ddff;
  --info-ink: #175cd3;

  --side: #0d1b2b;
  --side-2: #12263b;
  --side-ink: #c6d2de;
  --side-muted: #8194a8;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.07), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, 0.14);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --side-w: 252px;
  --side-gon: 72px;
  font-family: var(--font);
}

/* Giao diện tối: chỉ đổi biến màu, các khối dùng chung bộ biến nên tự đổi theo.
   Thanh bên vốn đã tối nên giữ nguyên. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b131d;
  --surface: #111c29;
  --surface-2: #0e1823;
  --line: #1f2c3b;
  --line-strong: #2d3d51;
  --ink: #e7eef6;
  --ink-2: #c2cedb;
  --muted: #8b9cb0;
  --brand: #3d7cc9;
  --brand-700: #2f6ab3;
  --brand-50: rgba(61, 124, 201, 0.16);
  --focus: #5b9bff;

  --nvl: #e07b45;
  --nvl-50: rgba(224, 123, 69, 0.16);
  --be-day: #2bb3a6;
  --be-day-50: rgba(43, 179, 166, 0.16);
  --vtkph: #e5584a;
  --vtkph-50: rgba(229, 88, 74, 0.16);
  --ppt: #9b7cf0;
  --ppt-50: rgba(155, 124, 240, 0.16);

  --danger: #f04438;
  --danger-ink: #ff9c91;
  --danger-50: rgba(240, 68, 56, 0.15);
  --warn: #f79009;
  --warn-ink: #fdb022;
  --warn-50: rgba(247, 144, 9, 0.15);
  --ok: #17b26a;
  --ok-ink: #6ce9a6;
  --ok-50: rgba(23, 178, 106, 0.15);
  --info: #2e90fa;
  --info-50: rgba(46, 144, 250, 0.15);

  --topbar-bg: rgba(11, 19, 29, 0.86);
  --line-hover: #3d5068;
  --chip-bg: #1b2837;
  --grid: #1a2735;
  --row-hover: #142131;
  --sk-1: #162231;
  --sk-2: #1d2b3c;
  --danger-line: rgba(240, 68, 56, 0.4);
  --danger-100: rgba(240, 68, 56, 0.24);
  --ok-line: rgba(23, 178, 106, 0.4);
  --info-line: rgba(46, 144, 250, 0.4);
  --info-ink: #84b8ff;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.45);
}

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

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* ------------------------------ khung trang ------------------------------ */

/* Thanh bên luôn thu gọn thành dải biểu tượng; rê chuột (hoặc Tab tới) thì bung
   ra phủ lên nội dung, rời chuột thì thu lại sau một nhịp ngắn. */
.app {
  min-height: 100vh;
  padding-left: var(--side-gon);
}

.app-main {
  display: flex;
  min-width: 0;
  min-height: 100vh;
  flex-direction: column;
}

/* ------------------------------ thanh bên ------------------------------ */

.side {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: var(--side-gon);
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  color: var(--side-ink);
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(74, 141, 214, 0.16), transparent 60%),
    linear-gradient(180deg, var(--side-2), var(--side));
  transition: width 0.2s ease 0.28s, box-shadow 0.2s ease 0.28s;
}

.side-brand {
  display: flex;
  min-height: 68px;
  align-items: center;
  gap: 11px;
  padding: 14px 17px;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
}

.side-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #173b5f 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18), 0 6px 16px rgba(0, 0, 0, 0.25);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

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

.side-brand-text strong,
.side-brand-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-brand-text strong {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.side-brand-text small {
  color: var(--side-muted);
  font-size: 11.5px;
}

.side-scroll {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 10px 12px;
  scrollbar-width: none;
}

.side-label {
  margin: 16px 10px 6px;
  color: var(--side-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  white-space: nowrap;
}

.side-link {
  position: relative;
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  gap: 11px;
  margin: 2px 0;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  color: var(--side-ink);
  background: transparent;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, color 0.12s ease;
}

.side-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.side-link[aria-current="page"] {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.side-link[aria-current="page"]::before {
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: -10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--tone, #60a5fa);
  content: "";
}

.side-ico {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border-radius: 8px;
  color: var(--tone, #9fb4c9);
  background: rgba(255, 255, 255, 0.06);
}

.side-ico svg {
  width: 16px;
  height: 16px;
}

.side-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-badge {
  position: absolute;
  top: 50%;
  right: 10px;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
  transform: translateY(-50%);
}

.side-foot {
  display: grid;
  gap: 2px;
  padding: 10px 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  padding: 7px 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

.side-avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  color: #0d1b2b;
  background: linear-gradient(135deg, #f6c69f, #e5a475);
  font-size: 12.5px;
  font-weight: 800;
}

.side-user-text {
  min-width: 0;
  flex: 1;
}

.side-user-text strong,
.side-user-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-user-text strong {
  color: #fff;
  font-size: 13.5px;
}

.side-user-text small {
  color: var(--side-muted);
  font-size: 11.5px;
}

.side-action {
  min-height: 36px;
  font-size: 13px;
}

/* Nút sáng / tối: đang sáng hiện mặt trăng (bấm để sang tối), đang tối hiện mặt trời. */
.side-theme .i-sun,
:root[data-theme="dark"] .side-theme .i-moon {
  display: none;
}

:root[data-theme="dark"] .side-theme .i-sun {
  display: block;
}

/* Chữ trong thanh bên chỉ hiện khi thanh bung ra. */
.side-brand-text,
.side-text,
.side-label,
.side-user-text {
  opacity: 0;
  transition: opacity 0.14s ease 0.2s;
}

@media (min-width: 901px) {
  .side:hover,
  .side:focus-within {
    width: var(--side-w);
    box-shadow: 14px 0 36px rgba(13, 27, 43, 0.3);
    transition-delay: 0.08s;
  }

  .side:hover :is(.side-brand-text, .side-text, .side-label, .side-user-text),
  .side:focus-within :is(.side-brand-text, .side-text, .side-label, .side-user-text) {
    opacity: 1;
    transition-delay: 0.12s;
  }

  /* Lúc thu gọn: số đếm nằm ở góc biểu tượng, ô Tự đồng bộ tạm ẩn. */
  .side:not(:hover):not(:focus-within) .side-badge {
    top: 3px;
    right: auto;
    left: 30px;
    min-width: 18px;
    padding: 0 5px;
    font-size: 10px;
    transform: none;
  }

  .side:not(:hover):not(:focus-within) .dbn {
    display: none;
  }
}

/* Ô "Tự đồng bộ" (tài khoản quản trị) nằm trong chân thanh bên. */
.side .dbn.dbn-inline {
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--side-ink);
}

.side .dbn-inline .dbn-title {
  display: block;
  width: 100%;
  margin: 0 0 2px 2px;
  color: var(--side-muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side .dbn-inline .dbn-item {
  color: var(--side-ink);
  background: rgba(255, 255, 255, 0.07);
}

.side .dbn-inline .dbn-item[data-state="quyen"],
.side .dbn-inline .dbn-item[data-state="can-xem"] {
  color: #7a5200;
  background: #fff4d6;
}

.side .dbn-inline .dbn-item[data-state="loi"] {
  color: #9b1c1c;
  background: #fde8e8;
}

/* ------------------------------ thanh trên ------------------------------ */

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  min-height: 64px;
  align-items: center;
  gap: 14px;
  padding: 12px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: saturate(160%) blur(10px);
}

.topbar-menu {
  display: none;
  width: 40px;
  height: 40px;
  flex: none;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.topbar-menu svg {
  width: 18px;
  height: 18px;
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.topbar-title h1 {
  margin: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title p {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.page {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: clamp(16px, 2.4vw, 28px) clamp(16px, 3vw, 32px) 48px;
}

/* ------------------------------ nút ------------------------------ */

.btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.btn:hover {
  border-color: var(--line-hover);
  color: var(--ink);
  background: var(--surface-2);
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn-primary {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
}

.btn-primary:hover {
  border-color: var(--brand-700);
  color: #fff;
  background: var(--brand-700);
}

.btn-sm {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12.5px;
}

.btn:disabled {
  cursor: wait;
  opacity: 0.6;
}

.btn.spin svg {
  animation: xoay 0.9s linear infinite;
}

@keyframes xoay {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------ thẻ chung ------------------------------ */

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 0;
}

.card-head h2,
.card-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card-head small {
  color: var(--muted);
  font-size: 12.5px;
}

.card-body {
  padding: 14px 18px 18px;
}

.section {
  margin-top: 26px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.count-pill {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  background: var(--danger);
  font-size: 12.5px;
  font-weight: 700;
}

.count-pill[data-tone="ok"] {
  background: var(--ok);
}

.count-pill[data-tone="warn"] {
  background: var(--warn);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--chip-bg);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.85;
}

.chip[data-tone="ok"] {
  color: var(--ok-ink);
  background: var(--ok-50);
}

.chip[data-tone="warn"] {
  color: var(--warn-ink);
  background: var(--warn-50);
}

.chip[data-tone="do"] {
  color: var(--danger-ink);
  background: var(--danger-50);
}

/* ------------------------------ Cần lưu ý ------------------------------ */

/* Thẻ Cần lưu ý có danh sách chi tiết nên để 2 cột cho dễ đọc, màn rất rộng mới 4 cột. */
.alerts {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.reports {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (min-width: 1760px) {
  .alerts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1240px) {
  .reports {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .alerts,
  .reports {
    grid-template-columns: minmax(0, 1fr);
  }
}

.alert {
  --tone: var(--muted);
  --tone-50: #f2f4f7;
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.alert::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--tone);
  content: "";
}

.alert[data-level="do"] {
  --tone: var(--danger);
  --tone-50: var(--danger-50);
  border-color: var(--danger-line);
}

.alert[data-level="vang"] {
  --tone: var(--warn);
  --tone-50: var(--warn-50);
  border-color: #f8dcb5;
}

.alert[data-level="xanh"] {
  --tone: var(--ok);
  --tone-50: var(--ok-50);
}

.alert-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 10px 20px;
}

.alert-ico {
  display: grid;
  width: 38px;
  height: 38px;
  flex: none;
  place-items: center;
  border-radius: 11px;
  color: var(--tone);
  background: var(--tone-50);
}

.alert-ico svg {
  width: 19px;
  height: 19px;
}

.alert-head {
  min-width: 0;
  flex: 1;
}

.alert-head small {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.alert-head h3 {
  margin: 2px 0 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.alert-num {
  color: var(--tone);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1;
}

.alert-desc {
  margin: 0;
  padding: 0 16px 10px 20px;
  color: var(--ink-2);
  font-size: 13px;
}

.alert-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0 10px 8px 14px;
  list-style: none;
}

.alert-list li {
  display: grid;
  align-items: baseline;
  gap: 2px 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 7px 6px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
}

.alert-list li:first-child {
  border-top: 0;
}

.alert-list b {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-list span {
  color: var(--muted);
  font-size: 12px;
}

.alert-list em {
  color: var(--tone);
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.alert-list .alert-sub {
  grid-column: 1 / -1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding: 10px 16px 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.alert-foot span {
  color: var(--muted);
  font-size: 12px;
}

.alert-link {
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.alert-link:hover {
  text-decoration: underline;
}

/* ------------------------------ số liệu chính ------------------------------ */

.kpis {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1279px) {
  .kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Ô số liệu bấm được: ô đang chọn là ô biểu đồ bên dưới đang vẽ. */
.kpi-pick {
  display: block;
  width: 100%;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.kpi-pick:hover {
  border-color: color-mix(in srgb, var(--tone) 45%, var(--line));
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}

.kpi-pick[aria-pressed="true"] {
  border-color: var(--tone);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 10%, var(--surface)), var(--surface) 70%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tone) 18%, transparent), var(--shadow);
}

.kpi-sub {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.sk-tile {
  height: 92px;
}

.chart-card,
.chart-pair {
  margin-top: 14px;
}

.chart-card .card-head small {
  display: block;
  margin-top: 2px;
}

.chart .bar-value {
  fill: var(--ink-2);
  font-size: 11px;
  font-weight: 600;
}

.chart .bar-value.is-strong {
  fill: var(--ink);
  font-weight: 800;
}

.kpi {
  --tone: var(--brand);
  --tone-50: var(--brand-50);
  position: relative;
  min-width: 0;
  padding: 16px 16px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi[data-tone="nvl"] {
  --tone: var(--nvl);
  --tone-50: var(--nvl-50);
}

.kpi[data-tone="be-day"] {
  --tone: var(--be-day);
  --tone-50: var(--be-day-50);
}

.kpi[data-tone="vtkph"] {
  --tone: var(--vtkph);
  --tone-50: var(--vtkph-50);
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.kpi-label i {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 3px;
  background: var(--tone);
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-top: 8px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-value small {
  color: var(--muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.kpi-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.delta[data-dir="up"] {
  color: var(--ok-ink);
  background: var(--ok-50);
}

.delta[data-dir="down"] {
  color: var(--danger-ink);
  background: var(--danger-50);
}

.delta[data-dir="flat"] {
  color: var(--ink-2);
  background: var(--chip-bg);
}

.kpi-bar {
  display: flex;
  height: 6px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--chip-bg);
}

.kpi-bar span {
  height: 100%;
}

/* ------------------------------ biểu đồ ------------------------------ */

.grid-2 {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr));
}

.chart {
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart text {
  fill: var(--muted);
  font-family: var(--font);
  font-size: 11px;
}

.chart .grid-line {
  stroke: var(--grid);
}

.chart .axis {
  stroke: var(--line-strong);
}

.chart .bar {
  transition: opacity 0.12s ease;
}

.chart .bar:hover {
  opacity: 0.82;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 0 0 8px;
  color: var(--ink-2);
  font-size: 12.5px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.chart-tip {
  position: fixed;
  z-index: 90;
  padding: 7px 10px;
  border-radius: 8px;
  color: #fff;
  background: rgba(16, 28, 43, 0.94);
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}

/* ------------------------------ thẻ báo cáo ------------------------------ */

.rp {
  --tone: var(--brand);
  --tone-50: var(--brand-50);
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.rp:hover {
  border-color: color-mix(in srgb, var(--tone) 35%, var(--line));
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.rp[data-tone="nvl"] {
  --tone: var(--nvl);
  --tone-50: var(--nvl-50);
}

.rp[data-tone="be-day"] {
  --tone: var(--be-day);
  --tone-50: var(--be-day-50);
}

.rp[data-tone="vtkph"] {
  --tone: var(--vtkph);
  --tone-50: var(--vtkph-50);
}

.rp[data-tone="ppt"] {
  --tone: var(--ppt);
  --tone-50: var(--ppt-50);
}

.rp-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rp-ico {
  display: grid;
  width: 42px;
  height: 42px;
  flex: none;
  place-items: center;
  border-radius: 12px;
  color: var(--tone);
  background: var(--tone-50);
}

.rp-ico svg {
  width: 21px;
  height: 21px;
}

.rp h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.rp p {
  margin: 0;
  color: var(--ink-2);
  font-size: 13px;
}

.rp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.rp-go {
  color: var(--tone);
  font-weight: 700;
  white-space: nowrap;
}

/* ------------------------------ bảng ------------------------------ */

.table-wrap {
  overflow-x: auto;
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tbl th,
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.tbl th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tbl tr:last-child td {
  border-bottom: 0;
}

.tbl td small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

/* ------------------------------ trạng thái tải ------------------------------ */

.sk {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--sk-1) 25%, var(--sk-2) 37%, var(--sk-1) 63%);
  background-size: 400% 100%;
  animation: sk 1.3s ease infinite;
}

.sk-block {
  width: 100%;
  height: 120px;
}

.sk-line {
  height: 18px;
}

@keyframes sk {
  0% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0 50%;
  }
}

.empty {
  padding: 28px 16px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.note-error {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--danger-line);
  border-radius: 12px;
  color: var(--danger-ink);
  background: var(--danger-50);
  font-size: 13.5px;
}

/* ------------------------------ biểu mẫu & hộp thoại ------------------------------ */

.field {
  margin-bottom: 16px;
}

.field label,
.field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(47, 111, 237, 0.14);
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-2);
  font-size: 13.5px;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(13, 27, 43, 0.5);
  backdrop-filter: blur(3px);
}

.dialog-content {
  padding: 24px;
}

.dialog-content h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
}

.dialog-content > p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

.form-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 8px;
}

.message {
  display: none;
  margin: 0 0 16px;
  padding: 11px 13px;
  border: 1px solid;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.45;
}

.message.visible {
  display: block;
}

.message.error {
  border-color: var(--danger-line);
  color: var(--danger-ink);
  background: var(--danger-50);
}

.message.success {
  border-color: var(--ok-line);
  color: var(--ok-ink);
  background: var(--ok-50);
}

.message.info {
  border-color: var(--info-line);
  color: var(--info-ink);
  background: var(--info-50);
}

/* Nút kiểu cũ của trang Quản lý tài khoản, cùng phong cách mới. */
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button-primary {
  border-color: var(--brand);
  color: #fff;
  background: var(--brand);
  box-shadow: var(--shadow-sm);
}

.button-primary:hover {
  background: var(--brand-700);
}

.button-secondary {
  border-color: var(--line-strong);
  color: var(--ink-2);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.button-secondary:hover {
  background: var(--surface-2);
}

.button-danger {
  border-color: var(--danger-line);
  color: var(--danger-ink);
  background: var(--danger-50);
}

.button-danger:hover {
  background: var(--danger-100);
}

.button-small {
  min-height: 32px;
  padding: 0 11px;
  border-radius: 8px;
  font-size: 12.5px;
}

.link-button {
  margin-top: 8px;
  padding: 0;
  border: 0;
  color: var(--focus);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.link-button:hover {
  text-decoration: underline;
}

/* ------------------------------ Quản lý tài khoản ------------------------------ */

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 18px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
}

.panel-body {
  padding: 20px;
}

.panel-note {
  margin: 0;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.55;
}

.create-grid {
  display: grid;
  align-items: end;
  gap: 12px;
  grid-template-columns: 1fr 1.25fr 1fr 0.8fr auto;
}

.create-grid .field {
  margin: 0;
}

.create-grid .button-primary {
  min-height: 44px;
}

.report-picks {
  min-width: 0;
  margin: 0;
  padding: 10px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  grid-column: 1 / -1;
}

.report-picks legend {
  padding: 0 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 600;
}

.report-pick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
}

.report-pick-list.stacked {
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.report-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.report-pick input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--brand);
}

.report-pick input:disabled + span {
  color: var(--muted);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  text-align: left;
  vertical-align: middle;
}

.users-table th {
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.users-table tr:last-child td {
  border-bottom: 0;
}

.users-table tbody tr:hover td {
  background: var(--row-hover);
}

.users-table td:first-child {
  min-width: 170px;
}

.user-name {
  font-weight: 700;
}

.user-login {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-admin {
  color: var(--warn-ink);
  background: var(--warn-50);
}

.badge-viewer,
.badge-report {
  color: var(--info-ink);
  background: var(--info-50);
}

.badge-active {
  color: var(--ok-ink);
  background: var(--ok-50);
}

.badge-locked {
  color: var(--danger-ink);
  background: var(--danger-50);
}

.access-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.access-all {
  color: var(--muted);
  font-size: 13px;
}

.empty-state {
  padding: 44px 20px;
  color: var(--muted);
  text-align: center;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

.password-row {
  display: flex;
  gap: 8px;
}

.password-row input {
  min-width: 0;
  flex: 1;
}

.password-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--ok-line);
  border-radius: 10px;
  background: var(--ok-50);
}

.password-reveal code {
  flex: 1;
  font: 700 18px/1.3 Consolas, "Cascadia Mono", "Courier New", monospace;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
}

.dialog-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  color: var(--danger-ink);
  background: var(--danger-50);
  font-size: 13px;
}

.access-help {
  margin: 0 0 16px;
}

#password-step-done .field-help {
  margin: 10px 0 18px;
}

/* ------------------------------ đăng nhập ------------------------------ */

.auth {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
}

.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  overflow: hidden;
  padding: clamp(28px, 5vw, 64px);
  color: #fff;
  background:
    radial-gradient(80% 60% at 10% 0%, rgba(59, 130, 246, 0.35), transparent 60%),
    radial-gradient(60% 50% at 100% 100%, rgba(229, 164, 117, 0.22), transparent 60%),
    linear-gradient(160deg, #12263b, #0b1724);
}

.auth-hero::after {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  content: "";
  mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent);
}

.auth-hero > * {
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand .side-mark {
  width: 44px;
  height: 44px;
}

.auth-brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
}

.auth-brand small {
  display: block;
  color: #9fb2c6;
  font-size: 12.5px;
}

.auth-copy h1 {
  max-width: 14ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(34px, 4.4vw, 56px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.06;
}

.auth-copy h1 span {
  color: #f2b98c;
}

.auth-copy p {
  max-width: 46ch;
  margin: 16px 0 0;
  color: #b8c7d6;
  font-size: 15px;
}

.auth-points {
  display: grid;
  gap: 10px;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d6e0ea;
  font-size: 14px;
}

.auth-points i {
  display: grid;
  width: 26px;
  height: 26px;
  flex: none;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-style: normal;
}

.auth-foot {
  color: #8ea2b6;
  font-size: 12.5px;
}

.auth-main {
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 64px);
}

.auth-card {
  width: min(100%, 420px);
}

.auth-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.auth-card > p {
  margin: 6px 0 26px;
  color: var(--muted);
}

.auth-card .button-primary {
  width: 100%;
  min-height: 46px;
  margin-top: 6px;
  font-size: 15px;
}

.setup-link {
  display: none;
  margin-top: 18px;
  color: var(--focus);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

.setup-link.visible {
  display: block;
}

/* ------------------------------ khung báo cáo ------------------------------ */

.app-report {
  height: 100vh;
  overflow: hidden;
}

.app-report .app-main {
  height: 100vh;
}

.app-report .topbar {
  display: none;
}

.report-frame {
  display: block;
  width: 100%;
  min-height: 0;
  flex: 1;
  border: 0;
  background: var(--bg);
}

/* ------------------------------ màn hình nhỏ ------------------------------ */

.side-scrim {
  display: none;
}

@media (max-width: 1100px) {
  .create-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .app {
    padding-left: 0;
  }

  /* Điện thoại / máy tính bảng: thanh bên mở bằng nút ☰, luôn đầy đủ chữ. */
  .side {
    width: min(86vw, 300px);
    transform: translateX(-102%);
    transition: transform 0.2s ease;
  }

  .app[data-side="mo"] .side {
    transform: none;
    box-shadow: var(--shadow-lg);
  }

  .app[data-side="mo"] .side-scrim {
    position: fixed;
    z-index: 35;
    inset: 0;
    display: block;
    background: rgba(13, 27, 43, 0.45);
  }

  .side-brand-text,
  .side-text,
  .side-label,
  .side-user-text {
    opacity: 1;
  }

  .topbar-menu {
    display: grid;
  }

  .app-report .topbar {
    display: flex;
    min-height: 54px;
    padding-block: 7px;
  }

  .app-report .topbar-title h1 {
    font-size: 16px;
  }

  .app-report .topbar-title p {
    display: none;
  }

  .auth {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    min-height: 0;
    padding: 26px 20px 30px;
  }

  .auth-points,
  .auth-foot {
    display: none;
  }

  .auth-copy h1 {
    font-size: 30px;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-title h1 {
    font-size: 19px;
  }

  .topbar-actions .btn-text {
    display: none;
  }

  .create-grid {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .panel-body {
    padding: 15px;
  }

  .kpi-value {
    font-size: 25px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .side,
  .topbar {
    display: none !important;
  }

  .app {
    display: block;
    padding-left: 0;
  }
}
