:root {
  --bg: #f5f6f8;
  --sidebar-bg: #ffffff;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #78808f;
  --border: #e7e9ee;
  --accent: #6f9b3f;
  --accent-dark: #4f7a2a;
  --accent-light: #eaf3df;
  --danger: #d33a2c;
  --danger-light: #fbe9e7;
  --warn-light: #fdf3d9;
  --info-light: #e3f0fb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Roboto', system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: inherit; }

/* ---- App shell: sidebar + main area ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.logo-badge {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(79, 122, 42, .3);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: .82em; letter-spacing: .04em; }
.brand-text small { color: var(--muted); font-size: .75em; }

.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  font-size: .92em;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--accent-light); color: var(--accent-dark); font-weight: 600; }
.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; opacity: .85; }
.nav-section-label {
  margin: 14px 12px 4px;
  font-size: .72em;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px; }
.sidebar-user-wrap { position: relative; }
.sidebar-user.action-toggle {
  display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 6px; border-radius: 8px;
  width: 100%; height: auto; background: none; border: none; cursor: pointer; font: inherit; font-size: 1em;
  text-align: left; color: inherit; justify-content: flex-start;
}
.sidebar-user:hover { background: var(--bg); }
.sidebar-user .chevron { color: var(--muted); font-size: .8em; }
.action-menu.sidebar-user-menu { left: 0; right: auto; bottom: calc(100% + 6px); top: auto; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9em; flex-shrink: 0;
}
.sidebar-user-info { display: flex; flex-direction: column; line-height: 1.3; flex: 1; min-width: 0; }
.sidebar-user-info strong { font-size: .88em; }
.sidebar-user-info small { color: var(--muted); font-size: .75em; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar-status {
  display: flex; align-items: center; gap: 6px;
  font-size: .8em; color: var(--muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.page-title { font-size: 1.15em; margin: 0; }
.topbar-spacer { flex: 1; }

.topbar-account { display: flex; align-items: center; gap: 14px; }
.account-chip-wrap { position: relative; }
.account-chip.action-toggle {
  display: flex; align-items: center; gap: 10px; width: auto; height: auto;
  background: none; border: none; cursor: pointer; padding: 4px 6px; border-radius: 10px; font-size: 1em;
}
.account-chip.action-toggle:hover { background: var(--bg); }
.account-info { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.25; }
.account-info strong { font-size: .88em; }
.account-info small { color: var(--muted); font-size: .75em; }
.account-chip .chevron { color: var(--muted); font-size: .8em; }
.account-menu { right: 0; left: auto; }

.content { max-width: 1760px; width: 100%; margin: 0 auto; padding: 28px; }
.content.content-account { max-width: 1280px; }
.content h1:first-child { margin-top: 0; }
.page-subtitle { color: var(--muted); margin: -8px 0 20px; font-size: .92em; }

/* ---- Mobile sidebar (hamburger toggle) ---- */
.sidebar-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; flex-shrink: 0; padding: 0;
}
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 210;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); box-shadow: 8px 0 24px rgba(0,0,0,.18); }
  .app-shell.sidebar-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 205; background: rgba(20,24,32,.45);
  }
}

