/* ====================================================================
   FIN-CASHFLOW — Global styles
   Yêu cầu giao diện:
   - Chữ trong bảng dùng chữ thường (text-transform:none), trừ dòng tiêu đề (thead)
   - Cỡ chữ bảng = 13px
   - Bảng có đường kẻ phân cột nhỏ, mờ
   ==================================================================== */

h1 { font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif; }

/* Reference theme: finance.cattuong.cloud */
:root {
  --fin-font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, sans-serif;
  --fin-page-bg: #f5f7fa;
  --fin-text: #1c2b3a;
  --fin-muted: #64748b;
  --fin-border: #e2e6ea;
  --fin-sidebar: #0a3560;
  --fin-table-head: #0f4c81;
  --fin-primary: #15578c;
}

html, body, button, input, select, textarea {
  font-family: var(--fin-font) !important;
  letter-spacing: 0 !important;
}

body {
  background: var(--fin-page-bg) !important;
  color: var(--fin-text) !important;
  font-size: 14px;
  line-height: 1.5;
}

#app, .app-shell, #content {
  background-color: var(--fin-page-bg);
  color: var(--fin-text);
}

#sidebar {
  background: var(--fin-sidebar) !important;
  color: #fff !important;
}

#sidebar .menu-item,
#sidebar button,
#sidebar a {
  font-family: var(--fin-font) !important;
  font-size: 13px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--fin-font) !important;
  color: var(--fin-text);
  letter-spacing: 0 !important;
}

#pageTitle {
  font-size: 16px !important;
  line-height: 20px !important;
  font-weight: 700 !important;
}

#breadcrumb {
  font-size: 12px;
  color: var(--fin-muted);
}

button, input, select, textarea {
  font-size: 12.5px;
}

input, select, textarea {
  color: var(--fin-text) !important;
  background-color: #fff;
  border-color: var(--fin-border) !important;
  border-radius: 5px !important;
}

#content .bg-white,
#modal .bg-white,
.card {
  background-color: #fff !important;
}

#content .rounded-xl,
#content .rounded-2xl,
.card {
  border-radius: 8px !important;
}

#content .border,
#content .border-b,
#content .border-t,
#modal .border,
#modal .border-b,
#modal .border-t {
  border-color: var(--fin-border) !important;
}

/* Annual plan fullscreen mode: avoid nested scroll containers. */
#modal.fin-modal-fullscreen {
  padding: .5rem !important;
}
#modal.fin-modal-fullscreen > div {
  display: flex;
  flex-direction: column;
  width: calc(100vw - 1rem) !important;
  max-width: none !important;
  height: calc(100dvh - 1rem) !important;
  max-height: calc(100dvh - 1rem) !important;
}
#modal.fin-modal-fullscreen #modalBody {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow: auto !important;
}
#modal.fin-modal-fullscreen #annualEditorBody > .overflow-auto {
  max-height: none !important;
}
#modal.fin-modal-fullscreen #modalFooter {
  flex: 0 0 auto;
}

/* ---- Bảng chung ---- */
table {
  font-family: var(--fin-font);
  font-size: 12.5px;
  border-collapse: collapse;
}

/* Ô dữ liệu trong thân bảng: chữ thường (không in hoa) */
table tbody td {
  text-transform: none !important;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--fin-text);
}

/* Dòng tiêu đề (thead) giữ nguyên định dạng tiêu đề (có thể in hoa) */
table thead th {
  font-size: 11.5px;
}

/* Tiêu đề bảng thống nhất: xanh coban, chữ trắng in hoa, khoảng dòng dễ đọc. */
#content table thead th {
  background-color: var(--fin-table-head) !important;
  color: #ffffff !important;
  text-transform: uppercase !important;
  font-weight: 600 !important;
  line-height: 1.5 !important;
  padding-top: .55rem !important;
  padding-bottom: .55rem !important;
  vertical-align: middle !important;
  letter-spacing: 0 !important;
  border-color: rgba(255, 255, 255, .2) !important;
}

#content table thead tr,
#content table thead {
  background-color: var(--fin-table-head) !important;
}

/* Đường kẻ phân cột nhỏ, mờ giữa các ô (cả thead & tbody) */
table thead th,
table tbody td {
  border-right: 1px solid rgba(148, 163, 184, 0.22); /* slate-400 ~22% */
}
table thead th:last-child,
table tbody td:last-child {
  border-right: none;
}

