/* =====================================================================
   Components + Bootstrap 5.3 overrides. Chỉ dùng token. Không !important.
   ===================================================================== */

/* ---------- Buttons ---------- */
.btn {
  font-weight: 500; border-radius: var(--r-md); font-size: var(--fs-md); line-height: 1.4;
  --bs-btn-padding-y: .34rem; --bs-btn-padding-x: .75rem; --bs-btn-font-size: var(--fs-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn-sm { --bs-btn-padding-y: .2rem; --bs-btn-padding-x: .55rem; --bs-btn-font-size: var(--fs-sm); font-size: var(--fs-sm); }
.btn-lg { --bs-btn-padding-y: .5rem; --bs-btn-padding-x: 1rem; --bs-btn-font-size: var(--fs-lg); font-size: var(--fs-lg); }
.btn i { font-size: 1.05em; line-height: 1; }
.btn-primary {
  --bs-btn-bg: var(--c-primary); --bs-btn-border-color: var(--c-primary);
  --bs-btn-hover-bg: var(--c-primary-hover); --bs-btn-hover-border-color: var(--c-primary-hover);
  --bs-btn-active-bg: var(--c-primary-hover); --bs-btn-active-border-color: var(--c-primary-hover);
  --bs-btn-disabled-bg: var(--c-primary); --bs-btn-disabled-border-color: var(--c-primary);
  --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-disabled-color: #fff;
  background-image: var(--btn-primary-grad);
  box-shadow: var(--sh-inset), 0 1px 2px rgba(var(--c-primary-rgb), .3);
}
.btn-primary:hover { box-shadow: var(--sh-inset), 0 2px 6px rgba(var(--c-primary-rgb), .35); }
.btn-outline-secondary, .btn-outline-primary, .btn-outline-danger { box-shadow: var(--sh-1); }
.btn-outline-primary {
  --bs-btn-color: var(--c-primary); --bs-btn-border-color: var(--sf-border-strong);
  --bs-btn-hover-bg: var(--c-primary-soft); --bs-btn-hover-color: var(--c-primary); --bs-btn-hover-border-color: var(--c-primary);
  --bs-btn-active-bg: var(--c-primary-soft); --bs-btn-active-color: var(--c-primary); --bs-btn-active-border-color: var(--c-primary);
}
.btn-outline-secondary {
  --bs-btn-color: var(--tx-2); --bs-btn-border-color: var(--sf-border-strong); --bs-btn-bg: var(--sf-surface);
  --bs-btn-hover-bg: var(--sf-surface-2); --bs-btn-hover-color: var(--tx-1); --bs-btn-hover-border-color: var(--sf-border-strong);
  --bs-btn-active-bg: var(--sf-surface-3); --bs-btn-active-color: var(--tx-1); --bs-btn-active-border-color: var(--sf-border-strong);
}
.btn-outline-danger {
  --bs-btn-color: var(--c-danger); --bs-btn-border-color: var(--sf-border-strong);
  --bs-btn-hover-bg: var(--c-danger-soft); --bs-btn-hover-color: var(--c-danger); --bs-btn-hover-border-color: var(--c-danger);
  --bs-btn-active-bg: var(--c-danger-soft); --bs-btn-active-color: var(--c-danger); --bs-btn-active-border-color: var(--c-danger);
}
.btn-danger {
  --bs-btn-bg: var(--c-danger); --bs-btn-border-color: var(--c-danger);
  --bs-btn-hover-bg: var(--c-danger); --bs-btn-hover-border-color: var(--c-danger); --bs-btn-color: #fff; --bs-btn-hover-color: #fff;
}
.btn-ghost {
  --bs-btn-color: var(--tx-2); --bs-btn-bg: transparent; --bs-btn-border-color: transparent;
  --bs-btn-hover-bg: var(--sf-surface-2); --bs-btn-hover-color: var(--tx-1);
  --bs-btn-active-bg: var(--sf-surface-3); --bs-btn-active-color: var(--tx-1);
}
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; }
.btn-icon i { font-size: 14px; }
.btn-icon.btn-sm { width: 28px; height: 28px; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  color: var(--tx-inverse); animation: spin .7s linear infinite;
}
.btn-outline-secondary.is-loading::after, .btn-ghost.is-loading::after { color: var(--tx-2); }
@keyframes spin { to { transform: rotate(360deg); } }
.bi-spin { display: inline-block; animation: spin 1s linear infinite; }

/* ---------- Cards ---------- */
.card {
  --bs-card-bg: var(--sf-surface); --bs-card-border-color: var(--sf-border);
  --bs-card-border-radius: var(--r-lg); --bs-card-inner-border-radius: calc(var(--r-lg) - 1px);
  --bs-card-cap-bg: transparent; --bs-card-spacer-y: 14px; --bs-card-spacer-x: 16px;
  box-shadow: var(--sh-1);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom-color: var(--sf-border); }
.card-title { font-size: var(--fs-md); font-weight: 600; margin: 0; color: var(--tx-1); letter-spacing: -.005em; }
.card-subtitle { font-size: var(--fs-xs); color: var(--tx-3); margin: 2px 0 0; }
.card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-footer { background: var(--sf-surface-2); padding: 10px 16px; }
.card.is-flush .card-body { padding: 0; }
.card + .card, .card-stack > * + * { margin-top: 16px; }

/* ---------- Forms ---------- */
.form-label { font-size: var(--fs-sm); font-weight: 500; color: var(--tx-1); margin-bottom: 5px; }
.form-control, .form-select {
  background-color: var(--sf-surface); border-color: var(--sf-border-strong); color: var(--tx-1);
  border-radius: var(--r-md); font-size: var(--fs-md); min-height: 34px; padding: .3rem .65rem;
  box-shadow: var(--sh-1);
}
.form-control-sm, .form-select-sm { min-height: 30px; font-size: var(--fs-sm); padding: .2rem .5rem; }
.form-control-lg { min-height: 40px; font-size: var(--fs-lg); }
.form-control::placeholder { color: var(--tx-3); }
.form-control:focus, .form-select:focus { border-color: var(--c-primary); box-shadow: var(--focus-ring); background-color: var(--sf-surface); color: var(--tx-1); }
.form-control:disabled, .form-select:disabled { background-color: var(--sf-surface-3); color: var(--tx-3); }
.form-text { color: var(--tx-3); font-size: var(--fs-xs); }
.form-check-input { border-color: var(--sf-border-strong); background-color: var(--sf-surface); }
.form-check-input:checked { background-color: var(--c-primary); border-color: var(--c-primary); }
.form-check-input:focus { box-shadow: var(--focus-ring); border-color: var(--c-primary); }
.input-group-text { background: var(--sf-surface-2); border-color: var(--sf-border-strong); color: var(--tx-2); }
.required-mark { color: var(--c-danger); margin-left: 3px; font-weight: 600; }
.form-section { padding: 16px 0; border-top: 1px solid var(--sf-border); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-title { font-size: var(--fs-sm); font-weight: 600; color: var(--tx-2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-error { color: var(--c-danger); font-size: var(--fs-xs); margin-top: 4px; }
.radio-card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--sf-border-strong); border-radius: var(--r-lg);
  background: var(--sf-surface); cursor: pointer; transition: border-color .12s, background .12s;
}
.radio-card:hover { background: var(--sf-surface-2); }
.radio-card.is-checked, .radio-card:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.radio-card .form-check-input { margin-top: 3px; flex: 0 0 auto; }
.radio-card-title { font-weight: 600; font-size: var(--fs-md); }
.radio-card-desc { font-size: var(--fs-sm); color: var(--tx-2); }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--tx-1);
  --bs-table-border-color: var(--sf-border); --bs-table-striped-bg: var(--sf-surface-2);
  --bs-table-hover-bg: var(--sf-surface-2); --bs-table-hover-color: var(--tx-1);
  margin-bottom: 0;
}
.data-table thead th {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tx-3); background: var(--sf-surface-2); border-bottom: 1px solid var(--sf-border);
  white-space: nowrap; padding: 9px 12px; vertical-align: middle;
}
.data-table tbody td { padding: 9px 12px; vertical-align: middle; border-color: var(--sf-border); font-size: var(--fs-md); }
.data-table tbody tr { transition: background .1s; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .cell-id { font-family: var(--ff-mono); font-size: var(--fs-sm); color: var(--tx-2); }
.data-table .cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .cell-muted { color: var(--tx-3); font-size: var(--fs-sm); }
.data-table .cell-title { font-weight: 500; min-width: 260px; max-width: 460px; }
.data-table .cell-title a { display: block; }
.data-table .cell-title .sub { display: block; font-size: var(--fs-xs); color: var(--tx-3); font-weight: 400; margin-top: 2px; }
.data-table .cell-actions { white-space: nowrap; text-align: right; }
.data-table .cell-actions .btn + .btn, .data-table .cell-actions .btn + .dropdown, .data-table .cell-actions .dropdown + .btn { margin-left: 4px; }
.table-card { border: 1px solid var(--sf-border); border-radius: var(--r-lg); background: var(--sf-surface); box-shadow: var(--sh-1); overflow: hidden; }
.table-card .table-responsive { border-radius: inherit; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--sf-border); flex-wrap: wrap; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--sf-border); font-size: var(--fs-sm); color: var(--tx-2); flex-wrap: wrap; }
.sticky-col-end { position: sticky; right: 0; background: var(--sf-surface); box-shadow: -8px 0 8px -8px rgba(0,0,0,.12); }
.data-table thead .sticky-col-end { background: var(--sf-surface-2); }
/* Ô sticky tạo lớp xếp chồng riêng → dòng dưới vẽ đè menu "⋯" của dòng trên: nâng ô đang mở menu lên trên */
.sticky-col-end { z-index: 1; }
.sticky-col-end:has(.dropdown-menu.show) { z-index: 5; }

