* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f5f5f5;
  color: #2c3e50;
  line-height: 1.6;
}

/* Lucide Icons - General styling */
i[data-lucide] {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  width: 18px;
  height: 18px;
}

/* Override Lucide Icons default size (24x24) - SVG inside icons */
i[data-lucide] > svg,
i[data-lucide] svg {
  width: 18px !important;
  height: 18px !important;
  display: block;
  flex-shrink: 0;
}

/* Header */
.header {
  background: #2c3e50;
  color: white;
  padding: 0 2rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  min-height: 60px;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-menu {
  position: relative;
}

.user-menu-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s, border-color 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-menu-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.user-menu-button.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.user-menu-button i {
  font-size: 0.9rem;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: white;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
}

.user-menu-item {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  background: white;
  color: #333;
  text-align: left;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.2s;
}

.user-menu-item:hover {
  background: #f5f5f5;
}

.user-menu-item i {
  width: 16px;
  text-align: center;
}

.logout-button {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.3s, border-color 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logout-button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.logout-button i {
  font-size: 0.9rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header h1 i[data-lucide] {
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
}

.year-selector {
  position: relative;
  min-width: 150px;
}

.year-selector-button {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.25rem;
  border: 1px solid #d0d7de;
  border-radius: 16px;
  background: #ffffff;
  color: #0f172a;
  font-size: 0.95rem;
  cursor: pointer;
  outline: none;
  min-width: 130px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  width: 100%;
  justify-content: space-between;
}

.year-selector-button:hover,
.year-selector-button.active {
  border-color: #0a66c2;
  box-shadow: 0 10px 30px rgba(10, 102, 194, 0.2);
}

.year-selector-button .year-icon {
  font-size: 1rem;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
}

.year-selector-button .year-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  width: 0.75rem;
  height: 0.75rem;
  display: inline-flex;
  align-items: center;
}

.year-selector-button.active .year-arrow {
  transform: rotate(180deg);
}

.year-selector select {
  display: none;
}

/* Custom Dropdown */
.year-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.18);
  min-width: 260px;
  z-index: 1000;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.year-dropdown-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
}

.year-dropdown-header .year-icon,
.year-dropdown-header i[data-lucide] {
  font-size: 1rem;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.year-dropdown-header .year-icon {
  font-size: 1rem;
}

.year-dropdown-list {
  max-height: 300px;
  overflow-y: auto;
}

.year-dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  color: #0f172a;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid #f1f5f9;
  position: relative;
  gap: 1rem;
}

.year-dropdown-item > div:first-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.year-dropdown-item:hover {
  background: #f8fafc;
}

.year-dropdown-item.selected {
  background: #e8f2ff;
}

.year-dropdown-item-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.year-dropdown-item-note {
  font-size: 0.85rem;
  color: #64748b;
}

.year-dropdown-item-checkmark {
  color: #0a66c2;
  font-weight: bold;
  font-size: 1.2rem;
  margin-left: 1rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.year-dropdown-item.selected .year-dropdown-item-checkmark {
  opacity: 1;
}

.year-dropdown-footer {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  color: #475569;
  font-size: 0.85rem;
  border-top: 1px solid #e2e8f0;
}

.year-dropdown-footer .info-icon,
.year-dropdown-footer i[data-lucide] {
  font-size: 1rem;
  width: 1rem;
  height: 1rem;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.year-dropdown-footer .info-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

/* Main Tabs */
.main-tabs {
  background: white;
  border-bottom: 2px solid #e0e0e0;
  display: flex;
  padding: 0 2rem;
  gap: 0;
  overflow-x: auto;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  min-height: 50px;
  height: 50px;
}

.main-tab {
  padding: 0 1.5rem;
  cursor: pointer;
  border-bottom: 4px solid transparent;
  transition: all 0.3s;
  font-weight: 500;
  white-space: nowrap;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 50px;
  margin: 0;
  position: relative;
}

.main-tab:hover {
  color: #2c3e50;
}

.main-tab.active {
  color: #2980b9;
  border-bottom: 4px solid #2980b9;
}

.main-tab .tab-icon,
.main-tab i[data-lucide] {
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  margin-right: 0.5rem;
}

.main-tab .tab-icon {
  font-size: 1.2rem;
}

.main-tab .tab-text {
  font-size: 0.95rem;
}

/* Sub Tabs Wrapper */
.sub-tabs-wrapper {
  position: relative;
  z-index: 100;
  transition: opacity 0.3s ease;
}

.sub-tabs-wrapper.hidden {
  display: none;
}

/* Sub Tabs */
.sub-tabs {
  /* background: white; */
  display: flex;
  padding: 0 2rem;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

.sub-tabs::-webkit-scrollbar {
  height: 4px;
}

.sub-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.sub-tabs::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 2px;
}

.sub-tabs::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.sub-tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 500;
  white-space: nowrap;
  color: #666;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  background: none !important;
  text-decoration: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin: 0;
}

.sub-tab:hover {
  color: #2c3e50;
  background: none !important;
}

.sub-tab.active {
  color: #2980b9;
  background: none !important;
  border-bottom: 2px solid #2980b9;
  text-decoration: none;
}

/* Content */
.content {
  padding: 2rem;
  max-width: 100%;
  /* Bỏ overflow để scroll ở viewport */
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  /* Đảm bảo không có height cố định để scroll ở viewport */
  max-height: none !important;
  height: auto !important;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Data Refresh Bar */
.data-refresh-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 0;
}

.data-refresh-bar .btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.code-thang-refresh {
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.code-thang-refresh .month-select-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.code-thang-refresh .month-select-wrapper label {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}

.code-thang-refresh .month-select-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.code-thang-refresh .month-select-wrapper .month-selector {
  width: auto;
}

.code-thang-refresh .month-select-wrapper .month-selector,
.code-thang-refresh .month-refresh-btn {
  margin-right: 0;
}

.code-thang-refresh .month-refresh-btn {
  align-self: center;
  white-space: nowrap;
}

.code-thang-refresh .last-update-text {
  margin-left: 0;
  font-size: 0.9rem;
  color: #475569;
}

.last-update-text {
  color: #666;
  font-size: 0.9rem;
}

.last-update-text span {
  font-weight: 500;
  color: #2c3e50;
}

/* Filters */
.filters {
  background: white;
  padding: 1rem 2rem;
  border-radius: 0;
  margin-bottom: 1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
}

.filter-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s;
  min-width: 150px;
  flex: 0 1 auto;
}

.filter-input:focus {
  border-color: #2980b9;
}

.filter-input::placeholder {
  color: #999;
}

.filters button.btn-secondary.has-filters {
  background: #e74c3c;
  color: white;
  font-weight: 600;
  opacity: 1;
}

.filters button.btn-secondary:not(.has-filters) {
  opacity: 0.5;
  cursor: not-allowed;
}

.month-filter-group {
  min-width: 240px;
}

.month-selector {
  position: relative;
  width: 240px;
}

.month-dropdown-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.month-dropdown-button:hover,
.month-dropdown-button.active {
  border-color: #0a66c2;
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.1);
}

