/* ============================================================
   Admin Panel - Light SaaS theme
   Nen sang, sidebar trang, active xanh, card bo goc lon,
   shadow rat nhe, badge pastel, table sach. Giu nguyen ten class.
   ============================================================ */
:root {
  /* Nen & be mat */
  --bg: #f8fafc;
  --bg-2: #ffffff;
  --bg-3: #f4f4f5;
  --bg-hover: #f8fafc;
  --surface-soft: #fafafa;

  /* Vien */
  --border: #e5e7eb;
  --border-2: #d1d5db;
  --divide: #f1f2f4;

  /* Chu */
  --text: #18181b;
  --text-dim: #52525b;
  --muted: #9ca3af;

  /* Mau nhan hieu */
  --accent: #2563eb;          /* xanh link/active */
  --accent-d: #1d4ed8;
  --accent-soft: #eff6ff;     /* nen active nhat */
  --primary: #4f46e5;         /* nut chinh (indigo) */
  --primary-d: #4338ca;
  --primary-soft: #eef2ff;

  --green: #16a34a;
  --green-d: #15803d;
  --green-bg: #dcfce7;
  --green-soft: #f0fdf4;
  --emerald: #059669;

  --danger: #e11d48;
  --danger-d: #be123c;
  --danger-bg: #ffe4e6;
  --danger-soft: #fff1f2;

  --warn: #d97706;
  --warn-d: #b45309;
  --warn-bg: #fef3c7;
  --warn-soft: #fffbeb;

  --info: #2563eb;
  --info-bg: #dbeafe;

  --purple: #7c3aed;
  --purple-bg: #f3e8ff;
  --violet: #7c3aed;

  /* Hinh hoc */
  --radius: 16px;             /* card, table */
  --radius-lg: 20px;          /* stat/chart card */
  --radius-btn: 12px;
  --radius-sm: 10px;
  --sidebar-w: 236px;

  /* Shadow nhe */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-pop: 0 20px 50px rgba(15, 23, 42, 0.14);
  --ring: 0 0 0 3px rgba(37, 99, 235, 0.14);

  /* Badge mac dinh */
  --badge-bg: #f3f4f6;
  --badge-fg: #52525b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-d); }
code {
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 6px;
  color: #4338ca;
  font-size: 12.5px;
  font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace;
  word-break: break-all;
}
h1, h2, h3, h4 { margin: 0 0 12px; font-weight: 750; letter-spacing: -0.01em; color: var(--text); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #dfe3e8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #cbd2da; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Layout ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #ffffff;
  border-right: 1px solid var(--border);
  position: fixed;
  inset: 0 auto 0 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 40;
  transition: transform .24s ease;
}
.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar .brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .35);
  flex-shrink: 0;
}
.sidebar .brand .logo svg { width: 20px; height: 20px; }
.sidebar .brand .logo img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
.sidebar .brand b { font-size: 15.5px; letter-spacing: -.01em; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; display: block; }
.sidebar .brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 20px 14px; }
.nav-group { margin-bottom: 6px; }
.nav-group .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  padding: 4px 12px 10px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-btn);
  color: var(--text-dim);
  margin-bottom: 3px;
  font-weight: 500;
  font-size: 14px;
  transition: background .13s, color .13s;
}
.nav-item .ic { width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }
.nav-item .ic svg { width: 20px; height: 20px; stroke-width: 2; }
.nav-item:hover { background: #f4f5f7; color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
  box-shadow: var(--shadow-sm);
}
.nav-item.active .ic svg { color: var(--accent); }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); background: #fafafa; flex-shrink: 0; }
.sidebar-foot .logout {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px; border-radius: var(--radius-btn);
  color: var(--text-dim); background: transparent; border: none;
  font-weight: 550; font-size: 14px; cursor: pointer; font-family: inherit;
  transition: .13s;
}
.sidebar-foot .logout:hover { background: var(--danger-soft); color: var(--danger); }
.sidebar-foot .logout svg { width: 20px; height: 20px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  height: 60px; padding: 0 20px;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 999px;
  background: var(--green-soft); color: var(--green-d);
  border: 1px solid #bbf7d0; box-shadow: var(--shadow-sm);
  font-size: 13px; font-weight: 650; white-space: nowrap;
}
.topbar .status-pill svg { width: 15px; height: 15px; }
.topbar .who { display: flex; align-items: center; gap: 9px; color: var(--text-dim); font-size: 13px; font-weight: 600; }
.topbar .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  color: #fff; display: grid; place-items: center;
  font-weight: 700; text-transform: uppercase;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
}
.menu-toggle {
  display: none; background: #f4f5f7; border: 1px solid var(--border);
  color: var(--text-dim); width: 40px; height: 40px; border-radius: var(--radius-btn);
  cursor: pointer; align-items: center; justify-content: center;
}
.menu-toggle svg { width: 20px; height: 20px; }

.container { padding: 20px 24px 48px; max-width: 1560px; width: 100%; }

/* ---------------- Section / page head ---------------- */
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.section-head h1 { font-size: 23px; margin: 0; display: flex; align-items: center; gap: 10px; letter-spacing: -.02em; }
.section-head h1 svg { width: 24px; height: 24px; color: var(--primary); }
.section-head .desc { color: var(--muted); font-size: 13.5px; margin-top: 5px; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.card > h3 { display: flex; align-items: center; gap: 8px; font-size: 15.5px; font-weight: 700; }
.card > h3 svg { width: 18px; height: 18px; flex: none; color: var(--primary); }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin: -6px 0 14px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > .table-wrap { border-radius: var(--radius); }

/* ---------------- Stat cards ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .15s, transform .15s;
}
.stat:hover { box-shadow: 0 6px 18px rgba(15, 23, 42, .07); }
.stat .st-label { color: var(--muted); font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; display: flex; align-items: center; gap: 8px; }
.stat .st-ic { font-size: 15px; }
.stat .st-value { font-size: 30px; font-weight: 800; margin-top: 12px; letter-spacing: -.03em; color: var(--text); }
.stat.accent .st-value { color: var(--green); }
.stat.warn .st-value { color: var(--warn); }
.stat.info .st-value { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }
.grid-2.even { grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ---------------- Chart ---------------- */
.chart-wrap { position: relative; height: 300px; }
.chart-wrap.sm { height: 250px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; gap: 8px; background: var(--surface-soft); border-radius: 14px; }
.chart-empty .big { font-size: 30px; opacity: .5; }
.chart-fallback { display: none; }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 14px 22px;
  color: var(--muted); font-weight: 700; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  background: #f9fafb; white-space: nowrap;
}
tbody td { padding: 15px 22px; border-bottom: 1px solid var(--divide); vertical-align: middle; color: var(--text-dim); }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #f9fafb; }
tbody tr:last-child td { border-bottom: none; }
tbody td b, tbody td strong { color: var(--text); font-weight: 700; }
tbody td a { color: var(--accent); font-weight: 650; }
table.kv td:first-child { color: var(--muted); width: 42%; font-weight: 500; }
.t-num { text-align: right; font-variant-numeric: tabular-nums; }
.empty-state { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; opacity: .45; margin-bottom: 10px; }