/* ---------- Status badge ---------- */
.status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .02em; line-height: 1.6;
  color: var(--st-E); background: var(--st-E-bg); white-space: nowrap;
}
.status-badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 6px; }
.status-badge.is-E, .status-badge.is-W { color: var(--st-E); background: var(--st-E-bg); }
.status-badge.is-R { color: var(--st-R); background: var(--st-R-bg); }
.status-badge.is-P { color: var(--st-P); background: var(--st-P-bg); }
.status-badge.is-S { color: var(--st-S); background: var(--st-S-bg); }
.status-badge.is-F { color: var(--st-F); background: var(--st-F-bg); }
.status-badge.is-B { color: var(--st-B); background: var(--st-B-bg); }
.status-badge.is-D, .status-badge.is-Z, .status-badge.is-N { color: var(--st-D); background: var(--st-D-bg); }
.status-badge.is-mail-F { color: var(--st-B); background: var(--st-B-bg); }
.status-badge.is-mail-S { color: var(--st-F); background: var(--st-F-bg); }
.status-badge.is-lg { font-size: var(--fs-sm); padding: 4px 12px 4px 10px; }
.status-badge.is-S .dot, .status-badge.is-P .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* generic soft badges */
.badge-soft { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; }
.badge-soft.is-primary { color: var(--c-primary); background: var(--c-primary-soft); }
.badge-soft.is-success { color: var(--c-success); background: var(--c-success-soft); }
.badge-soft.is-warning { color: var(--c-warning); background: var(--c-warning-soft); }
.badge-soft.is-danger { color: var(--c-danger); background: var(--c-danger-soft); }
.badge-soft.is-info { color: var(--c-info); background: var(--c-info-soft); }
.badge-soft.is-neutral { color: var(--c-neutral); background: var(--c-neutral-soft); }

