/* =====================================================================
   Shop Admin — app shell
   Tokens: navy ledger sidebar, cobalt actions, mint for money-in.
   Type: Be Vietnam Pro (UI) · JetBrains Mono (mã ND, số tiền, key)
   ===================================================================== */
:root {
  --paper: #f2f4f7;
  --panel: #ffffff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --brand: #2457e6;
  --brand-ink: #ffffff;
  --brand-soft: #e8eefc;
  --money: #12a36a;
  --money-soft: #e3f7ee;
  --warn: #c2410c;
  --warn-soft: #fff1e6;
  --danger: #d92d20;
  --danger-soft: #fee4e2;
  --nav-bg: #13233f;
  --nav-bg-2: #0f1c33;
  --nav-ink: #c7d2e6;
  --nav-ink-strong: #ffffff;
  --nav-active: #2457e6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.05);
  --font: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sidebar-w: 248px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
/* Thuộc tính hidden phải thắng mọi rule display của tác giả (vd button { display: inline-flex }) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; }
code, .mono {
  font-family: var(--mono);
  font-size: 0.86em;
  font-variant-numeric: tabular-nums;
}
/* Số tiền / số đếm: font chính + chữ số đều nhau (số 0 mono có chấm dễ nhầm số 8) */
.num { font-family: var(--font); font-variant-numeric: tabular-nums; }
code { background: #f2f4f7; padding: 1px 6px; border-radius: 6px; color: var(--ink-2); }
pre.mono { white-space: pre-wrap; word-break: break-word; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.nav-scrim { display: none; }
.sidebar {
  background: linear-gradient(180deg, var(--nav-bg), var(--nav-bg-2));
  color: var(--nav-ink);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 12px;
  color: var(--nav-ink-strong);
  font-weight: 700; font-size: 1.02rem; letter-spacing: -0.01em;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #2457e6, #12a36a);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 0.9rem;
}
.brand small { display: block; font-weight: 500; font-size: 0.72rem; color: var(--nav-ink); opacity: 0.8; }
.sidebar nav { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-title {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--nav-ink); opacity: 0.55; padding: 0 10px 6px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  color: var(--nav-ink); padding: 9px 10px; border-radius: 9px;
  font-weight: 500; font-size: 0.92rem;
  transition: background 0.15s, color 0.15s;
}
.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.85; }
.nav-link:hover { background: rgba(255,255,255,0.07); color: var(--nav-ink-strong); text-decoration: none; }
.nav-link.active { background: var(--nav-active); color: var(--nav-ink-strong); box-shadow: 0 6px 16px rgba(36,87,230,0.35); }
.nav-link.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 999px; background: #f59e0b; color: #1b1300;
  font-size: 0.72rem; font-weight: 700; display: grid; place-items: center;
  font-family: var(--mono);
}
.nav-link.active .nav-badge { background: #fff; color: var(--brand); }
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,0.1); padding-top: 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 0.86rem;
}
.sidebar-foot .who { display: flex; align-items: center; gap: 8px; color: var(--nav-ink-strong); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,0.12); display: grid; place-items: center; font-weight: 700; font-size: 0.8rem; }
.sidebar-foot a { color: var(--nav-ink); }

/* ---------- Topbar + lookup ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: rgba(242,244,247,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 1.2rem; white-space: nowrap; }
.menu-toggle { display: none; }
.lookup {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  width: min(460px, 100%);
}
.lookup-box {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--line-2); border-radius: 999px;
  padding: 6px 8px 6px 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.lookup-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.lookup-box svg { width: 18px; height: 18px; color: var(--muted); flex: 0 0 18px; }
.lookup-box input {
  border: 0; padding: 4px 0; background: transparent; width: 100%;
  font-family: var(--mono); font-size: 0.9rem; letter-spacing: 0.02em;
}
.lookup-box input:focus { outline: none; }
.lookup-box button {
  border-radius: 999px; padding: 6px 12px; font-size: 0.82rem;
}
.lookup-hint { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }

.content { padding: 22px 28px 48px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-content: start; }
/* Item lưới mặc định min-width: auto → bảng rộng đẩy tràn trang trên mobile. Chỉ bảng được cuộn ngang. */
.content > *, .panel, .panel-grid > *, .cards > * { min-width: 0; }