/* Đường kẻ phân hàng mờ */
table tbody tr {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

/* Bỏ in hoa cho các nhãn nhỏ "uppercase" trong THÂN bảng (giữ ở tiêu đề thead) */
table tbody .uppercase {
  text-transform: none !important;
}

/* ====================================================================
   RESPONSIVE — Điện thoại & Máy tính bảng
   ==================================================================== */

/* ---- An toàn vùng tràn: không cho trang bị tràn ngang ---- */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
#app,
.app-shell {
  width: 100%;
  max-width: 100vw;
}
#content { -webkit-overflow-scrolling: touch; }

/* ---- Vùng cuộn ngang cho bảng dữ liệu ----
   Bọc bảng trong <div class="table-scroll"> để bảng cuộn ngang
   thay vì làm vỡ layout trên màn hình nhỏ. */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Thanh cuộn mảnh, đỡ chiếm chỗ */
  scrollbar-width: thin;
}
.table-scroll table {
  min-width: 100%;
  width: max-content;          /* bảng giãn theo nội dung, cuộn ngang khi tràn */
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 4px;
}

/* Trên màn hình rất nhỏ: thu nhỏ cỡ chữ bảng + giảm padding ô */
@media (max-width: 640px) {
  table { font-size: 12px; }
  table tbody td, table thead th { font-size: 12px; }
  table thead th, table tbody td { padding-left: .4rem; padding-right: .4rem; }
}

/* ---- Sidebar drawer: hiệu ứng trượt mượt trên mobile/tablet ---- */
#sidebar { will-change: transform; }

/* ---- Modal: chiếm gần hết màn hình trên mobile, bo góc dưới phẳng ---- */
@media (max-width: 640px) {
  #modal { align-items: flex-end; padding: 0; }
  #modal > div {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 92vh !important;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}

/* ---- AI drawer chiếm toàn màn hình trên mobile ---- */
@media (max-width: 640px) {
  #aiDrawer .max-w-md { max-width: 100% !important; }
}

/* ---- Lưới thẻ KPI/biểu đồ: tránh tràn ---- */
.kpi-grid > * { min-width: 0; }
canvas { max-width: 100% !important; }

/* ---- Khoá cuộn nền khi mở drawer trên mobile ---- */
body.no-scroll { overflow: hidden; }

/* Final cascade guard for the reference visual system. */
html body,
body.bg-slate-100,
#app.app-shell,
#content {
  background-color: var(--fin-page-bg) !important;
}

@media (min-width: 641px) {
  html body input:not([type="checkbox"]):not([type="radio"]),
  html body select,
  html body textarea,
  html body button {
    font-family: var(--fin-font) !important;
    font-size: 12.5px !important;
    letter-spacing: 0 !important;
  }
}


/* ====================================================================
   MOBILE HARDENING — Trải nghiệm dùng trên điện thoại
   ==================================================================== */
:root {
  --app-safe-top: max(env(safe-area-inset-top, 0px), 18px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
}
@supports (height: 100dvh) {
  #app.app-shell { height: 100dvh; }
  #sidebar { height: 100dvh; }
}
@supports not (height: 100dvh) {
  #app.app-shell { height: 100vh; }
  #sidebar { height: 100vh; }
}

#sidebar {
  max-width: min(88vw, 20rem);
  overflow: hidden;
}
#menu {
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(5.5rem + var(--app-safe-bottom));
}
body.no-scroll {
  overflow: hidden;
}
body.no-scroll #pwaInstallBanner,
body.no-scroll #pushPromptBanner { display: none; }