.month-dropdown-button .chevron {
  font-size: 0.9rem;
  color: #475569;
}

.month-summary-text {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  color: #0f172a;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.month-summary-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: #0a66c2;
  background: #eef4ff;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  flex-shrink: 0;
}

.month-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 280px;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.15);
  padding: 0.75rem;
  z-index: 200;
  display: none;
}

.month-dropdown.open {
  display: block;
}

.month-dropdown-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.month-dropdown-actions button {
  flex: 1;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #f1f5f9;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.month-dropdown-actions button:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.month-options {
  max-height: 260px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.35rem;
}

.month-option {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.4rem 0.45rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
  color: #0f172a;
  font-weight: 600;
}

.month-option input {
  cursor: pointer;
}

.month-option-text {
  display: none;
}

.month-option:hover {
  background: #f5f7fb;
  border-color: #e2e8f0;
}

.month-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0a66c2;
  color: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  min-width: 40px;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.page-size-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.page-size-label .page-size-selector {
  margin: 0 0.25rem;
}

.page-size-selector {
  padding: 0.25rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  height: auto;
  min-height: auto;
  line-height: 1.4;
}

.page-input {
  padding: 0.25rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  width: 50px;
  text-align: center;
}

.page-input:focus {
  outline: none;
  border-color: #2980b9;
}

.page-info {
  margin: 0 0.5rem;
  font-weight: 500;
}

.pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
  background: #f0f0f0;
}

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

.pagination-btn-prev,
.pagination-btn-next {
  min-width: auto;
  padding: 0.3rem 0.75rem !important;
  white-space: nowrap;
}

/* Summary Boxes */
.summary-box {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.5rem;
  margin: 1rem 0;
  border-radius: 4px;
  flex-wrap: wrap;
  align-items: center;
}

.summary-all {
  background: #e3f2fd;
  border: 1px solid #90caf9;
}

.summary-filtered {
  background: #fff3e0;
  border: 1px solid #ffb74d;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.summary-label {
  font-weight: 500;
  color: #555;
  font-size: 0.9rem;
}

.summary-value {
  font-weight: 500;
  font-size: 0.9rem;
  color: #2980b9;
}

.filter-input:focus {
  border-color: #2980b9;
}

.filter-input::placeholder {
  color: #999;
}

/* Buttons */
.btn {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.25rem; /* Đảm bảo chiều cao tối thiểu */
  box-sizing: border-box;
}

