/* ==========================================================================
   METAN GROUP - HỆ THỐNG GIAO DIỆN QUẢN TRỊ DỰ CHI (UI/UX CHUẨN DOANH NGHIỆP)
   Tinh chỉnh bố cục chính xác, giao diện mượt mà, thông báo và hộp thoại chuẩn
   ========================================================================== */

:root {
  /* Bảng màu chính - Indigo / Slate Royal */
  --primary-50: #eff6ff;
  --primary-100: #dbeafe;
  --primary-200: #bfdbfe;
  --primary-300: #93c5fd;
  --primary-400: #60a5fa;
  --primary-500: #3b82f6;
  --primary-600: #2563eb;
  --primary-700: #1d4ed8;
  --primary-800: #1e40af;
  --primary-900: #1e3a8a;
  
  /* Thang màu Slate */
  --slate-950: #090d16;
  --slate-900: #0f172a;
  --slate-850: #131d33;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  
  /* Bảng màu nhấn cho trạng thái */
  --emerald-50: #ecfdf5;
  --emerald-100: #d1fae5;
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-200: #fde68a;
  --amber-300: #fcd34d;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --amber-700: #b45309;
  
  --rose-50: #fff1f2;
  --rose-100: #ffe4e6;
  --rose-500: #f43f5e;
  --rose-600: #e11d48;
  --rose-700: #be123c;
  
  --indigo-50: #eef2ff;
  --indigo-100: #e0e7ff;
  --indigo-500: #6366f1;
  --indigo-600: #4f46e5;
  --indigo-700: #4338ca;
  
  /* Bề mặt & Đường phân cách */
  --surface: #ffffff;
  --surface-subtle: #f8fafc;
  --canvas: #f1f5f9;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  --line-dark: #cbd5e1;
  
  /* Kích thước */
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Đổ bóng */
  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(15, 23, 42, 0.06), 0 2px 4px -1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 10px 22px -4px rgba(15, 23, 42, 0.08), 0 6px 8px -4px rgba(15, 23, 42, 0.03);
  --shadow-xl: 0 20px 30px -8px rgba(15, 23, 42, 0.12), 0 8px 12px -4px rgba(15, 23, 42, 0.04);
  
  /* Hiệu ứng chuyển động */
  --motion-fast: 140ms cubic-bezier(0.16, 1, 0.3, 1);
  --motion-base: 220ms cubic-bezier(0.16, 1, 0.3, 1);
  --motion-smooth: 320ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Thẻ cơ sở & Reset */
*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: light;
  scroll-padding-top: 80px;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  color: var(--slate-800);
  background-color: var(--canvas);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, .brand, .stat-card strong, .topbar-title, .eyebrow {
  font-family: var(--font-ui);
}

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  color: var(--slate-900);
  font-size: clamp(22px, 2.4vw, 28px);
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.03em;
}

h2 {
  margin-bottom: 3px;
  color: var(--slate-900);
  font-size: 17.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h3 {
  color: var(--slate-900);
  font-size: 15px;
  font-weight: 600;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ui-icon {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 12px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: #ffffff;
  background: var(--slate-900);
  box-shadow: var(--shadow-lg);
  font-weight: 600;
  font-size: 12px;
  transform: translateY(-160%);
  transition: transform var(--motion-fast);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ==========================================================================
   APP SHELL & LAYOUT STRUCTURE
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

/* Thanh điều hướng Sidebar */
.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 20px 16px 16px;
  color: #f1f5f9;
  background: linear-gradient(180deg, var(--slate-900) 0%, var(--slate-950) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 4px 0 20px rgba(15, 23, 42, 0.1);
}

.brand {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  border-radius: var(--radius-sm);
}

.brand-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 10px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--indigo-600) 100%);
  box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand-text strong {
  display: block;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.brand-text small {
  display: block;
  margin-top: 1px;
  color: var(--slate-400);
  font-size: 10.5px;
  font-weight: 600;
}

.main-nav {
  flex: 1;
  margin-top: 28px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.nav-label {
  margin: 0 10px 8px;
  color: var(--slate-500);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.nav-section {
  margin-top: 24px;
}

.nav-group {
  margin: 4px 0;
}

.nav-group-toggle {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--slate-200);
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  transition: color var(--motion-fast), background var(--motion-fast);
}

.nav-group-toggle > span:first-child {
  min-width: 0;
  line-height: 1.25;
}

.nav-group-toggle:hover,
.nav-group.is-open > .nav-group-toggle {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-group-toggle:focus-visible {
  outline: 2px solid var(--primary-400);
  outline-offset: 2px;
}

.nav-group-toggle small {
  display: block;
  margin-top: 2px;
  color: var(--slate-400);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.015em;
  line-height: 1.25;
}

.nav-chevron {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--motion-fast);
}

.nav-group.is-open > .nav-group-toggle .nav-chevron {
  transform: rotate(225deg) translateY(-2px);
}

.nav-group-content {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  visibility: hidden;
  transition: grid-template-rows var(--motion-smooth), opacity 200ms ease, visibility 0s linear 320ms;
}

.nav-group.is-open > .nav-group-content {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
  transition: grid-template-rows var(--motion-smooth), opacity 200ms ease, visibility 0s;
}

.nav-group-panel {
  min-height: 0;
  overflow: hidden;
  margin-left: 18px;
  padding-left: 9px;
  border-left: 1px solid rgba(148, 163, 184, 0.28);
}

.nav-group-panel .nav-link {
  min-height: 40px;
  padding-left: 12px;
}

.nav-placeholder {
  margin: 4px 0 8px;
  padding: 9px 12px;
  color: var(--slate-400);
  font-size: 12px;
  line-height: 1.5;
}

@media (prefers-reduced-motion: reduce) {
  .nav-group-content,
  .nav-group.is-open > .nav-group-content { transition: none; }
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin: 3px 0;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--slate-300);
  font-size: 13px;
  font-weight: 600;
  transition: color var(--motion-fast), background var(--motion-fast);
}

.nav-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  color: #ffffff;
  background: linear-gradient(90deg, rgba(59, 130, 246, 0.2) 0%, rgba(99, 102, 241, 0.1) 100%);
  border-left: 3px solid var(--primary-500);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.nav-group-panel .nav-link.active {
  color: #ffffff;
  background: rgba(148, 163, 184, 0.16);
  border-left: 0;
  box-shadow: none;
}

.nav-group-panel .nav-link.active::before {
  position: absolute;
  left: 0;
  width: 2px;
  height: 18px;
  border-radius: 2px;
  background: var(--primary-400);
  content: '';
}

.nav-icon {
  display: grid;
  width: 18px;
  place-items: center;
  opacity: 0.85;
}

.nav-link.active .nav-icon {
  color: var(--primary-400);
  opacity: 1;
}

.sidebar-user {
  display: grid;
  gap: 12px;
  padding: 14px 4px 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--indigo-700) 100%);
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 13px;
}

.avatar.small { width: 30px; height: 30px; font-size: 11.5px; }
.avatar.tiny { width: 24px; height: 24px; font-size: 10px; }

.user-copy {
  min-width: 0;
  flex: 1;
}

.user-copy strong, .user-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
}

.user-copy small {
  color: var(--slate-400);
  font-size: 10.5px;
}

.sidebar-account-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.sidebar-account-actions form {
  min-width: 0;
}

.sidebar-account-actions a, .sidebar-account-actions button {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: var(--slate-300);
  background: rgba(255, 255, 255, 0.05);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: color var(--motion-fast);
}

.sidebar-account-actions a:hover, .sidebar-account-actions button:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

/* Khung làm việc & Thanh Topbar */
.workspace {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  margin-left: var(--sidebar-width);
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  min-height: var(--topbar-height);
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px clamp(18px, 3vw, 32px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
}

.topbar-start {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
}

.topbar .eyebrow {
  margin-bottom: 1px;
}

.topbar-title {
  display: block;
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 750;
  color: var(--slate-900);
  line-height: 1.2;
}

.menu-button {
  display: none;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--slate-800);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

.topbar-user-status {
  display: flex;
  min-width: 0;
  min-height: 36px;
  align-items: center;
  gap: 10px;
  padding: 4px 14px;
  border: 1px solid var(--line);
  border-radius: 9999px;
  color: var(--slate-600);
  background: var(--surface-subtle);
  box-shadow: var(--shadow-xs);
  font-size: 11.5px;
  white-space: nowrap;
}

.topbar-user-status strong {
  color: var(--slate-900);
  font-weight: 700;
}

.topbar-company {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.topbar-company strong {
  color: var(--primary-700);
}

.company-dot {
  position: relative;
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--emerald-500);
}

.company-dot::after {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  content: "";
  background-color: var(--emerald-500);
  opacity: 0.4;
  animation: pulse-dot 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.6); opacity: 0; }
}

.topbar-status-separator {
  width: 1px;
  height: 16px;
  flex: 0 0 auto;
  background: var(--line-dark);
}

.topbar-greeting {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-role {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--primary-800);
  background: var(--primary-100);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.page-content {
  width: min(1280px, 100%);
  min-height: calc(100vh - var(--topbar-height) - 40px);
  margin: 0 auto;
  padding: 24px clamp(18px, 3vw, 32px) 40px;
}

.expense-page {
  min-height: 0;
  flex: 1;
  padding-top: 20px;
}

.app-footer {
  padding: 14px 20px 14px;
  color: var(--slate-400);
  text-align: center;
  font-size: 11px;
  font-weight: 500;
}

.sidebar-backdrop {
  display: none;
}

/* ==========================================================================
   HEADINGS, PANELS & COMMON UI BUTTONS
   ========================================================================== */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading > div:first-child {
  max-width: 740px;
}

.page-heading p:last-child {
  margin-bottom: 0;
  color: var(--slate-500);
  font-size: 13.5px;
}

.page-heading-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.import-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.import-summary > div {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.import-summary span,
.import-summary strong {
  display: block;
}

.import-summary span {
  color: var(--slate-500);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.import-summary strong {
  margin-top: 3px;
  color: var(--slate-900);
  font-size: 22px;
}

.import-summary .has-import-errors {
  border-color: var(--rose-100);
  background: var(--rose-50);
}

.import-notice {
  margin-bottom: 16px;
}

.import-table-wrap {
  max-height: 58vh;
}

.import-table th {
  position: sticky;
  z-index: 1;
  top: 0;
}

.import-row-error {
  background: var(--rose-50);
}

.import-errors {
  min-width: 220px;
  margin: 0;
  padding-left: 18px;
  color: var(--rose-700);
  font-size: 11.5px;
}

.import-valid {
  color: var(--emerald-700);
  font-size: 11.5px;
  font-weight: 700;
}

.import-confirm-bar {
  position: sticky;
  z-index: 5;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px 18px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
}

.import-confirm-bar strong,
.import-confirm-bar small {
  display: block;
}

.import-confirm-bar small {
  margin-top: 2px;
  color: var(--slate-500);
}

.import-confirm-bar > div:last-child {
  display: flex;
  gap: 10px;
}

.import-guide {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--primary-100);
  border-radius: var(--radius);
  background: var(--primary-50);
}

.import-guide-icon,
.import-review-file-icon {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--primary-700);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

.import-guide strong,
.import-review-file strong,
.import-review-table-heading strong,
.import-review-footer-copy strong {
  display: block;
  color: var(--slate-900);
}

.import-guide p {
  margin: 4px 0 0;
  color: var(--slate-600);
  font-size: 12.5px;
  line-height: 1.55;
}

.import-file-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--slate-600);
  font-size: 11.5px;
}