@media (max-width: 640px) {
  html, body {
    width: 100%;
    overflow-x: hidden;
  }
  body { touch-action: manipulation; }
  #app.app-shell {
    min-height: 100svh;
    padding-top: var(--app-safe-top);
    box-sizing: border-box;
    background: #f1f5f9;
  }

  /* Sidebar dùng như drawer, đủ rộng để đọc nhưng không che hết cảm giác ngữ cảnh. */
  #sidebar {
    top: var(--app-safe-top);
    bottom: 0;
    height: calc(100dvh - var(--app-safe-top)) !important;
    width: min(18rem, 88vw);
    max-width: 88vw;
  }
  #sidebarOverlay {
    top: var(--app-safe-top);
  }
  #sidebar .menu-item { min-height: 44px; }

  header {
    min-height: 3.25rem;
    padding-left: .75rem !important;
    padding-right: .75rem !important;
    gap: .5rem !important;
  }
  #pageTitle {
    min-width: 0;
    max-width: calc(100vw - 12.5rem);
    font-size: 1rem;
    line-height: 1.25rem;
  }
  #breadcrumb {
    padding-left: .75rem !important;
    padding-right: .75rem !important;
    scrollbar-width: none;
  }
  #breadcrumb::-webkit-scrollbar { display: none; }

  #content {
    padding: .75rem !important;
    overscroll-behavior: contain;
  }
  #content > * {
    min-width: 0;
    max-width: 100%;
  }
  #content .bg-white.rounded-xl,
  #content .bg-white.rounded-lg {
    border-radius: .75rem;
  }
  #content .p-4 { padding: .75rem !important; }
  #content .px-4 {
    padding-left: .75rem !important;
    padding-right: .75rem !important;
  }

  /* Ngăn iOS tự phóng to khi focus input nhỏ hơn 16px. */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important;
    min-height: 42px;
  }
  #content button,
  #modal button,
  header button {
    min-height: 40px;
  }

  /* Toolbar/filter trong từng chức năng tự xuống dòng, không làm tràn ngang. */
  #content .flex.flex-wrap {
    align-items: stretch;
  }
  #content .flex.flex-wrap > input:not([type="checkbox"]):not([type="radio"]),
  #content .flex.flex-wrap > select,
  #content .flex.flex-wrap > textarea {
    min-width: 0 !important;
    flex: 1 1 12rem;
  }
  #content .flex.flex-wrap > button {
    flex: 0 0 auto;
  }

  /* Bảng lớn cuộn ngang trong vùng bảng, không làm vỡ toàn bộ màn hình. */
  #content .overflow-x-auto,
  #content .table-scroll,
  #content .matrix-scroll {
    max-width: 100%;
    margin-left: -.75rem;
    margin-right: -.75rem;
    padding-left: .75rem;
    padding-right: .75rem;
    -webkit-overflow-scrolling: touch;
  }
  #content .overflow-x-auto > table:not(.matrix-table),
  #content .table-scroll > table:not(.matrix-table) {
    min-width: 720px;
    width: max-content;
  }
  #content table th,
  #content table td {
    white-space: nowrap;
    vertical-align: top;
  }
  .matrix-scroll { max-height: calc(100dvh - 240px); }
  .matrix-table { font-size: 11.5px; }

  /* Modal dạng bottom sheet, footer dễ bấm bằng một tay. */
  #modal > div {
    max-height: 96dvh !important;
  }
  #modalBody { padding: .75rem !important; }
  #modalFooter {
    padding: .75rem !important;
    flex-wrap: wrap;
    justify-content: stretch;
  }
  #modalFooter button {
    flex: 1 1 100%;
  }

  #notifPanel {
    position: fixed;
    top: calc(var(--app-safe-top) + 3.5rem);
    left: .75rem;
    right: .75rem;
    width: auto;
    max-width: none;
  }
  #toast {
    left: .75rem;
    right: .75rem;
    bottom: calc(.75rem + var(--app-safe-bottom));
    max-width: none;
  }

  /* Bảng nhiều cột trên điện thoại chuyển thành từng thẻ dữ liệu.
     Người dùng không phải kéo ngang rất xa để tới cột thao tác/trạng thái. */
  #content .mobile-table-wrap {
    overflow-x: auto;
  }
  #content .mobile-card-wrap {
    overflow-x: hidden !important;
    max-height: none !important;
  }
  #content .mobile-table-wrap > table.mobile-card-table {
    display: block;
    min-width: 100% !important;
    width: 100% !important;
    border: 0 !important;
  }
  #content table.mobile-card-table thead {
    display: none !important;
  }
  #content table.mobile-card-table tbody,
  #content table.mobile-card-table tfoot {
    display: block;
    width: 100%;
  }
  #content table.mobile-card-table tr {
    display: block;
    width: 100%;
    margin: 0 0 .75rem;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: .75rem;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }
  #content table.mobile-card-table tfoot tr {
    background: #f8fafc;
  }
  #content table.mobile-card-table td,
  #content table.mobile-card-table th {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    width: 100% !important;
    min-width: 0 !important;
    border-right: 0 !important;
    border-top: 1px solid rgba(148, 163, 184, .16);
    padding: .55rem .75rem !important;
    text-align: right;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  #content table.mobile-card-table td:first-child,
  #content table.mobile-card-table th:first-child {
    border-top: 0;
  }
  #content table.mobile-card-table td::before,
  #content table.mobile-card-table th::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    text-align: left;
    font-size: .68rem;
    line-height: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
  }
  #content table.mobile-card-table td[data-label=""]::before,
  #content table.mobile-card-table th[data-label=""]::before,
  #content table.mobile-card-table td[colspan]::before,
  #content table.mobile-card-table th[colspan]::before {
    content: none;
  }
  #content table.mobile-card-table td[data-label=""],
  #content table.mobile-card-table th[data-label=""],
  #content table.mobile-card-table td[colspan],
  #content table.mobile-card-table th[colspan] {
    display: block;
    text-align: center;
  }
  #content table.mobile-card-table td > *,
  #content table.mobile-card-table th > * {
    min-width: 0;
  }
}