/* ---------- Stat card ---------- */
.stat-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px; border: 1px solid var(--sf-border); border-radius: var(--r-lg);
  background: var(--sf-surface); box-shadow: var(--sh-1); min-width: 0; height: 100%;
}
.stat-card .stat-label { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tx-3); }
.stat-card .stat-label i { color: var(--tx-3); font-size: 14px; opacity: .8; }
.stat-card .stat-value { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.15; letter-spacing: -.025em; font-variant-numeric: tabular-nums; color: var(--tx-1); margin-top: 2px; }
.stat-card .stat-sub { font-size: var(--fs-xs); color: var(--tx-3); }
.stat-card.tone-primary .stat-value { color: var(--c-primary); }
.stat-card.tone-success .stat-value { color: var(--c-success); }
.stat-card.tone-warning .stat-value { color: var(--c-warning); }
.stat-card.tone-danger .stat-value { color: var(--c-danger); }
.stat-card.tone-info .stat-value { color: var(--c-info); }
.stat-card.is-compact { padding: 12px 14px; }
a.stat-card.is-link { text-decoration: none; color: inherit; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
a.stat-card.is-link:hover, a.stat-card.is-link:focus-visible { border-color: var(--c-primary); box-shadow: var(--sh-2, var(--sh-1)); }
a.stat-card.is-link:hover .stat-label span { color: var(--c-primary); }
.stat-card.is-compact .stat-value { font-size: var(--fs-xl); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--tx-2); }
.empty-state i { font-size: 32px; color: var(--tx-3); display: block; margin-bottom: 12px; }
.empty-state .empty-title { font-weight: 600; color: var(--tx-1); font-size: var(--fs-lg); margin-bottom: 4px; }
.empty-state .empty-text { font-size: var(--fs-sm); max-width: 420px; margin: 0 auto 16px; }