.import-file-meta span {
  max-width: 65%;
  overflow: hidden;
  color: var(--slate-800);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-upload-error {
  margin: 0;
}

.employee-import-dialog header button,
.import-review-dialog header button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  place-items: center;
}

.import-loading-state {
  min-height: 280px;
  padding: 48px 32px;
  text-align: center;
}

.import-loading-state .loading-spinner {
  display: block;
  width: 38px;
  height: 38px;
  margin: 0 auto 18px;
  border: 3px solid var(--primary-100);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: importSpin 0.8s linear infinite;
}

.import-loading-state strong {
  display: block;
  color: var(--slate-900);
  font-family: var(--font-ui);
  font-size: 16px;
}

.import-loading-state p {
  max-width: 390px;
  margin: 7px auto 0;
  color: var(--slate-500);
  font-size: 12.5px;
  line-height: 1.55;
}

@keyframes importSpin {
  to { transform: rotate(360deg); }
}

dialog.import-review-dialog {
  width: min(1120px, 96vw);
  max-height: 92vh;
}

.import-review-dialog > form {
  display: flex;
  max-height: 92vh;
  flex-direction: column;
}

.import-review-body {
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

.import-review-file {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.import-review-file > span:nth-child(2) {
  min-width: 0;
  flex: 1;
}

.import-review-file strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-review-file small,
.import-review-table-heading small,
.import-review-footer-copy small {
  display: block;
  margin-top: 2px;
  color: var(--slate-500);
  font-size: 11.5px;
}

.import-status-badge,
.import-action {
  display: inline-flex;
  align-items: center;
  width: max-content;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.import-status-badge {
  padding: 5px 9px;
}

.import-status-badge.is-ready,
.import-action.is-new {
  color: var(--emerald-700);
  background: var(--emerald-50);
}

.import-status-badge.is-error {
  color: var(--rose-700);
  background: var(--rose-50);
}

.import-action {
  padding: 4px 8px;
}

.import-action.is-update {
  color: var(--primary-700);
  background: var(--primary-50);
}

.import-review-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 14px;
}

.import-review-summary > div {
  padding: 13px 15px;
  box-shadow: none;
}

.import-review-notice {
  margin-bottom: 18px;
}

.import-review-table-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}

.import-review-table-heading > span {
  color: var(--slate-500);
  font-size: 11.5px;
  font-weight: 700;
}

.import-review-table-wrap {
  max-height: 38vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.import-review-table-wrap .data-table th,
.import-review-table-wrap .data-table td {
  padding-right: 14px;
  padding-left: 14px;
}

.import-person strong,
.import-person small {
  display: block;
  white-space: nowrap;
}

.import-person small {
  margin-top: 2px;
  color: var(--slate-500);
  font-size: 11px;
}

.import-valid {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.import-valid .ui-icon {
  width: 15px;
  height: 15px;
}

dialog.app-dialog footer.import-review-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--line);
}

.import-review-footer-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.import-review-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.button.is-loading::before {
  width: 14px;
  height: 14px;
  content: "";
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: importSpin 0.75s linear infinite;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary-600);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line-subtle);
}

.panel-heading h2 {
  margin-bottom: 0;
}

.panel-heading p {
  margin-top: 2px;
  margin-bottom: 0;
  color: var(--slate-500);
  font-size: 12.5px;
}

/* Hệ thống nút bấm */
.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: color var(--motion-fast);
}

.button-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button:focus-visible, a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.4);
  outline-offset: 2px;
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.button-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-700) 0%, var(--primary-800) 100%);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transform: translateY(-1px);
}

.button-secondary {
  border-color: var(--line-dark);
  color: var(--slate-800);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

.button-secondary:hover {
  background: var(--surface-subtle);
  border-color: var(--slate-400);
}

.button-back {
  min-height: 36px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid var(--primary-200);
  color: var(--primary-700);
  background: var(--primary-50);
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.button-back:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
  color: var(--primary-800);
}

.button-success {
  color: #ffffff;
  background: linear-gradient(135deg, var(--emerald-500) 0%, var(--emerald-600) 100%);
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.22);
}

.button-success:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--emerald-600) 0%, var(--emerald-700) 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.32);
  transform: translateY(-1px);
}

.button-warning {
  color: #ffffff;
  background: linear-gradient(135deg, var(--amber-500) 0%, var(--amber-600) 100%);
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.22);
}

.button-warning:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--amber-600) 0%, var(--amber-700) 100%);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.32);
  transform: translateY(-1px);
}

.button-danger {
  color: #ffffff;
  background: linear-gradient(135deg, var(--rose-500) 0%, var(--rose-600) 100%);
  box-shadow: 0 2px 6px rgba(244, 63, 94, 0.22);
}

.button-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--rose-600) 0%, var(--rose-700) 100%);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.32);
  transform: translateY(-1px);
}

.button-danger-soft {
  border-color: #fecdd3;
  color: var(--rose-700);
  background: var(--rose-50);
}

.button-danger-soft:hover {
  background: var(--rose-100);
  border-color: #fda4af;
}

.button-compact {
  min-height: 34px;
  padding: 0 10px;
  font-size: 11.5px;
}

.button-block {
  width: 100%;
}

.button-lg {
  min-height: 44px;
  font-size: 14.5px;
}

.button-dashed {
  width: 100%;
  border: 1.5px dashed var(--primary-300);
  color: var(--primary-700);
  background: var(--primary-50);
  border-radius: var(--radius);
}

.button-dashed:hover {
  background: var(--primary-100);
  border-color: var(--primary-500);
}

.text-link {
  color: var(--primary-600);
  font-weight: 600;
  font-size: 12.5px;
}

.text-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   FLOATING TOAST NOTIFICATIONS (POPUP THÔNG BÁO TỰ MẤT - GỌN VÀ HỢP LÝ)
   ========================================================================== */

.flash-stack {
  position: fixed;
  z-index: 10000;
  top: calc(var(--topbar-height) + 16px);
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100dvh - var(--topbar-height) - 40px);
  overflow-y: auto;
  scrollbar-width: thin;
  pointer-events: none;
}

.flash {
  position: relative;
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px 12px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px -5px rgba(15, 23, 42, 0.16), 0 4px 10px -2px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.flash-success { border-left: 4px solid var(--emerald-500); }
.flash-warning { border-left: 4px solid var(--amber-500); }
.flash-error, .flash-danger { border-left: 4px solid var(--rose-500); }
.flash-info { border-left: 4px solid var(--primary-500); }

.flash.is-leaving {
  animation: toastSlideOut 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to { opacity: 0; transform: translateX(100%) scale(0.95); }
}

.flash-symbol {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  margin-top: 1px;
}

.flash-symbol .ui-icon {
  width: 16px;
  height: 16px;
}

.flash-success .flash-symbol { color: var(--emerald-600); background: var(--emerald-50); }
.flash-warning .flash-symbol { color: var(--amber-600); background: var(--amber-50); }
.flash-error .flash-symbol, .flash-danger .flash-symbol { color: var(--rose-600); background: var(--rose-50); }
.flash-info .flash-symbol { color: var(--primary-600); background: var(--primary-50); }

.flash-message {
  flex: 1;
  color: var(--slate-900);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  padding-right: 4px;
}

.flash-close {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--slate-400);
  border-radius: 50%;
  transition: color var(--motion-fast);
  flex: 0 0 auto;
}

.flash-close:hover {
  color: var(--slate-800);
  background: var(--slate-100);
}

.flash-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: currentColor;
  opacity: 0.6;
  transform-origin: left;
  animation: toastProgress var(--flash-timeout, 4500ms) linear forwards;
}

.flash-success .flash-progress { background: var(--emerald-500); }
.flash-warning .flash-progress { background: var(--amber-500); }
.flash-error .flash-progress, .flash-danger .flash-progress { background: var(--rose-500); }
.flash-info .flash-progress { background: var(--primary-500); }

.flash.is-paused .flash-progress {
  animation-play-state: paused;
}

@keyframes toastProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.stat-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--motion-fast), box-shadow var(--motion-fast);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card div span {
  display: block;
  color: var(--slate-500);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 1px;
  color: var(--slate-900);
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-card small {
  display: block;
  margin-top: 2px;
  color: var(--slate-400);
  font-size: 10.5px;
}

/* ==========================================================================
   DATA TABLES & FILTER BARS
   ========================================================================== */

.data-panel {
  overflow: hidden;
}

.list-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 22px;
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--line-subtle);
  font-size: 12.5px;
  color: var(--slate-600);
}

.list-summary strong {
  color: var(--slate-900);
  font-weight: 700;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 180px;
}

.input-icon-wrap .input-icon {
  position: absolute;
  left: 12px;
  pointer-events: none;
  color: var(--slate-400);
}

.search-wide {
  flex: 2;
  min-width: 260px;
}

.filter-bar input, .filter-bar select, .project-filter-bar input, .project-filter-bar select, .team-filter input, .team-filter select, .field input, .field select, .field textarea, .auth-form input, .auth-form select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  outline: none;
  background: #ffffff;
  color: var(--slate-900);
  font-size: 13.5px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}

.input-icon-wrap input, .input-icon-wrap select {
  padding-left: 38px;
}

.filter-bar input:focus, .filter-bar select:focus, .project-filter-bar input:focus, .project-filter-bar select:focus, .team-filter input:focus, .team-filter select:focus, .field input:focus, .field select:focus, .field textarea:focus, .auth-form input:focus, .auth-form select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.field input[readonly] {
  border-color: var(--slate-200);
  background: var(--surface-subtle);
  color: var(--slate-700);
  cursor: default;
}

.filter-feedback {
  color: var(--slate-400);
  font-size: 11.5px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 12px 18px;
  color: var(--slate-500);
  background: var(--surface-subtle);
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background var(--motion-fast);
}

.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

.code-link {
  color: var(--slate-700);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
}

.code-link:hover {
  color: var(--primary-700);
  text-decoration: underline;
}

.money-cell {
  font-family: var(--font-ui);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--slate-900);
  white-space: nowrap;
}

.money-cell small {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  color: var(--slate-500);
}

/* Thẻ trạng thái (Badge) */
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.status::before {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  content: "";
}

.status-active {
  color: var(--emerald-700);
  background: var(--emerald-50);
  border: 1px solid var(--emerald-100);
}
.status-active::before { background: var(--emerald-500); }

.status-paused, .status-closed {
  color: var(--slate-600);
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
}
.status-paused::before, .status-closed::before { background: var(--slate-400); }

.row-action {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--slate-400);
  transition: color var(--motion-fast);
}

.row-action:hover {
  color: var(--primary-600);
  background: var(--primary-50);
}

.mobile-records {
  display: none;
}

.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--slate-500);
}

.empty-state .ui-icon {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  color: var(--slate-300);
}

.empty-state h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

.empty-state p {
  margin-bottom: 18px;
}

/* ==========================================================================
   FORMS, FIELD WARNINGS & DYNAMIC INPUT PANELS
   ========================================================================== */