/* ---- Auth page (no sidebar) ---- */
.auth-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 24px; }
.auth-shell {
  display: flex; width: 100%; max-width: 1100px; margin: 0 auto;
  border-radius: 20px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.08); background: var(--card);
}
.auth-info-panel {
  flex: 1 1 55%; background: linear-gradient(160deg, #f3f9ee, #eaf3df);
  padding: 48px; display: flex; flex-direction: column; gap: 20px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-headline { font-size: 1.85em; line-height: 1.25; margin: 8px 0 0; }
.accent-text { color: var(--accent-dark); }
.auth-lead { color: var(--muted); font-size: .95em; margin: 0; }
.auth-features { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.auth-feature { display: flex; align-items: flex-start; gap: 14px; }
.auth-feature strong { display: block; }
.auth-feature span { color: var(--muted); font-size: .88em; }
.auth-illustration { margin-top: auto; align-self: center; }

.auth-form-panel { flex: 1 1 45%; display: flex; align-items: center; justify-content: center; padding: 48px; }
.auth-form-card { width: 100%; max-width: 380px; }
.auth-shell-single { max-width: 480px; }
.auth-form-logo { display: flex; justify-content: center; margin-bottom: 12px; }
.logo-badge.lg { width: 56px; height: 56px; border-radius: 16px; box-shadow: 0 4px 12px rgba(79, 122, 42, .32); }
.auth-form-card h2 { text-align: center; margin: 0 0 4px; font-size: 1.3em; }
.auth-form-subtitle { text-align: center; color: var(--muted); font-size: .88em; margin: 0 0 24px; }
.auth-form-v2 { display: flex; flex-direction: column; gap: 16px; }
.auth-form-v2 label { display: flex; flex-direction: column; gap: 6px; font-size: .85em; color: var(--muted); }
.auth-form-row { display: flex; align-items: center; justify-content: space-between; margin-top: -6px; }
.auth-form-row .checkbox { margin: 0; }
.auth-forgot-link { color: var(--accent-dark); font-size: .85em; font-weight: 600; text-decoration: none; }
.auth-forgot-link:hover { text-decoration: underline; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: .95em; }
.auth-divider { position: relative; text-align: center; margin: 22px 0 18px; color: var(--muted); font-size: .75em; letter-spacing: .05em; }
.auth-divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; border-top: 1px solid var(--border); }
.auth-divider span { position: relative; background: var(--card); padding: 0 12px; }
.auth-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--accent-light); border: 1px solid #cfe3bd; border-radius: 12px;
  padding: 14px; font-size: .85em; color: var(--accent-dark);
}
.auth-note strong { display: block; margin-bottom: 2px; }
.auth-footer { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 20px; color: var(--muted); font-size: .8em; }
.auth-footer span { display: flex; align-items: center; gap: 6px; }
@media (max-width: 900px) {
  .auth-shell { flex-direction: column; }
  .auth-illustration { display: none; }
}

/* ---- Form controls ---- */
input, select, textarea {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: .95em; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { color: var(--muted); font-size: .85em; }

button, .btn-secondary, .btn-danger {
  padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer; font-size: .92em;
}
button[type=submit] { background: var(--accent); color: #fff; font-weight: 600; }
button[type=submit]:hover { background: var(--accent-dark); }
.btn-secondary {
  background: #fff; color: var(--text); border: 1px solid var(--border); text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { background: var(--bg); }
.btn-secondary svg { flex-shrink: 0; }
.btn-danger { background: var(--danger-light); color: var(--danger); }

.error { color: var(--danger); }
.notice-success { color: var(--accent-dark); background: var(--accent-light); padding: 10px 14px; border-radius: 8px; }
.hint { color: var(--muted); font-size: .85em; }

/* ---- Toast notification ---- */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 300;
  background: var(--accent-dark); color: #fff; font-size: .9em; font-weight: 600;
  padding: 12px 20px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.record-form .hint {
  background: var(--info-light); color: #2f6fa3; padding: 10px 14px; border-radius: 10px; margin: 0;
  display: flex; align-items: center; gap: 8px;
}
.note-counter { display: block; text-align: right; color: var(--muted); font-size: .75em; margin-top: 4px; }
.note-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.note-textarea { width: 100%; box-sizing: border-box; resize: vertical; }

/* ---- Stat cards ---- */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; margin-bottom: 28px; }
.stat-cards .card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 18px; display: flex; align-items: flex-start; gap: 14px;
}
.stat-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1em; flex-shrink: 0;
}
.stat-icon.green { background: var(--accent-light); color: var(--accent-dark); }
.stat-icon.yellow { background: var(--warn-light); color: #9a7a17; }
.stat-icon.blue { background: var(--info-light); color: #2f6fa3; }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple { background: #f1e9fb; color: #8a4fc7; }
.stat-body { display: flex; flex-direction: column; gap: 4px; }
.stat-cards .label { color: var(--muted); font-size: .78em; text-transform: uppercase; letter-spacing: .03em; }
.stat-cards .value { font-size: 1.5em; font-weight: 700; }
.stat-cards .delta { font-size: .78em; color: var(--muted); }

/* ---- Bottom info tiles ---- */
.info-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 16px; margin-top: 24px; }
.info-tile {
  border-radius: 14px; padding: 18px; border: 1px solid var(--border);
  background: var(--card);
}
.info-tile .label { color: var(--muted); font-size: .8em; text-transform: uppercase; }
.info-tile .value { font-size: 1.6em; font-weight: 700; margin: 6px 0; }
.info-tile a { color: var(--accent-dark); font-size: .85em; text-decoration: none; font-weight: 600; }
.info-tile a:hover { text-decoration: underline; }
.info-tile .muted { color: var(--muted); font-size: .85em; }

/* ---- Chart card ---- */
.chart-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px; margin-bottom: 24px;
}
.chart-card h2 { margin: 0 0 16px; font-size: 1em; }
.chart-card canvas { width: 100% !important; max-height: 280px; }