/* Buttons - Font Awesome Icon size 18px - Đơn giản với font-size */
.btn i.fas,
.btn i.far,
.btn i.fal,
.btn i.fab,
.btn-small i.fas,
.btn-small i.far,
.btn-small i.fal,
.btn-small i.fab {
  font-size: 18px !important;
  line-height: 1;
  display: inline-block;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.btn-primary {
  background: #2980b9;
  color: white;
}

.btn-primary:hover {
  background: #21618c;
}

.btn-primary:active {
  background: #1a4d73;
}

.btn-primary:disabled {
  background: #95a5a6;
  color: white;
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-secondary:disabled {
  background: #bdc3c7;
  color: white;
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-small {
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
  gap: 0.35rem; /* Giảm gap cho icon nhỏ hơn */
  min-height: 1.75rem; /* Đảm bảo chiều cao tối thiểu bằng nhau */
  box-sizing: border-box;
}

/* Row Action Buttons */
.row-action-buttons {
  background: #f8f9fa;
}

.action-buttons-cell {
  padding: 1rem 1.5rem !important;
  border: none !important;
  border-bottom: 1px solid #2980b9 !important;
  background: #f0f8ff;
  position: relative;
}

.action-buttons-cell::before,
.action-buttons-cell::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: #2980b9;
}

.action-buttons-cell::before {
  left: 0;
}

.action-buttons-cell::after {
  right: 0;
}

.row-action-buttons-container {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Đảm bảo tất cả buttons trong action row có cùng chiều cao */
.row-action-buttons-container .btn,
.row-action-buttons-container .btn-small {
  height: 1.75rem; /* Chiều cao cố định */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.selected-row {
  background: #e8f4f8 !important;
  position: relative;
}

.selected-row:hover {
  background: #d4edf5 !important;
}

/* Highlight selected row with left border */
.selected-row td:first-child {
  border-left: 1px solid #2980b9;
}

/* Table */
.table-container {
  background: white;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  position: relative;
  /* Không có overflow - để sticky hoạt động với viewport scroll */
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  /* Đảm bảo container không tràn ra ngoài */
  width: 100%;
  max-width: 100%;
  /* Không có height cố định */
  height: auto !important;
  max-height: none !important;
}

.table-placeholder {
  padding: 1.5rem;
  text-align: center;
  color: #626262;
  font-size: 0.95rem;
}

.tk-iccloud-table-wrapper {
  overflow-x: auto;
}

.tk-iccloud-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

.tk-iccloud-table th,
.tk-iccloud-table td {
  border: 1px solid #e0e0e0;
  padding: 0.5rem;
  text-align: left;
  vertical-align: top;
}

.tk-iccloud-table th {
  background: #f7f9fc;
  font-weight: 600;
}

.tk-iccloud-stt {
  width: 60px;
  text-align: center;
  font-weight: 600;
}

.tk-iccloud-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: relative;
}

.tk-iccloud-cell.bad-debt-cell {
  background: #ffebee;
}

.tk-iccloud-name {
  font-weight: 600;
  color: #2b3a4a;
  display: block;
}

.tk-iccloud-device-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: #54687a;
  margin-top: 0.15rem;
}

.tk-iccloud-device-label .device-icon {
  font-size: 0.8rem;
}

.tk-iccloud-toggle {
  border: none;
  background: #e3f2fd;
  color: #0a66c2;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 600;
  flex-shrink: 0;
}

.tk-iccloud-toggle:hover {
  background: #d0e7fb;
}

.tk-iccloud-popover {
  position: fixed;
  background: #fff;
  border: 1px solid #d0d7de;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.15);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  z-index: 999;
  width: 240px;
  font-size: 0.9rem;
  color: #2b3a4a;
}

.tk-iccloud-popover h4 {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
}

.tk-iccloud-popover p {
  margin: 0.15rem 0;
  font-size: 0.85rem;
  color: #4b5563;
}

#timKiemSearch .search-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}

.search-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  margin-bottom: 1rem;
}

.search-input-wrapper {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 160px;
  flex: 0 1 220px;
}

.search-input-wrapper select,
.search-input-wrapper input {
  padding: 0.5rem 0.75rem;
  border: 1px solid #d0d7de;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input-wrapper select:focus,
.search-input-wrapper input:focus {
  outline: none;
  border-color: #0a66c2;
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.15);
}

.search-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#timKiemSearch .filters {
  margin-bottom: 1rem;
}

@media (max-width: 992px) {
  .search-input-wrapper {
    flex: 1 1 100%;
  }
}

@media (max-width: 768px) {
  #timKiemSearch .search-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .search-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .search-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Scroll ngang wrapper - riêng biệt với table-container */
.table-scroll-wrapper {
  /* Chỉ scroll ngang ở đây */
  overflow-x: auto;
  overflow-y: visible !important;
  -webkit-overflow-scrolling: touch;
  /* Đảm bảo không có height cố định */
  height: auto !important;
  max-height: none !important;
  width: 100%;
  position: relative;
}

.table-wrapper {
  /* Không có overflow - sticky hoạt động với viewport scroll */
  overflow: visible !important;
  overflow-x: visible !important;
  overflow-y: visible !important;
  position: relative;
  /* Đảm bảo không có height cố định */
  max-height: none !important;
  height: auto !important;
  /* Cho phép wrapper theo chiều rộng container */
  width: 100%;
  min-width: 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 3000px;
  position: relative;
}

thead {
  /* Position will be controlled by JavaScript for viewport sticky */
  background: #f5f5f5 !important;
}

thead tr {
  background: #f5f5f5 !important;
}

th {
  background: #f5f5f5 !important;
  color: #333;
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-weight: 500;
  font-size: 0.85rem;
  border: 1px solid #e0e0e0;
  border-bottom: 1px solid #ddd;
  white-space: nowrap;
  /* Position will be controlled by JavaScript for viewport sticky */
  position: relative;
  z-index: 100;
}

th.sortable {
  cursor: pointer;
  user-select: none;
}

th.sortable .sort-icon {
  margin-left: 0.25rem;
  font-size: 0.75rem;
  color: #b0bec5;
  transition: color 0.2s ease;
}

th.sortable .sort-icon.active {
  color: #2980b9;
}

th:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 0;
}

th:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 0;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
  font-size: 0.85rem;
  white-space: nowrap;
}

td input[type="checkbox"],
td input[type="radio"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

tr:hover {
  background: #f5f5f5;
}

tr.bad-debt {
  background: #ffebee;
}

tr.bad-debt:hover {
  background: #ffcdd2;
}

tr.row-done {
  background: #e3f2fd;
}

tr.row-done:hover {
  background: #d0e7fb;
}


/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid #ddd;
  background: white;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s;
  outline: none;
}

.pagination button:hover:not(:disabled) {
  background: #f5f5f5;
  border-color: #2980b9;
}

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

.pagination .page-info {
  padding: 0 0.3rem;
  color: #666;
  font-size: 0.9rem;
}

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: #666;
}

.spinner {
  border: 3px solid #f3f3f3;
  border-top: 3px solid #2980b9;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 0.5rem 1rem;
    min-height: auto;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  
  .header-left {
    flex-direction: row;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
  }
  
  .header h1 {
    font-size: 1.2rem;
  }
  
  .year-selector-button {
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: 14px;
    width: 100%;
    min-width: auto;
  }
  
  .year-dropdown {
    min-width: 100%;
    width: 100%;
    left: 0;
    right: 0;
  }
  
  .data-refresh-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }
  
  .data-refresh-bar .btn {
    width: 100%;
    justify-content: center;
  }
  
  .code-thang-refresh .month-select-row {
    flex-direction: column;
    align-items: stretch;
  }
  .month-summary-text {
    white-space: normal;
    overflow: visible;
    text-overflow: initial;
    line-height: 1.6;
  }
  
  .month-options {
    grid-template-columns: 1fr;
  }
  .month-summary-text {
    grid-template-columns: repeat(auto-fill, minmax(60px, max-content));
  }

  .month-options {
    grid-template-columns: 1fr;
  }
  
  .code-thang-refresh .last-update-text {
    text-align: center;
    width: 100%;
    margin-left: 0;
  }
  
  .last-update-text {
    font-size: 0.85rem;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
    word-wrap: break-word;
  }
  
  .summary-box {
    gap: 1rem;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
  }
  
  .summary-item {
    gap: 0.25rem;
    font-size: 0.85rem;
  }
  
  .summary-label {
    font-size: 0.85rem;
  }
  
  .summary-value {
    font-size: 0.85rem;
  }
  
  .main-tabs {
    padding: 0 1rem;
    min-height: 45px;
    height: 45px;
  }
  
  th {
    top: 0; /* Header bảng sticky ở đầu trang */
  }
  
  .main-tab {
    padding: 0 1rem;
    height: 45px;
    border-bottom: 3px solid transparent;
  }
  
  .main-tab.active {
    border-bottom: 3px solid #2980b9;
  }
  
  .main-tab .tab-text {
    font-size: 0.85rem;
  }
  
  .main-tab .tab-icon {
    font-size: 1rem;
  }
  
  .sub-tabs {
    padding: 0 1rem;
    background: transparent;
  }
  
  .sub-tab {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    background: transparent !important;
  }
  
  .sub-tab.active {
    border-bottom: 3px solid #2980b9;
    background: transparent !important;
  }
  
  .content {
    padding: 1rem;
  }
  
  .filters {
    flex-direction: column;
    align-items: stretch;
  }
  
  .month-filter-group,
  .month-selector,
  .month-dropdown-button {
    width: 100%;
  }
  
  .month-dropdown {
    width: 100%;
    left: 0;
  }
  
  .filter-input {
    width: 100%;
    min-width: auto;
  }
}

/* Number formatting */
.number {
  text-align: right;
  font-family: 'Courier New', monospace;
}

/* Badge for status */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

.badge-warning {
  background: #fff3cd;
  color: #856404;
}

/* ============================================
   YEAR MANAGEMENT STYLES
   ============================================ */

.year-management-container {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  margin-bottom: 2rem;
  overflow: hidden;
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
}

.card-header h3,
.card-header h3 i[data-lucide] {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header h3 i[data-lucide] {
  width: 1.2rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #2c3e50;
}

.card-body {
  padding: 1.5rem;
  box-sizing: border-box;
  /* Cho phép scroll nếu cần, nhưng ưu tiên bảng tự fit */
  overflow-x: auto;
}

.template-info {
  margin-bottom: 1rem;
}

.template-info p {
  margin: 0.5rem 0;
  color: #555;
}

.template-info code {
  background: #f4f4f4;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
  word-break: break-all;
}

.template-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.year-table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  box-sizing: border-box;
  /* Đảm bảo wrapper không vượt quá container */
  min-width: 0;
}

.year-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  table-layout: fixed;
  box-sizing: border-box;
  /* Đảm bảo bảng không vượt quá wrapper */
  min-width: 0;
}