.expense-form-shell {
  max-width: 860px;
  margin: 0 auto;
}

.expense-form-heading {
  margin-bottom: 24px;
}

.expense-layout {
  display: grid;
  gap: 20px;
}

.form-panel {
  padding: 24px;
}

.pin-change-shell {
  width: min(100%, 540px);
  margin: 12px auto 0;
}
.pin-change-heading { margin-bottom: 18px; }
.pin-change-panel { padding: 28px; }
.pin-change-panel .notice { margin-bottom: 20px; }
.pin-change-form { display: grid; gap: 17px; }
.pin-change-form .field { margin: 0; }
.pin-change-form .field input { width: 100%; min-height: 44px; }
.pin-change-help {
  display: block;
  margin-top: 6px;
  color: var(--slate-500);
  font-size: 12px;
  line-height: 1.4;
}
.pin-change-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line-subtle);
}
.pin-change-actions .button { min-height: 40px; }

@media (max-width: 480px) {
  .pin-change-shell { margin-top: 0; }
  .pin-change-panel { padding: 20px; }
  .pin-change-actions .button { flex: 1 1 0; min-width: 0; }
}

.form-section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.form-section-heading span {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: linear-gradient(135deg, var(--primary-500) 0%, var(--indigo-600) 100%);
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 14px;
}

.field {
  position: relative;
  margin-bottom: 18px;
}

.field label, .field legend {
  display: block;
  margin-bottom: 6px;
  color: var(--slate-800);
  font-size: 13px;
  font-weight: 700;
}

.field label b {
  color: var(--rose-600);
}

.field textarea {
  height: auto;
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
}

/* Cảnh báo text đỏ inline ngay dưới ô nhập */
.field.has-error input,
.field.has-error select,
.field.has-error textarea,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
  border-color: var(--rose-500) !important;
  box-shadow: 0 0 0 3px rgba(244, 63, 94, 0.16) !important;
  background-color: #fffafb !important;
}

.field-error-msg {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  margin-top: 6px;
  color: var(--rose-600);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  animation: fieldErrorFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.field-error-msg::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 10px;
  line-height: 1;
}

@keyframes fieldErrorFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.field-help.danger-text, .danger-note, .danger-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--rose-700);
  background: var(--rose-50);
  border: 1px solid var(--rose-100);
  font-size: 12px;
  font-weight: 600;
}

.danger-note {
  display: flex;
  width: 100%;
  margin-top: 0;
  margin-bottom: 16px;
}

.info-note {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--primary-200);
  border-radius: 6px;
  color: var(--primary-800);
  background: var(--primary-50);
  font-size: 12px;
  line-height: 1.5;
}

.info-note .ui-icon {
  margin-top: 1px;
}

.info-note p,
.danger-note p {
  margin: 0;
}

.warning-note, .warning-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--amber-700);
  background: var(--amber-50);
  border: 1px solid var(--amber-200);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
}

.warning-text {
  padding: 5px 10px;
}

.warning-note {
  width: 100%;
  padding: 12px 14px;
  line-height: 1.5;
}

.warning-note .ui-icon {
  align-self: flex-start;
  margin-top: 1px;
}

.warning-note p {
  margin: 0;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.label-row span {
  color: var(--slate-400);
  font-size: 11px;
}

/* Thẻ tích chọn xác nhận ngân sách */
.check-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius-lg);
  background: var(--surface-card, #ffffff);
  cursor: pointer;
  user-select: none;
  transition: color 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.check-card:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
}

.check-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.check-card:has(input:checked) {
  border-color: #a7f3d0;
  background: #f0fdf4;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.08);
}

.check-card.is-checked {
  border-color: #a7f3d0;
  background: #f0fdf4;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.08);
}

/* Modern iOS-style Toggle Switch */
.custom-toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 44px;
  background-color: var(--slate-300);
  border-radius: 12px;
  transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.custom-toggle-switch .switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.check-card input:checked + .custom-toggle-switch {
  background-color: #10b981;
}

.check-card input:checked + .custom-toggle-switch .switch-thumb {
  transform: translateX(20px);
}

.budget-confirmation-copy {
  flex: 1;
  min-width: 0;
}

.budget-confirmation-status { flex-shrink: 0; }

.budget-confirmation-card:focus-within {
  outline: 2px solid var(--primary-500);
  outline-offset: 3px;
}

@media (max-width: 640px) {
  .budget-confirmation-title { flex-wrap: wrap; }
}

.budget-confirmation-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 3px;
}

.budget-confirmation-title strong {
  color: var(--slate-900);
  font-size: 14px;
  font-weight: 600;
}

.budget-confirmation-copy small {
  color: var(--slate-500);
  font-size: 12.5px;
}

/* Distinct Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  transition: color 0.25s ease;
}

.status-badge .status-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.status-badge.status-unchecked {
  background-color: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.status-badge.status-checked {
  background-color: #d1fae5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.expense-status-stack {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.budget-confirmation-status .status-checked { display: none !important; }
.check-card input:checked ~ .budget-confirmation-copy .budget-confirmation-status .status-unchecked { display: none !important; }
.check-card input:checked ~ .budget-confirmation-copy .budget-confirmation-status .status-checked { display: inline-flex !important; }

/* Thẻ đợt thanh toán phân bổ */
.allocation-list {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.allocation-card {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.allocation-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.allocation-card header strong {
  color: var(--slate-900);
  font-size: 13.5px;
}

.allocation-card header small {
  display: block;
  color: var(--slate-500);
  font-size: 10.5px;
}

.allocation-remove {
  padding: 4px;
  border: 0;
  border-radius: 50%;
  color: var(--slate-400);
  background: transparent;
}

.allocation-remove:hover {
  color: var(--rose-600);
  background: var(--rose-50);
}

.form-grid.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.allocation-card-grid {
  display: grid;
  grid-template-columns: 210px 1fr 240px;
  gap: 14px;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .allocation-card-grid {
    grid-template-columns: 1fr;
  }
}

.money-input {
  position: relative;
  display: flex;
  align-items: center;
}

.money-input input {
  padding-right: 32px;
  font-family: var(--font-ui);
  font-weight: 700;
}

.money-input span {
  position: absolute;
  right: 12px;
  color: var(--slate-400);
  font-weight: 700;
  pointer-events: none;
}

/* Thanh nút gửi cuối trang */
.form-submit-bar {
  position: sticky;
  bottom: 16px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 22px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.96);
}

.form-submit-bar div:first-child span {
  display: block;
  color: var(--slate-500);
  font-size: 11.5px;
}

.form-submit-bar div:first-child strong {
  display: block;
  color: var(--primary-700);
  font-family: var(--font-ui);
  font-size: 22px;
  font-weight: 800;
}

.submit-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ==========================================================================
   EXPENSE DETAIL & TIMELINE
   ========================================================================== */

.expense-detail-shell {
  max-width: 1040px;
  margin: 0 auto;
}

.detail-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.detail-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 10px;
  margin-left: auto;
}

.detail-delete-button {
  min-height: 44px;
  min-width: 112px;
  justify-content: center;
}

.detail-action-bar .button-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-700);
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  transition: color var(--motion-fast);
}

.detail-action-bar .button-back:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
  color: var(--primary-800);
}

.detail-edit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
}

.detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 24px 20px;
  border-bottom: 1px solid var(--line-subtle);
}

.detail-heading-title {
  min-width: 0;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.detail-panel {
  padding: 0;
}

.detail-overview-panel { overflow: hidden; }

.detail-section + .detail-section {
  border-top: 1px solid var(--line-subtle);
}

.detail-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 24px;
  border-top: 1px solid var(--primary-200);
  background: var(--primary-50);
}

.detail-total span,
.detail-total small {
  display: block;
}

.detail-total span {
  color: var(--slate-800);
  font-size: 14px;
  font-weight: 750;
}

.detail-total small {
  margin-top: 3px;
  color: var(--slate-600);
  font-size: 12px;
}

.detail-total strong {
  color: var(--primary-700);
  font-family: var(--font-ui);
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.detail-panel .panel-heading {
  flex-wrap: wrap;
  padding: 22px 24px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 28px;
  margin: 0;
  padding: 4px 24px 18px;
}

.detail-grid > div {
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-subtle);
}
.detail-grid > div:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.detail-grid dt {
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 3px;
}

.detail-grid dd {
  margin: 0;
  color: var(--slate-900);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.detail-grid dd small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--slate-500);
  margin-top: 2px;
}

.detail-panel .allocation-table {
  margin: 0;
  padding: 18px 24px 24px;
}

.panel-total {
  font-family: var(--font-ui);
  font-size: 19px;
  font-weight: 800;
  color: var(--primary-700);
}

.allocation-table,
.confirm-payment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.allocation-row {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--line-subtle);
  transition: border-color var(--motion-fast), background var(--motion-fast);
}

.allocation-row:hover {
  background: #ffffff;
  border-color: var(--line-dark);
}

.allocation-main {
  display: grid;
  grid-template-columns: minmax(100px, 1.2fr) minmax(200px, 2.5fr) minmax(110px, 1.3fr);
  align-items: center;
  gap: 12px;
  width: 100%;
}

.allocation-badge-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.allocation-index {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-100);
  color: var(--primary-700);
  font-weight: 800;
  font-size: 11.5px;
  flex-shrink: 0;
}

.allocation-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--slate-900);
  white-space: nowrap;
}

.allocation-date-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--slate-600);
  text-align: center;
}

.allocation-date-text {
  font-weight: 500;
  color: var(--slate-700);
}

.allocation-week-badge {
  color: var(--slate-500);
  font-size: 12px;
}

.allocation-amount {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-700);
  text-align: right;
  white-space: nowrap;
}

.allocation-purpose {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-subtle);
  padding-left: 36px;
  font-size: 12px;
  color: var(--slate-600);
  line-height: 1.45;
  word-break: break-word;
}

.allocation-purpose-label {
  font-weight: 700;
  color: var(--slate-500);
  margin-right: 4px;
}

@media (max-width: 640px) {
  .allocation-main {
    grid-template-columns: 1fr auto;
    grid-template-areas: 
      "badge amount"
      "date date";
    gap: 8px 12px;
  }
  .allocation-badge-group {
    grid-area: badge;
  }
  .allocation-date-info {
    grid-area: date;
    justify-content: flex-start;
    padding-left: 36px;
  }
  .allocation-amount {
    grid-area: amount;
  }
}

/* Dòng thời gian lịch sử */
.timeline {
  position: relative;
  padding-left: 22px;
  margin-top: 16px;
}

.timeline::before {
  position: absolute;
  left: 6px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  content: "";
  background: var(--line-dark);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-item > span {
  position: absolute;
  left: -22px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary-500);
  border: 2.5px solid #ffffff;
  box-shadow: 0 0 0 1px var(--line-dark);
}

.timeline-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.timeline-item time {
  color: var(--slate-400);
  font-size: 10.5px;
}

.timeline-item blockquote {
  margin: 8px 0 0;
  padding: 10px 14px;
  border-left: 3px solid var(--primary-300);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-subtle);
  color: var(--slate-700);
  font-style: italic;
  font-size: 12.5px;
}

.detail-side {
  display: grid;
  gap: 20px;
  align-content: start;
}