@media (max-width: 420px) {
  #pageTitle { max-width: calc(100vw - 10.5rem); }
  #content .overflow-x-auto > table:not(.matrix-table),
  #content .table-scroll > table:not(.matrix-table) {
    min-width: 640px;
  }
  #content .flex.flex-wrap > button:not([title]) {
    flex: 1 1 auto;
  }
}

/* ====================================================================
   THU GỌN SIDEBAR (collapse) — chỉ áp dụng trên desktop (lg+)
   ==================================================================== */
@media (min-width: 1024px) {
  #sidebar.collapsed { width: 4.5rem; }
  #sidebar.collapsed .sidebar-label,
  #sidebar.collapsed .menu-label,
  #sidebar.collapsed .menu-code,
  #sidebar.collapsed .menu-group-label,
  #sidebar.collapsed #userBox .user-detail { display: none; }
  #sidebar.collapsed .menu-item { justify-content: center; padding-left: 0; padding-right: 0; }
  #sidebar.collapsed .menu-item i { width: auto; }
  #sidebar.collapsed #userBox { justify-content: center; }
  #sidebar.collapsed #sidebarCollapse i { transform: rotate(180deg); }
  /* Tooltip khi hover trên menu thu gọn */
  #sidebar.collapsed .menu-item { position: relative; }
  #sidebar.collapsed .menu-item:hover::after {
    content: attr(data-label);
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    margin-left: 8px; background: #0f172a; color: #fff; padding: 4px 10px;
    border-radius: 6px; font-size: 12px; white-space: nowrap; z-index: 60;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
  }
}

/* ====================================================================
   Sticky table controls + headers for normal data tables
   Tables scroll inside their own data area, so toolbars/filters above
   the table stay visible while the user scrolls table rows.
   Matrix tables keep their separate freeze-column implementation below.
   ==================================================================== */
#content .overflow-x-auto:has(> table:not(.matrix-table)),
#content .table-scroll:has(> table:not(.matrix-table)) {
  max-height: min(72vh, calc(100dvh - 16rem));
  overflow: auto;
  position: relative;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

#content .overflow-x-auto:has(> table:not(.matrix-table))::-webkit-scrollbar,
#content .table-scroll:has(> table:not(.matrix-table))::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

#content .overflow-x-auto:has(> table:not(.matrix-table))::-webkit-scrollbar-thumb,
#content .table-scroll:has(> table:not(.matrix-table))::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.55);
  border-radius: 4px;
}

#content .overflow-x-auto > table:not(.matrix-table) thead,
#content .table-scroll > table:not(.matrix-table) thead {
  position: sticky;
  top: 0;
  z-index: 30;
}

#content .overflow-x-auto > table:not(.matrix-table) thead th,
#content .table-scroll > table:not(.matrix-table) thead th {
  background: inherit;
  box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.35);
}

#content .overflow-x-auto > table:not(.matrix-table) thead tr,
#content .table-scroll > table:not(.matrix-table) thead tr {
  background-clip: padding-box;
}

@media (max-width: 640px) {
  #content .overflow-x-auto:has(> table:not(.matrix-table)),
  #content .table-scroll:has(> table:not(.matrix-table)) {
    max-height: min(68vh, calc(100dvh - 13rem));
  }
}

/* ====================================================================
   STICKY HEADER + FREEZE COLUMNS cho bảng ma trận / dữ liệu lớn
   Dùng class .matrix-scroll bọc bảng .matrix-table
   ==================================================================== */
