/* ══════════════════════════════════════════════════════════════════
   EHC GROUP – Main Stylesheet
   Design: Modern dark-glass with blue/navy palette
   Font: Inter (Google Fonts)
══════════════════════════════════════════════════════════════════ */

/* ── Reset & Root ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #60a5fa;
  --teal:          #0d9488;
  --teal-dark:     #0f766e;
  --success:       #16a34a;
  --danger:        #dc2626;
  --warning:       #d97706;

  --header-h:      54px;
  --toolbar-h:     52px;
  --header-bg:     #0f172a;
  --toolbar-bg:    #1e293b;
  --body-bg:       #f0f4f8;
  --card-bg:       #ffffff;
  --border-color:  #e2e8f0;

  --text-main:     #1e293b;
  --text-muted:    #64748b;
  --text-inverse:  #f8fafc;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.14);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --font: 'Inter', system-ui, sans-serif;
  --fs-xs:  11px;
  --fs-sm:  12px;
  --fs-md:  13px;
  --fs-base: 14px;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--text-main);
  background: var(--body-bg);
  overscroll-behavior: none;
}

/* ── Loading Screen ────────────────────────────────────────────── */
#loading-screen {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  backdrop-filter: blur(4px);
  gap: 20px;
}

/* Loader ring */
.loader-ring {
  display: inline-block;
  position: relative;
  width: 64px;
  height: 64px;
}
.loader-ring div {
  box-sizing: border-box;
  display: block;
  position: absolute;
  width: 52px;
  height: 52px;
  margin: 6px;
  border: 5px solid transparent;
  border-radius: 50%;
  animation: loader-spin 1.2s cubic-bezier(0.5,0,0.5,1) infinite;
}
.loader-ring div:nth-child(1) { border-top-color: var(--primary-light); animation-delay: -0.45s; }
.loader-ring div:nth-child(2) { border-top-color: #818cf8; animation-delay: -0.3s; }
.loader-ring div:nth-child(3) { border-top-color: #38bdf8; animation-delay: -0.15s; }
.loader-ring div:nth-child(4) { border-top-color: #34d399; }

@keyframes loader-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

#loading-percentage {
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.7);
}

/* ── App Header ────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}
.app-logo img {
  height: 30px;
  width: auto;
  object-fit: contain;
  filter: brightness(0) invert(1);
}
.logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.logo-ehc   { color: #f87171; }
.logo-group { color: #fbbf24; }

.header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  flex-shrink: 0;
}

.tencoso {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header Right Nav */
.header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-nav-item { position: relative; }

.nav-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

.nav-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px; height: 16px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.nav-profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: background 0.2s;
  font-size: var(--fs-sm);
  font-family: var(--font);
}
.nav-profile-btn:hover { background: rgba(255,255,255,0.12); }

.avatar-circle {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
}

.profile-name { font-weight: 500; max-width: 120px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }

.chev-icon { font-size: 10px; color: rgba(255,255,255,0.4); }

/* Dropdown menus */
.app-dropdown {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 200px;
  background: #fff;
}

.notifications-dropdown { min-width: 300px; }

.profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 8px;
}
.profile-avatar-lg {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.profile-name-lg { font-weight: 700; font-size: 13px; color: var(--text-main); }
.profile-role    { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

.app-divider { border: none; border-top: 1px solid var(--border-color); margin: 4px 0; }

.app-dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  font-size: var(--fs-sm);
  font-family: var(--font);
  color: var(--text-main);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  text-align: left;
}
.app-dropdown-item:hover { background: #f1f5f9; }
.app-dropdown-item.danger { color: var(--danger); }
.app-dropdown-item.danger:hover { background: #fef2f2; }
.app-dropdown-item i { font-size: 14px; width: 16px; flex-shrink: 0; }

/* ── Toolbar ───────────────────────────────────────────────────── */
.app-toolbar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--toolbar-h);
  background: var(--toolbar-bg);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.kyhieu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 82px; height: 32px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65);
  font-size: 15px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.kyhieu-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }

.page-title-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.page-title-link:hover { filter: brightness(1.1); color: #fff; }

.toolbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
}

.toolbar-filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: var(--fs-xs);
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
}

.toolbar-dates {
  display: flex;
  align-items: center;
  gap: 4px;
}

.date-arrow { color: rgba(255,255,255,0.35); font-size: 13px; }

/* App Select */
.app-select {
  height: 30px;
  padding: 0 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.85);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.app-select:focus { border-color: var(--primary-light); background: rgba(255,255,255,0.12); }