.key-total {
  padding: 22px;
  text-align: center;
  background: linear-gradient(135deg, var(--slate-900) 0%, var(--slate-950) 100%);
  color: #ffffff;
}

.key-total span {
  display: block;
  color: var(--slate-400);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
}

.key-total strong {
  display: block;
  margin-top: 5px;
  font-family: var(--font-ui);
  font-size: 28px;
  font-weight: 800;
  color: #ffffff;
}

.key-total small {
  display: block;
  margin-top: 3px;
  color: var(--slate-400);
}

/* ==========================================================================
   ADMIN & MANAGEMENT SCREENS (TEAM & PROJECTS)
   ========================================================================== */

.team-filter {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) minmax(170px, 1fr);
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.team-filter label {
  display: none;
}

.team-filter .input-icon-wrap { min-width: 0; }

.person-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.person-cell strong {
  display: block;
  color: var(--slate-900);
  font-size: 13.5px;
}

.person-cell small {
  color: var(--slate-500);
  font-size: 10.5px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-tag {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 10.5px;
  font-weight: 700;
}

.role-tag.role-system {
  background: var(--indigo-50);
  color: var(--indigo-700);
}

.active-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--emerald-700);
  font-weight: 600;
  font-size: 11.5px;
}

.active-dot::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  content: "";
  background: var(--emerald-500);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
}

.blocked-action {
  position: relative;
  display: inline-flex;
  border-radius: var(--radius-sm);
}

.blocked-action:focus-visible {
  outline: 3px solid rgba(244, 63, 94, 0.28);
  outline-offset: 2px;
}

.button-danger-blocked:disabled {
  opacity: 1;
  border-color: #fecdd3;
  color: var(--rose-700);
  background: var(--rose-50);
}

.floating-help {
  position: fixed;
  z-index: 9000;
  top: 0;
  left: 0;
  display: block;
  width: max-content;
  max-width: 270px;
  padding: 11px 14px;
  border: 1px solid #fecdd3;
  border-radius: 18px;
  color: var(--slate-700);
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: none;
}

.floating-help::before,
.floating-help::after {
  position: absolute;
  border: 1px solid #fecdd3;
  border-radius: 50%;
  content: "";
  background: #ffffff;
}

.floating-help.is-below::before {
  top: -10px;
  bottom: auto;
}

.floating-help.is-below::after {
  top: -16px;
  bottom: auto;
}

.floating-help::before {
  right: 22px;
  bottom: -10px;
  width: 8px;
  height: 8px;
}

.floating-help::after {
  right: 14px;
  bottom: -16px;
  width: 4px;
  height: 4px;
}

.floating-help strong,
.floating-help span {
  display: block;
}

.floating-help strong {
  margin-bottom: 2px;
  color: var(--rose-700);
  font-size: 12.5px;
}

.blocked-action:hover .floating-help,
.blocked-action:focus-visible .floating-help {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 120ms ease-out, transform 120ms ease-out;
}

.security-action-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.security-action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-700);
  background: var(--primary-100);
}

.security-action-card strong,
.security-action-card small {
  display: block;
}

.security-action-card strong {
  color: var(--slate-900);
  font-size: 13px;
}

.security-action-card small {
  margin-top: 2px;
  color: var(--slate-500);
  font-size: 11.5px;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  .floating-help {
    transform: none;
    transition: none;
  }
}

/* Danh mục chương trình */
.project-filter-bar {
  display: grid;
  grid-template-columns: minmax(280px, 2fr) minmax(220px, 1fr);
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.project-search,
.project-status-filter { min-width: 0; }

.project-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.project-name-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.35;
}

.project-period {
  display: block;
  margin-top: 4px;
  color: var(--slate-600);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

.project-code-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--slate-700);
}

.updated-time {
  color: var(--slate-600);
  font-size: 12.5px;
  white-space: nowrap;
}

.action-column {
  text-align: right;
}

.team-no-results, .project-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--slate-500);
}

.team-no-results span, .project-no-results span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--slate-100);
  color: var(--slate-400);
  margin-bottom: 12px;
}

.team-no-results strong, .project-no-results strong {
  font-size: 15px;
  color: var(--slate-800);
  margin-bottom: 4px;
}

.team-no-results small, .project-no-results small {
  font-size: 12.5px;
  color: var(--slate-500);
}

/* ==========================================================================
   MODAL DIALOGS (CẢNH BÁO VÀ HỘP THOẠI POPUP)
   ========================================================================== */

dialog.app-dialog {
  width: min(520px, 92vw);
  padding: 0;
  border: 0;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

dialog.expense-confirm-dialog {
  width: min(640px, 94vw);
}

dialog.app-dialog.wide-dialog {
  width: min(760px, 94vw);
}

dialog.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

dialog.app-dialog[open] {
  animation: dialogScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialogScale {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

dialog.app-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

dialog.app-dialog header h2 {
  margin: 0;
  font-size: 18px;
}

dialog.app-dialog header button {
  padding: 4px;
  border: 0;
  border-radius: 50%;
  color: var(--slate-400);
  background: transparent;
}

dialog.app-dialog header button:hover {
  color: var(--slate-900);
  background: var(--slate-100);
}

.dialog-body {
  padding: 20px 24px;
  max-height: 65vh;
  overflow-y: auto;
}

dialog.app-dialog footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--line);
}

.delete-acknowledge {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--slate-700);
  font-size: 12.5px;
  line-height: 1.5;
  cursor: pointer;
}

.delete-acknowledge input {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--rose-700);
}

.unsaved-dialog-actions {
  flex-wrap: wrap;
}

.unsaved-dialog .dialog-body p {
  margin: 0;
  line-height: 1.5;
}

.confirm-information {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 14px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--surface-subtle);
}

.confirm-information dt {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--slate-500);
  text-transform: uppercase;
}

.confirm-information dd {
  margin: 2px 0 0;
  font-weight: 700;
  color: var(--slate-900);
}

.confirm-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  margin-top: 16px;
  border-radius: var(--radius);
  background: var(--primary-50);
  border: 1px solid var(--primary-100);
}

.confirm-total strong {
  font-family: var(--font-ui);
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-700);
}

/* Hộp kết quả tìm kiếm thả xuống */
.search-results {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  border-radius: var(--radius);
  background: #ffffff;
  border: 1px solid var(--line-dark);
  box-shadow: var(--shadow-xl);
}

.responsible-combobox {
  position: relative;
}

.responsible-picker .responsible-results {
  position: static;
  max-height: min(240px, 34vh);
  margin-top: 6px;
}

.search-results button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  text-align: left;
  border: 0;
  border-radius: 6px;
  background: transparent;
  transition: background var(--motion-fast);
}

.search-results button:hover, .search-results button[aria-selected="true"] {
  background: var(--primary-50);
}

.search-results button strong {
  display: block;
  color: var(--slate-900);
  font-size: 12.5px;
}

.search-results button small {
  color: var(--slate-500);
  font-size: 10.5px;
}

/* ==========================================================================
   AUTHENTICATION PAGES (LOGIN & CHANGE PIN)
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--slate-950) 0%, #1e1b4b 50%, var(--slate-900) 100%);
  padding: 20px;
}

.auth-layout {
  width: min(440px, 100%);
}

.auth-card {
  padding: 36px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.auth-brand strong {
  display: block;
  color: var(--slate-900);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.auth-brand small {
  display: block;
  color: var(--slate-500);
  font-size: 11.5px;
}

.auth-heading {
  margin-bottom: 20px;
}

.auth-form {
  display: grid;
  gap: 18px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  padding: 3px 8px;
  border: 0;
  border-radius: 5px;
  background: var(--slate-100);
  color: var(--slate-600);
  font-size: 11.5px;
  font-weight: 600;
}

.password-toggle:hover {
  background: var(--slate-200);
  color: var(--slate-900);
}

.auth-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  color: var(--slate-400);
  font-size: 11.5px;
}

.auth-note p {
  margin: 0;
}

/* ==========================================================================
   RESPONSIVE MOBILE ADAPTATION
   ========================================================================== */

@media (max-width: 992px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--motion-smooth);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 25;
    inset: 0;
    display: block;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--motion-smooth);
  }

  .sidebar-backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }

  .workspace {
    margin-left: 0;
  }

  .menu-button {
    display: grid;
  }

  .topbar-user-status {
    padding: 4px 10px;
  }

  .topbar-greeting {
    display: none;
  }

  .table-wrap {
    display: none;
  }

  .import-table-wrap {
    display: block;
  }

  .mobile-records {
    display: grid;
    gap: 12px;
    padding: 14px;
  }

  .record-card {
    padding: 14px;
    border-radius: var(--radius);
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow-xs);
  }

  .record-card div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .record-card strong {
    display: block;
    color: var(--slate-900);
    font-size: 14px;
    margin-bottom: 4px;
  }

  .record-card p {
    color: var(--slate-600);
    font-size: 12.5px;
    margin-bottom: 10px;
  }

  .record-card footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid var(--line-subtle);
  }

  .record-card footer span {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 800;
    color: var(--primary-700);
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading-actions,
  .page-heading-actions .button {
    width: 100%;
  }

  .import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .import-confirm-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .import-confirm-bar > div:last-child,
  .import-confirm-bar form,
  .import-confirm-bar .button {
    width: 100%;
  }

  dialog.import-review-dialog {
    width: min(96vw, 720px);
    max-height: 94vh;
  }

  .import-review-dialog > form {
    max-height: 94vh;
  }

  .import-review-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  dialog.app-dialog footer.import-review-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .import-review-actions,
  .import-review-actions .button {
    width: 100%;
  }

  .import-review-actions .button {
    flex: 1;
  }

  .security-action-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .security-action-card .button {
    grid-column: 1 / -1;
    width: 100%;
  }
}

@media (max-width: 560px) {
  .import-file-meta,
  .import-review-file {
    align-items: flex-start;
    flex-direction: column;
  }

  .import-review-file-icon {
    display: none;
  }

  .import-review-file > span:nth-child(2) {
    width: 100%;
  }

  .import-review-actions {
    flex-direction: column-reverse;
  }
}

@media (prefers-reduced-motion: reduce) {
  .import-loading-state .loading-spinner,
  .button.is-loading::before {
    animation-duration: 1.8s;
  }

  dialog.app-dialog[open] {
    animation: none;
  }
}

/* ==========================================================================
   HR EMPLOYEE IMPORT & REVIEW DIALOG ENHANCEMENTS
   ========================================================================== */

dialog.app-dialog.modal-wide {
  width: min(980px, 95vw);
  max-width: 980px;
}

/* Dropzone Tải lên */
.import-dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  border: 2px dashed var(--slate-300);
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  text-align: center;
  transition: color var(--motion-base);
  cursor: pointer;
}

.import-dropzone:hover,
.import-dropzone.is-dragover {
  border-color: var(--primary-500);
  background: var(--primary-50);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.import-dropzone.has-file {
  border-color: var(--emerald-500);
  background: var(--emerald-50);
}

.import-file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.dropzone-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.dropzone-icon-circle {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  color: var(--primary-600);
  background: #ffffff;
  box-shadow: var(--shadow-md);
  transition: transform var(--motion-fast);
}

.import-dropzone:hover .dropzone-icon-circle {
  transform: translateY(-2px) scale(1.05);
}

.dropzone-main-icon {
  width: 24px;
  height: 24px;
}

.dropzone-title {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--slate-900);
}