.year-table th {
  background: #f5f5f5;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #ddd;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.year-table th:nth-child(1) { width: 8%; }   /* Năm */
.year-table th:nth-child(2) { width: 35%; }  /* Sheet ID - nhiều text nhất */
.year-table th:nth-child(3) { width: 20%; }  /* Ngày Tạo */
.year-table th:nth-child(4) { width: 25%; }  /* Ghi Chú */
.year-table th:nth-child(5) { width: 12%; }  /* Thao Tác */

.year-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e0e0e0;
  font-size: 0.9rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  box-sizing: border-box;
  /* Cho phép nội dung xuống dòng, không ẩn */
  overflow: visible;
  max-width: 0;
}

/* Đảm bảo các cột có nội dung dài xuống dòng */
.year-table td:nth-child(3),
.year-table td:nth-child(4) {
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.4;
}

.year-table tr:hover {
  background: #f9f9f9;
}

.year-table tr.current-year-row {
  background: #fff9e6;
  border-left: 3px solid #f39c12;
}

.year-table tr.current-year-row:hover {
  background: #fff4d6;
}

.year-table code {
  background: #f4f4f4;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
  word-break: break-all;
  word-wrap: break-word;
  overflow-wrap: break-word;
  display: block;
  line-height: 1.4;
  white-space: normal;
  width: 100%;
  box-sizing: border-box;
}

.current-year-badge {
  display: inline-block;
  margin-left: 0.5rem;
  background: #27ae60;
  color: white;
  padding: 0.15rem 0.4rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.year-table a {
  color: #2980b9;
  text-decoration: none;
}

.year-table a:hover {
  text-decoration: underline;
}

.loading-small {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  color: #666;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid #e0e0e0;
  border-top-color: #2980b9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.5);
}

.modal-content {
  background-color: #fefefe;
  margin: 5% auto;
  padding: 0;
  border: none;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8f9fa;
  border-radius: 8px 8px 0 0;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.25rem;
  color: #2c3e50;
}

.close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.close:hover,
.close:focus {
  color: #000;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  background: #f8f9fa;
  border-radius: 0 0 8px 8px;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #333;
}

.form-group .required {
  color: #e74c3c;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #2980b9;
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: #666;
  font-size: 0.85rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  gap: 0.35rem; /* Giảm gap cho icon nhỏ hơn */
  min-height: 1.75rem; /* Đảm bảo chiều cao tối thiểu bằng nhau */
  box-sizing: border-box;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-success:hover {
  background: #229954;
}

.btn-warning {
  background: #f39c12;
  color: white;
}

.btn-warning:hover {
  background: #e67e22;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

/* Responsive */
@media (max-width: 768px) {
  .year-management-container {
    padding: 1rem;
  }
  
  .year-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .year-table {
    font-size: 0.8rem;
    min-width: 600px;
    table-layout: fixed;
  }
  
  .year-table th,
  .year-table td {
    padding: 0.5rem 0.3rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  
  .year-table code {
    font-size: 0.75rem;
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .card-header > div {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  
  .year-table {
    font-size: 0.8rem;
    table-layout: auto;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  .year-table thead,
  .year-table tbody,
  .year-table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }
  
  .year-table th,
  .year-table td {
    padding: 0.5rem 0.3rem;
    white-space: normal;
  }
  
  .year-table td.sheet-id-cell {
    word-break: break-all;
    white-space: normal;
  }
  
  .year-table code {
    font-size: 0.75rem;
  }
  
  .modal-content {
    width: 95%;
    margin: 10% auto;
  }
}

/* Column Tooltip */
.column-tooltip {
  position: fixed;
  background: #2c3e50;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.column-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #2c3e50;
}

/* Calculation Forms */
.calculation-container {
  padding: 1.5rem;
}

.calculation-form {
  margin-bottom: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: #2c3e50;
  font-size: 0.9rem;
}

.form-input {
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  transition: border-color 0.3s;
}

/* Auto-capitalize first letter for specific inputs in Bảng Tính tab only */
#muaMay_HO_TEN,
#muaMay_MAY,
#vayTien_HO_TEN,
#vayTien_MAY {
  text-transform: capitalize;
}

.form-input:focus {
  outline: none;
  border-color: #2980b9;
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.1);
}

/* Vay Tiền - 2 Column Layout */
.vay-tien-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 100%;
}

.vay-tien-input-section,
.vay-tien-result-section {
  display: flex;
  flex-direction: column;
}

.vay-tien-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.vay-tien-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.vay-tien-calculated-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e9ecef;
}

.vay-tien-calculated-full-width {
  width: 100%;
}

.vay-tien-calculated-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 768px) {
  .vay-tien-calculated-row {
    grid-template-columns: 1fr;
  }
}

.vay-tien-date-input-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  position: relative;
}

.vay-tien-date-text {
  font-family: 'Courier New', monospace;
  text-align: center;
  flex: 1;
  min-width: 120px;
  font-size: 0.9rem;
  padding: 0.5rem 0.5rem;
}

.vay-tien-date-picker {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
  pointer-events: none;
}

.vay-tien-date-today,
.vay-tien-date-reset {
  white-space: nowrap;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-width: auto;
  flex-shrink: 0;
  line-height: 1.2;
  height: auto;
}

.vay-tien-form .form-group {
  margin-bottom: 0;
}

.vay-tien-input {
  width: 100%;
}