/* ---------- Notices / flash ---------- */
.flash {
  padding: 11px 14px; border-radius: var(--radius-sm); font-weight: 500; font-size: 0.92rem;
  display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent;
}
.flash-ok, .flash-info { background: var(--money-soft); color: #0a6b45; border-color: #bde9d2; }
.flash-error { background: var(--danger-soft); color: #a3261b; border-color: #f7c3bd; }
.flash-warn { background: var(--warn-soft); color: #9a3412; border-color: #f9cfae; }
.notices { display: grid; gap: 8px; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: grid; gap: 4px; min-height: 92px;
}
.card-label { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.card-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card-delta {
  justify-self: start; font-size: 0.76rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums;
}
.card-delta.up { color: #0a6b45; background: var(--money-soft); }
.card-delta.down { color: #a3261b; background: var(--danger-soft); }
.card-delta.flat { color: var(--muted); background: var(--paper); }
.card-delta svg { width: 13px; height: 13px; }
.card-delta { display: inline-flex; align-items: center; gap: 4px; }
.card-sub { display: block; font-size: 0.78rem; font-weight: 500; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.card.accent { border-color: #c7d6fb; background: linear-gradient(180deg, #fff, #f5f8ff); }
.card.money .card-value { color: #0a6b45; }

/* ---------- Period tabs ---------- */
.period-tabs { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px; gap: 2px; }
.period-tab { padding: 6px 14px; border-radius: 999px; font-size: 0.88rem; font-weight: 500; color: var(--ink-2); min-height: 44px; display: inline-flex; align-items: center; }
.period-tab:hover { text-decoration: none; background: var(--paper); }
.period-tab.active { background: var(--ink); color: #fff; }
.period-hint { margin: -8px 0 0; font-size: 0.86rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- To-do (Cần xử lý) ---------- */
.todo { display: grid; gap: 8px; }
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff;
}
.todo-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px; }
.todo-item .dot.warn { background: #f59e0b; }
.todo-item .dot.danger { background: var(--danger); }
.todo-item .dot.info { background: var(--brand); }
.todo-item .text { flex: 1; min-width: 0; }
.todo-item .text b { font-weight: 600; }
.todo-item .text small { display: block; color: var(--muted); font-size: 0.8rem; }
.todo-empty { color: var(--muted); display: flex; align-items: center; gap: 8px; }

/* ---------- Spark bars ---------- */
.spark { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 8px 4px 0; }
.spark-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; min-width: 0; }
.spark-bar { width: 100%; max-width: 38px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, #4f7cf0, var(--brand)); min-height: 3px; transition: filter 0.15s; }
.spark-col:hover .spark-bar { filter: brightness(1.12); }
.spark-label { font-size: 0.7rem; color: var(--muted); font-family: var(--mono); white-space: nowrap; }

/* ---------- Panels ---------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.panel h2 .count { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); font-weight: 500; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 18px; }
.panel.danger-zone { border-color: #f7c3bd; background: #fffafa; }

/* ---------- Tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; font-size: 0.9rem; }
th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 0.76rem; letter-spacing: 0.06em; text-transform: uppercase; position: sticky; top: 0; }
tbody tr:hover td { background: #fafbfd; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-family: var(--font); font-variant-numeric: tabular-nums; font-weight: 500; }
th.num { font-weight: 600; }
td .sub { display: block; color: var(--muted); font-size: 0.78rem; }

/* ---------- Buttons / forms ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 13px; background: var(--brand); color: var(--brand-ink);
  font: inherit; font-weight: 600; font-size: 0.88rem; cursor: pointer; text-decoration: none;
  transition: filter 0.12s, transform 0.08s, background 0.12s;
  white-space: nowrap;
}
.btn:hover, button:hover { filter: brightness(1.06); text-decoration: none; }
.btn:active, button:active { transform: translateY(1px); }
.btn.secondary, button.secondary { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn.secondary:hover, button.secondary:hover { background: var(--paper); filter: none; }
.btn.danger, button.danger { background: var(--danger); color: #fff; }
.btn.warn, button.warn { background: var(--warn); color: #fff; }
.btn.ghost, button.ghost { background: transparent; color: var(--brand); }
.btn.sm, button.sm { padding: 5px 9px; font-size: 0.8rem; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }
.inline { display: inline; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
form.row-actions input { width: auto; flex: 1; min-width: 200px; }
/* Ô bảng phải giữ display: table-cell, nếu không sẽ mất đường kẻ dòng & lệch cột */
td.row-actions { display: table-cell; white-space: nowrap; text-align: right; }
td.row-actions > * { vertical-align: middle; }
td.row-actions > * + * { margin-left: 6px; }

form.stack { display: grid; gap: 12px; max-width: 680px; }
form.stack.wide { max-width: 960px; }
label { display: grid; gap: 6px; align-content: start; font-size: 0.85rem; color: var(--ink-2); font-weight: 500; }
/* Ô trong cùng hàng lưới căn đáy cho thẳng, dù nhãn dài ngắn khác nhau */
.grid-2 > label, .grid-3 > label { grid-template-rows: 1fr auto; align-content: stretch; }
.grid-2 > label > :last-child, .grid-3 > label > :last-child { align-self: end; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font: inherit; color: var(--ink); background: #fff;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea { min-height: 110px; resize: vertical; }
input[type="checkbox"] { width: auto; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; margin: 0; }
.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.settings-group { display: grid; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.settings-group:first-of-type { border-top: 0; padding-top: 0; }
.settings-group h3 { margin: 0; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.settings-group .hint { font-size: 0.8rem; color: var(--muted); margin: -2px 0 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px;
  border-radius: 999px; font-size: 0.76rem; font-weight: 600; background: #eef2f6; color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-ok { background: var(--money-soft); color: #0a6b45; }
.badge-warn { background: #fff4d6; color: #92400e; }
.badge-muted { background: #eef2f6; color: var(--muted); }
.badge-danger { background: var(--danger-soft); color: #a3261b; }

pre.ticket-msg, pre.ticket-reply {
  white-space: pre-wrap; word-break: break-word; background: #f8fafc;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0;
  font-family: var(--font); font-size: 0.92rem;
}
pre.ticket-reply { background: var(--money-soft); border-color: #bde9d2; }
.ticket-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ticket-head .when { color: var(--muted); font-size: 0.82rem; margin-left: auto; }

.empty { padding: 28px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- Categories ---------- */
.drag-cell { width: 28px; padding-right: 0; }
.drag-handle { cursor: grab; color: var(--line-2); font-weight: 700; letter-spacing: -2px; user-select: none; }
.drag-handle:hover { color: var(--muted); }
tr.cat-row.is-dragging { opacity: 0.45; background: var(--brand-soft); }
tr.cat-row.is-hidden td { opacity: 0.6; }
tr.cat-row.is-hidden td .badge, tr.cat-row.is-hidden td .btn { opacity: 1; }
.icon-cell { width: 36px; font-size: 1.15rem; text-align: center; padding-right: 0; }
.nowrap { white-space: nowrap; }
.tips { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 0.9rem; color: var(--ink-2); }
.card.warn-card { border-color: #f9cfae; background: linear-gradient(180deg, #fff, var(--warn-soft)); }
.card.warn-card .card-value { color: #9a3412; }
label .sub { display: block; font-weight: 400; color: var(--muted); font-size: 0.78rem; }

/* ---------- Products ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[name="q"] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; max-width: 240px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line-2); color: var(--ink-2); font-size: 0.82rem; font-weight: 500;
}
.chip b { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 0.7rem; font-weight: 600;
  background: #eef2f6; color: var(--ink-2); vertical-align: middle; margin-left: 2px;
}
.tag-sale { background: #fff4d6; color: #92400e; }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bulk-bar select { width: auto; }
tr.is-hidden td { opacity: 0.6; }
tr.is-hidden td .badge, tr.is-hidden td .btn, tr.is-hidden td button { opacity: 1; }
details.collapsible > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary h2 { margin: 0; }
details.collapsible > summary::before { content: "▸"; color: var(--muted); font-size: 0.9rem; }
details.collapsible[open] > summary::before { content: "▾"; }
details.collapsible[open] > summary { margin-bottom: 12px; }

/* ---------- Stock ---------- */
.badge-info { background: var(--brand-soft); color: var(--brand); }
.spacer { flex: 1 1 auto; }
.stock-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.stock-tools .filters { flex: 1 1 300px; flex-wrap: nowrap; }
.stock-tools .filters input { flex: 1 1 auto; width: auto; min-width: 0; }
.key-lookup input { font-family: var(--mono); font-size: 0.86rem; }
.stock-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* Thanh "đủ bán": độ dài = số ngày đủ hàng / mục tiêu */
.cover { height: 6px; border-radius: 999px; background: #eef2f6; overflow: hidden; min-width: 96px; margin: 4px 0 3px; }
.cover i { display: block; height: 100%; border-radius: inherit; background: var(--money); transition: width 0.3s ease; }
.cover i.cover-out, .cover i.cover-critical { background: var(--danger); }
.cover i.cover-low { background: #f59e0b; }
.cover i.cover-reorder { background: var(--brand); }
.cover i.cover-idle, .cover i.cover-hidden { background: #cbd5e1; }
.cover.cover-nodata { background: repeating-linear-gradient(135deg, #eef2f6 0 6px, #f8fafc 6px 12px); }
.cover-cell { min-width: 130px; }
.card .cover { margin-top: 8px; }
.card-sub { display: block; font-size: 0.78rem; font-weight: 500; color: var(--muted); margin-top: 3px; letter-spacing: 0; }
.suggest { color: var(--brand); }
.tag-wait { background: #fff4d6; color: #92400e; }
.tag-faulty { background: var(--danger-soft); color: #a3261b; }
.tag-next { background: var(--money-soft); color: #0a6b45; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.suggest-pill { font-size: 0.8rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }

/* Nhập kho */
.import-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(250px, 1fr); gap: 18px; align-items: start; }
.import-form { display: grid; gap: 12px; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: 12px; background: #fbfcfe; transition: border-color 0.15s, background 0.15s; }
.dropzone:focus-within { border-color: var(--brand); border-style: solid; background: #fff; }
.dropzone.is-over { border-color: var(--brand); border-style: dashed; background: var(--brand-soft); }
.dropzone textarea {
  border: 0; border-radius: 12px 12px 0 0; background: transparent; box-shadow: none !important;
  min-height: 210px; font-family: var(--mono); font-size: 0.86rem; line-height: 1.65;
}
.dz-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px dashed var(--line); font-size: 0.82rem; }
.link { display: inline; color: var(--brand); font-weight: 600; cursor: pointer; font-size: inherit; }
.link:hover { text-decoration: underline; }
.import-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.import-actions #importBtn { min-width: 150px; }

.analysis {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: #fff;
  display: grid; gap: 12px; position: sticky; top: calc(var(--topbar-h) + 12px); min-height: 120px;
}
.analysis-empty { color: var(--muted); font-size: 0.9rem; align-self: center; }
.an-big { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.an-big b { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.02em; color: var(--money); line-height: 1; font-variant-numeric: tabular-nums; }
.an-big.zero b { color: var(--muted); }
.an-big span { color: var(--ink-2); font-weight: 500; }
.an-rows { display: grid; gap: 7px; font-size: 0.88rem; }
.an-row { display: flex; justify-content: space-between; gap: 12px; }
.an-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.an-row.warn span:last-child { color: #9a3412; }
.an-row.muted { color: var(--muted); }
.an-warn { display: grid; gap: 6px; }
.an-warn div { font-size: 0.84rem; padding: 7px 10px; border-radius: 8px; background: var(--warn-soft); color: #9a3412; }
.an-note { font-size: 0.84rem; color: var(--muted); }

/* Danh sách key */
.keys-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.tabs { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tab { padding: 6px 12px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: baseline; }
.tab b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab:hover { text-decoration: none; background: #fff; }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.tab.active b { color: var(--brand); }
.keys-search { flex: 0 1 240px; }
.keys-search input { height: 34px; padding: 4px 10px; font-family: var(--mono); font-size: 0.84rem; }
.check-cell { width: 34px; }
code.k { cursor: copy; transition: filter 0.15s; word-break: break-all; }
.keys-masked code.k { filter: blur(5px); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 0.86rem; }

/* Lô nhập: tỉ lệ đã bán / lỗi / còn */
.batch-cell { min-width: 160px; }
.stack-bar { display: flex; height: 6px; border-radius: 999px; background: #eef2f6; overflow: hidden; margin: 4px 0 3px; }
.stack-bar i { display: block; height: 100%; }
.stack-bar .s-sold { background: var(--money); }
.stack-bar .s-faulty { background: var(--danger); }
.stack-bar .s-left { background: #93b4f8; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px);
  background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 10px; font-size: 0.86rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 960px) {
  .import-grid { grid-template-columns: 1fr; }
  .analysis { position: static; }
  .keys-search { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .cover i, .toast, .dropzone, code.k { transition: none !important; }
}

/* ---------- Products: thanh công cụ ---------- */
.ptoolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.psearch {
  position: relative; display: flex; align-items: center; flex: 1 1 280px; max-width: 420px;
}
.psearch svg { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.psearch input { padding-left: 38px; padding-right: 36px; height: 40px; }
.psearch input::-webkit-search-cancel-button { display: none; }
.psearch kbd {
  position: absolute; right: 10px; font-family: var(--mono); font-size: 0.72rem; color: var(--muted);
  border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; line-height: 1.5; background: #fff;
}
.psearch input:focus + kbd { opacity: 0; }
.pcat select { height: 40px; width: auto; min-width: 170px; }
.result-count { font-size: 0.84rem; font-variant-numeric: tabular-nums; }
.chip-danger { border-color: #f7c3bd; color: #a3261b; background: var(--danger-soft); }
.chip-warn { border-color: #f9cfae; color: #9a3412; background: var(--warn-soft); }

/* Bảng */
.name-cell .pname { font-weight: 600; color: var(--ink); }
.name-cell .pname:hover { color: var(--brand); }
.name-cell .tag { margin-left: 6px; }
.th-sort { color: inherit; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.th-sort:hover { color: var(--ink); text-decoration: none; }
.th-sort.active { color: var(--brand); }
.th-sort .arrow { font-size: 0.9em; }
tr.is-selected td { background: var(--brand-soft) !important; }
.warn-text { color: #9a3412 !important; font-weight: 600; }

/* Giá: bấm để sửa */
.price-edit {
  color: var(--ink); border-radius: 6px; padding: 2px 6px; margin: -2px -6px; cursor: text;
  border: 1px dashed transparent; display: inline-block; white-space: nowrap;
}
.price-edit:hover { border-color: var(--line-2); background: #fff; text-decoration: none; }
.price-edit s { color: var(--muted); font-weight: 400; margin-right: 2px; }
.price-input { width: 120px; height: 32px; padding: 4px 8px; text-align: right; font-variant-numeric: tabular-nums; }
.flash-cell { animation: cellFlash 0.9s ease-out; }
@keyframes cellFlash { from { background: var(--money-soft); } to { background: transparent; } }

/* Tồn kho dạng viên, bấm mở kho */
.stock-pill {
  display: inline-block; min-width: 34px; padding: 2px 9px; border-radius: 999px; text-align: center;
  font-weight: 600; font-size: 0.84rem; border: 1px solid var(--line); color: var(--ink-2); background: #fff;
}
.stock-pill:hover { text-decoration: none; border-color: var(--brand); color: var(--brand); }
.stock-pill.stock-warn { background: #fff4d6; border-color: #f9e1a8; color: #92400e; }
.stock-pill.stock-danger { background: var(--danger-soft); border-color: #f7c3bd; color: #a3261b; }

/* Công tắc hiện / ẩn */
.switch-cell { width: 60px; }
.switch {
  position: relative; width: 40px; height: 22px; padding: 0; border-radius: 999px;
  background: #cbd5e1; border: 0; transition: background 0.18s; flex: 0 0 auto;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25); transition: transform 0.18s;
}
.switch.on { background: var(--money); }
.switch.on .knob { transform: translateX(18px); }
.switch:hover { filter: brightness(1.05); }
.switch:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch[disabled] { opacity: 0.7; cursor: progress; }

.empty-live { margin: 14px 0 0; color: var(--muted); text-align: center; }

/* Thanh thao tác khi chọn nhiều (JS biến thành thanh nổi) */
.selbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 4px; }
.selbar select { width: auto; height: 32px; padding: 4px 8px; font-size: 0.84rem; }
.selbar-count { font-size: 0.88rem; font-weight: 500; margin-right: 4px; }
.selbar.floating {
  position: fixed; left: 50%; bottom: 20px; z-index: 45; margin: 0;
  transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 8px 10px 8px 16px; border-radius: 14px;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.3); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s;
  max-width: calc(100vw - 32px);
}
.selbar.floating.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.selbar.floating .btn.secondary, .selbar.floating button.secondary { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.18); }
.selbar.floating .btn.secondary:hover, .selbar.floating button.secondary:hover { background: rgba(255,255,255,0.18); }
.selbar.floating button.ghost { background: transparent; color: #c7d2e6; }
.selbar.floating select { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.18); }
.selbar.floating select option { color: var(--ink); }
/* Căn giữa vùng nội dung (trừ sidebar) thay vì giữa cả cửa sổ */
@media (min-width: 961px) {
  .toast, .selbar.floating { left: calc(50% + var(--sidebar-w) / 2); }
}
.toast-warn { background: #9a3412; }
.toast-error { background: var(--danger); }
.panel.danger-zone { display: flex; justify-content: flex-end; padding: 12px 16px; }

@media (max-width: 960px) {
  .psearch { max-width: none; }
  .result-count { display: none; }
  .selbar.floating { left: 16px; right: 16px; transform: translateY(140%); bottom: 12px; }
  .selbar.floating.show { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .switch, .switch .knob, .selbar.floating, .flash-cell { transition: none !important; animation: none !important; }
}

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-nav {
  position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 2px;
  padding: 6px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
.settings-nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-size: 0.88rem; font-weight: 500;
}
.settings-nav a:hover { background: var(--paper); text-decoration: none; }
.settings-nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.settings-nav .dot { width: 8px; height: 8px; border-radius: 50%; background: #f59e0b; flex: 0 0 8px; }
.settings-main { display: grid; gap: 18px; min-width: 0; }
.settings-main form { display: grid; gap: 18px; }
.settings-section { scroll-margin-top: calc(var(--topbar-h) + 16px); padding: 20px 22px; }
.settings-section > h2 { font-size: 1.05rem; margin: 0 0 6px; }
.settings-section .block + .block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.settings-section h3 { margin: 6px 0 4px; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* Dòng cài đặt: nhãn trái, điều khiển phải */
.srow {
  display: grid; grid-template-columns: minmax(180px, 34%) minmax(0, 1fr); gap: 16px; align-items: start;
  padding: 10px 0; border-bottom: 1px dashed var(--line);
}
.srow > .srow-label { padding-top: 10px; }
.srow-bool { align-items: center; }
.srow-bool > .srow-label { padding-top: 0; }
.srow:last-child { border-bottom: 0; }
.srow-label { font-size: 0.9rem; color: var(--ink-2); font-weight: 500; display: block; }
.srow-control { min-width: 0; display: grid; gap: 8px; justify-items: start; }
.srow-control > * { max-width: 100%; }
.srow-control > input, .srow-control > select, .srow-control > textarea, .srow-control > .affix { width: 100%; }
.srow-control input, .srow-control select, .srow-control textarea { max-width: 460px; }
.srow-control textarea { min-height: 70px; }
.srow-bool .srow-control { justify-items: start; }
.srow-advanced .srow-label { color: var(--muted); font-weight: 400; }
.is-off { opacity: 0.45; transition: opacity 0.15s; }
.is-off:focus-within { opacity: 1; }
input.upper { text-transform: uppercase; }

/* Ô có đơn vị */
.affix { display: flex; align-items: stretch; max-width: 460px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: #fff; overflow: hidden; }
.affix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.affix input { border: 0 !important; box-shadow: none !important; border-radius: 0; min-width: 0; flex: 1 1 auto; }
.affix > span { display: flex; align-items: center; padding: 0 12px; background: #f8fafc; color: var(--muted); font-size: 0.86rem; border-left: 1px solid var(--line); white-space: nowrap; }
.affix.affix-left > span { border-left: 0; border-right: 1px solid var(--line); }
.code-affix { max-width: 260px; }
.code-affix input { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; flex: 0 1 90px; padding-right: 0; }
.code-affix .affix-ghost { background: transparent; border-left: 0; padding-left: 0; font-family: var(--mono); letter-spacing: 0.06em; color: #b6bfcc; }

/* Công tắc dạng checkbox */
.toggle { position: relative; display: inline-flex; width: 42px; height: 24px; }
.toggle input[type="checkbox"] { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.toggle-track { position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1; transition: background 0.18s; }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.25); transition: transform 0.18s; }
.toggle input:checked + .toggle-track { background: var(--money); }
.toggle input:checked + .toggle-track .toggle-knob { transform: translateX(18px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--brand); outline-offset: 2px; }
.toggle input:disabled { cursor: not-allowed; }
.toggle input:disabled + .toggle-track { opacity: 0.6; }

/* Chọn cổng dạng nút */
.segmented { display: inline-flex; flex-wrap: wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented label { position: relative; display: block; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 8px; font-size: 0.88rem; font-weight: 600; color: var(--ink-2); }
.segmented input:checked + span { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.segmented input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 1px; }

.copy-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.copy-field code { padding: 7px 10px; border-radius: 8px; background: #f8fafc; border: 1px solid var(--line); word-break: break-all; font-size: 0.8rem; }
.test-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.test-result { font-size: 0.86rem; color: var(--muted); }
.test-result.is-ok { color: #0a6b45; font-weight: 600; }
.test-result.is-bad { color: #a3261b; font-weight: 600; }

/* Ngân hàng + QR mẫu */
.bank-grid { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 20px; align-items: start; }
.bank-grid .srow { grid-template-columns: minmax(150px, 40%) minmax(0, 1fr); }
.bin-other { max-width: 160px !important; font-family: var(--mono); }
.qr-preview {
  margin: 8px 0 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff;
  display: grid; justify-items: center; gap: 8px; text-align: center;
}
.qr-preview img { width: 164px; height: 164px; object-fit: contain; border-radius: 8px; background: #f8fafc; }
.qr-preview figcaption { font-size: 0.8rem; color: var(--muted); }
.qr-preview.is-empty img, .qr-preview.is-error img { visibility: hidden; height: 0; }
.qr-preview.is-empty, .qr-preview.is-error { min-height: 120px; align-content: center; border-style: dashed; }
.qr-preview.is-loading img { opacity: 0.4; }

/* Gói nạp + lời chào */
.pkg-preview { display: flex; flex-wrap: wrap; gap: 6px; }
.pkg { padding: 5px 12px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); font-size: 0.82rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bot-bubble {
  max-width: 360px; padding: 10px 12px; border-radius: 14px 14px 14px 4px; background: #eef4ff; border: 1px solid #dbe6fd;
  display: grid; gap: 4px; font-size: 0.88rem; white-space: pre-wrap; word-break: break-word;
}
.bot-bubble b { font-weight: 700; }
.bubble-meta { color: var(--muted); font-size: 0.8rem; }

/* Bảng hạng VIP */
.vip-editor { display: grid; gap: 8px; padding: 6px 0 4px; }
.mini-table { width: 100%; max-width: 620px; border-collapse: separate; border-spacing: 0 6px; background: transparent; }
.mini-table th { background: transparent; text-transform: none; letter-spacing: 0; font-size: 0.8rem; color: var(--muted); padding: 0 6px; border: 0; position: static; }
.mini-table td { padding: 0 6px 0 0; border: 0; background: transparent !important; }
.mini-table input { height: 36px; }
.mini-table .affix { max-width: 190px; }
#vipAdd { justify-self: start; }

/* Thanh lưu (JS biến thành thanh nổi khi có thay đổi) */
.savebar { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.savebar.floating {
  position: fixed; bottom: 20px; left: 50%; z-index: 45; transform: translate(-50%, 140%); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 8px 10px 8px 18px; border-radius: 14px;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.3); transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s;
}
.savebar.floating.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.savebar.floating button.ghost { background: transparent; color: #c7d2e6; }
.savebar-text { font-size: 0.88rem; font-weight: 500; margin-right: 6px; }
.savebar:not(.floating) .savebar-text { display: none; }

/* Hệ thống */
.backup-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 4px; font-size: 0.86rem; }
.backup-list li { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.backup-list a { font-family: var(--mono); font-size: 0.82rem; }
.sysinfo { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 18px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.sysinfo div { display: grid; gap: 2px; }
.sysinfo dt { font-size: 0.76rem; color: var(--muted); }
.sysinfo dd { margin: 0; font-weight: 600; font-size: 0.9rem; word-break: break-word; }

@media (min-width: 961px) {
  .savebar.floating { left: calc(50% + var(--sidebar-w) / 2); }
}
@media (max-width: 960px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav {
    position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; border-radius: 12px;
  }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav a { white-space: nowrap; }
  .settings-section { padding: 16px; }
  .srow, .bank-grid .srow { grid-template-columns: 1fr; gap: 6px; }
  .srow-bool { grid-template-columns: 1fr auto; }
  .bank-grid { grid-template-columns: 1fr; }
  .qr-preview { justify-self: start; }
  .savebar.floating { left: 16px; right: 16px; transform: translateY(140%); justify-content: space-between; }
  .savebar.floating.show { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .toggle-track, .toggle-knob, .savebar.floating, .is-off { transition: none !important; }
}

/* ---------- Orders ---------- */
.segnav { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.segnav .seg { padding: 6px 12px; border-radius: 8px; font-size: 0.86rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.segnav .seg:hover { text-decoration: none; background: #fff; }
.segnav .seg.active { background: #fff; color: var(--brand); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.range-form { display: inline-flex; align-items: center; gap: 6px; }
.range-form input[type="date"] { width: auto; height: 36px; padding: 4px 8px; font-size: 0.84rem; }
.range-form.is-active input { border-color: var(--brand); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 0.82rem; font-weight: 600;
}
.filter-pill:hover { text-decoration: none; background: #dbe5fc; }
.summary-strip {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; margin-top: 14px;
  background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.summary-strip > div { background: #fff; padding: 10px 14px; display: grid; gap: 2px; min-width: 0; }
.summary-strip span { font-size: 0.76rem; color: var(--muted); }
.summary-strip b { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.money-text { color: #0a6b45; }

tr.day-row td {
  background: #f8fafc !important; padding: 7px 12px; font-size: 0.8rem; color: var(--muted);
  border-bottom: 1px solid var(--line); position: sticky; top: 38px; z-index: 1;
}
tr.day-row td b { color: var(--ink-2); margin-right: 10px; }
.chips .pcat select { height: 32px; min-width: 150px; padding: 4px 8px; font-size: 0.84rem; }
tr.order-row { cursor: pointer; }
tr.order-row .oid { font-weight: 700; font-variant-numeric: tabular-nums; }
tr.order-row .cust { color: var(--ink); font-weight: 600; }
tr.order-row .cust:hover { color: var(--brand); }
.status-cell { white-space: nowrap; }
.status-cell .badge + .badge { margin-left: 4px; }
.tag.src-bot { background: #eef2f6; color: var(--ink-2); }
.tag.src-qr { background: var(--brand-soft); color: var(--brand); }
.tag.src-api { background: #f3e8ff; color: #6b21a8; }
.tag-new { background: var(--money-soft); color: #0a6b45; }

/* Chi tiết đơn */
.order-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.order-nav { display: inline-flex; gap: 4px; }
.order-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.order-main, .order-side { display: grid; gap: 18px; min-width: 0; }
.order-side { position: sticky; top: calc(var(--topbar-h) + 16px); }
.cust-head { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.cust-head b { font-size: 1rem; }
.avatar.lg { width: 42px; height: 42px; font-size: 1rem; background: var(--brand-soft); color: var(--brand); flex: 0 0 42px; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin: 0 0 14px; }
.kv div { display: grid; gap: 2px; min-width: 0; }
.kv dt { font-size: 0.76rem; color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-rows { grid-template-columns: 1fr; gap: 0; margin: 0; }
.kv-rows div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: baseline; }
.kv-rows div:last-child { border-bottom: 0; }
.kv-rows dt { font-size: 0.86rem; }
.kv-rows dd { text-align: right; font-weight: 500; }
.kv dd .sub { display: block; text-align: right; font-weight: 400; }
.msg-box { margin-top: 10px; }
.msg-box > summary { list-style: none; display: inline-flex; }
.msg-box > summary::-webkit-details-marker { display: none; }
.msg-box[open] > summary { margin-bottom: 10px; }
.msg-box form.stack { max-width: none; }
.side-h { margin: 16px 0 6px; font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.mini-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.86rem; }
.mini-list li { display: flex; gap: 6px; align-items: baseline; min-width: 0; }
.mini-list .mini-right { margin-left: auto; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Dòng thời gian */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; display: grid; gap: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; border-left: 2px solid var(--line); margin-left: 5px; }
.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 #94a3b8;
}
.timeline li.tl-ok::before { border-color: var(--money); background: var(--money-soft); }
.timeline li.tl-pay::before { border-color: var(--brand); background: var(--brand-soft); }
.timeline li.tl-warn::before { border-color: #f59e0b; background: #fff4d6; }
.timeline li.tl-bad::before { border-color: var(--danger); background: var(--danger-soft); }
.timeline li.tl-info::before { border-color: #8b5cf6; background: #f3e8ff; }
.tl-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.tl-head b { font-weight: 600; font-size: 0.92rem; }
.tl-head time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.tl-detail { font-size: 0.86rem; color: var(--ink-2); margin-top: 3px; word-break: break-word; }
.tl-reply, .tl-keys { display: block; margin-top: 4px; color: var(--muted); }

@media (max-width: 1100px) {
  .summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .order-grid { grid-template-columns: 1fr; }
  .order-side { position: static; }
  .summary-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .range-form { width: 100%; }
  .range-form input[type="date"] { flex: 1 1 0; min-width: 0; }
  tr.day-row td { position: static; }
}

/* ---------- Deposits ---------- */
.nav-badge.danger { background: var(--danger); color: #fff; }
.nav-link.active .nav-badge.danger { background: #fff; color: var(--danger); }
.view-tabs .nav-badge { display: inline-grid; min-width: 20px; height: 18px; font-size: 0.7rem; margin-left: 4px; vertical-align: 1px; }
.alert-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-radius: 12px;
  background: var(--danger-soft); border: 1px solid #f7c3bd; color: #a3261b; font-weight: 600; font-size: 0.92rem;
}
.alert-bar:hover { text-decoration: none; filter: brightness(0.98); }
.alert-bar b { padding: 4px 12px; border-radius: 8px; background: var(--danger); color: #fff; font-size: 0.84rem; }
.pulse-bar {
  position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 46;
  display: flex; align-items: center; gap: 12px; padding: 7px 8px 7px 16px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: 0.88rem; box-shadow: 0 12px 30px rgba(16, 24, 40, 0.25);
}
@media (min-width: 961px) { .pulse-bar { left: calc(50% + var(--sidebar-w) / 2); } }
.countdown { font-variant-numeric: tabular-nums; }
.countdown.is-soon { color: #9a3412 !important; font-weight: 600; }
.countdown.is-over { color: var(--muted) !important; }
.big-amount { font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }

/* Hộp giao dịch ngân hàng */
.txn-list { display: grid; gap: 10px; }
.txn {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 1.2fr); gap: 16px; align-items: start;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
}
.txn.is-matched, .txn.is-ignored { opacity: 0.75; box-shadow: none; }
.txn-main { display: grid; gap: 4px; min-width: 0; }
.txn-amount { font-size: 1.25rem; font-weight: 800; color: #0a6b45; font-variant-numeric: tabular-nums; }
.txn-content { justify-self: start; max-width: 100%; word-break: break-all; font-size: 0.86rem; }
.txn-side { display: grid; gap: 8px; min-width: 0; justify-items: stretch; }
.txn-side > .badge { justify-self: start; }
.sug {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px 9px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe;
}
.sug b { font-size: 0.9rem; }
.sug .sub { display: block; }
.sug-info { background: var(--brand-soft); border-color: #cfdcfb; }
.sug-list { display: grid; gap: 8px; }
.txn-manual { display: flex; gap: 6px; }
.txn-manual input { height: 32px; padding: 4px 10px; font-size: 0.84rem; min-width: 0; flex: 1 1 auto; }
.txn-side .inline { justify-self: start; }
.qr-panel { display: grid; justify-items: center; gap: 8px; text-align: center; }
.qr-panel img { width: 100%; max-width: 240px; border-radius: 10px; }
.qr-panel.is-error img { display: none; }
.qr-panel.is-error::before { content: "Không tạo được QR — kiểm tra ngân hàng trong Cài đặt"; font-size: 0.84rem; color: #9a3412; }

@media (max-width: 960px) {
  .txn { grid-template-columns: 1fr; }
  .alert-bar { flex-wrap: wrap; }
}

/* ---------- Customers ---------- */
.cust-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cust-cell .avatar { width: 34px; height: 34px; flex: 0 0 34px; font-size: 0.86rem; }
.avatar.xl { width: 58px; height: 58px; flex: 0 0 58px; font-size: 1.4rem; border-radius: 16px; }
.tag-vip { background: #fef3c7; color: #92400e; }
.summary-strip b small { font-size: 0.8rem; font-weight: 500; }
.profile-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.profile-id { flex: 1 1 280px; min-width: 0; display: grid; gap: 4px; }
.profile-id h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.insights { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.insights .tag, .insights .badge { margin: 0; font-size: 0.78rem; padding: 3px 9px; }
.profile-actions { margin-left: auto; }
td.num, th.num, td.nowrap { white-space: nowrap; }
td.pos { color: #0a6b45; font-weight: 600; }
td.neg { color: #a3261b; font-weight: 600; }
.tag.tx-deposit, .tag.tx-gift, .tag.tx-referral { background: var(--money-soft); color: #0a6b45; }
.tag.tx-purchase { background: #eef2f6; color: var(--ink-2); }
.tag.tx-refund { background: #fff4d6; color: #92400e; }
.tag.tx-admin_adjust { background: var(--brand-soft); color: var(--brand); }
.vip-progress { display: grid; gap: 4px; }
.vip-now { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.vip-progress .cover { height: 8px; margin: 4px 0; }
.adjust-form { max-width: none; gap: 10px; }
.adjust-form .segmented { justify-self: start; }
.adjust-form .affix { max-width: none; }
.adjust-form button { justify-self: start; }

@media (max-width: 960px) {
  .profile-actions { margin-left: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40;
    transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: 0 0 40px rgba(0,0,0,0.3);
  }
  #nav-open:checked ~ .shell .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: rgba(16,24,40,0.45); z-index: 30; }
  #nav-open:checked ~ .shell .nav-scrim { display: block; }
  .menu-toggle {
    display: inline-grid; place-items: center; width: 40px; height: 40px;
    border-radius: 10px; border: 1px solid var(--line-2); background: #fff; cursor: pointer;
  }
  .menu-toggle svg { width: 20px; height: 20px; }
  .topbar { padding: 0 16px; gap: 10px; height: auto; min-height: var(--topbar-h); flex-wrap: wrap; padding-top: 10px; padding-bottom: 10px; }
  .topbar h1 { font-size: 1.05rem; }
  .lookup { width: 100%; margin-left: 0; order: 3; }
  .lookup-hint { display: none; }
  .content { padding: 16px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters select, .bulk-bar select { max-width: 100%; flex: 1 1 140px; }
}
@media (prefers-reduced-motion: reduce) {
  .sidebar, .btn, button, .spark-bar { transition: none !important; }
}

/* ===== Login ===== */
.login-body { background: var(--paper); min-height: 100vh; }
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 44%) 1fr;
}

/* --- cột thương hiệu --- */
.login-side {
  position: relative; overflow: hidden;
  background: linear-gradient(160deg, #16284a 0%, var(--nav-bg) 45%, var(--nav-bg-2) 100%);
  color: var(--nav-ink);
  padding: 40px 44px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px;
}
.side-grid {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse at 30% 20%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 20%, #000 20%, transparent 75%);
}
.side-glow {
  position: absolute; width: 520px; height: 520px; right: -200px; bottom: -220px; pointer-events: none;
  background: radial-gradient(circle, rgba(36,87,230,0.55), rgba(18,163,106,0.18) 45%, transparent 70%);
  filter: blur(10px);
  animation: glowDrift 14s ease-in-out infinite alternate;
}
.side-top, .side-mid, .side-bottom { position: relative; }
.side-brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; font-size: 1.05rem; }
.side-brand small { display: block; font-weight: 500; font-size: 0.74rem; color: var(--nav-ink); opacity: 0.75; }
.brand-mark.big { width: 40px; height: 40px; border-radius: 11px; font-size: 1.05rem; }
.side-kicker { margin: 0 0 10px; font-size: 0.74rem; letter-spacing: 0.14em; text-transform: uppercase; color: #8fb0ff; font-weight: 600; }
.side-title { margin: 0 0 22px; font-size: clamp(1.5rem, 2.4vw, 2.1rem); line-height: 1.2; color: #fff; font-weight: 800; letter-spacing: -0.02em; }
.side-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 0.95rem; }
.side-points li { display: flex; align-items: center; gap: 12px; }
.side-points i {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 22px;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  position: relative;
}
.side-points i::after {
  content: ""; position: absolute; left: 7px; top: 4px; width: 5px; height: 9px;
  border: solid #4ade80; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.side-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 0.86rem; }
.status { display: inline-flex; align-items: center; gap: 9px; padding: 6px 12px 6px 9px; border-radius: 999px; background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1); }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #94a3b8; box-shadow: 0 0 0 0 rgba(148,163,184,0.5); }
.status.is-up .status-dot { background: #4ade80; animation: pulse 2s ease-out infinite; }
.status.is-down .status-dot { background: #f87171; }
.side-meta { color: var(--nav-ink); opacity: 0.7; font-size: 0.78rem; }

/* --- cột form --- */
.login-main { display: grid; place-items: center; padding: 48px 24px; }
.login-form { width: min(400px, 100%); display: grid; gap: 16px; animation: riseIn 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.form-head h1 { margin: 0 0 6px; font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em; }
.form-head p { margin: 0; font-size: 0.92rem; }
.form-brand-mobile { display: none; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 18px; }

.login-alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  background: var(--danger-soft); color: #a3261b; border: 1px solid #f7c3bd;
  font-size: 0.9rem; font-weight: 500;
}
.login-alert svg { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 1px; }
.login-alert.is-locked { background: var(--warn-soft); color: #9a3412; border-color: #f9cfae; font-variant-numeric: tabular-nums; }
.has-error .login-alert { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }

.login-form .field { display: grid; gap: 6px; }
.login-form .field > span, .field-label-row label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.field-label-row { display: flex; justify-content: space-between; align-items: baseline; }
.caps-hint { font-size: 0.76rem; color: #9a3412; background: var(--warn-soft); padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.login-form input[type="text"], .login-form input[type="password"], .login-form input:not([type]) {
  height: 48px; padding: 0 14px; font-size: 1rem; border-radius: 12px;
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; font-family: var(--mono); letter-spacing: 0.08em; }
.password-wrap input[type="text"] { letter-spacing: 0.04em; }
.toggle-pass {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; padding: 0; border-radius: 9px;
  background: transparent; color: var(--muted); border: 0; display: grid; place-items: center;
}
.toggle-pass:hover { background: var(--paper); color: var(--ink); filter: none; }
.toggle-pass svg { width: 20px; height: 20px; display: block; }
.toggle-pass .icon-eye-off { display: none; }
.toggle-pass.is-on .icon-eye { display: none; }
.toggle-pass.is-on .icon-eye-off { display: block; }

.remember { display: flex; align-items: center; gap: 9px; font-size: 0.88rem; color: var(--ink-2); font-weight: 500; cursor: pointer; }
.remember input { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; }

.login-submit {
  position: relative; height: 50px; border-radius: 12px; font-size: 1rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(180deg, #3366ff, var(--brand));
  box-shadow: 0 10px 24px rgba(36,87,230,0.28);
  transition: transform 0.08s, box-shadow 0.15s, filter 0.15s;
}
.login-submit:hover { box-shadow: 0 14px 30px rgba(36,87,230,0.36); }
.login-submit:active { transform: translateY(1px); }
.login-submit .arrow { width: 18px; height: 18px; transition: transform 0.15s; }
.login-submit:hover .arrow { transform: translateX(3px); }
.login-submit .spinner {
  display: none; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin 0.8s linear infinite;
}
.login-submit.is-loading .arrow { display: none; }
.login-submit.is-loading .spinner { display: block; }
.login-submit.is-loading .label::after { content: "…"; }
.login-submit[disabled] { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
.form-help { margin: 4px 0 0; font-size: 0.82rem; line-height: 1.5; }

@keyframes riseIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); }
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.6); } 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glowDrift { from { transform: translate(0, 0); } to { transform: translate(-60px, -40px); } }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .form-brand-mobile { display: flex; }
  .login-main { padding: 40px 20px; align-items: start; }
}
@media (prefers-reduced-motion: reduce) {
  .login-form, .login-alert, .side-glow, .status-dot, .login-submit .arrow { animation: none !important; transition: none !important; }
}

/* ===== Mã giảm giá & quà tặng ===== */
.v-form { gap: 14px; }
.v-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 14px; align-items: start; }
.v-form-side .v-grid { grid-template-columns: minmax(0, 1fr); }
.field { display: grid; gap: 6px; align-content: start; font-size: 0.85rem; color: var(--ink-2); font-weight: 500; min-width: 0; }
.field .segmented { justify-self: start; }
.v-form .affix { max-width: none; }
.code-input input { font-family: var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
.code-input button { border-radius: 0; border: 0; border-left: 1px solid var(--line); white-space: nowrap; }
.mono-up { font-family: var(--mono); letter-spacing: 0.05em; text-transform: uppercase; }
.v-check { align-self: end; min-height: 40px; display: flex; align-items: center; gap: 10px; font-weight: 500; }
.quick-dates { display: flex; flex-wrap: wrap; gap: 4px; }
.quick-dates .chip { font: inherit; font-size: 0.76rem; font-weight: 500; padding: 2px 9px; background: #fff; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; }
.quick-dates .chip:hover { border-color: var(--brand); color: var(--brand); filter: none; }

/* :has() — đổi trường theo lựa chọn không cần JS */
.v-form:has(input[name="mode"][value="bulk"]:checked) .only-single,
.v-form:has(input[name="mode"][value="bulk"]:checked) .only-single-label { display: none; }
.v-form:not(:has(input[name="mode"][value="bulk"]:checked)) .only-bulk,
.v-form:not(:has(input[name="mode"][value="bulk"]:checked)) .only-bulk-label { display: none; }
.v-form:has(input[name="discount_type"][value="fixed"]:checked) .only-percent { display: none; }
.v-form:not(:has(input[name="discount_type"][value="fixed"]:checked)) .only-fixed { display: none; }

.v-preview {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--brand-soft); border: 1px dashed #b9cdfb; color: var(--ink);
}
.v-preview b { font-weight: 700; }
.v-preview [data-p="example"] { color: var(--ink-2); font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.v-preview .warn-text { flex-basis: 100%; font-size: 0.82rem; }
.v-preview.is-bad { background: var(--danger-soft); border-color: #f7c3bd; color: #a3261b; }

.v-code { font-family: var(--mono); font-weight: 600; letter-spacing: 0.03em; color: var(--ink); }
.v-code:hover { color: var(--brand); }
td .sub .tag { font-size: 0.72rem; padding: 0 6px; vertical-align: 1px; }
.use-bar { display: block; width: 64px; height: 4px; margin: 5px 0 0 auto; border-radius: 999px; background: #eef2f6; overflow: hidden; }
.use-bar i { display: block; height: 100%; background: var(--brand); }
.use-bar.near i { background: var(--warn); }
.use-bar.full i { background: #94a3b8; }
.campaign-select { width: auto; height: 36px; padding: 4px 10px; font-size: 0.86rem; max-width: 220px; }
.chips-action { margin-left: auto; }
.create-panel > summary h2 { font-size: 1rem; }
.v-title { margin: 0; font-size: 1.35rem; }
.v-title code.k { font-size: inherit; padding: 2px 10px; cursor: copy; }
.v-desc { margin: 6px 0 16px; color: var(--ink-2); }
.v-holding { font-weight: 400; font-size: 0.86rem; }
.btn.full, button.full { width: 100%; justify-content: center; text-align: center; }
.btn.danger.ghost, button.danger.ghost { background: transparent; color: var(--danger); border-color: #f7c3bd; }
.btn.danger.ghost:hover, button.danger.ghost:hover { background: var(--danger-soft); filter: none; }
@media (max-width: 640px) {
  .chips-action { margin-left: 0; }
  .campaign-select { max-width: 100%; }
}

/* Dải tổng hợp: không để ô trống khi số ô lẻ */
@media (min-width: 1101px) {
  .summary-strip.s4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .summary-strip.s3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1100px) and (min-width: 961px) {
  .summary-strip > div:last-child:nth-child(3n + 1) { grid-column: span 3; }
  .summary-strip > div:last-child:nth-child(3n + 2) { grid-column: span 2; }
}
@media (max-width: 960px) {
  .summary-strip > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.panel > .summary-strip:first-child { margin-top: 0; }

/* ===== Hỗ trợ (ticket) ===== */
.tk-row.is-todo td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tk-snippet { color: var(--ink-2); max-width: 520px; font-size: 0.88rem; line-height: 1.45; }
.tk-from { color: var(--muted); font-weight: 600; }
.tk-count { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: 0.74rem; font-weight: 700; color: var(--ink-2); }
.tk-wait { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--paper); color: var(--ink-2); white-space: nowrap; }
.tk-wait.is-warn { background: var(--warn-soft); color: #9a3412; }
.tk-wait.is-danger { background: var(--danger-soft); color: #a3261b; }
.tk-title { margin: 0; font-size: 1.3rem; }

.tk-thread { display: flex; flex-direction: column; gap: 12px; max-height: min(62vh, 640px); overflow-y: auto; scroll-behavior: auto; }
.tk-msg { display: grid; gap: 4px; max-width: min(78%, 560px); }
.tk-msg.tk-user { align-self: flex-start; }
.tk-msg.tk-admin, .tk-msg.tk-note { align-self: flex-end; justify-items: end; }
.tk-bubble { padding: 10px 13px; border-radius: 16px; font-size: 0.92rem; line-height: 1.5; word-break: break-word; white-space: normal; }
.tk-user .tk-bubble { background: #f1f5f9; color: var(--ink); border-bottom-left-radius: 5px; }
.tk-admin .tk-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.tk-note .tk-bubble { background: #fff8e1; color: #6b4e00; border: 1px dashed #f0cf7a; border-bottom-right-radius: 5px; }
.tk-meta { font-size: 0.76rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tk-meta b { color: var(--ink-2); font-weight: 600; }
.tk-meta .ghost.sm { padding: 0 4px; }
.tk-msg.flash-cell .tk-bubble { box-shadow: 0 0 0 3px var(--brand-soft); }
.tk-sys { text-align: center; font-size: 0.76rem; color: var(--muted); }
.tk-sys span { background: var(--paper); padding: 3px 10px; border-radius: 999px; }

.tk-form { max-width: none; }
.tk-form textarea { min-height: 96px; resize: vertical; }
.tk-form:has(input[name="mode"][value="note"]:checked) .only-reply { display: none; }
.tk-form:not(:has(input[name="mode"][value="note"]:checked)) .only-note { display: none; }
.tk-form:has(input[name="mode"][value="note"]:checked) textarea { background: #fffdf3; border-color: #f0cf7a; }
.tk-actions { align-items: center; }
.tk-next { font-weight: 500; font-size: 0.84rem; margin-left: 4px; }
.tpl-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl { position: relative; display: inline-flex; }
.tpl .chip { font: inherit; font-size: 0.8rem; font-weight: 500; padding: 4px 22px 4px 10px; background: #fff; color: var(--ink-2); border: 1px solid var(--line); border-radius: 999px; cursor: pointer; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl .chip:hover { border-color: var(--brand); color: var(--brand); filter: none; }
.tpl-x { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: transparent; color: var(--muted); border: 0; padding: 0 4px; font-size: 0.95rem; line-height: 1; opacity: 0; }
.tpl-x:active { transform: translateY(-50%); }
.tpl:hover .tpl-x, .tpl-x:focus-visible { opacity: 1; }
.tpl-x:hover { color: var(--danger); filter: none; }
.tk-key { margin: 10px 0 12px; font-size: 0.8rem; color: var(--muted); }
.tk-key code { display: block; margin-top: 4px; }
@media (hover: none) { .tpl-x { opacity: 1; } }
@media (max-width: 640px) {
  .tk-msg { max-width: 92%; }
  .tk-thread { max-height: none; }
}

/* ---------- Dashboard Tổng quan ---------- */
/* Dải chỉ số phụ: một dòng, không tranh spotlight với KPI */
.dash-sub {
  display: flex; flex-wrap: wrap; gap: 8px 22px;
  padding: 4px 2px 0; font-size: 0.86rem; color: var(--muted);
}
.dash-sub b { color: var(--ink-2); font-weight: 700; margin-left: 4px; }

/* Hàng đợi theo mức gấp */
.todo-groups { display: grid; gap: 14px; }
.todo-group-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.todo-more { font-size: 0.8rem; font-weight: 600; letter-spacing: 0; text-transform: none; white-space: nowrap; }
.todo-more:hover { text-decoration: none; color: var(--ink); }
.todo-group-h .count { font-family: var(--mono); font-weight: 500; }
.todo-item.is-urgent { border-color: #f7c3bd; background: #fffafa; }
.todo-ic { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; }
.todo-ic svg { width: 18px; height: 18px; }
.todo-ic.danger { background: var(--danger-soft); color: #a3261b; }
.todo-ic.warn { background: #fff4d6; color: #92400e; }
.todo-ic.info { background: var(--brand-soft); color: var(--brand); }
.todo-item .btn { min-height: 44px; }

/* Biểu đồ: số liệu tổng + cột focus được */
.spark-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 8px; font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.spark-col:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.spark-col:focus-visible .spark-bar, .spark-col:hover .spark-bar { filter: brightness(1.12); }
.spark-col.is-zero .spark-bar { background: repeating-linear-gradient(180deg, var(--line-2) 0 3px, transparent 3px 6px); }
.metric-tabs { background: var(--paper); }
.metric-tabs .period-tab { padding: 6px 12px; }

@media (max-width: 640px) {
  .todo-item { align-items: flex-start; }
  .todo-item .btn { margin-left: auto; }
}