.dropzone-subtitle {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--slate-500);
}

.dropzone-trigger-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary-600);
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  pointer-events: auto;
}

.dropzone-selected-file {
  margin-top: 6px;
  pointer-events: auto;
}

.file-name-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  background: #ffffff;
  border: 1px solid var(--emerald-500);
  color: var(--emerald-700);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* Khung hướng dẫn & Cột bắt buộc */
.import-helper-box {
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #ffffff;
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.helper-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.helper-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-800);
}

.import-column-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 12px;
  border: 1px solid var(--line-subtle);
}

.column-chip b {
  color: var(--slate-900);
}

.column-chip small {
  color: var(--slate-500);
}

.template-download-link {
  font-size: 12px;
  white-space: nowrap;
}

/* Loading State Spinner Wrap */
.loading-spinner-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

/* Popup Xem trước (Review Modal) */
.import-review-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.import-review-header > div {
  min-width: 0;
}

.import-review-header > button {
  flex-shrink: 0;
  margin-top: 2px;
}

.eyebrow-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.import-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
}

.import-status-badge.is-ready {
  background: var(--emerald-50);
  color: var(--emerald-700);
  border: 1px solid var(--emerald-100);
}

.import-status-badge.is-error {
  background: var(--rose-50);
  color: var(--rose-700);
  border: 1px solid var(--rose-100);
}

.import-review-file-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--radius);
  background: var(--slate-900);
  color: #ffffff;
  margin-bottom: 14px;
  overflow: hidden;
}

.file-strip-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.file-strip-icon {
  display: grid;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--primary-300);
}

.file-name-heading {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta-sub {
  display: block;
  font-size: 11.5px;
  color: var(--slate-400);
  margin-top: 2px;
}

/* Thẻ chỉ số thống kê (Stats Grid) */
.import-review-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.import-review-stats .stat-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  min-height: 72px;
}

.stat-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-family: var(--font-ui);
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--slate-900);
}

.import-review-stats .stat-card.is-new .stat-value {
  color: var(--emerald-600);
}

.import-review-stats .stat-card.is-update .stat-value {
  color: var(--primary-600);
}

.import-review-stats .stat-card.is-error {
  background: var(--rose-50);
  border-color: #fecdd3;
}

.import-review-stats .stat-card.is-error .stat-value {
  color: var(--rose-600);
}

/* Khung thông báo xem trước */
.import-review-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.import-review-notice strong {
  display: block;
  margin-bottom: 2px;
}

.import-review-notice p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

/* Tiêu đề & Bảng dữ liệu */
.import-review-table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.import-review-table-heading strong {
  display: block;
  font-size: 14px;
  color: var(--slate-900);
}

.import-review-table-heading small {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
}

.row-count-badge {
  padding: 3px 9px;
  border-radius: 12px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-size: 11.5px;
  font-weight: 700;
}

.import-review-table-wrap {
  max-height: 400px;
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.import-review-table-wrap table {
  min-width: 800px;
  width: 100%;
  table-layout: auto;
}

.import-review-table-wrap table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-subtle);
  box-shadow: 0 1px 0 var(--line);
  white-space: nowrap;
}

/* Định rộng cột cố định */
.import-review-table-wrap table th:nth-child(1),
.import-review-table-wrap table td:nth-child(1) { width: 48px; min-width: 48px; }
.import-review-table-wrap table th:nth-child(2),
.import-review-table-wrap table td:nth-child(2) { min-width: 150px; }
.import-review-table-wrap table th:nth-child(3),
.import-review-table-wrap table td:nth-child(3) { min-width: 200px; }
.import-review-table-wrap table th:nth-child(4),
.import-review-table-wrap table td:nth-child(4) { min-width: 90px; white-space: nowrap; }
.import-review-table-wrap table th:nth-child(5),
.import-review-table-wrap table td:nth-child(5) { min-width: 100px; white-space: nowrap; }
.import-review-table-wrap table th:nth-child(6),
.import-review-table-wrap table td:nth-child(6) { min-width: 100px; white-space: nowrap; }
.import-review-table-wrap table th:nth-child(7),
.import-review-table-wrap table td:nth-child(7) { min-width: 110px; white-space: nowrap; }

.cell-index {
  color: var(--slate-400);
  font-weight: 600;
  font-size: 12px;
  text-align: center;
}

.import-person-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.import-person-cell strong {
  font-size: 13.5px;
  color: var(--slate-900);
  white-space: nowrap;
}

.code-pill {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--slate-100);
  color: var(--slate-700);
  font-family: monospace;
  font-size: 11px;
  font-weight: 600;
  width: fit-content;
  white-space: nowrap;
}

.cell-email {
  font-size: 12.5px;
  color: var(--slate-600);
  white-space: nowrap;
}

.import-action-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  width: max-content;
}

.import-action-badge.is-new {
  background: var(--emerald-100);
  color: var(--emerald-700);
}

.import-action-badge.is-update {
  background: var(--primary-100);
  color: var(--primary-700);
}

.import-valid-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--emerald-600);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  width: max-content;
}

.import-errors-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.import-errors-list li {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  color: var(--rose-600);
  font-size: 12px;
  font-weight: 600;
  white-space: normal;
}

.import-row-error {
  background: #fff5f5 !important;
}

/* Footer xem trước - override cuối cùng */
dialog.app-dialog footer.import-review-footer {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface-subtle);
  border-top: 1px solid var(--line);
}

.import-review-footer-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.import-review-footer-copy strong {
  display: block;
  font-size: 13.5px;
  color: var(--slate-900);
}

.import-review-footer-copy small {
  display: block;
  font-size: 12px;
  color: var(--slate-500);
  margin-top: 1px;
}

.import-review-actions {
  display: flex;
  flex: 0 0 auto;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
}

.import-review-actions .button {
  white-space: nowrap;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  color: var(--slate-900);
  font-variant-numeric: tabular-nums;
  display: block;
}

/* Button variants: sm và ghost */
.button-sm {
  height: 34px !important;
  padding: 0 12px !important;
  font-size: 12.5px !important;
}

.button-ghost {
  background: transparent !important;
  border: 1px solid var(--line-dark) !important;
  color: var(--slate-500) !important;
  box-shadow: none !important;
}

.button-ghost:hover {
  background: var(--slate-50) !important;
  border-color: var(--slate-300) !important;
  color: var(--slate-700) !important;
}

/* ── Person cell trong audit ───────────────────────────────────────────── */
.person-cell.compact {
  display: flex;
  align-items: center;
  gap: 8px;
}

.person-cell.compact .avatar.small {
  width: 28px;
  height: 28px;
  font-size: 11px;
  flex-shrink: 0;
}

.person-cell.compact > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.person-cell.compact strong {
  font-size: 13px;
  color: var(--slate-800);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.person-cell.compact small {
  font-size: 11px;
  color: var(--slate-400);
}

/* ── Responsive adjustments ─────────────────────────────────────────────── */

@media (max-width: 700px) {

  .stat-value {
    font-size: 22px;
  }
}

.stat-card {
  --card-accent: var(--primary-500);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.875rem;
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--motion-fast), transform var(--motion-fast);
  border-top: 3px solid var(--card-accent);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.stat-card > div {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}
.stat-card > div > span:first-child {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}
.stat-card > div > strong {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-card > div > small {
  font-size: 0.75rem;
  color: var(--slate-400);
}
.stat-card.stat-projects  { --card-accent: var(--indigo-500); }

@media (max-width: 500px) {
  .stat-card { padding: 0.75rem 0.875rem; }
  .stat-card > div > strong { font-size: 1.25rem; }
}

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--line-subtle);
  background: var(--surface-subtle);
}
.filter-bar .input-icon-wrap { flex: 1; }
.filter-bar .text-link {
  font-size: 0.8125rem;
  color: var(--slate-500);
  text-decoration: none;
  white-space: nowrap;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: color var(--motion-fast), background var(--motion-fast);
}
.filter-bar .text-link:hover {
  color: var(--primary-600);
  background: var(--primary-50);
}

/* ── List summary bar ────────────────────────────────────────────────────── */
.list-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  font-size: 0.8125rem;
  color: var(--slate-500);
  border-bottom: 1px solid var(--line-subtle);
  background: var(--canvas);
  gap: 1rem;
}
.list-summary strong { color: var(--slate-700); font-weight: 700; }
.list-summary span:last-child strong {
  color: var(--primary-700);
}

/* ── Panel heading for list page ─────────────────────────────────────────── */
.list-panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem 0.875rem;
  border-bottom: 1px solid var(--line-subtle);
}
.list-panel-heading h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-800);
  margin: 0;
}
.list-panel-heading p {
  font-size: 0.8125rem;
  color: var(--slate-500);
  margin: 0.125rem 0 0;
}

/* ── Status badges (inside modal table) ──────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  white-space: nowrap;
}
.status-badge.status-checked {
  background: var(--emerald-100);
  color: var(--emerald-700);
}
.status-badge.status-checked .status-icon { width: 0.875rem; height: 0.875rem; }
.status-badge.status-unchecked {
  background: var(--amber-100);
  color: var(--amber-700);
}

/* ── Status dots (inline in project row) ─────────────────────────────────── */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.status-dot-ok   { background: var(--emerald-500); }
.status-dot.status-dot-warn { background: var(--amber-500); }

/* ── Mobile record cards (inside modal) ──────────────────────────────────── */
.mobile-records { display: none; }

.record-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--line-subtle);
  text-decoration: none;
  color: inherit;
  transition: background var(--motion-fast);
}
.record-card:hover { background: var(--primary-50); }
.record-card > div:first-child {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.record-card strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--slate-800);
  line-height: 1.4;
}
.record-supplier {
  font-size: 0.8rem;
  color: var(--slate-500);
}
.record-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: var(--slate-500);
}
.record-card footer span { font-weight: 700; color: var(--slate-800); font-variant-numeric: tabular-nums; }
.record-card footer span small { font-weight: 400; color: var(--slate-500); margin-left: 0.25rem; font-size: 0.75rem; }

@media (max-width: 700px) {
  .mobile-records { display: block; }
  .expense-modal-table-wrap { display: none; }
  .filter-bar { padding: 0.75rem 1rem; }
  .list-summary { padding: 0.375rem 1rem; }
}

/* ==========================================================================
   PROJECT LIST + EXPENSE MODAL
   ========================================================================== */

.stat-card.stat-projects { --card-accent: var(--indigo-500); }

/* -- Project list as native table -- */
.project-table { width: 100%; }

.project-table-row {
  cursor: pointer;
  transition: background var(--motion-fast);
}
.project-table-row:hover { background: var(--primary-50) !important; }
.project-table-row:focus-visible { outline: 2px solid var(--primary-400); outline-offset: -2px; }

.project-row-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.project-row-badge {
  display: inline-flex;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-700);
  background: var(--primary-100);
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.project-row-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--slate-800);
  white-space: nowrap;
}
.project-row-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--slate-700);
  white-space: nowrap;
}
.project-row-meta {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}
.project-row-status {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.8125rem;
  color: var(--slate-500);
  white-space: nowrap;
}
.project-row-money {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--slate-800);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right !important;
}