.vay-tien-calculated {
  width: 100%;
  background-color: #f5f5f5;
  cursor: not-allowed;
  font-weight: 500;
  color: #2980b9;
}

.vay-tien-result-content {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.vay-tien-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
}

.vay-tien-result-header-label {
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  flex: 1;
}

.vay-tien-result-header-value {
  text-align: right;
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  min-width: 120px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

.vay-tien-date-display {
  font-family: 'Courier New', monospace;
  color: #2c3e50;
}

.vay-tien-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e9ecef;
  min-height: 50px;
}

.vay-tien-result-item:last-of-type {
  border-bottom: none;
}

.vay-tien-result-item-highlight {
  background: #fff3e0;
}

.vay-tien-result-item-highlight .vay-tien-result-item-value {
  color: #ff9800;
  font-weight: 700;
  font-size: 1.2rem;
}

.vay-tien-result-item-label {
  font-weight: 500;
  color: #2c3e50;
  font-size: 0.95rem;
  flex: 1;
}

.vay-tien-result-item-value {
  text-align: right;
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  min-width: 150px;
}

.vay-tien-result-footer {
  padding: 1rem 1.5rem;
  border-top: 2px solid #e9ecef;
  background: #f8f9fa;
  text-align: center;
}

.vay-tien-result-footer-text {
  font-weight: 500;
  color: #2c3e50;
  font-size: 0.95rem;
}

.info-note {
  line-height: 1.5;
}

@media (max-width: 1200px) {
  .vay-tien-container {
    grid-template-columns: 1fr;
  }
}

/* Mua Máy - 2 Column Layout (tương tự Vay Tiền) */
.mua-may-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 100%;
}

.mua-may-input-section,
.mua-may-result-section {
  display: flex;
  flex-direction: column;
}

.mua-may-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mua-may-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.mua-may-calculated-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 2px solid #e9ecef;
}

.mua-may-additional-info-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

.mua-may-additional-info-title {
  font-size: 0.95rem !important;
  font-weight: 700 !important;
  color: #555 !important;
  margin-bottom: 1.5rem !important;
  padding-bottom: 0.5rem;
  /* border-bottom: 1px solid #f0f0f0; */
  display: block;
}

.mua-may-calculated-full-width {
  width: 100%;
}

.mua-may-calculated {
  width: 100%;
  background-color: #f5f5f5;
  cursor: not-allowed;
  font-weight: 500;
  color: #2980b9;
}

/* Styles for Mua Máy result display (matching image) */
.mua-may-result-content {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.mua-may-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  font-weight: 600;
}

.mua-may-result-header-label {
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  flex: 1;
}

.mua-may-result-header-value {
  text-align: right;
  font-weight: 600;
  color: #2c3e50;
  font-size: 1rem;
  min-width: 120px;
}

.mua-may-date-display {
  font-family: 'Courier New', monospace;
  color: #2c3e50;
}

.mua-may-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e9ecef;
  min-height: 50px;
}

.mua-may-result-item:last-of-type {
  border-bottom: none;
}

.mua-may-result-item-label {
  font-weight: 500;
  color: #2c3e50;
  font-size: 0.95rem;
  flex: 1;
}

.mua-may-result-item-value {
  text-align: right;
  font-weight: 600;
  color: #2c3e50; /* Black text (changed from red) */
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  min-width: 150px;
}

.mua-may-result-item-value.calculated {
  color: #2c3e50; /* Black for calculated values */
}


.mua-may-device-name {
  font-weight: 600;
  color: #2c3e50;
}

.mua-may-result-item-highlight {
  background: #fff3e0; /* Light orange background */
}

.mua-may-result-item-highlight .mua-may-result-item-label {
  font-weight: 700;
}

.mua-may-result-item-highlight .mua-may-result-item-value {
  color: #ff9800; /* Orange text for highlighted value */
  font-weight: 700;
  font-size: 1.2rem;
}

.mua-may-result-footer {
  padding: 1rem 1.5rem;
  border-top: 2px solid #e9ecef;
  background: #f8f9fa;
  text-align: center;
}

.mua-may-result-footer-text {
  font-weight: 500;
  color: #2c3e50;
  font-size: 0.95rem;
}