/* ---------- Filter bar / toolbar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filter-bar .form-control, .filter-bar .form-select { min-height: 34px; font-size: var(--fs-sm); }
.filter-bar .filter-search { flex: 1 1 260px; max-width: 420px; }
.filter-bar .filter-field { flex: 0 1 180px; }
.filter-bar .filter-group { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 10px; border: 1px dashed var(--sf-border-strong); border-radius: var(--r-md); font-size: var(--fs-sm); color: var(--tx-2); }
.filter-bar .filter-group .form-control, .filter-bar .filter-group .form-select { width: auto; border: 0; background: transparent; min-height: 28px; padding: 2px 4px; }
.filter-bar .btn-link { color: var(--tx-2); text-decoration: none; font-size: var(--fs-sm); }
.filter-bar .btn-link:hover { color: var(--tx-1); }

@media (max-width: 767.98px) {
  .filter-bar .filter-search, .filter-bar .filter-field, .filter-bar .filter-group { flex: 1 1 100%; max-width: none; }
  .filter-bar .filter-group { flex-wrap: wrap; }
  .filter-bar .filter-group .form-control { flex: 1 1 40%; }
  .filter-bar .filter-group .form-select { flex: 1 1 80%; min-width: 0; }
  /* tab: 1 hàng, vuốt ngang thay vì xuống dòng */
  .nav-underline { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--sf-border); }
  .nav-underline::-webkit-scrollbar { display: none; }
  .nav-underline .nav-link { white-space: nowrap; margin-bottom: 0; }
  .filter-bar .dropdown.ms-auto { margin-left: 0; }
  .sticky-col-end { position: static; box-shadow: none; }
}

.bulk-bar {
  display: none; align-items: center; gap: 12px;
  padding: 8px 14px; margin-bottom: 12px;
  background: var(--c-primary-soft); color: var(--c-primary);
  border: 1px solid var(--c-primary); border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500;
}
.bulk-bar.is-visible { display: flex; }
.bulk-bar .bulk-actions { margin-left: auto; display: flex; gap: 8px; }