/* ?? Expense Modal ?? */
.expense-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.expense-modal[hidden] { display: none !important; }

.expense-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(3px);
  cursor: pointer;
}

.expense-modal-box {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 1320px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn var(--motion-base) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.expense-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.expense-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-width: 0;
}
.expense-modal-heading-text { min-width: 0; }
.expense-modal-period {
  display: flex;
  flex-wrap: wrap;
  gap: 0.125rem 0.75rem;
  margin-top: 0.2rem;
  color: var(--slate-600);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}
.expense-modal-badge {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--primary-700);
  background: var(--primary-100);
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.expense-modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--slate-900);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.expense-modal-header-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.expense-modal-total {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-700);
  font-variant-numeric: tabular-nums;
}
.expense-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--slate-500);
  transition: background var(--motion-fast), color var(--motion-fast);
}
.expense-modal-close:hover {
  background: var(--slate-100);
  color: var(--slate-800);
}

.expense-modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.expense-modal-table-wrap {
  border-radius: 0;
  box-shadow: none;
  border: none;
  overflow-x: auto;
}
.expense-modal-table-wrap .data-table { border-radius: 0; }

.expense-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 1.5rem;
  font-size: 0.8125rem;
  color: var(--slate-500);
  border-top: 1px solid var(--line-subtle);
  background: var(--slate-50);
  flex-shrink: 0;
  gap: 1rem;
}
.expense-modal-footer-total {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--slate-600);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Prevent body scroll when modal open */
body.modal-open { overflow: hidden; }

.td-desc {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--slate-600);
}
.expense-modal-table-wrap .data-table td:not(.td-desc):not(.td-supplier) { white-space: nowrap; }

@media (max-width: 640px) {
  .project-row { padding: 0.75rem 1rem; }
  .project-row-status { display: none; }
  .expense-modal-box { max-height: 95vh; border-radius: var(--radius); }
  .expense-modal-header { padding: 0.875rem 1rem; }
}

/* Footer actions (export button + total) */
.expense-modal-footer-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}
.project-bulk-delete-button { min-height: 40px; padding-inline: 14px; }

/* ========================================================================== 
   EXPENSE LIST — CLEAR SUMMARY & EXCEL EXPORT PREVIEW
   ========================================================================== */

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.text-right { text-align: right !important; }

.expense-stat-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card.stat-amount { --card-accent: var(--emerald-500); }
.stat-card.stat-amount > div > strong {
  font-size: clamp(1.15rem, 2vw, 1.625rem);
  white-space: nowrap;
}

.project-code-column { width: 210px; }
.project-name-column { width: auto; }
.project-count-column { width: 190px; }
.project-money-column { width: 180px; }
.project-code-cell {
  display: inline-block;
  max-width: 240px;
  overflow: hidden;
  color: var(--slate-700);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-table .project-row-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-row-count strong { color: var(--primary-700); }

.expense-table-muted {
  color: var(--slate-500);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.expense-modal-footer-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.expense-modal-footer-summary strong {
  color: var(--slate-800);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.expense-modal-footer-count { white-space: nowrap; }
.expense-modal-footer-total strong {
  color: var(--primary-700);
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.expense-modal-footer-divider {
  width: 1px;
  height: 18px;
  background: var(--line-dark);
}
.export-preview-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding-inline: 14px;
  flex: 0 0 auto;
  color: #ffffff;
  background: #217346;
  border-color: #217346;
  font-weight: 700;
}

dialog.app-dialog.export-preview-dialog {
  width: min(1440px, 97vw);
  max-height: 94vh;
}
.export-preview-dialog header .eyebrow { margin-bottom: 3px; }
.export-preview-dialog header > button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
}
.export-preview-body {
  min-height: 280px;
  max-height: 72vh;
  padding: 16px 20px 18px;
}

.export-preview-loading {
  min-height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--slate-700);
}
.export-preview-loading > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.export-preview-loading small { color: var(--slate-500); }
.export-preview-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--primary-100);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: exportPreviewSpin 0.8s linear infinite;
}
@keyframes exportPreviewSpin { to { transform: rotate(360deg); } }

.export-preview-error {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--rose-200);
  border-radius: var(--radius);
  color: var(--rose-800);
  background: var(--rose-50);
}
.export-preview-error[hidden] { display: none; }
.export-preview-error > .ui-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}
.export-preview-error p { margin: 3px 0 0; color: var(--rose-700); }