@media (max-width: 1200px) {
  .mua-may-container {
    grid-template-columns: 1fr;
  }
  
  .mua-may-result-row-3col {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #eee;
}

.form-actions .btn {
  min-width: 120px;
}

.calculation-results {
  margin-top: 2rem;
  padding: 1.5rem;
  background: #f8f9fa;
  border-radius: 8px;
  border: 1px solid #e9ecef;
}

.calculation-results h4 {
  margin: 0 0 1rem 0;
  color: #2c3e50;
  font-size: 1.1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.result-item {
  background: white;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.result-label {
  font-size: 0.85rem;
  color: #666;
  margin-bottom: 0.25rem;
}

.result-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: #2c3e50;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn {
    width: 100%;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
}

/* Modal: Tính Tất Toán */
.modal-tat-toan {
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.modal-tat-toan-content {
  background-color: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 700px;
  width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  margin: 2rem auto;
  position: relative;
  overflow-x: hidden;
}

.modal-tat-toan-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  background-color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 8px 8px 0 0;
}

.modal-tat-toan-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #2b3a4a;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-tat-toan-header h2 i[data-lucide] {
  width: 1.3rem;
  height: 1.3rem;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.modal-tat-toan-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.modal-tat-toan-close:hover {
  background-color: #f0f0f0;
  color: #333;
}

.modal-tat-toan-body {
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.modal-tat-toan-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e9ecef;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.tat-toan-table {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  border-collapse: collapse;
  word-wrap: break-word;
  box-sizing: border-box;
}

.tat-toan-table tr {
  border-bottom: 1px solid #e9ecef;
}

.tat-toan-table tr:last-child {
  border-bottom: none;
}

.tat-toan-table td {
  padding: 0.75rem 0.5rem;
  vertical-align: top;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  hyphens: auto;
  box-sizing: border-box;
  white-space: normal;
  overflow: visible;
}

.tat-toan-table .tat-toan-label {
  font-weight: 600;
  color: #555;
  min-width: 150px;
  max-width: 40%;
  width: auto;
  padding-right: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
}

.tat-toan-table .tat-toan-value {
  color: #2b3a4a;
  font-weight: 500;
  text-align: left;
  min-width: 100px;
  width: auto;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
}

.tat-toan-table .tat-toan-value > div {
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  overflow: visible;
  max-width: 100%;
}

/* Mobile responsive cho modal Tính Tất Toán */
@media (max-width: 768px) {
  .modal-tat-toan-content {
    width: 95%;
    max-width: 95%;
    margin: 1rem auto;
    max-height: 95vh;
  }
  
  .modal-tat-toan-header {
    padding: 0.75rem 1rem;
  }
  
  .modal-tat-toan-header h2 {
    font-size: 1rem;
    line-height: 1.4;
  }
  
  .modal-tat-toan-body {
    padding: 1rem;
  }
  
  .tat-toan-table {
    display: table;
    width: 100%;
    table-layout: auto;
  }
  
  .tat-toan-table td {
    padding: 0.5rem 0.25rem;
    display: table-cell;
    width: auto;
  }
  
  .tat-toan-table .tat-toan-label {
    min-width: 0;
    max-width: none;
    width: auto;
    padding-right: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
  }
  
  .tat-toan-table .tat-toan-value {
    min-width: 0;
    width: auto;
    font-size: 0.9rem;
    line-height: 1.4;
  }
  
  .tat-toan-input {
    font-size: 0.9rem !important;
    padding: 0.4rem !important;
  }
}

@media (max-width: 480px) {
  .modal-tat-toan-content {
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    max-height: 100vh;
  }
  
  .modal-tat-toan-header {
    padding: 0.75rem;
    border-radius: 0;
  }
  
  .modal-tat-toan-body {
    padding: 0.75rem;
  }
  
  .tat-toan-table .tat-toan-label {
    font-size: 0.85rem;
    padding-right: 0.5rem;
  }
  
  .tat-toan-table .tat-toan-value {
    font-size: 0.85rem;
  }
  
  .tat-toan-table .tat-toan-value div {
    font-size: 0.8rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: normal;
  }
  
  .tat-toan-table .tat-toan-value input {
    font-size: 0.85rem !important;
    padding: 0.35rem !important;
  }
}

/* Modal Sửa Hồ Sơ */
.sua-ho-so-modal-content {
  max-width: 1200px !important;
  width: 95% !important;
}

.sua-ho-so-form-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.sua-ho-so-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sua-ho-so-label {
  font-weight: 600;
  color: #555;
  font-size: 0.9rem;
}

.sua-ho-so-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sua-ho-so-input:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.sua-ho-so-input:read-only {
  background-color: #f5f5f5;
  cursor: not-allowed;
  color: #666;
}

.sua-ho-so-input.sua-ho-so-calculated {
  background-color: #f9f9f9;
  font-weight: 500;
}

.sua-ho-so-input.sua-ho-so-number {
  text-align: right;
}

.sua-ho-so-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
  margin-top: 1rem;
}

/* Mobile responsive cho modal Sửa Hồ Sơ */
@media (max-width: 768px) {
  .sua-ho-so-form-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
  }
  
  .sua-ho-so-modal-content {
    max-width: 95% !important;
    width: 95% !important;
  }
  
  .sua-ho-so-actions {
    flex-direction: column;
  }
  
  .sua-ho-so-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .sua-ho-so-modal-content {
    width: 100% !important;
    max-width: 100% !important;
  }
  
  .sua-ho-so-form-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  .sua-ho-so-form-group {
    gap: 0.4rem;
  }
  
  .sua-ho-so-label {
    font-size: 0.85rem;
  }
  
  .sua-ho-so-input {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

/* Modal Đóng Thêm */
.dong-them-modal-content {
  max-width: 800px !important;
  width: 90% !important;
}

/* Reference info section - dạng nhãn (badge) với border */
.dong-them-ref-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}



.dong-them-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  background-color: #fafafa;
  font-size: 0.8rem;
}

.dong-them-ref-label {
  color: #666;
  font-weight: 500;
}

.dong-them-ref-value {
  color: #333;
  font-weight: 600;
}

/* Pending section */
.dong-them-pending-section {
  margin-bottom: 1.5rem;
}

.dong-them-pending-list {
  margin-top: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background-color: #fafafa;
  min-height: 50px;
}

.dong-them-pending-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  gap: 1rem;
}