.matrix-scroll {
  width: 100%;
  overflow: auto;
  max-height: calc(100vh - 320px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  position: relative;
}
.matrix-scroll::-webkit-scrollbar { height: 9px; width: 9px; }
.matrix-scroll::-webkit-scrollbar-thumb { background: rgba(148,163,184,.55); border-radius: 4px; }

.matrix-table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }

/* Sticky header (cuộn dọc vẫn thấy tiêu đề) */
.matrix-table thead th {
  position: sticky; top: 0; z-index: 20;
  background: #f1f5f9;
  box-shadow: inset 0 -1px 0 rgba(148,163,184,.35);
}
/* Sticky footer (tổng cộng luôn hiển thị dưới đáy bảng) */
.matrix-table tfoot td {
  position: sticky; bottom: 0; z-index: 20;
  box-shadow: inset 0 1px 0 rgba(148,163,184,.35);
}

/* Freeze columns: cột "Mã" (1) và "Nhóm" (2) cố định khi cuộn ngang */
.matrix-table .freeze-col-1,
.matrix-table .freeze-col-2 {
  position: sticky; z-index: 15; background: #fff;
}
.matrix-table thead .freeze-col-1,
.matrix-table thead .freeze-col-2 { z-index: 25; background: #f1f5f9; }
.matrix-table tfoot .freeze-col-1,
.matrix-table tfoot .freeze-col-2 { z-index: 25; }
.matrix-table .freeze-col-1 { left: 0; min-width: 84px; max-width: 110px; }
.matrix-table .freeze-col-2 { left: 84px; min-width: 200px; box-shadow: 2px 0 4px -1px rgba(0,0,0,.08); }
@media (max-width: 640px) {
  .matrix-table .freeze-col-1 { min-width: 64px; max-width: 72px; }
  .matrix-table .freeze-col-2 { left: 64px; min-width: 150px; }
}
/* Tô nền theo trạng thái hover/đậm cho cột đóng băng */
.matrix-table tbody tr:hover .freeze-col-1,
.matrix-table tbody tr:hover .freeze-col-2 { background: #f8fafc; }

/* Hàng cha (nhóm) có thể bung/thu gọn */
.matrix-table tr.group-parent { cursor: pointer; }
.matrix-table tr.child-row > td { background: #fcfdff; }
.matrix-table tr.child-row td:first-child { padding-left: 1.5rem; }

/* Hàng đang chọn (cho Status Bar) */
.matrix-table tbody tr.row-selected > td { background: #dbeafe !important; }

/* Gợi ý #3: khi kéo chọn vùng, chặn bôi đen văn bản & đổi con trỏ */
body.matrix-dragging { cursor: cell; }
body.matrix-dragging .matrix-table { user-select: none; -webkit-user-select: none; -moz-user-select: none; }
body.matrix-dragging .matrix-table tr.group-parent { cursor: cell; }

/* Chế độ sửa trực tiếp ma trận */
body.matrix-edit-mode .matrix-month-cell { background: #eef2ff; cursor: text; }
body.matrix-edit-mode .matrix-month-cell input { background: #fff; }
body.matrix-edit-mode .matrix-table tr.group-parent { cursor: default; }
.matrix-cell-input { outline: none; }
.matrix-cell-input:focus { border-color: #6366f1; box-shadow: 0 0 0 2px rgba(99,102,241,.25); }

/* Việc 3: ô đã sửa đè (USER override) khác với baseline KHTC */
.matrix-cell-override { background: #fffbeb !important; position: relative; }
.matrix-cell-override .ov-dot { color: #f59e0b; font-size: 8px; vertical-align: super; margin-left: 1px; }
body.matrix-edit-mode .matrix-cell-override { background: #fef3c7 !important; }

/* ====================================================================
   APP COLOR THEME — xanh navy và nền xám xanh theo giao diện tham chiếu
   ==================================================================== */
:root {
  --app-canvas: #f4f7fb;
  --app-sidebar: #0A3560;
  --app-sidebar-active: #2b5f88;
  --app-sidebar-hover: #1b5683;
  --app-sidebar-border: rgba(255, 255, 255, .16);
}

html,
body,
#app.app-shell {
  background-color: var(--app-canvas) !important;
}

#content {
  background-color: var(--app-canvas) !important;
}

#sidebar {
  background-color: var(--app-sidebar) !important;
  background-image: none !important;
  color: #f8fafc !important;
  opacity: 1 !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  isolation: isolate;
}

#sidebar::before,
#sidebar::after {
  display: none !important;
  content: none !important;
  background: none !important;
}

#sidebar > div,
#sidebar #menu,
#sidebar nav {
  background-color: transparent !important;
  background-image: none !important;
  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#sidebar > div:first-child,
#sidebar > div:last-child {
  border-color: var(--app-sidebar-border) !important;
}

#sidebar .menu-group-label {
  color: #8fc7ef !important;
}

#sidebar .menu-item {
  color: #f8fafc !important;
}

#sidebar .menu-item:hover {
  background-color: var(--app-sidebar-hover) !important;
}

#sidebar .menu-item.bg-brand-600 {
  background-color: var(--app-sidebar-active) !important;
  box-shadow: inset 3px 0 0 #7dd3fc;
}

#sidebar .menu-item .menu-icon {
  color: var(--menu-icon-color, #7dd3fc) !important;
  font-size: 14px;
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--menu-icon-color, #7dd3fc) 38%, transparent));
  transform: translateZ(0);
  transition: color .16s ease, filter .16s ease, transform .16s ease;
}

#sidebar .menu-item:hover .menu-icon,
#sidebar .menu-item.bg-brand-600 .menu-icon {
  color: var(--menu-icon-color, #7dd3fc) !important;
  filter: drop-shadow(0 0 5px color-mix(in srgb, var(--menu-icon-color, #7dd3fc) 58%, transparent));
  transform: scale(1.08);
}

#sidebar .menu-code {
  display: none !important;
}

header,
#breadcrumb,
#filterPanel,
#quickSearchMobile {
  background-color: #ffffff !important;
}

/* Các màn hình Vay vốn/Báo cáo đã có tiêu đề và bộ lọc riêng trong nội dung. */
body.compact-report-shell #breadcrumb {
  display: none !important;
}

@media (min-width: 1024px) {
  body.compact-report-shell header {
    display: none !important;
  }
}

@media (max-width: 1023px) {
  body.compact-report-shell header {
    min-height: 3rem;
    justify-content: flex-end;
  }
  body.compact-report-shell #pageTitle,
  body.compact-report-shell #quickSearchMobileBtn,
  body.compact-report-shell #filterToggle,
  body.compact-report-shell header .relative.ml-auto,
  body.compact-report-shell header .hidden.md\:flex {
    display: none !important;
  }
  body.compact-report-shell #menuToggle {
    display: inline-flex !important;
    margin-right: auto;
  }
}
.matrix-restore-btn { cursor: pointer; background: none; border: none; padding: 0 2px; line-height: 1; }