/* ---- Tables ---- */
table.orders-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.orders-table th, .orders-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: .88em; }
.orders-table th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: .78em; text-transform: uppercase; letter-spacing: .02em; }
.orders-table tbody tr:last-child td { border-bottom: none; }
.orders-table tbody tr:hover { background: var(--bg); }
/* Boxes in each per-order cell that got merged (rowspan) across a multi-item
   order — checkbox, mã đơn, ngày đặt, ngày HT, khách hàng, thanh toán HH,
   trạng thái — so it's visually clear each belongs to one order. Adjacent
   merge-cells share a collapsed border (border-collapse: collapse on the
   table), so this doesn't double up between them. Single-item orders have no
   rowspan and so never get this. */
.orders-table td.merge-cell { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.th-sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.th-sort-link:hover { color: var(--text); }
.th-sort-link.active { color: var(--accent-dark); }
.orders-table tfoot td {
  padding: 12px 14px; font-weight: 700; background: var(--bg);
  border-top: 2px solid var(--border); border-bottom: none;
}

h2 { font-size: 1.05em; margin-top: 32px; }

/* ---- Filters ---- */
.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; margin-bottom: 16px; width: 100%;
}
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .82em; color: var(--muted); }
.filters label:not(.search-field) { flex: 1 1 150px; min-width: 130px; }
.filters label.search-field { flex: 2.2 1 260px; min-width: 220px; }
.filters label input, .filters label .input-icon, .filters .filter-dropdown { width: 100%; }
.filters input[type="date"] { font-family: inherit; }
.filters label input, .filters .filter-dd-toggle.action-toggle { height: 38px; box-sizing: border-box; }
.filters-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.summary { color: var(--muted); margin-bottom: 12px; }

.input-icon { position: relative; display: flex; align-items: center; }
.input-icon .icon { position: absolute; left: 10px; color: var(--muted); font-size: .9em; pointer-events: none; }
.input-icon input { padding-left: 30px; width: 100%; }

.btn-primary {
  background: var(--accent); color: #fff; border: none; text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px; font-weight: 600;
  padding: 16px 16px; border-radius: 8px; font-size: .92em; cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary svg { flex-shrink: 0; }

/* ---- Colored-dot custom dropdown (filters) ---- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; margin-right: 8px; }
.dot-green { background: var(--accent); }
.dot-red { background: var(--danger); }
.dot-warn { background: #d9a017; }
.dot-blue { background: #2f6fa3; }
.dot-neutral { background: var(--muted); }

.filter-dropdown { position: relative; }
.filter-dd-toggle.action-toggle {
  width: 100%; height: auto; display: flex; align-items: center;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: .95em; font-family: inherit;
}
.filter-dd-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-dd-toggle .chevron { color: var(--muted); font-size: .8em; margin-left: 8px; }
.action-menu.filter-dd-menu {
  left: auto; right: 0; width: 100%; min-width: 180px; max-height: 260px; overflow-y: auto;
}
.filter-dd-option {
  display: flex; align-items: center; width: 100%; text-align: left;
  padding: 8px 12px; background: none; border: none; cursor: pointer; font-size: .88em; color: var(--text);
}
.filter-dd-option:hover { background: var(--bg); }
.dd-check { margin-left: auto; color: var(--accent); font-weight: 700; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .78em; font-weight: 600; white-space: nowrap;
}
.badge-success { background: var(--accent-light); color: var(--accent-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warn { background: var(--warn-light); color: #9a7a17; }
.badge-neutral { background: var(--info-light); color: #2f6fa3; }

.paid-toggle { border: none; cursor: pointer; font-family: inherit; }
.paid-toggle:hover { filter: brightness(0.95); }

.money-value { color: #d9726f; font-weight: 600; }
.money-order { color: #e0701e; font-weight: 600; }
.money-net { color: #2f6fa3; font-weight: 600; }
.money-customer { color: #2f8a52; font-weight: 600; }
.money-admin { color: #8a4fc7; font-weight: 600; }

.icon-only { display: inline-flex; align-items: center; justify-content: center; padding: 6px; }

.btn-sm { padding: 5px 12px; font-size: .82em; }

.table-scroll { overflow-x: auto; border-radius: 12px; }
.table-scroll table.orders-table { min-width: 1100px; }

.checkbox-col { width: 36px; text-align: center; vertical-align: middle; }

.bulk-bar {
  display: none; align-items: center; gap: 12px;
  background: var(--accent-light); border: 1px solid var(--accent); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 12px; font-size: .88em; color: var(--accent-dark);
}
.bulk-bar.open { display: flex; }
.bulk-bar select { padding: 7px 10px; }
.bulk-bar button { padding: 7px 14px; font-size: .88em; }

.pagination {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  margin-top: 16px; padding: 14px 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  font-size: .88em; color: var(--muted);
}
.per-page { display: flex; align-items: center; gap: 8px; }
.per-page select { padding: 5px 8px; }
.pages { display: flex; align-items: center; gap: 8px; }
.page-indicator { padding: 0 4px; color: var(--text); font-weight: 600; }
.pages .disabled { opacity: .45; pointer-events: none; }

.order-detail { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-bottom: 16px; }
.checkbox { flex-direction: row !important; align-items: center; gap: 8px !important; }
.btn-icon { vertical-align: -2px; margin-right: 2px; }

/* ---- Product name truncation ---- */
.product-name-trunc { color: var(--text); text-decoration: none; border-bottom: 1px dashed var(--muted); cursor: pointer; }
.product-name-trunc:hover { color: var(--accent-dark); }

/* ---- Row action menu (kebab dropdown) ---- */
.action-cell { position: relative; text-align: center; vertical-align: middle; }
.action-toggle {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 30px; height: 30px; cursor: pointer; font-size: 1.1em; color: var(--muted); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.action-toggle:hover { background: var(--bg); }
.action-menu {
  display: none; position: absolute; top: calc(100% + 2px); z-index: 20;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1); min-width: 150px; overflow: hidden;
  flex-direction: column;
}
.action-menu.open { display: flex; }
.action-menu a, .action-menu button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 9px 14px;
  background: none; border: none; font-size: .88em; color: var(--text); text-decoration: none; cursor: pointer;
}
.action-menu a svg, .action-menu button svg { flex-shrink: 0; }
.action-menu a:hover, .action-menu button:hover { background: var(--bg); }
.action-menu button.danger { color: var(--danger); }
.action-menu form { margin: 0; }