.export-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--emerald-200);
  border-radius: var(--radius);
  background: var(--emerald-50);
}
.export-file-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  color: var(--emerald-700);
  background: #ffffff;
  border: 1px solid var(--emerald-200);
}
.export-file-icon .ui-icon { width: 21px; height: 21px; }
.export-file-card > div {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}
.export-file-card > div strong {
  overflow: hidden;
  color: var(--slate-900);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.export-file-card > div small { color: var(--slate-500); font-size: 0.75rem; }
.export-file-ready {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--emerald-700);
  background: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.export-preview-summary {
  display: grid;
  grid-template-columns: 1.4fr 1.4fr 0.8fr 1fr;
  gap: 1px;
  margin: 14px 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}
.export-preview-summary > div {
  min-width: 0;
  padding: 11px 13px;
  background: var(--surface-subtle);
}
.export-preview-summary dt {
  color: var(--slate-500);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.export-preview-summary dd {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--slate-800);
  font-size: 0.82rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-preview-section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 9px;
}
.export-preview-section-heading h3 { margin: 0; color: var(--slate-900); font-size: 0.95rem; }
.export-preview-section-heading p { margin: 2px 0 0; color: var(--slate-500); font-size: 0.78rem; }
.export-preview-section-heading > span { color: var(--slate-400); font-size: 0.72rem; white-space: nowrap; }

.export-preview-table-wrap {
  max-height: 330px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.export-preview-table { min-width: 1280px; }
.export-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
}
.export-preview-table td {
  max-width: 220px;
  padding: 10px 12px;
  color: var(--slate-600);
  font-size: 0.77rem;
  vertical-align: top;
}
.export-preview-table .money-cell,
.export-preview-table .export-preview-number,
.export-preview-table .export-preview-updated { white-space: nowrap; }
.export-preview-code {
  color: var(--primary-700) !important;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
  white-space: nowrap;
}
.export-preview-description { min-width: 210px; white-space: normal; }
.export-preview-empty { padding: 28px !important; text-align: center; }
.export-allocation-list {
  display: flex;
  min-width: 260px;
  flex-direction: column;
  gap: 4px;
  white-space: normal;
}
.export-allocation-list span + span {
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}
.export-preview-note {
  margin: 9px 0 0;
  color: var(--slate-500);
  font-size: 0.76rem;
}

/* Spreadsheet-like preview: mirrors the workbook rows, columns and values. */
.excel-preview-window {
  overflow: hidden;
  border: 1px solid #9da5ad;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  color: #1f2937;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
}
.excel-titlebar {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  color: #ffffff;
  background: #217346;
}
.excel-app-mark {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  font-weight: 800;
}
.excel-titlebar > div {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}
.excel-titlebar strong {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.excel-titlebar small { color: rgba(255, 255, 255, 0.78); font-size: 0.68rem; }
.excel-sheet-size {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.7rem;
  white-space: nowrap;
}
.excel-ribbon {
  display: flex;
  min-height: 35px;
  align-items: flex-end;
  gap: 2px;
  padding: 0 10px;
  border-bottom: 1px solid #c9cdd1;
  background: #f7f7f7;
}
.excel-ribbon span {
  padding: 10px 11px 8px;
  color: #475569;
  font-size: 0.7rem;
}
.excel-ribbon span.is-active {
  color: #185c37;
  border-bottom: 2px solid #217346;
  font-weight: 700;
}
.excel-formula-bar {
  display: grid;
  min-height: 34px;
  grid-template-columns: 70px 34px minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid #c9cdd1;
  background: #ffffff;
  font-size: 0.72rem;
}
.excel-name-box,
.excel-fx,
.excel-formula-value {
  min-width: 0;
  padding: 5px 9px;
}
.excel-name-box,
.excel-fx { border-right: 1px solid #d7dade; text-align: center; }
.excel-fx { color: #64748b; font-family: Georgia, serif; font-style: italic; }
.excel-formula-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.excel-grid-scroll {
  max-height: min(52vh, 560px);
  overflow: auto;
  background: #ffffff;
}
.excel-grid-scroll:focus-visible {
  outline: 3px solid rgba(33, 115, 70, 0.35);
  outline-offset: -3px;
}
.excel-grid {
  width: max-content;
  min-width: 100%;
  border-spacing: 0;
  border-collapse: separate;
  table-layout: fixed;
  font-size: 0.72rem;
}
.excel-corner,
.excel-column-heading,
.excel-row-heading {
  color: #4b5563;
  background: #f3f4f6;
  font-weight: 500;
  text-align: center;
  user-select: none;
}
.excel-corner {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 5;
  width: 42px;
  min-width: 42px;
  border-right: 1px solid #bfc4c9;
  border-bottom: 1px solid #bfc4c9;
}
.excel-column-heading {
  position: sticky;
  top: 0;
  z-index: 4;
  height: 25px;
  border-right: 1px solid #c9cdd1;
  border-bottom: 1px solid #bfc4c9;
}
.excel-row-heading {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 42px;
  min-width: 42px;
  height: 27px;
  border-right: 1px solid #bfc4c9;
  border-bottom: 1px solid #d7dade;
}
.excel-cell {
  height: 27px;
  max-width: 280px;
  overflow: hidden;
  padding: 4px 7px;
  border-right: 1px solid #d7dade;
  border-bottom: 1px solid #d7dade;
  background: #ffffff;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: cell;
}
.excel-cell.is-selected {
  position: relative;
  overflow: visible;
  outline: 2px solid #217346;
  outline-offset: -2px;
  z-index: 1;
}
.excel-cell.is-selected::after {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 5px;
  height: 5px;
  content: "";
  background: #217346;
}
.excel-col-narrow { width: 72px; min-width: 72px; }
.excel-col-code { width: 180px; min-width: 180px; }
.excel-col-standard { width: 150px; min-width: 150px; }
.excel-col-wide { width: 260px; min-width: 260px; }
.excel-col-money { width: 145px; min-width: 145px; }
.excel-info-row .excel-cell { background: #ebf3fb; }
.excel-info-label { color: #1e3a5f; font-weight: 700; }
.excel-info-value { color: #111827; font-weight: 600; }
.excel-info-row .excel-empty-cell { background: #ffffff; }
.excel-blank-row .excel-cell,
.excel-blank-row .excel-row-heading { height: 14px; background: #ffffff; }
.excel-data-heading {
  height: 42px;
  color: #ffffff;
  background: #1e3a5f;
  font-weight: 700;
  text-align: center;
  white-space: normal;
}
.excel-alt-row .excel-cell { background: #f7fafd; }
.excel-align-center { text-align: center; }
.excel-align-right { text-align: right; }
.excel-number-cell { font-variant-numeric: tabular-nums; }
.excel-confirmed-cell { color: #166534; background: #d1fae5 !important; font-weight: 700; text-align: center; }
.excel-unconfirmed-cell { color: #854d0e; background: #fef9c3 !important; font-weight: 700; text-align: center; }
.excel-statusbar {
  display: flex;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 12px;
  border-top: 1px solid #c9cdd1;
  color: #4b5563;
  background: #f3f4f6;
  font-size: 0.7rem;
}
.excel-sheet-tabs {
  align-self: stretch;
  display: flex;
  align-items: stretch;
}
.excel-sheet-tabs span {
  display: flex;
  align-items: center;
  padding: 0 15px;
  border-right: 1px solid #d7dade;
}
.excel-sheet-tabs span.is-active {
  color: #185c37;
  background: #ffffff;
  border-bottom: 3px solid #217346;
  font-weight: 700;
}
.excel-preview-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 9px;
  color: var(--slate-500);
  font-size: 0.74rem;
}
.excel-preview-caption strong { color: var(--slate-600); font-weight: 600; white-space: nowrap; }

@media (max-width: 900px) {
  .expense-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card.stat-amount { grid-column: span 1; }
  .export-preview-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project-code-column { width: 170px; }
}

@media (max-width: 640px) {
  .expense-stat-grid { grid-template-columns: 1fr; }
  .list-summary,
  .expense-modal-footer {
    align-items: stretch;
    flex-direction: column;
  }
  .expense-modal-footer { gap: 10px; padding: 12px 16px; }
  .expense-modal-footer-summary { justify-content: space-between; gap: 8px; }
  .expense-modal-footer-divider { display: none; }
  .expense-modal-footer-total { flex-direction: column; align-items: flex-end; gap: 1px; }
  .expense-modal-footer-actions { width: 100%; }
  .expense-modal-footer-actions .button { flex: 1 1 0; min-width: 0; }
  dialog.app-dialog.export-preview-dialog { width: 97vw; max-height: 96vh; }
  .export-preview-body { padding: 10px; }
  .export-file-ready { display: none; }
  .export-preview-summary { grid-template-columns: 1fr; }
  .export-preview-section-heading { align-items: flex-start; flex-direction: column; gap: 4px; }
  .export-preview-dialog footer { align-items: stretch; flex-direction: column-reverse; }
  .export-preview-dialog footer .button { width: 100%; }
  .excel-ribbon span:not(.is-active) { display: none; }
  .excel-sheet-size { display: none; }
  .excel-grid-scroll { max-height: 50vh; }
  .excel-preview-caption { align-items: flex-start; flex-direction: column; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .export-preview-spinner { animation-duration: 1.8s; }
}

/* ========================================================================== 
   EXPENSE LIST — REFINED SINGLE-SURFACE LAYOUT
   ========================================================================== */

.expense-list-heading {
  align-items: flex-end;
  margin-bottom: 20px;
}
.expense-list-heading h1 { letter-spacing: -0.035em; }
.expense-list-heading > div > p:last-child { max-width: 640px; }

.expense-list-panel {
  border-color: var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.055);
}

.expense-list-toolbar {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(340px, 360px);
  align-items: center;
  gap: 22px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}
.expense-list-search {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}
.expense-list-search .input-icon-wrap { flex: 1; }
.expense-list-search input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 42px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  outline: none;
  background: var(--slate-50);
  color: var(--slate-900);
  font: inherit;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--motion-fast), background-color var(--motion-fast), box-shadow var(--motion-fast);
}
.expense-list-search input::placeholder {
  color: var(--slate-500);
  opacity: 1;
}
.expense-list-search input:hover {
  border-color: var(--slate-300);
  background: #ffffff;
}
.expense-list-search input:focus {
  border-color: var(--primary-400);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.expense-list-search .text-link { flex: 0 0 auto; }

.expense-list-overview {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.expense-list-overview > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 0 18px;
}
.expense-list-overview > div:first-child {
  padding-left: 0;
  border-right: 1px solid var(--line);
}
.expense-list-overview > div:last-child { padding-right: 0; }
.expense-list-overview span {
  color: var(--slate-400);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.expense-list-overview strong {
  color: var(--slate-800);
  font-size: 0.84rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.expense-list-overview > div:last-child strong { color: var(--primary-700); }

.project-table-wrap { overflow-x: auto; }
.project-table { min-width: 820px; }
.project-table .data-table { border-radius: 0; }
.project-table th {
  padding: 11px 18px;
  color: var(--slate-700);
  background: #edf3fb;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.035em;
  border-bottom: 1px solid var(--line-dark);
}
.project-table td {
  height: 64px;
  padding: 14px 18px;
  background: #ffffff;
}
.project-table tbody tr:last-child td { border-bottom: 0; }
.project-table-row:hover { background: transparent !important; }
.project-table-row:hover td { background: #f8fbff; }
.project-table-row:focus-visible td { background: #f8fbff; }
.project-name-cell { position: relative; padding-right: 128px !important; }
.project-row-hint {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-600);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-fast);
}
.project-table-row:hover .project-row-hint,
.project-table-row:focus-visible .project-row-hint { opacity: 0.68; }
.project-code-cell {
  max-width: 190px;
  color: var(--slate-700);
  font-size: 14px;
  font-weight: 600;
}
.project-table .project-row-name {
  color: var(--slate-900);
  font-size: 0.92rem;
  font-weight: 700;
}
.project-row-count {
  color: var(--slate-500);
  font-size: 0.8rem;
  font-weight: 500;
}
.project-row-count strong {
  color: var(--slate-900);
  font-size: 0.94rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.project-row-money {
  color: var(--slate-900);
  font-size: 0.94rem;
  font-weight: 750;
}

.expense-modal-box {
  border: 1px solid var(--line);
}
.expense-modal-header {
  padding-block: 1rem;
}
.expense-modal-table {
  width: 100%;
  min-width: 1280px;
  table-layout: fixed;
}
.expense-modal-table .expense-col-code { width: 240px; }
.expense-modal-table .expense-col-content { width: 230px; }
.expense-modal-table .expense-col-supplier { width: 180px; }
.expense-modal-table .expense-col-amount { width: 155px; }
.expense-modal-table .expense-col-payment { width: 105px; }
.expense-modal-table .expense-col-status { width: 160px; }
.expense-modal-table .expense-col-updated { width: 160px; }
.expense-modal-table .expense-col-action { width: 50px; }
.expense-modal-table th {
  color: var(--slate-700);
  background: #edf3fb;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.025em;
  white-space: normal;
  line-height: 1.35;
  vertical-align: middle;
}
.expense-modal-table td {
  padding-right: 12px;
  padding-left: 12px;
  vertical-align: middle;
  overflow: hidden;
}
.expense-modal-table .td-desc,
.expense-modal-table .td-supplier {
  overflow: hidden;
  white-space: normal;
}
.expense-modal-table .td-desc span,
.expense-modal-table .td-supplier span {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  white-space: normal;
}
.expense-modal-table .money-cell,
.expense-modal-table .expense-table-muted {
  white-space: nowrap;
}
.expense-modal-table .code-link {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.expense-modal-table .row-action {
  position: relative;
}

.expense-detail-row { cursor: pointer; }
.expense-detail-row:hover td,
.expense-detail-row:focus-visible td { background: #f8fbff; }
.expense-detail-row:focus-visible { outline: 2px solid var(--primary-400); outline-offset: -2px; }
.row-action-hint {
  position: absolute;
  right: calc(100% + 6px);
  top: 50%;
  transform: translateY(-50%);
  padding: 6px 9px;
  border: 1px solid var(--primary-100);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
  color: var(--primary-700);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}
.row-action:hover .row-action-hint,
.row-action:focus-visible .row-action-hint {
  opacity: 1;
  visibility: visible;
}
.export-preview-trigger:hover,
.export-preview-trigger:focus-visible {
  color: #ffffff;
  background: #185c37;
  border-color: #185c37;
}
.export-preview-trigger:focus-visible { outline: 3px solid #a7dfbd; outline-offset: 2px; }

/* ========================================================================== 
   WORKBOOK PREVIEW — CLEAN REVIEW SURFACE
   ========================================================================== */

.export-preview-body { background: #f6f8fa; }
.workbook-preview {
  overflow: hidden;
  border: 1px solid #d8dee6;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.workbook-preview-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 16px;
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}
.workbook-file-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}
.workbook-file-type {
  display: grid;
  width: 46px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: #ffffff;
  background: #217346;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.workbook-file-identity > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}
.workbook-file-identity strong {
  overflow: hidden;
  color: var(--slate-900);
  font-size: 0.86rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workbook-file-identity small {
  max-width: 620px;
  overflow: hidden;
  color: var(--slate-500);
  font-size: 0.71rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.workbook-preview-metrics {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  margin: 0;
}
.workbook-preview-metrics > div {
  min-width: 112px;
  padding: 2px 16px;
  border-left: 1px solid #e2e8f0;
}
.workbook-preview-metrics dt {
  color: var(--slate-400);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}
.workbook-preview-metrics dd {
  margin: 3px 0 0;
  color: var(--slate-900);
  font-size: 0.84rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.workbook-sheet-toolbar {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-bottom: 1px solid #d8dee6;
  color: var(--slate-500);
  background: #f8fafc;
  font-size: 0.7rem;
}
.workbook-sheet-name {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 10px;
  color: #185c37;
  border-bottom: 2px solid #217346;
  background: #ffffff;
  font-weight: 700;
}
.workbook-preview .excel-grid-scroll {
  max-height: min(52vh, 540px);
  background: #ffffff;
}
.workbook-preview .excel-column-heading,
.workbook-preview .excel-corner,
.workbook-preview .excel-row-heading {
  color: #64748b;
  background: #f1f5f9;
}
.workbook-preview .excel-cell {
  height: 30px;
  border-color: #e1e6ec;
  color: #334155;
  cursor: default;
}
.workbook-preview .excel-info-row .excel-cell { background: #f7fbff; }
.workbook-preview .excel-info-row .excel-empty-cell { background: #ffffff; }
.workbook-preview .excel-info-label { color: #315b7d; }
.workbook-preview .excel-data-heading {
  height: 44px;
  color: #334155;
  border-bottom: 2px solid #9fb3c8;
  background: #edf3f8;
  font-size: 0.69rem;
}
.workbook-preview .excel-alt-row .excel-cell { background: #fafcff; }
.workbook-preview-status {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 14px;
  border-top: 1px solid #d8dee6;
  color: var(--slate-500);
  background: #f8fafc;
  font-size: 0.7rem;
}
.workbook-preview-status strong { color: var(--slate-600); font-weight: 600; white-space: nowrap; }

@media (max-width: 1050px) {
  .expense-list-toolbar { grid-template-columns: 1fr; gap: 14px; }
  .expense-list-overview { justify-content: flex-end; }
}

@media (max-width: 900px) {
  .team-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-filter .search-wide { grid-column: 1 / -1; }
}

@media (max-width: 700px) {
  .team-filter,
  .project-filter-bar { grid-template-columns: minmax(0, 1fr); }
  .team-filter .search-wide { grid-column: auto; }
  .expense-list-heading { align-items: stretch; }
  .expense-list-heading .button { width: 100%; }
  .expense-list-toolbar { min-width: 0; padding: 12px; }
  .expense-list-search { align-items: stretch; flex-direction: column; }
  .expense-list-search .text-link { align-self: flex-end; }
  .expense-list-overview {
    align-items: stretch;
    justify-content: space-between;
    white-space: normal;
  }
  .expense-list-overview > div { flex: 1; padding: 0 12px; }
  .expense-list-overview > div:first-child { padding-left: 0; }
  .expense-list-overview > div:last-child { padding-right: 0; text-align: right; }
  .project-table { min-width: 760px; }
  .workbook-preview-header { align-items: stretch; flex-direction: column; gap: 12px; }
  .workbook-preview-metrics { border-top: 1px solid #e2e8f0; }
  .workbook-preview-metrics > div { flex: 1; padding: 10px 12px 0; }
  .workbook-preview-metrics > div:first-child { padding-left: 0; border-left: 0; }
  .workbook-preview-status { align-items: flex-start; flex-direction: column; gap: 3px; padding-block: 9px; }
}

.mobile-records .record-card footer { gap: 8px; align-items: flex-end; }
.mobile-records .record-card footer span small { display: block; margin-left: 0; }
.mobile-records .record-card footer > small { text-align: right; }

@media (max-width: 1100px) {
  .expense-modal-table-wrap { display: none; }
  .mobile-records {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
  }
  .mobile-records .record-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }
}

@media (max-width: 700px) {
  .mobile-records { grid-template-columns: minmax(0, 1fr); }
  .detail-heading { padding: 20px 18px; }
  .detail-total { flex-direction: column; align-items: stretch; gap: 10px; padding: 18px; }
  .detail-total strong { align-self: flex-end; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); padding: 4px 18px 14px; }
  .detail-grid > div:nth-last-child(-n + 2) { border-bottom: 1px solid var(--line-subtle); }
  .detail-grid > div:last-child { border-bottom: 0; }
  .detail-panel .panel-heading { padding: 18px; }
  .detail-panel .allocation-table { padding: 14px 18px 18px; }
}

/* Project and expense lists share the same typography and plain code style. */
.project-table th,
.expense-modal-table th {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.025em;
}

.project-table tbody td,
.expense-modal-table tbody td {
  line-height: 1.45;
}

.project-table .project-code-cell,
.expense-modal-table .code-link,
.mobile-records .code-link {
  color: var(--slate-700);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.expense-modal-table .td-desc {
  color: var(--slate-900);
  font-weight: 600;
}

@media (max-width: 420px) {
  .topbar-company,
  .topbar-status-separator { display: none; }
  .topbar-title { white-space: nowrap; }
  .detail-action-bar { align-items: stretch; }
  .detail-action-bar .button-back { width: fit-content; }
  .detail-action-buttons { width: 100%; margin-left: 0; }
  .detail-action-buttons .button { flex: 1 1 0; min-width: 0; padding-inline: 10px; }
}

/* Keep list records visible when the shared desktop table is hidden on phones. */
@media (max-width: 1100px) {
  .team-panel > .table-wrap,
  .project-directory > .table-wrap,
  .expense-list-panel > .project-table-wrap {
    display: block;
    overflow: visible;
    padding: 12px;
  }

  .team-panel > .table-wrap table,
  .project-directory > .table-wrap table,
  .expense-list-panel > .project-table-wrap table,
  .team-panel > .table-wrap tbody,
  .project-directory > .table-wrap tbody,
  .expense-list-panel > .project-table-wrap tbody {
    display: grid;
    width: 100%;
    min-width: 0;
  }

  .team-panel > .table-wrap thead,
  .project-directory > .table-wrap thead,
  .expense-list-panel > .project-table-wrap thead,
  .expense-list-panel > .project-table-wrap colgroup { display: none; }

  .team-panel > .table-wrap tbody,
  .project-directory > .table-wrap tbody,
  .expense-list-panel > .project-table-wrap tbody { gap: 12px; }

  .team-panel [data-team-row],
  .project-directory [data-project-row],
  .expense-list-panel .project-table-row {
    display: grid;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  .team-panel [data-team-row] > td,
  .project-directory [data-project-row] > td,
  .expense-list-panel .project-table-row > td {
    display: block;
    min-width: 0;
    height: auto;
    padding: 6px 0;
    border: 0;
    background: transparent;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .team-panel [data-team-row] > td:first-child,
  .project-directory [data-project-row] > td:nth-child(2),
  .expense-list-panel .project-table-row > td:nth-child(2) {
    padding-top: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-subtle);
  }

  .team-panel [data-team-row] > td[data-label],
  .project-directory [data-project-row] > td[data-label] {
    display: grid;
    grid-template-columns: minmax(72px, 28%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
  }

  .team-panel [data-team-row] > td[data-label]::before,
  .project-directory [data-project-row] > td[data-label]::before {
    content: attr(data-label);
    color: var(--slate-500);
    font-size: 12px;
    font-weight: 600;
  }

  .team-panel [data-team-row] > td:last-child,
  .project-directory [data-project-row] > td:last-child:has(.row-actions) {
    padding-top: 12px;
    border-top: 1px solid var(--line-subtle);
  }

  .team-panel .row-actions,
  .project-directory .row-actions { flex-wrap: wrap; }

  .team-panel .row-actions .button,
  .project-directory .row-actions .button { min-height: 44px; }

  .project-directory [data-project-row] > td:first-child {
    order: -2;
    padding-top: 0;
    color: var(--primary-700);
    font-weight: 700;
  }

  .project-directory [data-project-row] > td:nth-child(2) { order: -1; }
  .project-directory .project-period { white-space: normal; }

  .expense-list-panel .project-table-row > td:first-child {
    order: -2;
    padding-top: 0;
  }

  .expense-list-panel .project-table-row > td:nth-child(2) {
    order: -1;
    padding-right: 0 !important;
  }

  .expense-list-panel .project-row-name { white-space: normal; }
  .expense-list-panel .project-row-hint { display: none; }
  .expense-list-panel .project-table-row > .project-row-count::before {
    content: 'Khoản dự chi: ';
    color: var(--slate-500);
    font-weight: 500;
  }

  .expense-list-panel .project-table-row > .project-row-money {
    padding-top: 10px;
    border-top: 1px solid var(--line-subtle);
    text-align: left !important;
  }

  .expense-list-panel .project-table-row::after {
    content: 'Xem khoản dự chi ›';
    padding-top: 10px;
    color: var(--primary-700);
    font-size: 12px;
    font-weight: 700;
    text-align: right;
  }
}

@media (min-width: 700px) and (max-width: 1100px) {
  .team-panel > .table-wrap tbody,
  .project-directory > .table-wrap tbody,
  .expense-list-panel > .project-table-wrap tbody {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Let narrow forms wrap naturally and keep their action bar after the fields. */
.expense-layout { grid-template-columns: minmax(0, 1fr); }
.expense-layout > *,
.budget-confirmation-copy,
.budget-confirmation-title { min-width: 0; }

@media (max-width: 640px) {
  .menu-button,
  dialog.app-dialog header button,
  .expense-modal-close { width: 44px; height: 44px; }
  .sidebar-account-actions a,
  .sidebar-account-actions button { min-height: 44px; }
  dialog.app-dialog header { padding: 16px 20px; }
  dialog.app-dialog footer { padding: 12px 20px; }
  dialog.app-dialog .dialog-body .form-grid.two { gap: 8px; }
  dialog.app-dialog .dialog-body .field { margin-bottom: 14px; }
  .workbook-file-identity strong,
  .workbook-file-identity small {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .expense-layout .form-panel { padding: 20px; }
  .budget-confirmation-card { align-items: flex-start; padding: 14px; }
  .budget-confirmation-title { flex-wrap: wrap; }
  .form-submit-bar {
    position: static;
    flex-wrap: wrap;
    padding: 16px;
  }
  .form-submit-bar > div,
  .form-submit-bar .submit-actions { width: 100%; }
  .form-submit-bar .submit-actions .button { flex: 1 1 0; min-width: 0; }
  dialog.app-dialog { max-height: calc(100dvh - 24px); }
  dialog.app-dialog > form {
    display: flex;
    max-height: calc(100dvh - 24px);
    flex-direction: column;
  }
  dialog.app-dialog .dialog-body {
    min-height: 0;
    max-height: none;
    overflow-y: auto;
  }
  dialog.app-dialog.export-preview-dialog[open],
  dialog.app-dialog.expense-confirm-dialog[open] {
    display: flex;
    max-height: calc(100dvh - 24px);
    flex-direction: column;
  }
  dialog.app-dialog.export-preview-dialog > .dialog-body,
  dialog.app-dialog.expense-confirm-dialog > .dialog-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
  }
  dialog.app-dialog.export-preview-dialog > header,
  dialog.app-dialog.export-preview-dialog > footer,
  dialog.app-dialog.expense-confirm-dialog > header,
  dialog.app-dialog.expense-confirm-dialog > footer { flex: 0 0 auto; }
  dialog.app-dialog.expense-confirm-dialog footer.expense-confirm-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }
  dialog.app-dialog.expense-confirm-dialog footer.expense-confirm-actions .button {
    width: 100%;
    min-width: 0;
    justify-content: center;
    white-space: normal;
  }
}

@media (max-width: 360px) {
  .topbar-actions { display: none; }
  .topbar-start > div { min-width: 0; }
  .topbar-title { white-space: normal; }
  dialog.app-dialog header { padding: 14px 16px; }
  dialog.app-dialog header h2 { font-size: 16px; }
  dialog.app-dialog .dialog-body { padding: 16px; }
  dialog.app-dialog .dialog-body .form-grid.two { gap: 0; }
  dialog.app-dialog .dialog-body .field { margin-bottom: 14px; }
  dialog.app-dialog footer { padding: 12px 16px; }
}

/* Project expenses use the main page shell and shared list controls. */
.project-expense-actions, .project-expense-period, .project-expense-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.project-expense-actions { justify-content: flex-end; }
.project-expense-period { margin-top: 10px; color: var(--slate-500); font-size: 13px; }
.project-expense-toolbar {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
}
.project-expense-filters { align-items: end; }
.project-expense-filters .field { min-width: 170px; }
.project-expense-toolbar .expense-list-overview { grid-column: 1 / -1; justify-content: flex-start; }
.project-expense-panel .expense-modal-table-wrap { padding: 0; }
.project-table-row[role="link"]:focus-visible { outline: 2px solid var(--primary-500); outline-offset: -2px; }
@media (max-width: 1000px) {
  .project-expense-toolbar { grid-template-columns: minmax(0, 1fr); }
  .project-expense-filters .field { flex: 1; min-width: 150px; }
}
@media (max-width: 640px) {
  .project-expense-actions { justify-content: flex-start; }
  .project-expense-filters { width: 100%; }
  .project-expense-filters .field { min-width: 0; flex-basis: calc(50% - 6px); }
  .project-expense-toolbar .expense-list-overview { flex-wrap: wrap; gap: 12px; }
}

.finance-list-status { display: grid; justify-items: start; gap: 8px; }
.finance-list-status .button { font-size: 12px; padding: 6px 10px; }
.finance-workflow-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.finance-request-note { padding: 14px; margin-block: 14px; background: var(--amber-100); border-radius: var(--radius); }
.finance-request-note p { overflow-wrap: anywhere; white-space: pre-wrap; }
.finance-workflow .stack-form { margin-top: 14px; }
.project-expense-toolbar { grid-template-columns: minmax(0, 1fr); }