/* ---------------- Badges (pastel + ring theo trang thai) ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 7px;
  font-size: 12px; font-weight: 700; line-height: 1.4;
  background: var(--badge-bg, #f3f4f6); color: var(--badge-fg, var(--text-dim));
  border: 1px solid transparent;
  white-space: nowrap;
}
/* Success / on */
.badge.b-on, .badge.b-delivered, .badge.b-credited, .badge.b-sent, .badge.b-available, .badge.b-success, .badge.b-completed, .badge.b-active {
  background: var(--green-bg); color: var(--green-d); border-color: rgba(22, 163, 74, .28);
}
/* Paid = xanh duong de tach voi "Da giao" */
.badge.b-paid {
  background: var(--info-bg); color: var(--accent-d, var(--accent)); border-color: rgba(37, 99, 235, .28);
}
/* Danger / off */
.badge.b-off, .badge.b-cancelled, .badge.b-failed, .badge.b-sold, .badge.b-error, .badge.b-banned {
  background: var(--danger-bg); color: var(--danger-d); border-color: rgba(225, 29, 72, .28);
}
/* Expired = do nhat + gach ngang nhe (khac "Da huy") */
.badge.b-expired {
  background: var(--danger-bg); color: var(--danger-d); border-color: rgba(225, 29, 72, .22);
  opacity: .92;
}
/* Pending / warn */
.badge.b-pending, .badge.b-reserved, .badge.b-draft, .badge.b-scheduled, .badge.b-created, .badge.b-warn, .badge.b-sending, .badge.b-running {
  background: var(--warn-bg); color: var(--warn-d); border-color: rgba(217, 119, 6, .28);
}
.badge.b-info { background: var(--info-bg); color: var(--accent); border-color: rgba(37, 99, 235, .22); }
.badge.plain { background: var(--badge-bg, #f3f4f6); color: var(--badge-fg, var(--text-dim)); border-color: transparent; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: #ffffff; color: var(--text);
  border: 1px solid var(--border-2);
  padding: 9px 16px; border-radius: var(--radius-btn);
  cursor: pointer; font-size: 13.5px; font-family: inherit; font-weight: 600;
  transition: .13s; white-space: nowrap; line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: #f9fafb; border-color: var(--muted); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--primary); color: #fff; border-color: transparent; box-shadow: 0 2px 8px rgba(79, 70, 229, .22); }
.btn-primary:hover { background: var(--primary-d); color: #fff; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecdd3; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger-d); border-color: #fda4af; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: #f4f5f7; border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.inline { display: inline; }
.actions { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-row { display: flex; flex-direction: column; gap: 7px; }
.form-row.full { grid-column: 1 / -1; }
label { color: var(--text-dim); font-size: 13px; font-weight: 600; }
.hint { color: var(--muted); font-size: 11.5px; }
input[type=text], input[type=number], input[type=password], input[type=date], input[type=datetime-local],
input[type=time], input[type=file], input[type=search], input[type=email], textarea, select {
  background: #f9fafb;
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-btn);
  font-size: 13.5px; width: 100%; font-family: inherit;
  transition: border-color .13s, box-shadow .13s, background .13s;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 90px; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.input-mask { position: relative; }
.input-mask .toggle-eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }

/* ---------------- Toolbar (search/filter) ---------------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow-card); }
.toolbar form { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; width: 100%; }
.toolbar input, .toolbar select { min-width: 160px; width: auto; }
.toolbar .grow { flex: 1; min-width: 220px; }
.card-flush .toolbar { border: none; box-shadow: none; margin-bottom: 0; border-bottom: 1px solid var(--border); border-radius: 0; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { padding: 8px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.pagination a:hover { background: #f9fafb; border-color: var(--border-2); }
.pagination a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pagination .muted { border: none; background: none; color: var(--muted); }

/* ---------------- Flash / alerts ---------------- */
.flash {
  position: fixed; right: 24px; top: 80px; z-index: 90;
  min-width: 270px; max-width: min(420px, calc(100vw - 28px));
  padding: 13px 16px; border-radius: 14px; margin-bottom: 18px;
  display: flex; gap: 10px; align-items: center; font-weight: 600;
  box-shadow: var(--shadow-pop); transition: opacity .18s ease, transform .18s ease;
}
.flash.hide { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.flash-success { background: var(--green-soft); color: var(--green-d); border: 1px solid #bbf7d0; }
.flash-error { background: var(--danger-soft); color: var(--danger-d); border: 1px solid #fecdd3; }
.flash-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.flash-warning { background: var(--warn-soft); color: var(--warn-d); border: 1px solid #fde68a; }
.alert { padding: 12px 15px; border-radius: 12px; font-size: 13px; margin-bottom: 14px; }
.alert-warn { background: var(--warn-soft); color: var(--warn-d); border: 1px solid #fde68a; }
.alert-danger { background: var(--danger-soft); color: var(--danger-d); border: 1px solid #fecdd3; }

/* ---------------- Modal (backdrop mo, box sac net) ---------------- */
body.modal-open { overflow: hidden; }
.modal { position: fixed; inset: 0; z-index: 10000; display: none; align-items: center; justify-content: center; padding: 24px; background: transparent; }
.modal::before { content: ''; position: absolute; inset: 0; background: rgba(15, 23, 42, .45); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.modal.show { display: flex; }
.modal-box {
  position: relative; z-index: 10001; width: min(560px, 100%);
  max-height: 88vh; display: flex; flex-direction: column;
  background: #ffffff; color: var(--text);
  border: 1px solid var(--border);
  border-radius: 22px; box-shadow: var(--shadow-pop); overflow: hidden;
}
.modal-box.modal-lg { width: min(760px, 100%); }
/* Form bao head/body/foot -> phai la flex column de modal-body cuon duoc va modal-foot (nut gui) LUON hien. */
.modal-box > form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 13px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.modal-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 17px; flex: 0 0 auto; }
.modal-icon svg { width: 19px; height: 19px; }
.modal-head h3 { margin: 0; font-size: 16.5px; font-weight: 700; }
.modal-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.modal-x { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: #f9fafb; color: var(--text-dim); cursor: pointer; font-size: 18px; }
.modal-x:hover { color: var(--text); background: #f1f2f4; }
.modal-body { padding: 22px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; border-top: 1px solid var(--border); background: #fafafa; flex: 0 0 auto; }
.modal-foot .btn { min-width: 108px; justify-content: center; }
.modal-warning { background: var(--warn-soft); border: 1px solid #fde68a; color: var(--warn-d); padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 500; }
.modal-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.modal-meta .item { background: #f9fafb; border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; }
.modal-meta .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.modal-meta .v { margin-top: 4px; font-weight: 650; word-break: break-word; color: var(--text); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #f9fafb; border: 1px solid var(--border-2); border-radius: 12px; padding: 12px 14px; }
.toggle-row label { color: var(--text); font-size: 13.5px; }

/* ---------------- Misc ---------------- */
.emoji-preview { color: var(--text-dim); font-size: 12px; font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace; }
.muted { color: var(--muted); }
.masked-content { font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace; letter-spacing: .08em; color: var(--text-dim); }
.is-hidden { display: none !important; }
.thumb { display: block; width: 54px; height: 54px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); background: #f9fafb; }
.thumb-sm { width: 46px; height: 46px; }
.image-preview { display: none; margin-top: 10px; max-width: 220px; max-height: 160px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); background: #f9fafb; }
.image-preview.show { display: block; }
.broadcast-snippet { max-width: 240px; color: var(--text-dim); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; line-height: 1.45; }

/* Timeline (order detail) */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 20px 26px; border-left: 2px solid var(--border); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--border-2); }
.timeline li.done::before { background: var(--green); border-color: var(--green); }
.timeline li.cur::before { background: var(--warn); border-color: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.timeline li.bad::before { background: var(--danger); border-color: var(--danger); }
.timeline .tl-title { font-weight: 650; color: var(--text); }
.timeline .tl-time { color: var(--muted); font-size: 12px; }

/* Secret / delivery content */
.secret { display: inline-flex; align-items: center; gap: 8px; }
.secret code { filter: blur(5px); transition: filter .12s; cursor: pointer; }
.secret.reveal code { filter: none; }
.delivery-list { list-style: none; padding: 0; margin: 0; }
.delivery-list li { display: flex; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--divide); }

.mini-list { list-style: none; padding: 0; margin: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--divide); font-size: 13.5px; }
.mini-list li:last-child { border-bottom: none; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.kbd { background: #f1f2f4; border: 1px solid var(--border-2); border-radius: 6px; padding: 2px 8px; font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-dim); }

/* Runtime log view (terminal style, van hop trong theme sang) */
.log-view { background: #0f172a; border: 1px solid #1e293b; border-radius: 14px; padding: 16px; font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.75; max-height: 620px; overflow: auto; white-space: pre-wrap; word-break: break-word; color: #cbd5e1; }
.log-view .lg-error { color: #fb7185; } .log-view .lg-warn { color: #fbbf24; } .log-view .lg-audit { color: #7dd3fc; }

/* ---------------- Login ---------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(1000px 520px at 50% -10%, #e0e7ff88, transparent), var(--bg); padding: 20px; }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 22px; padding: 36px; width: 390px; max-width: 100%; box-shadow: var(--shadow-pop); }
.login-card .logo { width: 54px; height: 54px; border-radius: 16px; background: linear-gradient(135deg, #6366f1, #2563eb); display: grid; place-items: center; font-size: 26px; color: #fff; margin: 0 auto 16px; box-shadow: 0 8px 22px rgba(79, 70, 229, .4); overflow: hidden; }
.login-card .logo img { width: 100%; height: 100%; display: block; object-fit: cover; border-radius: inherit; }
.login-card h2 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card label { margin-top: 14px; display: block; margin-bottom: 7px; }
.login-card .flash { position: static; box-shadow: none; min-width: 0; max-width: none; margin-bottom: 6px; }

/* ---------------- Responsive ---------------- */
.backdrop { display: none; }
@media (max-width: 1024px) { .grid-2, .grid-2.even, .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .form-grid { grid-template-columns: 1fr; }
  .container { padding: 20px 16px 52px; }
  .topbar { padding: 0 16px; }
  .modal-meta { grid-template-columns: 1fr; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; }
}
@media (max-width: 700px) {
  .modal { padding: 12px; align-items: flex-end; }
  .modal-box, .modal-box.modal-lg { width: 100%; max-height: 92vh; border-radius: 20px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .flash { right: 14px; left: 14px; top: 72px; }
  .section-head h1 { font-size: 20px; }
}

/* ---------------- Action icon-only buttons (trong bang) ---------------- */
.actions .act {
  padding: 8px; border-radius: 9px; border: none; background: transparent;
  cursor: pointer; display: inline-grid; place-items: center; line-height: 0;
  color: var(--text-dim); transition: background .13s, color .13s;
}
.actions .act svg { width: 17px; height: 17px; }
.act-view, .act-edit { color: var(--accent); }
.act-view:hover, .act-edit:hover { background: var(--accent-soft); }
.act-del { color: var(--danger); }
.act-del:hover { background: var(--danger-soft); }
.act-toggle, .act-cancel { color: var(--warn); }
.act-toggle:hover, .act-cancel:hover { background: var(--warn-soft); }
.act-stock { color: var(--violet); }
.act-stock:hover { background: #f5f3ff; }
.act-send, .act-add { color: var(--green); }
.act-send:hover, .act-add:hover { background: var(--green-soft); }
.act-sub { color: var(--danger); }
.act-sub:hover { background: var(--danger-soft); }

/* ---------------- Stat card icon box (thay emoji) ---------------- */
.stat .st-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.st-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-soft); color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.st-icon svg { width: 20px; height: 20px; }
.stat.accent .st-icon { color: var(--green); background: var(--green-soft); }
.stat.info .st-icon { color: var(--accent); background: var(--accent-soft); }
.stat.warn .st-icon { color: var(--warn); background: var(--warn-soft); }
.stat .st-top + .st-value { margin-top: 14px; }

/* ---------------- Kho hàng thông minh (inventory) ---------------- */
.inv-grid { display: grid; grid-template-columns: minmax(300px, 340px) 1fr; gap: 20px; align-items: start; }
.inv-left, .inv-right { min-width: 0; }
.inv-left > .card:last-child, .inv-right > *:last-child { margin-bottom: 0; }

.inv-product-info .ip-head { display: flex; align-items: center; gap: 12px; }
.inv-product-info .ip-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: 0 0 auto; }
.inv-product-info .ip-icon svg { width: 21px; height: 21px; }
.inv-product-info .ip-name { font-weight: 700; font-size: 15px; color: var(--text); word-break: break-word; }
.inv-product-info .ip-cat { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.inv-product-info .ip-price { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--text-dim); font-size: 13.5px; }
.inv-product-info .ip-price b { color: var(--green); font-size: 15px; }

.inv-add-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; flex-wrap: wrap; }

.inv-add-actions { display: inline-flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inv-notify-check { font-size: 13px; color: var(--text-dim); font-weight: 600; user-select: none; gap: 7px; }
.inv-notify-check input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.inv-notify-label { white-space: nowrap; }


.inv-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 18px; }
.inv-stats .stat { padding: 16px 18px; }
.inv-stats .st-value { font-size: 26px; margin-top: 10px; }

.inv-search { position: relative; }
.inv-search .inv-search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); display: grid; place-items: center; pointer-events: none; }
.inv-search .inv-search-ic svg { width: 17px; height: 17px; }
.inv-search input { padding-left: 38px; }

.bulk-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.bulk-bar .check { font-weight: 600; color: var(--text-dim); font-size: 13.5px; }
.bulk-bar [data-inv-count] { font-size: 12.5px; }

.inv-check-col { width: 44px; text-align: center; }
.inv-check-col input[type=checkbox] { width: 17px; height: 17px; vertical-align: middle; }

.inv-time { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); white-space: nowrap; }
.inv-time svg { width: 14px; height: 14px; }

@media (max-width: 1024px) { .inv-grid { grid-template-columns: 1fr; } }


/* ================= Payment settings (Cấu hình thanh toán) ================= */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 2px 0 20px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.tab-pill { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg-2); color: var(--text-dim); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.tab-pill svg { width: 16px; height: 16px; flex: none; }
.tab-pill:hover { color: var(--text); border-color: var(--border-2); }
.tab-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(79,70,229,.28); }
.tab-panel { animation: payFade .18s ease; }
@keyframes payFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.pay-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.pay-stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; box-shadow: var(--shadow-card); }
.pay-stat .l { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.pay-stat .v { font-weight: 700; font-size: 13.5px; text-align: right; word-break: break-word; }

.card-head-inline { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 8px; }
.card-head-inline h3 svg { width: 18px; height: 18px; flex: none; color: var(--primary); }

.secret-field { position: relative; display: flex; align-items: center; }
.secret-field input { flex: 1; padding-right: 40px; }
.secret-field .toggle-eye { position: absolute; right: 4px; background: none; border: none; cursor: pointer; font-size: 15px; opacity: .55; padding: 6px; line-height: 1; }
.secret-field .toggle-eye:hover { opacity: 1; }

.url-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); flex-wrap: wrap; }
.url-row:last-child { border-bottom: none; }
.url-label { min-width: 140px; color: var(--muted); font-size: 12.5px; font-weight: 700; }
.url-code { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--bg-3); padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); word-break: break-all; color: var(--text); }

.qr-preview { display: flex; justify-content: center; align-items: center; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); min-height: 180px; }
/* Giữ tỉ lệ thật của template (print/compact/qr_only khác nhau) — không ép vuông 210x210. */
.qr-preview img { max-width: 100%; max-height: 360px; width: auto; height: auto; object-fit: contain; display: block; }
.qr-fallback { color: var(--muted); font-size: 13px; padding: 40px 10px; text-align: center; }

.test-result { margin-top: 12px; }
.test-result:empty { display: none; }
.empty-inline { color: var(--muted); font-size: 13px; padding: 6px 0; }

.alert-ok { background: var(--green-bg); border: 1px solid var(--green); color: var(--green-d); }
.badge.b-info { background: var(--info-bg); color: var(--info); }


/* ================= Polish v2 — accessibility + micro-interactions (additive, safe) ================= */
/* Keyboard focus ring (does not affect mouse click styling) */
.btn:focus-visible, .nav-item:focus-visible, .actions .act:focus-visible, .tab-pill:focus-visible,
.pagination a:focus-visible, .modal-x:focus-visible, .sidebar-foot .logout:focus-visible,
[data-modal-open]:focus-visible, [data-copy]:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}
/* Press feedback for buttons */
.btn:active { transform: translateY(1px); }
.actions .act:active { transform: scale(.9); }
.tab-pill:active { transform: translateY(1px); }

/* Consistent, subtle card hover elevation */
.card { transition: box-shadow .16s ease, border-color .16s ease; }
.card:hover { box-shadow: 0 4px 16px rgba(15, 23, 42, .06); }

/* Premium accent bar on stat cards (reveals on hover) */
.stat { position: relative; overflow: hidden; }
.stat::before {
  content: ''; position: absolute; left: 0; top: 0; height: 3px; width: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0; transition: opacity .18s ease;
}
.stat:hover::before { opacity: .85; }
.stat.accent::before { background: linear-gradient(90deg, var(--green), var(--emerald)); }
.stat.warn::before { background: linear-gradient(90deg, var(--warn), #f59e0b); }
.stat.info::before { background: linear-gradient(90deg, var(--accent), #38bdf8); }

/* Empty state secondary line */
.empty-state .big { line-height: 1; }
.empty-state .sub { font-size: 12.5px; margin-top: 6px; color: var(--muted); }

/* Disabled buttons read as disabled */
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}


/* ---- Emoji palette (trinh soan broadcast: chen custom emoji) ---- */
.emoji-palette { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; padding: 8px 10px; background: var(--bg-3); border: 1px solid var(--border); border-radius: var(--radius-sm); max-height: 118px; overflow-y: auto; }
.emoji-palette-label { font-size: 12px; color: var(--muted); font-weight: 700; margin-right: 4px; }
.emoji-chip { width: 34px; height: 34px; display: inline-grid; place-items: center; font-size: 18px; line-height: 1; background: #fff; border: 1px solid var(--border); border-radius: 9px; cursor: pointer; transition: transform .1s, border-color .12s, box-shadow .12s; padding: 0; }
.emoji-chip:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.emoji-chip:active { transform: scale(.9); }


/* ---- Copy-code chip (ma giam gia: click de copy, noi bat) ---- */
.copy-code {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: 'SFMono-Regular', ui-monospace, Consolas, monospace;
  font-weight: 800; font-size: 13px; letter-spacing: .04em;
  color: var(--primary); background: var(--primary-soft);
  border: 1px solid #c7d2fe; border-radius: 9px;
  padding: 6px 11px; cursor: pointer; line-height: 1.2;
  transition: background .13s, border-color .13s, transform .1s, color .13s;
}
.copy-code:hover { background: #e0e7ff; border-color: var(--primary); }
.copy-code:active { transform: scale(.96); }
.copy-code:focus-visible { outline: none; box-shadow: var(--ring); }
.copy-code > svg { width: 14px; height: 14px; flex: none; opacity: .6; }
.copy-code .cc-done { display: none; align-items: center; gap: 5px; }
.copy-code .cc-done svg { width: 14px; height: 14px; flex: none; opacity: 1; }
.copy-code.copied { background: var(--green-bg); border-color: var(--green); color: var(--green-d); }
.copy-code.copied .cc-code, .copy-code.copied > svg { display: none; }
.copy-code.copied .cc-done { display: inline-flex; }

/* ===== Popup chi tiet don hang (trang Don hang) ===== */
.od-loading { color: var(--muted); text-align: center; padding: 26px 0; }
.od-block + .od-block { margin-top: 20px; }
.od-h { font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 10px; }
.od-block .delivery-list .secret { flex: 1 1 auto; min-width: 0; }
.od-block .delivery-list .secret code { overflow-wrap: anywhere; }

/* ================= Dashboard KPI (hero doanh thu + luoi chi so) ================= */
.kpi-hero { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.stat-hero {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .16s ease, transform .16s ease;
}
.stat-hero::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--sh-accent, var(--primary));
}
.stat-hero:hover { box-shadow: 0 8px 24px rgba(15, 23, 42, .08); transform: translateY(-1px); }
.sh-icon {
  width: 52px; height: 52px; border-radius: 15px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--sh-accent, var(--primary)), var(--sh-accent-2, var(--accent)));
  box-shadow: 0 6px 16px var(--sh-glow, rgba(79, 70, 229, .28));
}
.sh-icon svg { width: 24px; height: 24px; }
.sh-main { min-width: 0; flex: 1 1 auto; }
.sh-label { color: var(--muted); font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.sh-value { font-size: 29px; font-weight: 800; letter-spacing: -.03em; color: var(--text); margin-top: 6px; line-height: 1.12; word-break: break-word; }
.sh-tag { align-self: flex-start; font-size: 11px; font-weight: 700; color: var(--text-dim); background: var(--bg-3); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.stat-hero.s-green  { --sh-accent: #16a34a; --sh-accent-2: #059669; --sh-glow: rgba(22, 163, 74, .26); }
.stat-hero.s-indigo { --sh-accent: #4f46e5; --sh-accent-2: #6366f1; --sh-glow: rgba(79, 70, 229, .26); }
.stat-hero.s-violet { --sh-accent: #7c3aed; --sh-accent-2: #a855f7; --sh-glow: rgba(124, 58, 237, .26); }
.stat-hero.s-green .sh-value { color: var(--green-d); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-grid .stat { padding: 17px 19px; border-radius: var(--radius); }
.kpi-grid .st-value { font-size: 25px; margin-top: 10px; }
.kpi-grid .st-icon { width: 36px; height: 36px; border-radius: 11px; }
.kpi-grid .st-icon svg { width: 18px; height: 18px; }
.kpi-grid .st-label { font-size: 12px; }

.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title-row h3 { margin: 0; }

@media (max-width: 900px) { .kpi-hero { grid-template-columns: 1fr; } }

/* ===== Dashboard: chon khoang thoi gian (segmented — legacy) ===== */
.dash-controls { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 2px; }
.seg-btn { border: none; background: transparent; color: var(--text-dim); font-weight: 650; font-size: 13px; font-family: inherit; padding: 7px 16px; border-radius: 999px; cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.seg-btn:hover { color: var(--text); }
.seg-btn.active { background: var(--bg-2); color: var(--accent); box-shadow: var(--shadow-sm); }
.dash-hint { color: var(--muted); font-size: 12.5px; font-weight: 600; }

/* ===== Dashboard: dropdown bo loc bieu do (range / sort) ===== */
.dash-filter { display: inline-flex; align-items: center; margin: 0; flex: 0 0 auto; }
.dash-select {
  appearance: none;
  -webkit-appearance: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  background: var(--bg-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 32px 7px 12px;
  min-width: 150px;
  max-width: 240px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.dash-select:hover { border-color: var(--accent); }
.dash-select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===== Nut chuyen giao dien Sang / Toi ===== */
.theme-toggle { position: relative; width: 40px; height: 40px; border-radius: var(--radius-btn); border: 1px solid var(--border); background: var(--bg-2); color: var(--text-dim); cursor: pointer; display: grid; place-items: center; flex: 0 0 auto; transition: color .15s, background .15s, border-color .15s; }
.theme-toggle:hover { color: var(--text); border-color: var(--border-2); }
.theme-toggle svg { width: 19px; height: 19px; position: absolute; transition: opacity .2s ease, transform .2s ease; }
.theme-toggle .i-sun { opacity: 0; transform: rotate(-90deg) scale(.5); }
.theme-toggle .i-moon { opacity: 1; transform: none; }
[data-theme="dark"] .theme-toggle .i-sun { opacity: 1; transform: none; }
[data-theme="dark"] .theme-toggle .i-moon { opacity: 0; transform: rotate(90deg) scale(.5); }

/* ============================================================
   DARK MODE — chi ghi de bien + cac be mat mau cung (light giu nguyen)
   ============================================================ */
[data-theme="dark"] {
  --bg: #0d1320;
  --bg-2: #161f31;
  --bg-3: #1e2941;
  --bg-hover: #1c2740;
  --surface-soft: #1a2336;

  --border: #273249;
  --border-2: #3a4763;
  --divide: #222c42;

  --text: #e7ecf6;
  --text-dim: #b6c0d8;
  --muted: #808daa;

  --accent: #7aa2ff;
  --accent-d: #a9c2ff;
  --accent-soft: #1c2947;
  --primary: #8b7cff;
  --primary-d: #a99bff;
  --primary-soft: #202744;

  --green: #34d399;
  --green-d: #6ee7b7;
  --green-bg: rgba(16, 185, 129, .16);
  --green-soft: rgba(16, 185, 129, .12);
  --emerald: #34d399;

  --danger: #fb7185;
  --danger-d: #fda4af;
  --danger-bg: rgba(244, 63, 94, .16);
  --danger-soft: rgba(244, 63, 94, .12);

  --warn: #fbbf24;
  --warn-d: #fcd34d;
  --warn-bg: rgba(217, 119, 6, .2);
  --warn-soft: rgba(217, 119, 6, .13);

  --info: #7aa2ff;
  --info-bg: rgba(59, 130, 246, .22);
  --purple: #c084fc;
  --purple-bg: rgba(124, 58, 237, .22);
  --violet: #c084fc;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .4);
  --shadow-card: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(122, 162, 255, .3);

  /* Badge mac dinh (trang thai van dung --green-bg / --danger-bg / ...) */
  --badge-bg: #223049;
  --badge-fg: var(--text-dim);
  color-scheme: dark;
}

[data-theme="dark"] body { background: var(--bg); }
[data-theme="dark"] .sidebar { background: var(--bg-2); }
[data-theme="dark"] .nav-item:hover { background: var(--bg-hover); }
[data-theme="dark"] .sidebar-foot { background: rgba(255, 255, 255, .02); }
[data-theme="dark"] .topbar { background: rgba(13, 19, 32, .82); }
[data-theme="dark"] .menu-toggle { background: var(--bg-3); }
[data-theme="dark"] thead th { background: #131b2b; }
[data-theme="dark"] tbody tr:hover { background: rgba(255, 255, 255, .035); }
/* Badge trang thai: GIU mau (truoc day bi .badge ghi de -> moi status giong nhau) */
[data-theme="dark"] .badge.plain { background: var(--badge-bg); color: var(--badge-fg); border-color: transparent; }
[data-theme="dark"] .badge.b-on,
[data-theme="dark"] .badge.b-delivered,
[data-theme="dark"] .badge.b-credited,
[data-theme="dark"] .badge.b-sent,
[data-theme="dark"] .badge.b-available,
[data-theme="dark"] .badge.b-success,
[data-theme="dark"] .badge.b-completed,
[data-theme="dark"] .badge.b-active {
  background: var(--green-bg); color: var(--green-d); border-color: rgba(52, 211, 153, .38);
}
[data-theme="dark"] .badge.b-paid {
  background: var(--info-bg); color: var(--accent-d); border-color: rgba(122, 162, 255, .4);
}
[data-theme="dark"] .badge.b-off,
[data-theme="dark"] .badge.b-cancelled,
[data-theme="dark"] .badge.b-failed,
[data-theme="dark"] .badge.b-sold,
[data-theme="dark"] .badge.b-error,
[data-theme="dark"] .badge.b-banned {
  background: var(--danger-bg); color: var(--danger-d); border-color: rgba(251, 113, 133, .4);
}
[data-theme="dark"] .badge.b-expired {
  background: var(--danger-bg); color: var(--danger-d); border-color: rgba(251, 113, 133, .32);
}
[data-theme="dark"] .badge.b-pending,
[data-theme="dark"] .badge.b-reserved,
[data-theme="dark"] .badge.b-draft,
[data-theme="dark"] .badge.b-scheduled,
[data-theme="dark"] .badge.b-created,
[data-theme="dark"] .badge.b-warn,
[data-theme="dark"] .badge.b-sending,
[data-theme="dark"] .badge.b-running {
  background: var(--warn-bg); color: var(--warn-d); border-color: rgba(251, 191, 36, .38);
}
[data-theme="dark"] .badge.b-info {
  background: var(--info-bg); color: var(--accent-d); border-color: rgba(122, 162, 255, .35);
}
[data-theme="dark"] .btn { background: var(--bg-3); color: var(--text); }
[data-theme="dark"] .btn:hover { background: var(--bg-hover); border-color: var(--border-2); color: var(--text); }
[data-theme="dark"] .btn-primary { background: var(--primary); color: #fff; }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-d); }
[data-theme="dark"] .btn-danger { background: var(--bg-3); color: var(--danger); border-color: rgba(244, 63, 94, .42); }
[data-theme="dark"] .btn-ghost { background: transparent; }
[data-theme="dark"] .btn-ghost:hover { background: var(--bg-hover); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select { background: var(--bg-3); color: var(--text); border-color: var(--border); }
[data-theme="dark"] input:focus, [data-theme="dark"] textarea:focus, [data-theme="dark"] select:focus { background: #14203a; }
[data-theme="dark"] input::placeholder, [data-theme="dark"] textarea::placeholder { color: var(--muted); }
[data-theme="dark"] .toolbar { background: var(--bg-2); }
[data-theme="dark"] .pagination a, [data-theme="dark"] .pagination span { background: var(--bg-2); color: var(--text-dim); }
[data-theme="dark"] .pagination a:hover { background: var(--bg-hover); }
[data-theme="dark"] .pagination a.active { background: var(--accent); color: #0d1320; }

[data-theme="dark"] .modal-box { background: var(--bg-2); }
[data-theme="dark"] .modal::before { background: rgba(0, 0, 0, .62); }
[data-theme="dark"] .modal-x { background: var(--bg-3); }
[data-theme="dark"] .modal-x:hover { background: var(--bg-hover); }
[data-theme="dark"] .modal-foot { background: rgba(255, 255, 255, .02); }
[data-theme="dark"] .modal-meta .item { background: var(--bg-3); }
[data-theme="dark"] .toggle-row { background: var(--bg-3); }
[data-theme="dark"] .thumb, [data-theme="dark"] .image-preview { background: var(--bg-3); }
[data-theme="dark"] .timeline li::before { background: var(--bg-2); }
[data-theme="dark"] .kbd { background: var(--bg-3); }
[data-theme="dark"] code { background: var(--bg-3); color: #c4b5fd; }
[data-theme="dark"] .seg { background: #0f1728; }
[data-theme="dark"] .seg-btn.active { background: #26335a; color: var(--accent-d); }
[data-theme="dark"] .dash-select {
  background-color: #0f1728;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa6c2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  border-color: var(--border);
}
[data-theme="dark"] .dash-select:focus { background-color: #14203a; }
[data-theme="dark"] .qr-preview { background: #0e1626; }
[data-theme="dark"] .emoji-chip { background: var(--bg-3); }
[data-theme="dark"] .copy-code:hover { background: var(--primary-soft); }
[data-theme="dark"] .act-stock:hover { background: var(--primary-soft); }
[data-theme="dark"] .status-pill { border-color: rgba(16, 185, 129, .42); }
[data-theme="dark"] .flash-success { border-color: rgba(16, 185, 129, .45); }
[data-theme="dark"] .flash-error { border-color: rgba(244, 63, 94, .45); }
[data-theme="dark"] .flash-info { background: var(--info-bg); color: var(--accent-d); border: 1px solid rgba(59, 130, 246, .45); }
[data-theme="dark"] .flash-warning { border-color: rgba(217, 119, 6, .45); }
[data-theme="dark"] .alert-warn { border-color: rgba(217, 119, 6, .4); }
[data-theme="dark"] .alert-danger { border-color: rgba(244, 63, 94, .4); }
[data-theme="dark"] .login-body { background: var(--bg); }
[data-theme="dark"] .login-card { background: var(--bg-2); }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #2b3854; }
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #3a4763; }

/* ============================================================
   Dashboard Vision-style (KPI + hero + gauge + timeline)
   ============================================================ */
.vkpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 20px; }
.vkpi { display: flex; align-items: center; gap: 14px; background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-card); transition: box-shadow .16s ease, transform .16s ease; }
.vkpi:hover { box-shadow: 0 10px 26px rgba(15, 23, 42, .1); transform: translateY(-1px); }
.vk-body { flex: 1 1 auto; min-width: 0; }
.vk-label { color: var(--muted); font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .03em; }
.vk-row { display: flex; align-items: baseline; gap: 8px; margin-top: 7px; flex-wrap: wrap; }
.vk-value { font-size: 22px; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; word-break: break-word; }
.vk-delta { font-size: 12.5px; font-weight: 750; white-space: nowrap; }
.vk-delta.up { color: var(--green); }
.vk-delta.down { color: var(--danger); }
.vk-ic { width: 48px; height: 48px; border-radius: 14px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .26); }
.vk-ic svg { width: 22px; height: 22px; }

.g-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.g-violet { background: linear-gradient(135deg, #7c3aed, #a855f7); }
.g-cyan { background: linear-gradient(135deg, #06b6d4, #0ea5e9); }
.g-green { background: linear-gradient(135deg, #16a34a, #22c55e); }
.g-orange { background: linear-gradient(135deg, #f59e0b, #f97316); }
.g-red { background: linear-gradient(135deg, #ef4444, #f43f5e); }

/* 3 card cung hang: stretch de day/thap bang nhau */
.dash-row-2 {
  display: grid;
  grid-template-columns: 1.35fr 1fr 1.15fr;
  gap: 20px;
  margin-bottom: 20px;
  align-items: stretch;
}
.dash-row-2 > .hero-card,
.dash-row-2 > .card {
  height: 100%;
  min-height: 0;
  box-sizing: border-box;
}
.hero-card { position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 26px 28px; color: #fff; background: linear-gradient(120deg, #1e2a78 0%, #2563eb 58%, #4338ca 100%); box-shadow: var(--shadow-card); display: flex; align-items: flex-end; min-height: 200px; }
.hero-glow { position: absolute; right: -70px; top: -70px; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle at 32% 32%, rgba(139, 92, 246, .9), rgba(56, 189, 248, .35) 46%, transparent 70%); pointer-events: none; }
.hero-inner { position: relative; z-index: 1; }
.hero-eyebrow { font-size: 13px; opacity: .82; font-weight: 500; }
.hero-name { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; word-break: break-word; }
.hero-sub { font-size: 13px; opacity: .82; margin: 10px 0 16px; max-width: 330px; line-height: 1.55; }
.hero-cta { display: inline-flex; align-items: center; gap: 7px; color: #fff; font-weight: 700; font-size: 13.5px; }
.hero-cta svg { width: 15px; height: 15px; transition: transform .15s; }
.hero-cta:hover { color: #fff; }
.hero-cta:hover svg { transform: translateX(3px); }

/* LIVE FEED — dong bo chieu cao voi 2 gauge card (giam padding/spacing nhe) */
.hero-card.live-feed-card {
  align-items: stretch;
  flex-direction: column;
  justify-content: flex-start;
  padding: 14px 16px 12px;
  min-height: 0; /* bo min-height 220 de khong keo cao hon hang */
  height: 100%;
}
.lf-inner { display: flex; flex-direction: column; width: 100%; height: 100%; min-height: 0; gap: 0; }
.lf-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
.lf-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lf-title { font-size: 14.5px; font-weight: 800; letter-spacing: .06em; }
.lf-live { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; letter-spacing: .04em; opacity: .95; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.18); padding: 2px 7px; border-radius: 999px; }
.lf-dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .7); animation: lf-pulse 1.6s ease-out infinite; }
@keyframes lf-pulse { 0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, .55); } 70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0); } 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); } }
.lf-sub { font-size: 11.5px; opacity: .78; margin-top: 2px; font-weight: 500; line-height: 1.3; }
.lf-all { font-size: 11.5px; font-weight: 700; color: #fff; opacity: .88; white-space: nowrap; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.35); padding-bottom: 1px; }
.lf-all:hover { opacity: 1; color: #fff; }
/* Vung feed chiem phan giua: chia deu chieu cao cho tung row (khong de khoang trang chet truoc footer) */
.lf-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: stretch;
}
.lf-item {
  display: flex;
  align-items: center; /* can giua noi dung trong moi row khi chieu cao duoc chia deu */
  gap: 7px;
  flex: 1 1 0; /* 5 row chia deu chieu cao vung feed — khong don len tren */
  min-height: 26px;
  padding: 0;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 12.5px;
  line-height: 1.3;
}
.lf-item:first-child { border-top: 0; }
.lf-time { flex: 0 0 36px; font-variant-numeric: tabular-nums; font-weight: 700; opacity: .78; font-size: 12px; }
.lf-icon { flex: 0 0 16px; text-align: center; font-size: 12.5px; line-height: 1; }
.lf-text { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; opacity: .96; }
.lf-empty {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  padding: 8px 4px;
  opacity: .8;
  font-size: 13px;
  font-weight: 600;
}
.lf-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 0; /* list da flex:1 — footer sat day, khong de blank o giua */
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: 11px;
  opacity: .72;
  font-weight: 600;
  flex: 0 0 auto;
}
.lf-hint { opacity: .85; }

.gauge-card { display: flex; flex-direction: column; height: 100%; }
.gauge-wrap { position: relative; width: 100%; }
.gauge-wrap.semi { height: 150px; margin-top: 8px; }
.gauge-wrap.ring { height: 130px; width: 130px; flex: 0 0 auto; }
.gauge-center { position: absolute; left: 0; right: 0; text-align: center; pointer-events: none; }
.gauge-wrap.semi .gauge-center { bottom: 8px; }
.gauge-wrap.ring .gauge-center { top: 50%; transform: translateY(-50%); }
.gc-value { font-size: 27px; font-weight: 800; color: var(--text); letter-spacing: -.02em; line-height: 1; }
.gc-value.sm { font-size: 20px; }
.gc-label { font-size: 11.5px; color: var(--muted); font-weight: 600; margin-top: 3px; }
.gauge-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 600; margin-top: 6px; }

.referral-grid { display: flex; align-items: center; gap: 16px; margin-top: 10px; }
.mini-boxes { display: flex; flex-direction: column; gap: 12px; flex: 1 1 auto; min-width: 0; }
.mini-box { background: var(--bg-3); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; }
.mb-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.mb-value { font-size: 20px; font-weight: 800; color: var(--text); margin-top: 3px; }

.actline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--divide); }
.actline .al-top { display: flex; align-items: center; gap: 8px; }
.al-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: 0 0 auto; }
.al-ic svg { width: 15px; height: 15px; }
.al-label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.al-value { font-size: 19px; font-weight: 800; color: var(--text); margin: 6px 0 7px; }
.al-bar { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.al-bar i { display: block; height: 100%; border-radius: 999px; min-width: 3px; }

.otimeline { list-style: none; padding: 4px 0 0; margin: 0; }
.otimeline .ot-item { display: flex; gap: 12px; padding: 9px 0; }
.ot-dot { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 auto; display: grid; place-items: center; color: #fff; }
.ot-dot svg { width: 15px; height: 15px; }
.ot-ok .ot-dot { background: linear-gradient(135deg, #16a34a, #22c55e); }
.ot-wait .ot-dot { background: linear-gradient(135deg, #f59e0b, #f97316); }
.ot-bad .ot-dot { background: linear-gradient(135deg, #ef4444, #f43f5e); }
.ot-body { min-width: 0; }
.ot-title { font-weight: 700; font-size: 13.5px; color: var(--text); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ot-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }

@media (max-width: 1100px) { .vkpi-grid { grid-template-columns: repeat(2, 1fr); } .dash-row-2 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .vkpi-grid { grid-template-columns: 1fr; } .actline-grid { grid-template-columns: 1fr; } .referral-grid { flex-direction: column; align-items: stretch; } .gauge-wrap.ring { align-self: center; } }

/* ===== Coupon: nhap VND kem USDT quy doi ===== */
.vnd-usdt { display: flex; align-items: center; gap: 8px; }
.vnd-usdt input { flex: 1 1 0; min-width: 0; }
.vnd-usdt .usdt-input { flex: 0 1 128px; }
.vnd-usdt .vu-sep { color: var(--muted); font-weight: 700; }
.vnd-usdt .vu-unit { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.form-row.is-disabled { opacity: .5; }
.form-row.is-disabled input { cursor: not-allowed; }

/* ===== Popup chi tiet khach hang ===== */
.ud-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 4px; }
.ud-stat { background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.uds-label { color: var(--muted); font-size: 11.5px; font-weight: 600; }
.uds-value { font-size: 18px; font-weight: 800; color: var(--text); margin-top: 4px; word-break: break-word; }
.ud-stat.accent .uds-value { color: var(--accent); }
.ud-actions { margin-bottom: 12px; }
.ud-adjust { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ud-adjust select { flex: 0 0 auto; }
.ud-adjust input[data-ud-amount] { flex: 0 1 150px; }
.ud-adjust input[data-ud-note] { flex: 1 1 160px; min-width: 120px; }
.ud-msg { color: var(--muted); font-size: 12.5px; margin-top: 8px; min-height: 16px; }
@media (max-width: 560px) { .ud-stat-grid { grid-template-columns: repeat(2, 1fr); } }

/* ============================================================
   Responsive Pro Pass 2026-07-08
   Scope: UI/UX only. Desktop visuals preserved; mobile/tablet hardened.
   ============================================================ */
html { overflow-x: clip; }
body { min-width: 0; overflow-x: clip; }
img, svg, canvas, video { max-width: 100%; }
pre, code, .masked-content, .broadcast-snippet { overflow-wrap: anywhere; }
.layout, .main, .container, .card, .table-wrap, .toolbar, .modal-box { min-width: 0; }

@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

@media (hover: hover) and (pointer: fine) {
  .stat:hover, .vkpi:hover { transform: translateY(-1px); }
}

@media (max-width: 1180px) {
  .container { padding: 24px 24px 56px; max-width: 100%; }
  .topbar { padding-inline: 22px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}

@media (max-width: 860px) {
  html, body { width: 100%; }
  .sidebar { width: min(86vw, var(--sidebar-w)); max-width: 320px; }
  .sidebar-nav { padding: 14px 12px calc(18px + env(safe-area-inset-bottom)); }
  .nav-item { min-height: 44px; padding: 11px 12px; font-size: 14.5px; }
  .sidebar-foot .logout { min-height: 44px; }
  .topbar {
    height: 58px;
    padding: 0 14px;
    gap: 10px;
    background: rgba(255,255,255,.92);
  }
  .topbar .page-title { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .status-pill { display: none; }
  .topbar .who span, .topbar .who .name { display: none; }
  .topbar .avatar { width: 34px; height: 34px; font-size: 12px; }
  .menu-toggle { width: 42px; height: 42px; flex: 0 0 42px; }
  .backdrop.show { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 23, 42, .38); backdrop-filter: blur(2px); }
  .container { padding: 18px 14px calc(44px + env(safe-area-inset-bottom)); }
  .section-head { gap: 12px; margin-bottom: 16px; }
  .section-head h1 { font-size: clamp(19px, 5vw, 22px); line-height: 1.15; }
  .section-head .desc { font-size: 13px; }
  .section-head > .btn, .section-head > div:last-child .btn { min-height: 44px; }
  .card { border-radius: 18px; padding: 16px; margin-bottom: 16px; }
  .card-flush { padding: 0; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
  .stat { padding: 15px; border-radius: 16px; }
  .stat .st-value { font-size: clamp(22px, 7vw, 28px); }
  .grid-2, .grid-2.even, .grid-3, .inv-grid, .dash-row-2 { grid-template-columns: 1fr !important; gap: 16px; }
  .chart-wrap { height: 240px; }
  .chart-wrap.sm { height: 220px; }

  .toolbar, .toolbar form { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar { padding: 13px; border-radius: 16px; }
  .toolbar input, .toolbar select, .toolbar .grow, .toolbar .btn { width: 100%; min-width: 0; }
  .toolbar .btn { justify-content: center; min-height: 44px; }

  .btn { min-height: 44px; justify-content: center; white-space: normal; text-align: center; }
  .btn-sm { min-height: 38px; }
  .btn-row, .actions { gap: 8px; }
  .actions .btn, .actions form, .actions button { flex: 1 1 auto; }
  input[type=text], input[type=number], input[type=password], input[type=date], input[type=datetime-local],
  input[type=time], input[type=file], input[type=search], input[type=email], textarea, select {
    min-height: 44px;
    font-size: 16px;
    padding: 11px 13px;
  }
  .form-grid { gap: 14px; }
  .inline-row, .ud-adjust, .vnd-usdt { flex-direction: column; align-items: stretch; }
  .inline-row input, .ud-adjust input, .ud-adjust select, .vnd-usdt input, .vnd-usdt .usdt-input { width: 100%; flex-basis: auto; min-width: 0; }
  .vnd-usdt .vu-sep { display: none; }

  .flash { left: 12px; right: 12px; top: 70px; min-width: 0; max-width: none; }
  .pagination { justify-content: center; gap: 7px; }
  .pagination a, .pagination span { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
}

@media (max-width: 700px) {
  .table-wrap { overflow-x: visible; }
  .table-wrap table.resp-card,
  .table-wrap table.resp-card thead,
  .table-wrap table.resp-card tbody,
  .table-wrap table.resp-card tr,
  .table-wrap table.resp-card th,
  .table-wrap table.resp-card td { display: block; width: 100%; }
  .table-wrap table.resp-card thead { display: none; }
  .table-wrap table.resp-card tbody { padding: 10px; }
  .table-wrap table.resp-card tbody tr {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    margin: 0 0 12px;
    padding: 12px;
  }
  .table-wrap table.resp-card tbody tr:hover { background: #fff; }
  .table-wrap table.resp-card tbody tr:last-child { margin-bottom: 0; }
  .table-wrap table.resp-card tbody td {
    display: grid;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 0;
    border-bottom: 1px solid var(--divide);
    text-align: left !important;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .table-wrap table.resp-card tbody td:last-child { border-bottom: none; padding-bottom: 0; }
  .table-wrap table.resp-card tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .table-wrap table.resp-card tbody td[data-label=""]::before,
  .table-wrap table.resp-card tbody td.empty-state::before { display: none; }
  .table-wrap table.resp-card tbody td.empty-state { display: block; padding: 30px 14px; text-align: center !important; }
  .table-wrap table.resp-card .actions { justify-content: stretch; }
  .table-wrap table.resp-card .actions .btn { width: 100%; }

  table.kv, table.kv tbody, table.kv tr, table.kv td { display: block; width: 100% !important; }
  table.kv tr { padding: 10px 0; border-bottom: 1px solid var(--divide); }
  table.kv td { border: 0; padding: 2px 0; }
  table.kv td:first-child { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

  .modal { padding: 10px 10px max(10px, env(safe-area-inset-bottom)); }
  .modal-box, .modal-box.modal-lg { width: calc(100vw - 20px); max-height: min(92dvh, 720px); border-radius: 22px 22px 18px 18px; }
  .modal-head { padding: 16px 16px 13px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px max(16px, env(safe-area-inset-bottom)); }
  .modal-x { width: 40px; height: 40px; }
  .modal-meta { grid-template-columns: 1fr; }

  .login-body { min-height: 100dvh; padding: 14px; }
  .login-card { padding: 26px 20px; border-radius: 20px; width: min(390px, 100%); }
}

@media (max-width: 560px) {
  .container { padding-inline: 12px; }
  .stat-grid, .vkpi-grid, .ud-stat-grid { grid-template-columns: 1fr !important; }
  .vkpi { padding: 15px; align-items: flex-start; }
  .vk-ic { width: 42px; height: 42px; border-radius: 12px; }
  .vk-value { font-size: 23px; }
  .hero-card { min-height: 180px; padding: 22px; border-radius: 18px; }
  .hero-card.live-feed-card { min-height: 0; padding: 14px 16px 12px; }
  .hero-name { font-size: 22px; }
  .hero-sub { font-size: 12.8px; }
  .pay-grid { grid-template-columns: 1fr; }
  .inv-stats { grid-template-columns: 1fr !important; }
  .delivery-list li, .mini-list li { flex-direction: column; align-items: flex-start; }
  .card > h3 { font-size: 15px; line-height: 1.25; }
  .section-head > div:last-child { width: 100%; }
  .section-head > div:last-child .btn { width: 100%; }
}

@media (max-width: 380px) {
  .topbar { padding-inline: 10px; }
  .container { padding-inline: 10px; }
  .card { padding: 14px; }
  .table-wrap table.resp-card tbody { padding: 8px; }
  .table-wrap table.resp-card tbody td { grid-template-columns: 1fr; gap: 3px; }
  .badge { white-space: normal; }
}

[data-theme="dark"] .table-wrap table.resp-card tbody tr { background: var(--bg-2); border-color: var(--border); }
[data-theme="dark"] .table-wrap table.resp-card tbody tr:hover { background: var(--bg-2); }

/* ============================================================
   Products/categories mobile card hardening
   Fix: force resp-card tables to become real cards on phones.
   Desktop untouched because this only runs <= 720px.
   ============================================================ */
@media (max-width: 720px) {
  .card-flush > .table-wrap,
  .table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: visible !important;
  }

  table.resp-card {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }

  table.resp-card thead,
  table.resp-card thead tr,
  table.resp-card thead th {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
  }

  table.resp-card tbody {
    display: block !important;
    width: 100% !important;
    padding: 10px !important;
  }

  table.resp-card tbody tr {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 14px !important;
    padding: 14px !important;
    background: var(--bg-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 18px !important;
    box-shadow: var(--shadow-card) !important;
  }

  table.resp-card tbody tr:last-child { margin-bottom: 0 !important; }

  table.resp-card tbody td {
    display: grid !important;
    grid-template-columns: 106px minmax(0, 1fr) !important;
    gap: 10px !important;
    align-items: start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding: 9px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid var(--divide) !important;
    text-align: left !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    color: var(--text-dim);
  }

  table.resp-card tbody td::before {
    content: attr(data-label) !important;
    display: block !important;
    color: var(--muted) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: .045em !important;
    text-transform: uppercase !important;
    line-height: 1.35 !important;
  }

  table.resp-card tbody td:first-child,
  table.resp-card tbody td[data-label="Tên"] {
    grid-template-columns: 1fr !important;
    gap: 5px !important;
  }

  table.resp-card tbody td[data-label="Tên"] b {
    color: var(--text) !important;
    font-size: 15px !important;
    line-height: 1.35 !important;
    overflow-wrap: anywhere !important;
  }

  table.resp-card tbody td:last-child {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    align-items: center !important;
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  table.resp-card tbody td:last-child::before {
    flex: 0 0 100% !important;
    width: 100% !important;
  }

  table.resp-card tbody td.actions form,
  table.resp-card tbody td.actions .inline {
    display: inline-flex !important;
    margin: 0 !important;
    flex: 0 0 auto !important;
  }

  table.resp-card tbody td.actions .act {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    border-radius: 12px !important;
    background: var(--bg-3) !important;
    border: 1px solid var(--border) !important;
  }

  table.resp-card tbody td.empty-state {
    display: block !important;
    padding: 34px 16px !important;
    border: 0 !important;
    text-align: center !important;
  }

  table.resp-card tbody td.empty-state::before { display: none !important; }
}

@media (max-width: 380px) {
  table.resp-card tbody { padding: 8px !important; }
  table.resp-card tbody tr { padding: 12px !important; border-radius: 16px !important; }
  table.resp-card tbody td { grid-template-columns: 92px minmax(0, 1fr) !important; gap: 8px !important; }
  table.resp-card tbody td:first-child,
  table.resp-card tbody td[data-label="Tên"] { grid-template-columns: 1fr !important; }
}

/* ============================================================
   Products mobile card final override
   Reason: cached/earlier table rules can keep desktop table layout.
   This block is intentionally narrow: only admin responsive-card tables
   and only mobile/tablet drawer breakpoint (<= 860px).
   ============================================================ */
@media screen and (max-width: 860px) {
  .container .card.card-flush .table-wrap:has(> table.resp-card),
  .container .card.card-flush .table-wrap {
    overflow-x: visible !important;
    overflow-y: visible !important;
    max-width: 100% !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .container table.resp-card {
    display: block !important;
    table-layout: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
  }

  .container table.resp-card colgroup,
  .container table.resp-card thead,
  .container table.resp-card thead tr,
  .container table.resp-card thead th {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    max-width: 0 !important;
    height: 0 !important;
    max-height: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
  }

  .container table.resp-card tbody,
  .container table.resp-card tbody tr,
  .container table.resp-card tbody td {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .container table.resp-card tbody {
    padding: 10px !important;
  }

  .container table.resp-card tbody tr {
    margin: 0 0 14px !important;
    padding: 14px !important;
    border: 1px solid var(--border) !important;
    border-radius: 18px !important;
    background: var(--bg-2) !important;
    box-shadow: var(--shadow-card) !important;
    overflow: visible !important;
  }

  .container table.resp-card tbody tr:last-child {
    margin-bottom: 0 !important;
  }

  .container table.resp-card tbody td {
    position: relative !important;
    padding: 10px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid var(--divide) !important;
    text-align: left !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    line-height: 1.45 !important;
  }

  .container table.resp-card tbody td:last-child {
    border-bottom: 0 !important;
    padding-bottom: 0 !important;
  }

  .container table.resp-card tbody td::before {
    content: attr(data-label) !important;
    display: block !important;
    margin: 0 0 4px !important;
    color: var(--muted) !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    letter-spacing: .045em !important;
    line-height: 1.3 !important;
    text-transform: uppercase !important;
    white-space: normal !important;
  }

  .container table.resp-card tbody td[data-label="Tên"] {
    padding-top: 2px !important;
  }

  .container table.resp-card tbody td[data-label="Tên"] b {
    display: inline !important;
    color: var(--text) !important;
    font-size: 15.5px !important;
    font-weight: 800 !important;
    line-height: 1.35 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }

  .container table.resp-card tbody td[data-label="Giá"],
  .container table.resp-card tbody td[data-label="Kho"],
  .container table.resp-card tbody td[data-label="Trạng thái"] {
    font-weight: 650 !important;
    color: var(--text) !important;
  }

  .container table.resp-card tbody td.actions {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    gap: 8px !important;
    padding-top: 12px !important;
  }

  .container table.resp-card tbody td.actions::before {
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-bottom: 0 !important;
  }

  .container table.resp-card tbody td.actions a,
  .container table.resp-card tbody td.actions form,
  .container table.resp-card tbody td.actions button {
    flex: 0 0 auto !important;
  }

  .container table.resp-card tbody td.actions .act {
    display: inline-grid !important;
    place-items: center !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0 !important;
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
    background: var(--bg-3) !important;
    overflow: visible !important;
  }

  .container table.resp-card tbody td.empty-state {
    display: block !important;
    text-align: center !important;
    padding: 34px 16px !important;
    border: 0 !important;
  }

  .container table.resp-card tbody td.empty-state::before {
    display: none !important;
    content: none !important;
  }
}

/* ============================================================
   Performance polish: reduce paint/reflow cost on touch/mobile.
   Keeps desktop visual stable; only trims expensive effects where
   hover is unavailable or viewport is small.
   ============================================================ */
.sidebar,
.topbar,
.card,
.stat,
.stat-hero,
.vkpi,
.hero-card,
.modal-box,
.toolbar {
  backface-visibility: hidden;
}

@media (hover: none), (max-width: 860px) {
  .topbar,
  .modal::before,
  .backdrop.show {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .card,
  .stat,
  .stat-hero,
  .vkpi,
  .hero-card,
  .pay-stat,
  .toolbar {
    transition: none !important;
  }

  .card:hover,
  .stat:hover,
  .stat-hero:hover,
  .vkpi:hover {
    transform: none !important;
    box-shadow: var(--shadow-card) !important;
  }

  .emoji-chip:hover,
  .hero-cta:hover svg {
    transform: none !important;
  }
}

@media (max-width: 720px) {
  .sidebar { transition-duration: .16s !important; }
  .modal-box { transition: none !important; }
  .chart-wrap { height: 220px; }
  .chart-wrap.sm { height: 200px; }
}

/* Turbo mode: eliminate expensive micro-animations causing jank on low-end/mobile browsers. */
:root { scroll-behavior: auto; }
*, *::before, *::after {
  transition-duration: 0s !important;
  animation-duration: 0s !important;
  animation-delay: 0s !important;
}
.card:hover,
.stat:hover,
.stat-hero:hover,
.vkpi:hover,
.emoji-chip:hover,
.hero-cta:hover svg {
  transform: none !important;
}
.topbar,
.modal::before,
.backdrop.show {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
@media (max-width: 1024px) {
  .card,
  .stat,
  .stat-hero,
  .vkpi,
  .pay-stat,
  .toolbar,
  table.resp-card tbody tr,
  .container table.resp-card tbody tr {
    box-shadow: none !important;
  }
}

/* ============================================================
   Dashboard polish PC/Mobile 2026-07-20
   Root causes fixed:
   - empty space: overview grid stretch + revenue flex fill
   - loading stuck: loading only when data-chart-loading=1
   - sticky overlap: single sticky topbar, no sticky page header
   ============================================================ */

:root {
  --dash-gap: 14px;
  --dash-card-pad: 14px 16px;
  --dash-radius: 14px;
  --dash-title: 15.5px;
  --dash-kpi-min-h: 128px;
  --dash-hover-lift: -2px;
  --dash-hover-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  --dash-hover-border: rgba(148, 163, 184, .28);
}

/* ---- Shell: sidebar collapse + transitions ---- */
.sidebar {
  transition: width .22s ease, transform .24s ease;
}
.main {
  transition: margin-left .22s ease;
}
.sidebar .sidebar-collapse-btn {
  margin-left: auto;
  width: 30px; height: 30px;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--text-dim);
  display: grid; place-items: center; cursor: pointer;
  flex-shrink: 0; padding: 0;
}
.sidebar .sidebar-collapse-btn svg { width: 16px; height: 16px; transition: transform .2s; }
.sidebar .sidebar-collapse-btn:hover { color: var(--text); background: var(--bg-3); }
.sidebar .brand { gap: 10px; }
.sidebar .brand b { max-width: 140px; }

.sidebar.collapsed { width: 72px; }
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-group .label,
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .brand { justify-content: center; padding: 0 8px; gap: 0; position: relative; }
.sidebar.collapsed .sidebar-collapse-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  margin: 0; width: 26px; height: 26px;
}
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .logo { width: 34px; height: 34px; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px; }
.sidebar.collapsed .sidebar-foot .logout { justify-content: center; padding-inline: 10px; }
.sidebar.collapsed .nav-item .ic { margin: 0; }
body.sidebar-collapsed { --sidebar-w: 72px; }
body.sidebar-collapsed .main { margin-left: 72px; }

.sidebar.collapsed .nav-item { position: relative; }
.sidebar.collapsed .nav-item:hover::after,
.sidebar.collapsed .nav-item:focus-visible::after {
  content: attr(data-tooltip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: #0f172a; color: #e2e8f0; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap; z-index: 70;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); pointer-events: none;
}

/* ---- Topbar polish ---- */
.topbar {
  min-height: 60px;
  height: auto;
  flex-wrap: nowrap;
  gap: 10px;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand-mobile {
  display: none;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.topbar-brand-mobile img {
  width: 28px; height: 28px; border-radius: 8px; object-fit: cover; flex: 0 0 auto;
}
.topbar-page-label {
  font-size: 15px; font-weight: 700; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw;
}
.topbar-search {
  display: flex; align-items: center;
  flex: 1 1 auto; max-width: 380px; min-width: 0;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 6px 0 12px;
  height: 38px;
}
.topbar-search-ic { display: grid; place-items: center; color: var(--muted); }
.topbar-search-ic svg { width: 15px; height: 15px; }
.topbar-search input[type=search] {
  border: none !important; background: transparent !important; box-shadow: none !important;
  flex: 1; min-width: 0; height: 34px; padding: 0 8px; font-size: 13px;
}
.topbar-search-scope {
  border: none !important; background: transparent !important; box-shadow: none !important;
  font-size: 12px; font-weight: 650; color: var(--text-dim);
  max-width: 104px; padding: 0 6px; cursor: pointer;
}
.topbar-search-toggle {
  display: none;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-3); color: var(--text-dim);
  place-items: center; cursor: pointer; flex: 0 0 auto;
}
.topbar-search-toggle svg { width: 18px; height: 18px; }
.topbar-search-panel {
  display: none;
  padding: 10px 14px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 60px; z-index: 39;
}
.topbar-search-panel.is-open { display: block; }
.topbar-search-panel[hidden] { display: none !important; }
.topbar-search-panel-form {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
}
.topbar-search-panel-form input,
.topbar-search-panel-form select {
  min-width: 0; width: 100%;
}
.topbar .status-pill {
  gap: 7px; padding: 6px 12px;
}
.topbar .status-pill .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(34,197,94,.16);
  display: inline-block;
}
.topbar .status-pill svg { display: none; }
.topbar .status-text { font-size: 12.5px; }
.who-name {
  max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .avatar { width: 34px; height: 34px; font-size: 13px; }

/* Body lock when mobile drawer open */
body.nav-open { overflow: hidden; touch-action: none; }

/* ---- Dashboard page ---- */
.dashboard-page {
  display: flex;
  flex-direction: column;
  gap: var(--dash-gap);
  max-width: none;
  min-width: 0;
}
.dashboard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  flex-wrap: wrap;
}
.dashboard-title {
  margin: 0;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -.02em;
  line-height: 1.2;
}
.dashboard-subtitle {
  margin: 5px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
  opacity: .95;
}
.dashboard-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dashboard-date-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-2);
  color: var(--text-dim); font-size: 12.5px; font-weight: 600;
  min-height: 36px;
}
.dashboard-date-chip svg { width: 14px; height: 14px; opacity: .85; }
.dashboard-btn-secondary,
.dashboard-btn-primary {
  min-height: 36px;
}

/* Cards */
.dashboard-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--dash-radius);
  padding: var(--dash-card-pad);
  box-shadow: var(--shadow-card);
  margin-bottom: 0;
  min-width: 0;
}
.dashboard-card.card-flush { padding: 0; overflow: hidden; }
.dashboard-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.dashboard-card-head.compact { margin-bottom: 10px; align-items: center; }
.dashboard-card-head.pad { padding: 14px 16px 0; margin-bottom: 8px; }
.dashboard-card-titles { min-width: 0; flex: 1 1 auto; }
.dashboard-card-title {
  margin: 0;
  font-size: var(--dash-title);
  font-weight: 720;
  letter-spacing: -.01em;
  line-height: 1.3;
  color: var(--text);
}
.dashboard-card-sub {
  margin: 3px 0 0;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.4;
  opacity: .95;
}

.dashboard-text-link {
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
}
.dashboard-text-link:hover { text-decoration: underline; }
.dashboard-meta-chip {
  font-size: 12px; font-weight: 650; color: var(--muted);
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px;
}
.dash-filter { display: inline-flex; margin: 0; flex: 0 0 auto; }
.dash-select {
  appearance: none; -webkit-appearance: none;
  font-family: inherit; font-size: 13px; font-weight: 650;
  color: var(--text);
  background: var(--bg-3) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 30px 7px 11px;
  min-width: 140px; max-width: 220px;
  cursor: pointer;
  min-height: 36px;
}
.dash-select:hover { border-color: var(--accent); }
.dash-select:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* KPI — grid: icon+copy left, sparkline right spanning */
.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--dash-gap);
}
.dashboard-kpi {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 100px;
  grid-template-rows: auto auto auto auto;
  column-gap: 8px;
  row-gap: 0;
  min-height: var(--dash-kpi-min-h);
  height: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--dash-radius);
  padding: 12px 13px 11px;
  box-shadow: var(--shadow-card);
  min-width: 0;
  isolation: isolate;
}
.dashboard-kpi::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
  background: radial-gradient(180px circle at var(--mx, 50%) var(--my, 30%), rgba(148,163,184,.12), transparent 55%);
  z-index: 0;
}
.dashboard-kpi > * { position: relative; z-index: 1; }
.dk-top { display: contents; }
.dk-ic {
  grid-column: 1; grid-row: 1;
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  margin-bottom: 4px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04);
}
.dk-ic svg { width: 17px; height: 17px; }
.dk-ic.g-blue { background: rgba(79,140,255,.16); color: #5b9bff; }
.dk-ic.g-violet { background: rgba(167,139,250,.18); color: #b39afc; }
.dk-ic.g-cyan { background: rgba(56,189,248,.16); color: #4ec8f5; }
.dk-ic.g-green { background: rgba(52,211,153,.16); color: #3dd9a0; }
.dk-spark {
  grid-column: 2; grid-row: 1 / -1;
  width: 100px; height: 44px;
  align-self: center; justify-self: end;
  display: block;
}
.dk-body {
  grid-column: 1; grid-row: 2 / -1;
  display: flex; flex-direction: column; justify-content: flex-start;
  min-width: 0; gap: 3px; padding-top: 2px;
}
.dk-label {
  color: var(--text-dim); font-size: 13px; font-weight: 600; letter-spacing: .01em; opacity: .95;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dk-value {
  font-size: 22px; font-weight: 780; letter-spacing: -.02em;
  line-height: 1.15; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dk-delta {
  margin-top: 2px; font-size: 12.5px; font-weight: 700;
  display: flex; align-items: baseline; gap: 5px; flex-wrap: nowrap;
  white-space: nowrap; overflow: hidden;
}
.dk-delta.up { color: #16a34a; }
.dk-delta.down { color: #e11d48; }
.dk-cmp { color: var(--text-dim); font-weight: 550; font-size: 12.5px; opacity: .94; }

/* Overview: desktop stretch revenue to match ops column height */
.dashboard-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr);
  gap: 12px;
  align-items: start;
}
.revenue-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px 12px;
}
.revenue-card .dashboard-card-head { margin-bottom: 8px; flex: 0 0 auto; }
.revenue-chart-wrap {
  position: relative;
  flex: 0 0 auto;
  height: 320px;
  min-height: 320px;
  max-height: 380px;
}
.dashboard-operations {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-width: 0;
  align-content: start;
}
/* Delivery gauge loading/error (range sync) */
.delivery-card.is-loading .delivery-gauge { opacity: .35; transition: opacity .18s ease; }
.delivery-card.is-loading [data-delivery-rate],
.delivery-card.is-loading [data-delivery-counts] { opacity: .45; }
.delivery-status {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}
.delivery-status.is-error { color: #f0445e; }
.delivery-status.is-empty { color: var(--muted); }
.delivery-status[hidden] { display: none !important; }
.dashboard-operations > .dashboard-card { min-width: 0; }
.dashboard-operations .action-card {
  grid-column: 1 / -1;
  padding: 11px 12px 10px;
}
.dashboard-operations .action-card .dashboard-card-head.compact { margin-bottom: 6px; }

/* Desktop wide: stretch revenue to ops bottom + compress ops (sau base rules) */
@media (min-width: 1280px) {
  .dashboard-overview-grid {
    align-items: stretch;
  }
  .revenue-card {
    height: 100%;
    min-height: 0;
    max-height: none;
  }
  .revenue-chart-wrap {
    flex: 1 1 auto !important;
    height: auto !important;
    min-height: 320px;
    max-height: 360px;
  }
  .dashboard-operations { gap: 8px; }
  .delivery-card { padding: 9px 10px 6px; }
  .inventory-card { padding: 9px 10px 6px; }
  /* override legacy .gauge-wrap.semi { height:150px } */
  .delivery-gauge.gauge-wrap.semi,
  .delivery-card .delivery-gauge {
    height: 84px !important;
    max-height: 84px;
    max-width: 156px;
    margin-top: 0 !important;
  }
  .delivery-card .gc-value { font-size: 18px; }
  .delivery-card .gc-label { font-size: 11.5px; }
  .delivery-card .dashboard-card-head.compact { margin-bottom: 2px; }
  .delivery-card .dashboard-card-sub { font-size: 12px; margin-top: 1px; }
  .inventory-card .dashboard-card-head.compact { margin-bottom: 4px; }
  .stock-status-list { gap: 4px; }
  .stock-status-list li { min-height: 32px; padding: 0 8px; }
  .stock-foot { display: none !important; }
  .dashboard-operations .action-card {
    padding: 9px 10px 7px;
  }
  .dashboard-operations .action-card .dashboard-card-head.compact { margin-bottom: 4px; }
  .action-queue { gap: 4px; }
  .aq-item { min-height: 38px; padding: 4px 7px; }
  .aq-ic { width: 28px; height: 28px; }
  .aq-body strong { font-size: 14px; }
  .aq-body span { font-size: 12px; }
}


/* Chart loading — ONLY when loading attr is 1 */
.chart-wrap { position: relative; }
.chart-loading {
  position: absolute; inset: 0;
  display: none;
  place-items: center;
  color: var(--muted); font-size: 13px; font-weight: 600;
  z-index: 3; pointer-events: none;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  border-radius: 10px;
}
.chart-wrap[data-chart-loading="1"] .chart-loading { display: grid; }
.chart-wrap[data-chart-loading="1"] canvas { opacity: .28; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); text-align: center; gap: 6px;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border-radius: 10px; z-index: 2; padding: 12px;
}
.chart-empty .big { font-size: 28px; opacity: .45; }

/* Delivery gauge compact */
.delivery-card { padding: 11px 12px 8px; }
.delivery-gauge {
  position: relative;
  height: 96px;
  margin-top: 0;
  max-width: 176px;
  margin-inline: auto;
}
.delivery-card .gauge-center { bottom: 1px; }
.delivery-card .gc-value { font-size: 20px; font-weight: 800; line-height: 1.1; }
.delivery-card .gc-label { font-size: 12px; color: var(--text-dim); margin-top: 0; }
.delivery-card .gauge-scale {
  display: flex; justify-content: space-between;
  color: var(--text-dim); font-size: 11px; font-weight: 600; margin-top: 0;
  max-width: 176px; margin-inline: auto; opacity: .9;
}
.delivery-card .dashboard-card-sub { font-size: 12.5px; }
.delivery-card .dashboard-card-head.compact { margin-bottom: 4px; }

/* Inventory rows */
.stock-status-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.inventory-card { padding: 11px 12px 8px; }
.inventory-card .dashboard-card-head.compact { margin-bottom: 6px; }
.stock-status-list li {
  display: grid; grid-template-columns: 12px 1fr auto; gap: 8px; align-items: center;
  min-height: 36px; padding: 0 9px;
  border-radius: 9px; background: var(--bg-3); border: 1px solid var(--border);
}
.ss-dot { width: 9px; height: 9px; border-radius: 50%; }
.ss-dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.ss-dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.ss-dot.bad { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.ss-label { color: var(--text-dim); font-weight: 600; font-size: 13px; }
.ss-val { font-weight: 780; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.stock-foot {
  margin: 6px 0 0; font-size: 12px; color: var(--text-dim); line-height: 1.4; opacity: .9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Action queue — tighter */
.action-queue {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.aq-item {
  display: flex; align-items: center; gap: 8px;
  min-height: 42px; padding: 6px 8px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--bg-3);
  transition: background .18s ease, border-color .18s ease, transform .18s ease;
}
.aq-ic {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; flex: 0 0 auto;
  background: rgba(79,140,255,.12); color: #4f8cff;
}
.aq-ic svg { width: 15px; height: 15px; }
.aq-item.tone-warn .aq-ic { background: rgba(245,158,11,.14); color: #f59e0b; }
.aq-item.tone-danger .aq-ic { background: rgba(239,68,68,.14); color: #ef4444; }
.aq-item.is-zero .aq-ic { background: var(--bg-2); color: var(--muted); }
.aq-item.is-zero strong { color: var(--muted); }
.aq-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.aq-body strong { font-size: 15px; font-weight: 780; line-height: 1.15; }
.aq-body span {
  color: var(--muted); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.aq-link {
  flex: 0 0 auto;
  min-width: 44px; min-height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
}
.empty-mini { color: var(--muted); font-size: 13px; padding: 6px 0; }

/* Secondary row */
.dashboard-secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--dash-gap);
  align-items: stretch;
}
.top-products-card,
.activity-card {
  display: flex; flex-direction: column; min-height: 0;
}
.top-chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 270px;
  height: 270px;
}
.top-products-list {
  display: none;
  list-style: none; margin: 0; padding: 0;
  flex-direction: column; gap: 8px;
}
.top-products-list li {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px; align-items: center;
  padding: 10px 10px;
  border-radius: 11px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  min-height: 44px;
}
.top-products-list .tp-rank {
  font-size: 12px; font-weight: 780; color: var(--muted); text-align: center;
}
.top-products-list .tp-name {
  font-size: 13.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.top-products-list .tp-val {
  font-size: 13px; font-weight: 750; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.top-products-list .tp-bar {
  grid-column: 2 / 4;
  height: 4px; border-radius: 999px; background: var(--border);
  overflow: hidden; margin-top: -2px;
}
.top-products-list .tp-bar > i {
  display: block; height: 100%; border-radius: inherit; background: #4f8cff;
}

/* Activity */
.activity-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0;
  flex: 1 1 auto;
  max-height: 300px; overflow: auto;
  min-height: 180px;
}
.activity-item {
  display: grid;
  grid-template-columns: 44px 20px minmax(0, 1fr);
  gap: 8px; align-items: start;
  padding: 9px 6px;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.act-time {
  color: var(--muted); font-size: 12px; font-weight: 650;
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.act-icon { text-align: center; line-height: 1.2; padding-top: 1px; }
.act-text {
  color: var(--text); font-size: 13.5px; font-weight: 550; line-height: 1.4;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.act-bad .act-text { color: #f0445e; }
.act-warn .act-text { color: #d97706; }
.act-money .act-text { color: #059669; }
.activity-empty { color: var(--muted); padding: 20px 8px; text-align: center; }
.activity-foot {
  display: flex; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border);
  color: var(--text-dim); font-size: 12.5px; opacity: .92;
}

/* Recent orders */
.recent-orders-card .table-wrap { border-radius: 0 0 var(--dash-radius) var(--dash-radius); }
.dashboard-orders-table th,
.dashboard-orders-table td {
  padding: 12px 14px;
  vertical-align: middle;
}
.dashboard-orders-table tbody tr { height: 50px; }
.dashboard-orders-table .t-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dashboard-orders-table .t-actions { width: 88px; text-align: right; }
.dashboard-orders-table code {
  background: var(--bg-3); color: var(--text);
  font-size: 12px; padding: 3px 7px;
}
.order-view-btn { min-height: 36px; min-width: 36px; gap: 4px; }
.order-view-text { display: none; }
.customer-cell {
  display: inline-block; max-width: 180px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.time-cell { white-space: nowrap; font-size: 12.5px; }

/* Dark refinements */
[data-theme="dark"] .dashboard-kpi,
[data-theme="dark"] .dashboard-card,
[data-theme="dark"] .dashboard-date-chip {
  background: #111c30;
  border-color: rgba(148,163,184,.14);
  box-shadow: none;
}
[data-theme="dark"] body { background: #07101f; }
[data-theme="dark"] .sidebar { background: #0b1425; }
[data-theme="dark"] .topbar {
  background: rgba(11, 20, 37, .9);
  border-bottom-color: rgba(148,163,184,.12);
}
[data-theme="dark"] .topbar-search,
[data-theme="dark"] .topbar-search-panel { background: #0f1728; }
[data-theme="dark"] .stock-status-list li,
[data-theme="dark"] .aq-item,
[data-theme="dark"] .top-products-list li {
  background: #0f1728;
  border-color: rgba(148,163,184,.12);
}
[data-theme="dark"] .nav-item.active {
  background: rgba(99,102,241,.16);
  color: #a5b4fc;
  box-shadow: none;
}
[data-theme="dark"] .dk-delta.up { color: #34d399; }
[data-theme="dark"] .dk-delta.down { color: #fb7185; }
[data-theme="dark"] .dash-select {
  background-color: #0f1728;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa6c2' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: var(--text);
  border-color: rgba(148,163,184,.16);
}
[data-theme="dark"] .dashboard-orders-table code {
  background: #0f1728; color: #c7d2fe;
}

/* ========== Breakpoints ========== */

/* Laptop ≤1279: overview stack; ops still 2-col gauge|inv + action span */
@media (max-width: 1279px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-overview-grid { grid-template-columns: 1fr; }
  .dashboard-operations {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .dashboard-operations .action-card { grid-column: 1 / -1; }
  .revenue-chart-wrap { height: 300px; min-height: 300px; max-height: 320px; flex: none; }
  .dashboard-secondary-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Narrow laptop */
@media (max-width: 1100px) {
  .topbar-search { max-width: 280px; }
}

/* When ops column too narrow inside side-by-side (desktop only if needed) */
@media (max-width: 1180px) and (min-width: 1280px) {
  .dashboard-overview-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr);
  }
}

/* Tablet portrait-ish */
@media (max-width: 1024px) {
  .dashboard-secondary-grid { grid-template-columns: 1fr; }
  .top-chart-wrap { height: 280px; min-height: 280px; }
}

/* Mobile shell ≤860 (matches existing sidebar drawer breakpoint) */
@media (max-width: 860px) {
  .sidebar .sidebar-collapse-btn { display: none; }
  body.sidebar-collapsed .main { margin-left: 0; }
  .sidebar.collapsed { width: min(86vw, 280px); }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-group .label,
  .sidebar.collapsed .nav-text { display: revert; }
  .sidebar.collapsed .brand { justify-content: flex-start; padding: 0 16px; gap: 10px; position: static; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
  .sidebar.collapsed .nav-item:hover::after { display: none; }

  .topbar {
    min-height: 56px;
    padding-inline: 12px;
    gap: 8px;
  }
  .topbar-brand-mobile { display: inline-flex; flex: 1 1 auto; min-width: 0; }
  .topbar .page-title,
  .topbar-title-mobile { display: none; }
  .topbar-search { display: none; }
  .topbar-search-toggle { display: grid; }
  .topbar .status-pill { display: none; }
  .who-name { display: none; }
  .topbar .spacer { display: none; }
  .topbar .avatar { width: 32px; height: 32px; font-size: 12px; flex: 0 0 auto; }
  .topbar .theme-toggle { width: 36px; height: 36px; flex: 0 0 auto; }
  .topbar-search-toggle { width: 36px; height: 36px; }

  .topbar-search-panel { top: 56px; padding-inline: 12px; }
  .topbar-search-panel-form {
    grid-template-columns: 1fr;
  }
  .topbar-search-panel-form .btn { min-height: 44px; }

  .container { padding: 14px 12px calc(36px + env(safe-area-inset-bottom)); }

  .dashboard-title { font-size: 22px; }
  .dashboard-subtitle { font-size: 13px; }
  .dashboard-heading-actions { width: 100%; }
  .dashboard-heading-actions .dashboard-date-chip { flex: 1 1 100%; justify-content: center; min-height: 40px; }
  .dashboard-heading-actions .btn {
    flex: 1 1 calc(50% - 6px);
    min-width: calc(50% - 6px);
    min-height: 44px;
    justify-content: center;
  }

  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dashboard-kpi {
    min-height: 118px; padding: 12px;
    grid-template-columns: minmax(0, 1fr) 72px;
  }
  .dk-value { font-size: 20px; }
  .dk-spark { width: 72px; height: 36px; }
  .dashboard-kpi:hover { transform: none; box-shadow: var(--shadow-card); }
  .dashboard-card:hover { transform: none; }

  .dashboard-operations { grid-template-columns: 1fr; }
  .dashboard-operations .delivery-card,
  .dashboard-operations .action-card { grid-column: auto; }

  .revenue-chart-wrap { height: 240px; min-height: 240px; }
  .top-chart-wrap { display: none; }
  .top-products-list { display: flex; }
  .activity-list { max-height: none; min-height: 0; }

  .dashboard-orders-table thead { display: none; }
  .dashboard-orders-table,
  .dashboard-orders-table tbody,
  .dashboard-orders-table tr,
  .dashboard-orders-table td { display: block; width: 100%; }
  .dashboard-orders-table tbody tr {
    height: auto;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .dashboard-orders-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    border: none;
    text-align: right;
  }
  .dashboard-orders-table td::before {
    content: attr(data-label);
    color: var(--muted); font-weight: 650; font-size: 12px;
    text-align: left; flex: 0 0 auto;
  }
  .dashboard-orders-table .t-num { text-align: right; }
  .dashboard-orders-table .t-actions { justify-content: flex-end; }
  .dashboard-orders-table .t-actions::before { display: none; }
  .order-view-text { display: inline; }
  .order-view-btn { min-width: 64px; min-height: 40px; }
  .customer-cell { max-width: 60vw; }
  .time-cell { white-space: normal; }
}

/* Small phones */
@media (max-width: 390px) {
  .dashboard-kpis { grid-template-columns: 1fr; }
  .dashboard-kpi { min-height: 0; }
  .dashboard-heading-actions .btn { flex: 1 1 100%; }
  .dk-value { font-size: 22px; }
  .revenue-chart-wrap { height: 220px; min-height: 220px; }
  .dash-select { min-width: 0; width: 100%; max-width: none; }
  .dashboard-card-head { flex-direction: column; align-items: stretch; }
}

/* Very small */
@media (max-width: 360px) {
  .container { padding-inline: 10px; }
  .topbar { padding-inline: 8px; }
  .dashboard-title { font-size: 20px; }
  .aq-body span { white-space: normal; }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .main { transition: none; }
}

/* ============================================================
   Micro-interactions (desktop hover-capable only)
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
  .dashboard-kpi,
  .dashboard-card:not(.card-flush),
  .recent-orders-card {
    transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
  }
  .dashboard-kpi:hover,
  .dashboard-card:not(.card-flush):hover,
  .recent-orders-card:hover {
    transform: translateY(var(--dash-hover-lift));
    border-color: var(--dash-hover-border);
    box-shadow: var(--dash-hover-shadow);
  }
  [data-theme="dark"] .dashboard-kpi:hover,
  [data-theme="dark"] .dashboard-card:not(.card-flush):hover,
  [data-theme="dark"] .recent-orders-card:hover {
    background: #152239;
    border-color: rgba(148,163,184,.26);
    box-shadow: 0 10px 28px rgba(0,0,0,.28);
  }
  .dashboard-kpi:hover::before { opacity: 1; }

  .btn {
    transition: transform .18s ease, background-color .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease;
  }
  .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
  }
  .btn-primary:hover {
    filter: brightness(1.06);
  }
  .aq-link:hover,
  .order-view-btn:hover,
  .dashboard-text-link:hover {
    transform: translateY(-1px);
  }
  .aq-item:hover {
    border-color: rgba(148,163,184,.28);
    background: color-mix(in srgb, var(--bg-2) 40%, var(--bg-3));
  }

  .nav-item {
    transition: background .15s ease, color .15s ease, transform .18s ease, padding-left .18s ease;
  }
  .nav-item:hover {
    transform: translateX(2px);
  }
  .sidebar.collapsed .nav-item:hover {
    transform: none;
  }

  .dashboard-orders-table tbody tr {
    transition: background-color .15s ease;
  }
  .dashboard-orders-table tbody tr:hover {
    background: color-mix(in srgb, var(--accent) 6%, transparent);
  }
  .dashboard-orders-table tbody tr:hover .order-view-btn {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  }

  .theme-toggle:hover,
  .topbar-search-toggle:hover,
  .menu-toggle:hover,
  .sidebar-collapse-btn:hover {
    transform: translateY(-1px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-kpi,
  .dashboard-card,
  .recent-orders-card,
  .btn,
  .nav-item,
  .aq-item {
    transition: none !important;
  }
  .dashboard-kpi:hover,
  .dashboard-card:hover,
  .recent-orders-card:hover,
  .btn:hover,
  .nav-item:hover {
    transform: none !important;
  }
  .dashboard-kpi::before { display: none; }
}

/* KPI depth on dark */
[data-theme="dark"] .dashboard-kpi {
  background: linear-gradient(165deg, #152033 0%, #111c30 55%, #0f1a2c 100%);
  border-color: rgba(148,163,184,.14);
}