/* ---- Modal ---- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(20,24,32,.45);
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--card); border-radius: 14px; padding: 24px; max-width: 480px; width: calc(100% - 32px);
  position: relative; box-shadow: 0 16px 40px rgba(0,0,0,.2);
}
.modal-box h3 { margin: 0 0 12px; font-size: 1em; }
.modal-body { margin: 0; line-height: 1.5; white-space: pre-line; }
.modal-close {
  position: absolute; top: 12px; right: 14px; background: none; border: none;
  font-size: 1.3em; color: var(--muted); cursor: pointer; line-height: 1;
}
.modal-box-lg { max-width: 720px; max-height: 88vh; overflow-y: auto; padding: 0; }
.modal-box-lg .modal-content { padding: 0 24px 24px; }
.modal-box-lg .record-form, .modal-box-lg .order-detail { max-width: none; border: none; padding: 0; }
.modal-box-lg form.record-form { padding: 0; }
.modal-box-lg .modal-close {
  background: rgba(255,255,255,.85); width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; top: 14px; right: 14px; z-index: 2;
}

/* ---- Confirm modal ---- */
.modal-confirm { max-width: 380px; text-align: center; }
.modal-confirm-icon {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--warn-light); color: #9a7a17;
}
.modal-confirm-icon.danger { background: var(--danger-light); color: var(--danger); }
.modal-confirm-icon.success { background: var(--accent-light); color: var(--accent-dark); }
.modal-confirm-message { margin: 0 0 20px; font-size: .95em; line-height: 1.5; color: var(--text); white-space: pre-line; }
.modal-confirm-actions { display: flex; gap: 10px; }
.modal-confirm-actions button { flex: 1; justify-content: center; }