.dong-them-pending-item:last-child {
  border-bottom: none;
}

.dong-them-pending-item-amount {
  min-width: 150px;
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

.dong-them-pending-item-amount.positive {
  color: #27ae60;
}

.dong-them-pending-item-amount.negative {
  color: #e74c3c;
}

.dong-them-pending-item-date {
  flex: 1;
  color: #666;
  font-size: 0.9rem;
}

.dong-them-pending-item-actions {
  display: flex;
  gap: 0.5rem;
}

.dong-them-pending-empty {
  padding: 2rem;
  text-align: center;
  color: #999;
  font-style: italic;
}


.dong-them-new-payment {
  margin-bottom: 1.5rem;
}

.dong-them-label {
  display: block;
  font-weight: 600;
  color: #555;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.dong-them-input-group {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.dong-them-input-number {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  text-align: right;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dong-them-input-number:focus {
  outline: none;
  border-color: #4a90e2;
  box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.dong-them-input-number.empty-warning {
  border-color: #ff9faa;
  box-shadow: 0 0 0 3px rgba(255, 159, 170, 0.2);
  animation: fadeBorder 1.5s ease-out forwards;
}

@keyframes fadeBorder {
  0% {
    border-color: #ff9faa;
    box-shadow: 0 0 0 3px rgba(255, 159, 170, 0.2);
  }
  100% {
    border-color: #ddd;
    box-shadow: none;
  }
}

/* Toast Notification Styles */
.toast-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(39, 174, 96, 0.4);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 500px;
  pointer-events: auto;
  animation: fadeInCenter 0.3s ease-out, fadeOutCenter 0.3s ease-in 1.7s forwards;
  font-size: 0.95rem;
  line-height: 1.5;
}

.toast i {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

@keyframes fadeInCenter {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOutCenter {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.9);
  }
}

.dong-them-history {
  margin-bottom: 1.5rem;
}

.dong-them-history-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background-color: #f9f9f9;
}

.dong-them-history-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  transition: background-color 0.2s;
}

.dong-them-history-item:last-child {
  border-bottom: none;
}

.dong-them-history-item:hover {
  background-color: #f0f0f0;
}

.dong-them-history-item.editing {
  background-color: #e8f4fd;
  border: 2px solid #4a90e2;
}

.dong-them-history-item-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.dong-them-history-item-amount {
  min-width: 150px;
  font-weight: 600;
  color: #333;
  font-size: 1rem;
}

.dong-them-history-item-amount.positive {
  color: #27ae60;
}

.dong-them-history-item-amount.negative {
  color: #e74c3c;
}

.dong-them-history-item-date {
  flex: 1;
  color: #666;
  font-size: 0.9rem;
}

.dong-them-history-item-actions {
  display: flex;
  gap: 0.5rem;
}

.dong-them-history-item-edit-input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #4a90e2;
  border-radius: 4px;
  font-size: 0.95rem;
  text-align: right;
}

.dong-them-history-item-edit-date {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #4a90e2;
  border-radius: 4px;
  font-size: 0.95rem;
}

.dong-them-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
  margin-top: 1rem;
}

.dong-them-empty {
  padding: 2rem;
  text-align: center;
  color: #999;
  font-style: italic;
}

/* Mobile responsive cho modal Đóng Thêm */
@media (max-width: 768px) {
  .dong-them-modal-content {
    max-width: 95% !important;
    width: 95% !important;
  }
  
  .dong-them-input-group {
    flex-direction: column;
    align-items: stretch;
  }
  
  .dong-them-input-group .btn {
    width: 100%;
  }
  
  .dong-them-ref-info {
    gap: 0.4rem;
  }
  
  .dong-them-ref-badge {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }
  
  .dong-them-ref-label {
    font-size: 0.75rem;
  }
  
  .dong-them-ref-value {
    font-size: 0.75rem;
  }
  
  .dong-them-history-item-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .dong-them-history-item-amount {
    min-width: auto;
    width: 100%;
  }
  
  .dong-them-actions {
    flex-direction: column;
  }
  
  .dong-them-actions .btn {
    width: 100%;
  }
}

/* ============================================
   LOGIN MODAL
   ============================================ */

.login-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.login-modal-content {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 1.5rem;
  border-radius: 8px 8px 0 0;
  text-align: center;
}

.login-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.login-modal-header i {
  margin-right: 0.5rem;
}

.login-modal-body {
  padding: 2rem;
}

.login-form-group {
  margin-bottom: 1.5rem;
}

.login-form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #333;
  font-weight: 500;
  font-size: 0.9rem;
}

.login-form-group label i {
  margin-right: 0.5rem;
  color: #667eea;
}

.login-input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.3s;
  box-sizing: border-box;
}

.login-input:focus {
  outline: none;
  border-color: #667eea;
}

.login-error {
  background: #fee;
  color: #c33;
  padding: 0.75rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border-left: 4px solid #c33;
  font-size: 0.9rem;
}

.login-button {
  width: 100%;
  padding: 0.75rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.login-button:active {
  transform: translateY(0);
}

.login-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.login-button i {
  margin-right: 0.5rem;
}