.action-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 16px; border: 1px solid var(--sf-border); border-radius: var(--r-lg);
  background: var(--sf-surface); box-shadow: var(--sh-1);
}
.action-bar.is-sticky { position: sticky; bottom: 16px; z-index: 10; box-shadow: var(--sh-2); }
/* Che khe 16px dưới thanh dính: nội dung cuộn phía sau không lộ ra bên dưới thanh */
.action-bar.is-sticky::after { content: ''; position: absolute; left: -1px; right: -1px; top: 100%; height: 17px; background: var(--sf-bg); pointer-events: none; }
.action-bar .spacer { flex: 1; }

/* ---------- Tabs ---------- */
.nav-underline { gap: 4px; border-bottom: 1px solid var(--sf-border); margin-bottom: 20px; --bs-nav-underline-link-active-color: var(--c-primary); --bs-nav-underline-border-width: 2px; }
.nav-underline .nav-link { color: var(--tx-2); font-weight: 500; padding: 8px 10px; font-size: var(--fs-md); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.nav-underline .nav-link:hover { color: var(--tx-1); border-color: var(--sf-border-strong); }
.nav-underline .nav-link.active { color: var(--c-primary); border-color: var(--c-primary); background: transparent; }
.nav-underline .nav-link i { margin-right: 6px; }
.nav-underline .nav-link.disabled { color: var(--tx-3); }

/* ---------- Dropdown / modal / alert / toast ---------- */
.dropdown-menu { --bs-dropdown-bg: var(--sf-surface); --bs-dropdown-border-color: var(--sf-border); --bs-dropdown-link-color: var(--tx-1); --bs-dropdown-link-hover-bg: var(--sf-surface-2); --bs-dropdown-link-hover-color: var(--tx-1); --bs-dropdown-border-radius: var(--r-lg); box-shadow: var(--sh-2); font-size: var(--fs-md); padding: 6px; }
.dropdown-item { border-radius: var(--r-sm); padding: 7px 10px; display: flex; align-items: center; gap: 8px; }
.dropdown-item i { width: 16px; color: var(--tx-2); }
.dropdown-item.text-danger i { color: var(--c-danger); }
.modal-content { --bs-modal-bg: var(--sf-surface); --bs-modal-border-color: var(--sf-border); --bs-modal-border-radius: var(--r-lg); box-shadow: var(--sh-3); }
.modal-header, .modal-footer { border-color: var(--sf-border); }
.modal-title { font-size: var(--fs-lg); font-weight: 600; }
.alert { border-radius: var(--r-lg); font-size: var(--fs-sm); }
.alert-danger { --bs-alert-bg: var(--c-danger-soft); --bs-alert-color: var(--c-danger); --bs-alert-border-color: transparent; }
.alert-warning { --bs-alert-bg: var(--c-warning-soft); --bs-alert-color: var(--c-warning); --bs-alert-border-color: transparent; }
.alert-success { --bs-alert-bg: var(--c-success-soft); --bs-alert-color: var(--c-success); --bs-alert-border-color: transparent; }
.alert-info { --bs-alert-bg: var(--c-info-soft); --bs-alert-color: var(--c-info); --bs-alert-border-color: transparent; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.toast-container { z-index: 1090; }
.toast { --bs-toast-bg: var(--sf-surface); --bs-toast-border-color: var(--sf-border); --bs-toast-border-radius: var(--r-lg); box-shadow: var(--sh-2); font-size: var(--fs-sm); }
.toast .toast-body { display: flex; gap: 10px; align-items: flex-start; }
.toast .toast-icon { font-size: 16px; line-height: 1.3; }
.toast.is-success .toast-icon { color: var(--c-success); }
.toast.is-danger .toast-icon { color: var(--c-danger); }
.toast.is-warning .toast-icon { color: var(--c-warning); }
.toast.is-info .toast-icon { color: var(--c-info); }
.tooltip { --bs-tooltip-bg: var(--tx-1); --bs-tooltip-color: var(--sf-surface); --bs-tooltip-border-radius: var(--r-sm); font-size: var(--fs-xs); }

/* ---------- Pagination / progress ---------- */
.pagination { --bs-pagination-bg: var(--sf-surface); --bs-pagination-color: var(--tx-2); --bs-pagination-border-color: var(--sf-border); --bs-pagination-hover-bg: var(--sf-surface-2); --bs-pagination-hover-color: var(--tx-1); --bs-pagination-active-bg: var(--c-primary); --bs-pagination-active-border-color: var(--c-primary); --bs-pagination-disabled-bg: var(--sf-surface); --bs-pagination-disabled-color: var(--tx-3); --bs-pagination-font-size: var(--fs-sm); margin: 0; }
.progress { --bs-progress-bg: var(--sf-surface-3); --bs-progress-bar-bg: var(--c-primary); --bs-progress-height: 6px; border-radius: 999px; }
.progress.is-thick { --bs-progress-height: 10px; }

/* ---------- Key-value list ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--tx-3); font-weight: 500; margin: 0; }
.kv dd { color: var(--tx-1); margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--sf-border); margin: 16px 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.copy-btn { cursor: pointer; }
.code-block { font-family: var(--ff-mono); font-size: var(--fs-sm); background: var(--sf-surface-2); border: 1px solid var(--sf-border); border-radius: var(--r-md); padding: 10px 12px; overflow: auto; }
.hint { font-size: var(--fs-xs); color: var(--tx-3); }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 8px 0; border-bottom: 1px solid var(--sf-border); }
.list-plain li:last-child { border-bottom: 0; }

/* Link "?" tới mục Help (prop `help` của <x-card> / <x-page-header>) */
.help-link { display: inline-flex; align-items: center; margin-left: 6px; color: var(--tx-3); font-size: .8em; font-weight: 400; text-decoration: none; vertical-align: middle; }
.help-link:hover, .help-link:focus-visible { color: var(--c-primary); }

/* ---------- Đèn gợi ý (public/js/help-lamp.js) — rê chuột vào [data-hint] ---------- */
.help-lamp {
  --hl: var(--c-warning); --hl-soft: var(--c-warning-soft);
  position: fixed; right: 24px; bottom: 24px; z-index: 1040; display: none; align-items: flex-end; gap: 12px;
  max-width: min(380px, calc(100vw - 48px)); pointer-events: none;
}
body.help-lamp-on .help-lamp { display: flex; }
.help-lamp.tone-danger { --hl: var(--c-danger); --hl-soft: var(--c-danger-soft); }
.help-lamp-bubble {
  min-width: 0; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--hl) 40%, transparent); border-radius: 16px;
  background: color-mix(in srgb, var(--hl-soft) 70%, var(--sf-surface)); box-shadow: var(--sh-3);
  display: flex; gap: 12px; align-items: flex-start;
  opacity: 0; transform: translateY(8px); transition: opacity .25s ease-out, transform .25s ease-out;
}
.help-lamp.is-active .help-lamp-bubble { opacity: 1; transform: none; }
.help-lamp .hl-icon { flex: 0 0 auto; display: grid; place-items: center; width: 30px; height: 30px; margin-top: 1px; border-radius: 50%; color: var(--hl); background: color-mix(in srgb, var(--hl) 16%, transparent); font-size: 14px; }
.help-lamp .hl-body { min-width: 0; }
.help-lamp .hl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.help-lamp .hl-title { font-size: var(--fs-sm); color: var(--tx-1); }
.help-lamp .hl-badge { padding: 1px 8px; border: 1px solid color-mix(in srgb, var(--hl) 35%, transparent); border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--hl); }
.help-lamp.tone-info .hl-badge { color: var(--tx-2); border-color: var(--sf-border-strong); }
.help-lamp .hl-lines { margin-top: 4px; }
.help-lamp .hl-lines p { margin: 0 0 2px; font-size: var(--fs-xs); line-height: 1.55; color: var(--tx-2); }
.help-lamp-bulb {
  position: relative; flex: 0 0 auto; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid var(--sf-border-strong); background: var(--sf-surface); color: var(--tx-3); box-shadow: var(--sh-2);
  font-size: 24px; transition: color .4s ease-out, border-color .4s ease-out, background .4s ease-out, transform .4s ease-out;
}
.help-lamp .hl-halo { position: absolute; inset: 0; border-radius: 50%; background: var(--hl); filter: blur(18px); opacity: 0; transform: scale(1); transition: opacity .5s ease-out, transform .5s ease-out; z-index: -1; }
.help-lamp.is-active .help-lamp-bulb { color: var(--hl); border-color: color-mix(in srgb, var(--hl) 70%, transparent); background: color-mix(in srgb, var(--hl) 14%, var(--sf-surface)); transform: scale(1.04); }
.help-lamp.is-active .hl-halo { opacity: .35; transform: scale(1.25); }
.help-lamp.is-first .help-lamp-bulb { animation: help-lamp-pulse 1.5s ease-out 1; }
.help-lamp.is-first .hl-halo { animation: help-lamp-halo 1.5s ease-out 1; }
@keyframes help-lamp-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hl) 25%, transparent); }
  40% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--hl) 10%, transparent); }
  100% { box-shadow: 0 0 0 20px transparent; }
}
@keyframes help-lamp-halo { 0% { opacity: .45; transform: scale(1); } 50% { opacity: .8; transform: scale(1.25); } 100% { opacity: .35; transform: scale(1.3); } }
/* Toast không bị đèn che */
#appToasts { bottom: 0; }
body.help-lamp-on #appToasts { bottom: 84px; }
/* Nút bật / tắt trên topbar */
.icon-btn.lamp-toggle.is-on { color: var(--c-warning); border-color: color-mix(in srgb, var(--c-warning) 45%, transparent); background: color-mix(in srgb, var(--c-warning) 12%, transparent); }
/* Thiết bị cảm ứng (không rê chuột được) → không dùng đèn */
@media (hover: none) { body.help-lamp-on .help-lamp, .icon-btn.lamp-toggle { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .help-lamp-bubble, .help-lamp-bulb, .help-lamp .hl-halo { transition: none; }
  .help-lamp.is-first .help-lamp-bulb, .help-lamp.is-first .hl-halo { animation: none; }
}

/* ---------- Hướng dẫn người dùng mới (public/js/onboarding.js): phủ tối + vùng sáng + bong bóng ---------- */
.ob-root { position: fixed; inset: 0; z-index: 1085; pointer-events: none; }
/* Hộp xác nhận (App.confirm) mở trong lúc hướng dẫn phải nằm trên lớp phủ, nếu không sẽ bị che và không bấm được */
body:has(.ob-root) .modal-backdrop { z-index: 1086; }
body:has(.ob-root) .modal { z-index: 1087; }
.ob-pane { position: fixed; background: rgba(2, 6, 23, .62); pointer-events: auto; transition: all .18s ease-out; }
.ob-ring { position: fixed; border-radius: var(--r-md); box-shadow: 0 0 0 2px var(--c-primary), 0 0 0 6px color-mix(in srgb, var(--c-primary) 30%, transparent); pointer-events: none; transition: all .18s ease-out; animation: ob-ring 1.6s ease-in-out infinite; }
@keyframes ob-ring { 50% { box-shadow: 0 0 0 2px var(--c-primary), 0 0 0 10px color-mix(in srgb, var(--c-primary) 12%, transparent); } }
.ob-pop {
  position: fixed; width: min(380px, calc(100vw - 32px)); padding: 16px 18px 14px; pointer-events: auto;
  border: 1px solid var(--sf-border-strong); border-radius: 14px; background: var(--sf-surface); box-shadow: var(--sh-3); color: var(--tx-1);
}
.ob-pop.is-center { width: min(460px, calc(100vw - 32px)); padding: 22px 24px 18px; }
.ob-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ob-count { font-size: var(--fs-xs); font-weight: 700; color: var(--c-primary); white-space: nowrap; }
.ob-bar { flex: 1; height: 4px; border-radius: 99px; background: var(--sf-surface-2); overflow: hidden; }
.ob-bar > span { display: block; height: 100%; background: var(--c-primary); transition: width .3s ease-out; }
.ob-title { margin: 0 0 6px; font-size: var(--fs-md); font-weight: 700; }
.ob-pop.is-center .ob-title { font-size: var(--fs-lg); }
.ob-text { margin: 0 0 8px; font-size: var(--fs-sm); line-height: 1.55; color: var(--tx-2); white-space: pre-line; }
.ob-muted { color: var(--tx-3); }
.ob-note { margin: 0 0 10px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--c-danger); background: var(--c-danger-soft); }
.ob-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.ob-foot-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.ob-exit { padding-left: 0; color: var(--tx-3); text-decoration: none; }
.ob-exit:hover { color: var(--tx-1); }
.ob-hint { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--c-primary); }
body.onboarding-active .help-lamp { visibility: hidden; }
@media (prefers-reduced-motion: reduce) { .ob-ring { animation: none; } .ob-pane, .ob-ring { transition: none; } }