/* ---- Import result modal ---- */
.import-result-stats { display: flex; gap: 12px; margin: 0 0 20px; }
.import-result-stat { flex: 1; background: var(--bg); border-radius: 10px; padding: 14px 10px; }
.import-result-stat-num { display: block; font-size: 1.6em; font-weight: 700; color: var(--accent-dark); line-height: 1.2; }
.import-result-stat.warn .import-result-stat-num { color: #9a7a17; }
.import-result-stat-label { display: block; font-size: .78em; color: var(--muted); margin-top: 2px; }

/* ---- Modal banner (order detail header) ---- */
.modal-simple-header { display: flex; align-items: center; gap: 14px; padding: 24px 0 20px; }
.modal-banner-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  background: #dbe9fb; color: #2f6fa3; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 10px rgba(47,111,163,.15);
}
.modal-banner-text { position: relative; z-index: 1; }
.modal-banner-text h1 { margin: 0; font-size: 1.25em; }
.modal-banner-subtitle { color: var(--muted); font-size: .9em; margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.copy-btn { background: none; border: none; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; padding: 2px; }
.copy-btn:hover { color: var(--accent-dark); }

/* ---- Field icon labels ---- */
.field-label { display: flex; align-items: center; gap: 8px; }
.field-icon {
  width: 24px; height: 24px; border-radius: 8px; flex-shrink: 0;
  background: var(--info-light); color: #2f6fa3; display: flex; align-items: center; justify-content: center;
}
.field-icon.blue { background: var(--info-light); color: #2f6fa3; }
.field-icon.green { background: var(--accent-light); color: var(--accent-dark); }
.field-icon.orange { background: var(--warn-light); color: #b35c00; }
.field-icon.purple { background: #f1e9fb; color: #8a4fc7; }
.field-icon.red { background: var(--danger-light); color: var(--danger); }
.detail-rows { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.detail-row { display: flex; align-items: flex-start; gap: 10px; font-size: .9em; }
.detail-row .field-icon { margin-top: 1px; }
.detail-lv { display: grid; grid-template-columns: 128px 1fr; gap: 10px; flex: 1; align-items: start; }
.detail-row .detail-value { font-weight: 600; }
.detail-row .detail-label { color: var(--muted); font-size: .82em; font-weight: 400; }

/* ---- Commission summary mini stat cards ---- */
.commission-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.commission-summary.inline { grid-template-columns: repeat(4, 1fr); margin: 4px 0 6px; }
.stat-mini {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--border);
}
.stat-mini .field-icon { width: 30px; height: 30px; border-radius: 9px; }
.stat-mini-body { display: flex; flex-direction: column; line-height: 1.3; }
.stat-mini-label { color: var(--muted); font-size: .72em; text-transform: uppercase; letter-spacing: .02em; }
.stat-mini-value { font-weight: 700; font-size: 1em; }

.summary-box {
  background: var(--info-light); border: 1px solid #cfe1f5; border-radius: 12px; padding: 14px;
  margin-bottom: 20px;
}
.summary-box-title { font-size: .78em; font-weight: 700; color: #2f6fa3; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 10px; }
.summary-box .stat-mini { background: var(--card); }
@media (max-width: 640px) { .commission-summary.inline { grid-template-columns: repeat(2, 1fr); } }

/* ---- Record form (create/edit order) ---- */
.record-form {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; max-width: 640px; display: flex; flex-direction: column; gap: 14px;
}
.record-form .row { display: flex; gap: 14px; }
.record-form .row label { flex: 1; }
.record-form label { display: flex; flex-direction: column; gap: 6px; font-size: .85em; color: var(--muted); }
.actions {
  display: flex; gap: 10px; margin-top: 6px; align-items: center; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 16px;
}
.actions .actions-right { display: flex; gap: 10px; margin-left: auto; flex-wrap: wrap; }
/* .record-form's own flex `gap: 14px` already spaces .actions from the field
   above it (note.php's form has no such wrapper, so its .actions relies only
   on margin-top) — without this, edit.php stacked both and the gap above the
   actions row ended up visibly bigger than note.php's for the same divider. */
.record-form .actions { margin-top: -8px; }

/* ---- Toggle switch (used for "Thanh toán HH" in the order detail/edit forms) ---- */
.toggle-switch {
  /* .record-form label (higher specificity) forces display:flex/flex-direction:column/gap:6px —
     same override this codebase already applies to .checkbox for the same reason. */
  display: inline-flex !important; flex-direction: row !important; gap: 10px !important;
  align-items: center; cursor: pointer; user-select: none;
}
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  position: relative; width: 40px; height: 22px; flex-shrink: 0;
  background: var(--border); border-radius: 999px; transition: background .18s ease;
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s ease;
}
.toggle-switch input:checked + .toggle-track { background: var(--accent); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-track { outline: 2px solid var(--accent-dark); outline-offset: 2px; }
.toggle-text { font-size: .9em; color: var(--text); white-space: nowrap; }

/* ---- Import CSV page ---- */
.import-card { margin-bottom: 20px; }
.import-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
@media (max-width: 760px) { .import-grid { grid-template-columns: 1fr; } }
.import-col {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; height: 100%; display: flex; flex-direction: column;
}
.import-col-title { font-size: 1em; margin: 0 0 14px; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  text-align: center; flex: 1; min-height: 260px; padding: 24px;
  border: 2px dashed var(--border); border-radius: 12px; background: var(--bg);
  cursor: pointer; transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-light); }
.dropzone-icon { color: var(--accent); margin-bottom: 4px; }
.dropzone-text { font-weight: 600; }
.dropzone-or { color: var(--muted); font-size: .85em; }
.dropzone-btn { pointer-events: none; margin: 6px 0; }
.dropzone-hint { color: var(--muted); font-size: .8em; }
.dropzone-filename { color: var(--accent-dark); font-weight: 600; font-size: .85em; }

.import-options { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.import-option {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 12px; color: var(--text);
}
.import-option input { margin-top: 3px; accent-color: var(--accent); flex-shrink: 0; }
.import-option-icon { flex-shrink: 0; }
.import-option-body { display: flex; flex-direction: column; gap: 4px; font-size: .88em; }
.import-option-body strong { font-size: 1em; }
.import-option-body span { color: var(--muted); }
.import-option:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.import-note {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px;
  background: var(--warn-light); border: 1px solid #f0dfa3; border-radius: 12px;
  font-size: .85em; color: #8a6a10;
}
.import-note strong { display: block; margin-bottom: 2px; }
.import-checklist {
  display: flex; align-items: flex-start; gap: 10px; padding: 14px;
  background: var(--accent-light); border: 1px solid #cfe3bd; border-radius: 12px;
  font-size: .85em; color: var(--accent-dark);
}
.import-checklist-body { display: flex; flex-direction: column; gap: 6px; }
.import-checklist-body strong { display: block; }
.import-checklist-item { display: flex; align-items: center; gap: 6px; color: var(--text); }
.import-checklist-item svg { color: var(--accent-dark); flex-shrink: 0; }

.import-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.import-file-status { display: flex; align-items: center; gap: 6px; font-size: .85em; color: var(--muted); }
.import-file-status svg { flex-shrink: 0; }

.import-guide {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--accent-light); border: 1px solid #cfe3bd; border-radius: 12px;
  padding: 16px 20px; margin-bottom: 20px;
}
.import-guide-text { display: flex; align-items: flex-start; gap: 12px; font-size: .9em; color: var(--accent-dark); }
.import-guide-text strong { display: block; }

.import-features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .import-features { grid-template-columns: 1fr; } }
.feature-card {
  position: relative; overflow: hidden;
  display: flex; align-items: flex-start; gap: 12px; padding: 18px;
  background: var(--card); border: 1px solid var(--border); border-radius: 14px; font-size: .9em;
}
.feature-card .field-icon { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; }
.feature-card-text { color: var(--muted); position: relative; z-index: 1; }
.feature-card strong { display: block; color: var(--text); margin-bottom: 2px; }
.feature-card-num {
  position: absolute; right: 14px; bottom: 6px; font-size: 1.8em; font-weight: 700;
  color: var(--border); line-height: 1; pointer-events: none;
}

/* ---- Numbered pagination (customers page) ---- */
.pages-info { color: var(--muted); }
.pages-numbered { display: flex; align-items: center; gap: 6px; }
.page-num-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text); text-decoration: none; font-size: .85em; font-weight: 600;
}
.page-num-btn:hover { background: var(--bg); }
.page-num-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-num-btn.disabled { opacity: .4; pointer-events: none; }
.page-ellipsis { color: var(--muted); padding: 0 2px; }

/* ---- Commission formula box (customers page) ---- */
.formula-box {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 24px; margin-top: 20px;
}
.formula-box-title { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 16px; }
.formula-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.formula-item { display: flex; align-items: center; gap: 10px; }
.formula-item-body { display: flex; flex-direction: column; line-height: 1.3; font-size: .9em; }
.formula-item-body span:last-child { color: var(--muted); font-size: .85em; }
.formula-op { font-size: 1.3em; font-weight: 700; color: var(--muted); }

.th-icon { display: inline-flex; align-items: center; gap: 6px; }
.row-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

/* ---- Dashboard header ---- */
.dashboard-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.dashboard-header-title { display: flex; align-items: center; gap: 14px; }
.dashboard-header-title h1 { margin: 0; }
.dashboard-header-title .page-subtitle { margin: 2px 0 0; }
.dashboard-header-actions { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
/* Chỉ scope riêng ở đây (KHÔNG sửa .btn-secondary chung — class đó còn dùng
   cho rất nhiều nút nhỏ khác khắp app) — ép "Xuất Excel" cùng kích thước
   padding với "Thêm đơn hàng" (.btn-primary đã có padding: 16px 16px). */
.dashboard-header-actions .btn-secondary { padding: 16px 16px; }
.page-icon-badge {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.page-icon-badge.green { background: var(--accent-light); color: var(--accent-dark); }
.page-icon-badge.blue { background: var(--info-light); color: #2f6fa3; }
.page-icon-badge.orange { background: var(--warn-light); color: #b35c00; }
.page-icon-badge.purple { background: #f1e9fb; color: #8a4fc7; }
.page-icon-badge.red { background: var(--danger-light); color: var(--danger); }
.page-icon-badge.teal { background: #dff5f4; color: #147d75; }

/* ---- Date range picker (dashboard) ---- */
.date-range-picker { position: relative; }
.date-range-toggle.action-toggle {
  width: auto; height: auto; display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: .88em; font-family: inherit;
}
.date-range-toggle .chevron { color: var(--muted); font-size: .8em; }
.date-range-menu { left: auto; right: 0; min-width: 240px; padding: 14px; gap: 10px; }
.date-range-menu label { display: flex; flex-direction: column; gap: 4px; font-size: .82em; color: var(--muted); }

/* ---- Dashboard stat cards (circular icon) ---- */
.dashboard-stats .stat-icon { width: 48px; height: 48px; border-radius: 50%; }

/* ---- Chart card header + day-range toggle ---- */
.chart-card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.chart-card-header h2 { margin: 0; }
.section-title { display: flex; align-items: center; gap: 10px; color: var(--accent-dark); }
.chart-toggle { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 10px; }
.chart-toggle a {
  padding: 6px 14px; border-radius: 7px; font-size: .82em; color: var(--muted);
  text-decoration: none; font-weight: 500;
}
.chart-toggle a:hover { color: var(--text); }
.chart-toggle a.active { background: var(--card); color: var(--accent-dark); font-weight: 700; box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---- Info tiles icon ---- */
.info-tile .field-icon { margin-bottom: 10px; }

/* ---- Shop leaderboard (dashboard) ---- */
.rank-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 50%; font-size: .82em; font-weight: 700;
}
.rank-badge.gold { background: #f5c344; color: #7a5200; }
.rank-badge.silver { background: #d8dce3; color: #54606e; }
.rank-badge.bronze { background: #e3a466; color: #6b3d10; }
.rank-badge.plain { background: transparent; color: var(--muted); }
.shop-avatar {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .82em;
}
.shop-avatar.c1 { background: #8a4fc7; }
.shop-avatar.c2 { background: #d9648a; }
.shop-avatar.c3 { background: #2f6fa3; }
.shop-avatar.c4 { background: #e0701e; }
.shop-avatar.c5 { background: #4f8a3f; }
.shop-avatar.c6 { background: #b35c8a; }
.share-cell { display: flex; flex-direction: column; gap: 5px; font-size: .88em; }
.share-bar { display: block; width: 100%; max-width: 140px; height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.share-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* ---- Users page ---- */
.stat-icon.circle { border-radius: 50%; }
.stats-inline-card {
  display: flex; flex-wrap: wrap; background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px 24px; margin-bottom: 20px;
}
.stats-inline-item { display: flex; align-items: center; gap: 14px; flex: 1 1 200px; padding: 0 20px; }
.stats-inline-item:first-child { padding-left: 0; }
.stats-inline-item:not(:first-child) { border-left: 1px solid var(--border); }

.card-section {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; margin-bottom: 20px;
}
.card-section .section-title { margin: 0 0 16px; }

.stats-inline-item .label { color: var(--muted); font-size: .78em; text-transform: uppercase; letter-spacing: .03em; }
.stats-inline-item .value { font-size: 1.7em; font-weight: 700; line-height: 1.15; }
.stats-inline-item .delta { font-size: .78em; color: var(--muted); }
.stats-inline-item .value.value-green { color: var(--accent-dark); }
.stats-inline-item .value.value-blue { color: #2f6fa3; }
.stats-inline-item .value.value-yellow { color: #9a7a17; }
.stats-inline-item .value.value-purple { color: #8a4fc7; }
.stats-inline-item .value.value-red { color: var(--danger); }

.user-add-form { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.user-add-fields { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.user-add-fields label { display: flex; flex-direction: column; gap: 6px; font-size: .85em; color: var(--muted); flex: 1; min-width: 170px; }
.password-field { position: relative; }
.password-field input { padding-right: 34px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; display: flex;
}
.password-toggle:hover { color: var(--text); }

.section-header-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section-header-row .section-title { margin: 0; }
.users-search-bar { display: flex; align-items: center; gap: 10px; }
.users-search-bar .input-icon input { width: 240px; }
.filter-dd-toggle.icon-only-filter { width: 40px; height: 40px; padding: 0; justify-content: center; }
.filter-dd-toggle.icon-only-filter .dot,
.filter-dd-toggle.icon-only-filter .filter-dd-label,
.filter-dd-toggle.icon-only-filter .chevron { display: none; }
.filter-dd-apply { padding: 10px 12px 4px; border-top: 1px solid var(--border); margin-top: 4px; }

.badge-role { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .78em; font-weight: 600; }
.badge-role-admin { background: var(--accent-light); color: var(--accent-dark); }
.badge-role-viewer { background: var(--info-light); color: #2f6fa3; }

.cell-icon { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

/* ---- Account page ---- */
.account-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: stretch; }
.account-grid.account-grid-2col { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .account-grid, .account-grid.account-grid-2col { grid-template-columns: 1fr; } }
.account-avatar-card { display: flex; flex-direction: column; align-items: center; text-align: center; }
.account-avatar-lg { width: 92px; height: 92px; font-size: 2em; margin-bottom: 12px; }
.account-avatar-card h2 { margin: 4px 0 0; font-size: 1.05em; }
.account-avatar-card .badge-role { margin-top: 10px; }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.account-form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.account-form .row label { flex: 1; min-width: 200px; }
.account-form label { display: flex; flex-direction: column; gap: 6px; font-size: .85em; color: var(--muted); }
.account-form input:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }

/* ---- Account page profile card ---- */
.account-mini-list { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 14px; text-align: left; }
.account-mini-row { display: flex; align-items: center; gap: 8px; font-size: .85em; color: var(--text); }
.account-mini-row svg { color: var(--muted); flex-shrink: 0; }
.account-mini-row strong { color: var(--text); margin-left: auto; text-align: right; white-space: nowrap; }
.account-mini-row .status-pill { margin-left: auto; }
.account-mini-divider { width: 100%; border-top: 1px dashed var(--border); margin: 2px 0; }

/* ---- Decorative corner accent on a card ---- */
.card-decorated { position: relative; overflow: hidden; }
.card-decoration { position: absolute; top: 16px; right: 18px; color: var(--accent); opacity: .16; pointer-events: none; }
.card-decoration .spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .5; }
.card-decoration .spark-1 { top: -12px; right: 34px; }
.card-decoration .spark-2 { top: 16px; right: -10px; }
.card-decoration .spark-3 { top: 44px; right: 26px; }

/* ---- Password strength checklist ---- */
.password-checklist { display: flex; flex-wrap: wrap; gap: 16px; margin-top: -6px; }
.check-item { display: flex; align-items: center; gap: 6px; font-size: .8em; color: var(--muted); }
.check-item .check-on { display: none; color: var(--accent-dark); }
.check-item.valid { color: var(--accent-dark); font-weight: 600; }
.check-item.valid .check-on { display: inline-flex; }
.check-item.valid .check-off { display: none; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .85em; color: var(--accent-dark); font-weight: 600; }
.status-pill.status-locked { color: var(--danger); }

/* ==== Responsive: tablet ==== */
@media (max-width: 900px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .content { padding: 20px 16px; }
  .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
  .account-info { display: none; }
  .account-chip.action-toggle { padding: 4px; }
  .record-form { max-width: none; }
  .record-form .row, .account-form .row { flex-direction: column; gap: 14px; }
  .user-add-form { flex-direction: column; align-items: stretch; }
  .user-add-fields { flex-direction: column; }
  .user-add-fields label { min-width: 0; }
  .users-search-bar .input-icon input { width: 100%; }
  .section-header-row { flex-direction: column; align-items: stretch; }
  .dashboard-header { flex-direction: column; align-items: stretch; }
  .stats-inline-item { flex: 1 1 45%; padding: 10px 0 !important; border-left: none !important; }
}

/* ==== Responsive: phone ==== */
@media (max-width: 560px) {
  .topbar-status { display: none; }
  .page-title { max-width: 60vw; font-size: 1em; }
  .auth-info-panel, .auth-form-panel { padding: 28px 22px; }
  .auth-page { padding: 12px; }
  .commission-summary { grid-template-columns: 1fr 1fr; }
  .commission-summary.inline { grid-template-columns: repeat(2, 1fr); }
  .stats-inline-item { flex: 1 1 100%; }
  .dashboard-header-actions { width: 100%; justify-content: flex-end; }
  .pagination { flex-direction: column; align-items: stretch; text-align: center; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}