.app-select option { background: #1e293b; color: #fff; }

/* App Input (toolbar) */
.app-input {
  height: 30px;
  padding: 0 32px 0 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.9);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  width: 130px;
  transition: border-color 0.2s, background 0.2s;
}
.app-input:focus { border-color: var(--primary-light); background: rgba(255,255,255,0.12); }
.app-input::placeholder { color: rgba(255,255,255,0.3); }

/* Datetime container */
.datetime-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.dt-btn {
  position: absolute;
  right: 4px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  font-size: 13px;
  padding: 2px;
  transition: color 0.2s;
  margin-right: 0;
}
.dt-btn:hover { color: rgba(255,255,255,0.85); }

/* App Button */
.app-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
  text-decoration: none;
}
.app-btn:hover:not(:disabled) { filter: brightness(1.1); }
.app-btn:active:not(:disabled) { transform: scale(0.97); }
.app-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.app-btn.primary { background: var(--primary); color: #fff; }
.app-btn.success { background: var(--success); color: #fff; }
.app-btn.danger  { background: var(--danger);  color: #fff; }
.app-btn.teal    { background: var(--teal);     color: #fff; }
.app-btn.secondary { background: #475569; color: #fff; }
.app-btn.outline-light {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
}
.app-btn.outline-light:hover:not(:disabled) { background: rgba(255,255,255,0.2); filter: none; }

.app-btn.sm { height: 28px; padding: 0 10px; font-size: var(--fs-xs); }

/* Toolbar Right */
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Search box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 8px;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  pointer-events: none;
}
.search-input {
  height: 30px;
  padding: 0 28px 0 26px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.9);
  font-family: var(--font);
  font-size: var(--fs-sm);
  outline: none;
  width: 160px;
  transition: border-color 0.2s, background 0.2s, width 0.3s;
}
.search-input:focus {
  border-color: var(--primary-light);
  background: rgba(255,255,255,0.12);
  width: 200px;
}
.search-input::placeholder { color: rgba(255,255,255,0.3); }
.search-btn {
  position: absolute;
  right: 2px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  margin-right: 0;
  padding: 2px;
  transition: color 0.2s;
}
.search-btn:hover { color: #fff; }

/* ── App Content (below header+toolbar) ────────────────────────── */
.app-content {
  margin-top: calc(var(--header-h) + var(--toolbar-h));
  padding: 12px;
  height: calc(100vh - var(--header-h) - var(--toolbar-h));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Table Card ────────────────────────────────────────────────── */
.table-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border-color);
}

/* Main Table Wrapper */
.table-wrapper {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

/* Detail / XML3 Table Wrapper */
.table-wrapper-xml3 {
  width: 100%;
  overflow: auto;
  height: 62vh;
}

/* ── App Table ─────────────────────────────────────────────────── */
.app-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.app-table thead th {
  background: #1e3a5f;
  color: #e2e8f0;
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  padding: 9px 8px;
  white-space: nowrap;
  border-bottom: 2px solid #2d5a96;
  position: sticky;
  top: 0;
  z-index: 2;
  vertical-align: middle;
}

.app-table.teal-table thead th {
  background: #0d4a4a;
  border-bottom-color: #0f766e;
}

.app-table tbody tr {
  transition: background 0.12s;
}
.app-table tbody tr:nth-child(odd)  { background: #f8fafc; }
.app-table tbody tr:nth-child(even) { background: #ffffff; }
.app-table tbody tr:hover { background: #eff6ff; }

.app-table td {
  padding: 7px 8px;
  border-bottom: 1px solid #edf2f7;
  vertical-align: middle;
  color: var(--text-main);
  font-size: var(--fs-sm);
}

/* Minimum widths for specific columns */
.app-table .table-wrapper .app-table { min-width: 2100px; }
.table-wrapper-xml3 .app-table       { min-width: 2000px; }

/* ── Cột cố định trong bảng hóa đơn chính ──────────────────────── */
/* STT */
#danhmuc-table th:nth-child(1),
#danhmuc-table td:nth-child(1) { width: 40px; min-width: 40px; text-align: center; }
/* Checkbox */
#danhmuc-table th:nth-child(2),
#danhmuc-table td:nth-child(2) { width: 44px; min-width: 44px; text-align: center; }
/* Action */
#danhmuc-table th:nth-child(3),
#danhmuc-table td:nth-child(3) { width: 38px; min-width: 38px; text-align: center; }
/* Tên bệnh nhân (col 10) */
#danhmuc-table th:nth-child(10),
#danhmuc-table td:nth-child(10) { min-width: 160px; }
/* Địa chỉ (col 15) */
#danhmuc-table th:nth-child(15),
#danhmuc-table td:nth-child(15) { min-width: 220px; max-width: 320px; white-space: normal; word-break: break-word; }
/* Khoa điều trị (col 17) */
#danhmuc-table th:nth-child(17),
#danhmuc-table td:nth-child(17) { min-width: 140px; }
/* Phòng điều trị (col 18) */
#danhmuc-table th:nth-child(18),
#danhmuc-table td:nth-child(18) { min-width: 130px; }
/* Hoá đơn (col 7) */
#danhmuc-table th:nth-child(7),
#danhmuc-table td:nth-child(7) { min-width: 180px; }
/* Tổng tiền (cols 23-26) */
#danhmuc-table th:nth-child(23),
#danhmuc-table td:nth-child(23),
#danhmuc-table th:nth-child(24),
#danhmuc-table td:nth-child(24),
#danhmuc-table th:nth-child(25),
#danhmuc-table td:nth-child(25),
#danhmuc-table th:nth-child(26),
#danhmuc-table td:nth-child(26) { min-width: 120px; text-align: right; white-space: nowrap; }


/* ── Action Buttons in table rows ──────────────────────────────── */
.xuat, .xem, .day, .taive, .lichsu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 1px 2px;
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: #fff !important;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1;
  white-space: nowrap;
}
.xuat   { background: #2563eb; }
.xem    { background: #d97706; }
.day    { background: #16a34a; }
.lichsu { background: #1e40af; }
.taive  { background: #dc2626; }

.xuat:hover   { background: #fff; color: #2563eb !important; border-color: #2563eb; }
.xem:hover    { background: #fff; color: #d97706 !important; border-color: #d97706; }
.day:hover    { background: #fff; color: #16a34a !important; border-color: #16a34a; }
.lichsu:hover { background: #fff; color: #1e40af !important; border-color: #1e40af; }
.taive:hover  { background: #fff; color: #dc2626 !important; border-color: #dc2626; }

/* ── Table Footer (pagination) ─────────────────────────────────── */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  flex-shrink: 0;
  min-height: 44px;
}

.table-info {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 500;
}

#pagination {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0;
  margin: 0;
}
#pagination button {
  height: 28px;
  min-width: 28px;
  padding: 0 6px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
  color: var(--text-main);
  font-size: var(--fs-xs);
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  margin: 0;
}
#pagination button:hover { background: #e0f2fe; border-color: var(--primary-light); }
#pagination button.active,
#pagination button.active-page {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

/* ── Switch/Toggle ─────────────────────────────────────────────── */
.switch-btn { padding-top: 3px; display: inline-block; }
.switch-btn span {
  display: flex;
  align-items: center;
  width: 44px; height: 22px;
  border-radius: 11px;
  background: #cbd5e1;
  transition: background 0.3s;
  padding: 0 2px;
  position: relative;
  cursor: pointer;
}
.switch-btn span::before {
  content: '';
  display: block;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  left: 2px;
  transition: left 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch-btn input { display: none; }
.switch-btn input:checked ~ span { background: #38bdf8; }
.switch-btn input:checked ~ span::before { left: 24px; }

/* ── Status badges ─────────────────────────────────────────────── */
.thanhcong { color: var(--success); font-weight: 600; }
.thatbai   { color: var(--danger);  font-weight: 600; }
.dacheck   { color: var(--success); font-weight: 700; font-size: 18px; }

/* ── Modal Overlays ────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9000;
  backdrop-filter: blur(3px);
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

/* Modal Box */
.app-modal {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: 90%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.app-modal.medium { max-width: 680px; }
.app-modal.wide   { max-width: 1800px; }

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%, -48%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* Modal Head */
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border-color);
  background: #fff;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.modal-title i { color: var(--primary); font-size: 18px; }

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
  margin: 0;
  flex-shrink: 0;
}
.modal-close-btn:hover { background: #fee2e2; border-color: #fca5a5; color: var(--danger); }

/* Modal Body */
.modal-body-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

/* Teal bar in chi tiết modal */
.modal-actions-bar.teal-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--teal-dark);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

/* ── Section labels inside modals ──────────────────────────────── */
.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding: 0 0 8px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 12px;
}
.section-label i { color: var(--primary); }

/* ── Forms inside modals ───────────────────────────────────────── */
.app-form { display: flex; flex-direction: column; gap: 10px; }

.form-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.form-lbl {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  min-width: 140px;
  padding-top: 6px;
  text-align: right;
  flex-shrink: 0;
}
.app-textarea {
  flex: 1;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: var(--fs-sm);
  color: var(--text-main);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.app-textarea:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}

/* ── Notification items ────────────────────────────────────────── */
.notification-item {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: var(--fs-sm);
}
.notification-item:last-child { border-bottom: none; }
.dropdown-header {
  padding: 8px 10px 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

/* ── Media queries ─────────────────────────────────────────────── */
@media (max-width: 1400px) {
  :root {
    --header-h: 48px;
    --toolbar-h: 46px;
  }
  .page-title-link { font-size: 12px; padding: 4px 10px; }
  .app-table thead th { font-size: 10px; padding: 7px 6px; }
  .app-table td        { padding: 5px 6px; font-size: 11px; }
  .search-input { width: 130px; }
  .search-input:focus { width: 160px; }
  .toolbar-center { gap: 6px; }
  .modal-head { padding: 10px 14px 8px; }
  .modal-title { font-size: 14px; }
}

@media (max-width: 1024px) {
  .toolbar-center { display: none; }
  .search-input { width: 120px; }
}

/* ── Misc legacy compatibility ─────────────────────────────────── */
.col-pageinfo table { border: 1px solid var(--border-color); }
.col-pageinfo td, .col-pageinfo th { border: 1px solid var(--border-color); font-size: var(--fs-xs); }

/* jQuery UI datepicker overrides */
.ui-datepicker { max-height: 320px; overflow-y: auto; }
.ui-datepicker-calendar { max-height: 220px; overflow-y: auto; }
.ui-timepicker-div .ui-timepicker-hour,
.ui-timepicker-div .ui-timepicker-minute,
.ui-timepicker-div .ui-timepicker-second { max-height: 150px; overflow-y: auto; }

/* Toastr override */
#toast-container > div { border-radius: var(--radius-md) !important; font-family: var(--font) !important; }

/* No-outline util */
.no-outline:focus { outline: none; box-shadow: none; }

/* Global button spacing reset */
button { margin: 0; }

/* ── Toggle Action Dropdown (cell #3 trong bảng) ───────────────── */
.toggle-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Nút mở menu */
.toggle-container > button#btnbelow,
.toggle-container > [id^="btnbelow"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  border: none;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  flex-shrink: 0;
  margin: 0;
}
.toggle-container > button:hover {
  background: var(--primary-dark);
  transform: scale(1.08);
}

/* Popup menu */
.toggleDiv {
  display: none;
  position: fixed;        /* fixed để không bị cắt bởi overflow:hidden của table */
  z-index: 8000;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  padding: 4px;
  min-width: 160px;
  animation: dropIn 0.18s cubic-bezier(0.16,1,0.3,1);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Bên trong menu: dạng cột dọc */
.togglediv-inside {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Mỗi item trong menu */
.togglediv-inside button,
.togglediv-inside .xem,
.togglediv-inside .day,
.togglediv-inside .taive,
.togglediv-inside .lichsu,
.togglediv-inside .xuat {
  display: flex !important;
  align-items: center;
  width: 100%;
  padding: 7px 10px !important;
  border-radius: 6px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  text-align: left;
  justify-content: flex-start !important;
  border: none !important;
  margin: 0 !important;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s !important;
  color: #fff !important;
  border-bottom-left-radius: 6px !important;
}

/* Giữ màu background gốc cho từng loại button khi ở trong menu */
.togglediv-inside .xem   { background: #d97706 !important; }
.togglediv-inside .day   { background: #16a34a !important; }
.togglediv-inside .taive { background: #dc2626 !important; }
.togglediv-inside .lichsu{ background: #1e40af !important; }
.togglediv-inside .xuat  { background: #2563eb !important; }

.togglediv-inside button:hover { filter: brightness(1.12) !important; }

/* ── Dòng tổng cuối bảng ────────────────────────────────────────── */
.total-summary-row {
  background: linear-gradient(90deg, #eff6ff, #f0fdf4) !important;
  border-top: 2px solid var(--border-color);
}
.total-summary-row td {
  font-weight: 700;
  color: var(--text-main);
  font-size: 11px;
}

/* ── Inline tax edit trong bảng chi tiết ────────────────────────── */
.app-table .form-control-sm {
  height: 26px;
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: #f8fafc;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.app-table .form-control-sm:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(96,165,250,0.2);
}