/* Context menu item */
#contextMenu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 14px; }
#contextMenu button:hover { background: #f1f5f9; }
#contextMenu .ctx-divider { height: 1px; background: #e2e8f0; margin: 4px 0; }

/* Shared KPI, toolbar and data-panel system modeled on the annual-plan reference. */
.fin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.fin-kpi-card {
  container-type: inline-size;
  min-width: 0;
  min-height: 86px;
  padding: 17px 18px 14px;
  background: #fff;
  border: 1px solid #edf0f3;
  border-left: 4px solid var(--kpi-accent, #0f4c81);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 44, 72, .08);
}
.fin-kpi-label {
  color: #60758a;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  text-transform: uppercase;
}
.fin-kpi-value {
  margin-top: 7px;
  color: #062f5b;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: visible;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.fin-kpi-value--compact { font-size: 18px; }
.fin-kpi-value--dense { font-size: 16px; }
.fin-kpi-value--tight { font-size: 14px; }
@container (min-width: 220px) {
  .fin-kpi-value--compact { font-size: 23px; }
  .fin-kpi-value--dense { font-size: 20px; }
  .fin-kpi-value--tight { font-size: 17px; }
}
.fin-kpi-sub {
  margin-top: 6px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.35;
}
.annual-detail-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.annual-detail-kpis .fin-kpi-card {
  min-height: 96px;
  padding: 17px 18px;
}
.annual-detail-kpis .fin-kpi-label {
  color: #334e68;
  font-size: 13px;
  font-weight: 800;
}
.annual-detail-kpis .fin-kpi-value {
  margin-top: 9px;
  font-size: 29px;
  font-weight: 800;
}
.annual-detail-kpis .fin-kpi-value--compact { font-size: 18px; }
.annual-detail-kpis .fin-kpi-value--dense { font-size: 16px; }
.annual-detail-kpis .fin-kpi-value--tight { font-size: 14px; }
@container (min-width: 220px) {
  .annual-detail-kpis .fin-kpi-value--compact { font-size: 24px; }
  .annual-detail-kpis .fin-kpi-value--dense { font-size: 21px; }
  .annual-detail-kpis .fin-kpi-value--tight { font-size: 18px; }
}
@media (max-width: 1100px) {
  .annual-detail-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .annual-detail-kpis { grid-template-columns: 1fr; }
}
.fin-status-kpi {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 86px;
  padding: 15px 16px;
  overflow: hidden;
  text-align: left;
  background: #fff;
  border: 1px solid #edf0f3;
  border-left: 4px solid var(--kpi-accent, #0f4c81);
  border-radius: 8px !important;
  box-shadow: 0 4px 12px rgba(15, 44, 72, .08);
  transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.fin-status-kpi:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 44, 72, .12);
}
.fin-status-kpi.is-active {
  border-color: color-mix(in srgb, var(--kpi-accent) 42%, #edf0f3);
  border-left-color: var(--kpi-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--kpi-accent) 16%, transparent), 0 5px 14px rgba(15, 44, 72, .1);
}
.fin-status-kpi .fin-kpi-value {
  display: block;
  margin-top: 7px;
}
.fin-status-active {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--kpi-accent);
  font-size: 10px;
  font-weight: 600;
}
.fin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 18px;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #edf0f3;
  border-radius: 8px;
  box-shadow: 0 3px 10px rgba(15, 44, 72, .05);
}
.fin-toolbar-actions,
.fin-toolbar-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.fin-toolbar-filters { justify-content: flex-end; }
.fin-toolbar label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #53697e;
  font-size: 12.5px;
  white-space: nowrap;
}
.fin-toolbar select {
  min-width: 96px;
  height: 38px;
  padding: 0 30px 0 12px;
  background: #fff;
  border: 1px solid #d8e0e8 !important;
  border-radius: 6px !important;
}
.fin-toolbar label:last-child select { min-width: 180px; }
.fin-btn-primary,
.fin-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border-radius: 5px !important;
  font-weight: 600;
  white-space: nowrap;
}
.fin-btn-primary {
  color: #fff;
  background: #0f4c81;
  border: 1px solid #0f4c81;
}
.fin-btn-primary:hover { background: #0a3560; }
.fin-btn-outline {
  color: #0f4c81;
  background: #fff;
  border: 1px solid #0f4c81;
}
.fin-btn-outline:hover { background: #f0f6fb; }
.fin-data-panel {
  overflow: hidden;
  background: #fff;
  border: 1px solid #edf0f3;
  border-radius: 8px;
  box-shadow: 0 3px 12px rgba(15, 44, 72, .05);
}
.fin-panel-title {
  padding: 17px 22px 14px;
  color: #102f4e;
  font-size: 14px;
  font-weight: 700;
}

@media (max-width: 1023px) {
  .fin-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-toolbar { align-items: stretch; flex-direction: column; }
  .fin-toolbar-filters { justify-content: flex-start; }
}
@media (max-width: 640px) {
  .fin-kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .fin-kpi-card { min-height: 78px; padding: 13px 12px 11px; }
  .fin-kpi-value { font-size: 21px; }
  .fin-kpi-value--compact { font-size: 18px; }
  .fin-kpi-value--dense { font-size: 16px; }
  .fin-kpi-value--tight { font-size: 14px; }
  .annual-detail-kpis .fin-kpi-value--compact { font-size: 18px; }
  .annual-detail-kpis .fin-kpi-value--dense { font-size: 16px; }
  .annual-detail-kpis .fin-kpi-value--tight { font-size: 14px; }
  .fin-toolbar { padding: 12px; }
  .fin-toolbar-actions > button { flex: 1 1 calc(50% - 6px); }
  .fin-toolbar-filters label { width: 100%; justify-content: space-between; }
  .fin-toolbar-filters select { flex: 1; min-width: 0 !important; }
}

/* Keep the finance reference palette after all legacy declarations. */
html body,
body.bg-slate-100,
#app.app-shell,
#content {
  background-color: var(--fin-page-bg) !important;
}

@media (min-width: 641px) {
  html body input:not([type="checkbox"]):not([type="radio"]),
  html body select,
  html body textarea,
  html body button {
    font-family: var(--fin-font) !important;
    font-size: 12.5px !important;
    letter-spacing: 0 !important;
  }
}