/* ---------------------------------------------------------------- Chuông thông báo (topbar, public/js/notifications.js) */
.notify-btn { position: relative; }
.notify-btn.has-unread { color: var(--tx-1); }
.notify-badge {
  position: absolute; top: -5px; right: -6px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--c-danger); color: #fff; border: 2px solid var(--sf-surface);
  font-size: 10px; font-weight: 700; line-height: 13px; text-align: center; box-sizing: border-box;
}
.notify-panel { width: 380px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.notify-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--sf-border); }
.notify-head .btn-link { font-size: var(--fs-sm); text-decoration: none; }
.notify-list { max-height: min(420px, 70vh); overflow-y: auto; }
.notify-list:empty { display: none; }
.notify-item { display: flex; gap: 10px; padding: 10px 14px; color: var(--tx-1); text-decoration: none; border-bottom: 1px solid var(--sf-border); }
.notify-item:last-child { border-bottom: 0; }
a.notify-item:hover { background: var(--sf-surface-2); color: var(--tx-1); }
.notify-item.is-unread { background: color-mix(in srgb, var(--c-primary) 6%, transparent); }
.notify-item.is-unread .notify-title::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--c-primary); vertical-align: middle; }
.notify-icon { flex: 0 0 auto; font-size: 16px; line-height: 1.3; }
.notify-item.is-success .notify-icon { color: var(--c-success); }
.notify-item.is-info .notify-icon { color: var(--c-info); }
.notify-item.is-warning .notify-icon { color: var(--c-warning); }
.notify-item.is-danger .notify-icon { color: var(--c-danger); }
.notify-text { min-width: 0; flex: 1; }
.notify-title { font-weight: 600; font-size: var(--fs-md); overflow-wrap: anywhere; }
.notify-body { font-size: var(--fs-sm); color: var(--tx-2); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.notify-time { font-size: var(--fs-xs); color: var(--tx-3); margin-top: 2px; }
.notify-empty { padding: 24px 14px; text-align: center; color: var(--tx-3); font-size: var(--fs-sm); }

/* Tour của hướng dẫn (public/js/guide-tour.js) — dùng chung .ob-* của onboarding */
.guide-tour .guide-tour-name { margin: 0 0 2px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; }
