/* Dena Kho — giao diện quản lý đơn hàng
   Màu lấy từ chính hạt cà phê: bụi nhân xanh (nền), rang đậm (hành động chính),
   nhân xanh (đạt/freeship), quả chín (nguy hiểm/bom hàng), vàng mật (cảnh báo). */
:root {
  --bg: #EEF0EA;
  --surface: #FFFFFF;
  --surface-2: #F6F7F3;
  --line: #D9DDD2;
  --ink: #1F2A22;
  --ink-2: #56614F;
  --ink-3: #7F8878;
  --roast: #5B3420;
  --roast-ink: #FFFFFF;
  --roast-soft: #EFE4DC;
  --bean: #5F7F3A;
  --bean-soft: #E3EBD6;
  --cherry: #B8321F;
  --cherry-soft: #F7E1DC;
  --honey: #9A6A0C;
  --honey-soft: #F6ECD3;
  --sky: #2F5F7A;
  --sky-soft: #DDE9EF;
  --focus: #2F5F7A;
  --radius-s: 6px;
  --radius-m: 10px;
  --shadow: 0 1px 0 rgba(31, 42, 34, .06), 0 8px 24px -12px rgba(31, 42, 34, .25);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151A16; --surface: #1D241F; --surface-2: #232B25; --line: #343E36;
    --ink: #E7ECE3; --ink-2: #B3BCAD; --ink-3: #8A9484;
    --roast: #C99273; --roast-ink: #1A120D; --roast-soft: #3A2A21;
    --bean: #9DBE73; --bean-soft: #2B3622; --cherry: #F08A76; --cherry-soft: #42231D;
    --honey: #E2B357; --honey-soft: #3D3119; --sky: #8FC0DA; --sky-soft: #1F3340; --focus: #8FC0DA;
    --shadow: 0 1px 0 rgba(0,0,0,.3), 0 10px 30px -12px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, .money { font-variant-numeric: tabular-nums; }
a { color: var(--sky); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Khung ---------- */
.shell { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }
.rail { background: var(--ink); color: #DDE3D6; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .rail { background: #0E120F; } }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand svg { flex: none; }
.brand b { font-size: 17px; letter-spacing: -.01em; color: #fff; }
.brand small { display: block; color: #9AA693; font-size: 12px; margin-top: -2px; }
.nav { all: unset; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-s); cursor: pointer; color: #C9D1C2; }
.nav:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.nav:focus-visible { outline: 2px solid #8FC0DA; }
.nav .count { margin-left: auto; background: var(--cherry); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.rail .who { margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,.1); font-size: 13px; color: #AEB8A7; }
.rail .who b { color: #fff; display: block; font-weight: 600; }
.rail .who button { all: unset; cursor: pointer; text-decoration: underline; font-size: 12px; margin-top: 4px; display: inline-block; }
.main { padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { font-size: 24px; line-height: 1.2; margin: 0; letter-spacing: -.02em; font-weight: 700; }
.page-head .sub { color: var(--ink-2); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Nút & ô nhập ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: var(--radius-s); cursor: pointer; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--roast); border-color: var(--roast); color: var(--roast-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.good { background: var(--bean); border-color: var(--bean); color: #fff; font-weight: 600; }
.btn.danger { color: var(--cherry); border-color: color-mix(in srgb, var(--cherry) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 4px 10px; font-size: 13px; }
kbd { font: 600 11px var(--font); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--ink-2); background: var(--surface-2); }
.btn.primary kbd, .btn.good kbd { background: transparent; color: inherit; border-color: rgba(255,255,255,.4); }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.in, select.in, textarea.in { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-s); padding: 8px 10px; font-size: 14px; color: var(--ink); width: 100%; min-width: 0; }
.in:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.in.num { text-align: right; }
textarea.in { resize: vertical; min-height: 60px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); }
.seg button { all: unset; padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* ---------- Thanh số liệu ---------- */
.pulse { display: flex; flex-wrap: wrap; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; margin-bottom: 18px; }
.pulse > div { background: var(--surface); padding: 12px 16px; flex: 1 1 170px; }
.pulse b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pulse span { color: var(--ink-2); font-size: 12.5px; }
.pulse .alert b { color: var(--cherry); }
.pulse button { all: unset; cursor: pointer; display: block; }

/* ---------- Thanh lọc đơn ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { all: unset; cursor: pointer; padding: 9px 14px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--roast); font-weight: 600; }
.tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.tabs .n { font-size: 12px; color: var(--ink-3); margin-left: 4px; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters .search { flex: 1 1 260px; position: relative; }
.filters .search .in { padding-left: 32px; }
.filters .search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.filters select.in, .filters input[type=date] { width: auto; }

/* ---------- Bảng ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-2); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--surface-2); }
.t tbody tr.sel td { background: var(--sky-soft); }
.t .num { text-align: right; white-space: nowrap; }
.t .muted, .muted { color: var(--ink-3); }
.t .code { font-weight: 600; white-space: nowrap; }
.t .items { color: var(--ink-2); font-size: 13px; max-width: 320px; }
.t input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--roast); }
.bulkbar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--ink); color: var(--bg); border-radius: var(--radius-m); margin-bottom: 10px; }
.bulkbar .btn { background: transparent; color: inherit; border-color: rgba(255,255,255,.3); }
.pager { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 10px 12px; color: var(--ink-2); font-size: 13px; }

/* Trạng thái: chữ + biểu tượng, không chỉ dựa vào màu */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st.draft { background: var(--surface-2); color: var(--ink-2); border: 1px dashed var(--line); }
.st.pending { background: var(--honey-soft); color: var(--honey); }
.st.shipped { background: var(--sky-soft); color: var(--sky); }
.st.delivered { background: var(--bean-soft); color: var(--bean); }
.st.returned, .st.cancelled { background: var(--cherry-soft); color: var(--cherry); }
.st.cancelled { text-decoration: line-through; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.tag.bom { background: var(--cherry); color: #fff; border-color: var(--cherry); }
.tag.warn { background: var(--honey-soft); color: var(--honey); border-color: transparent; }
.tag.ok { background: var(--bean-soft); color: var(--bean); border-color: transparent; }
.tag.info { background: var(--sky-soft); color: var(--sky); border-color: transparent; }

.empty { padding: 48px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- Ngăn kéo chi tiết & bảng lên đơn ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 26, 21, .45); z-index: 20; animation: fade .15s ease-out; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); background: var(--bg); z-index: 21; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slide .18s ease-out; }
.drawer header { padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; gap: 12px; }
.drawer header h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.drawer .body { padding: 16px 20px 24px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; }
.drawer footer { padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 8px; flex-wrap: wrap; }
.x { all: unset; cursor: pointer; margin-left: auto; padding: 4px 8px; border-radius: var(--radius-s); color: var(--ink-2); font-size: 20px; line-height: 1; }
.x:hover { background: var(--surface-2); }
.sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; }
.sec h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kv .total { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.kv .total + dd, .kv dd.total { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 2px; }
.lots { font-size: 12px; color: var(--ink-3); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.timeline li { padding: 4px 0 4px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.timeline time { color: var(--ink-3); margin-right: 6px; font-variant-numeric: tabular-nums; }

.sheet { position: fixed; inset: 16px; z-index: 21; background: var(--bg); border-radius: 14px; display: grid; grid-template-rows: auto 1fr auto; box-shadow: var(--shadow); animation: rise .18s ease-out; overflow: hidden; max-width: 1240px; margin: 0 auto; }
.sheet > header { padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.sheet > header h2 { margin: 0; font-size: 19px; }
.sheet > .cols { display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.sheet .left { overflow-y: auto; padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.sheet > footer { padding: 12px 20px; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sheet > footer .hint { color: var(--ink-3); font-size: 12.5px; margin-right: auto; }

/* Phiếu tạm tính bên phải: điểm nhấn của màn lên đơn */
.receipt { background: var(--surface); border-left: 1px solid var(--line); padding: 18px 18px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.receipt .big { font-size: 30px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.receipt .big-label { color: var(--ink-2); font-size: 12.5px; }
.beanbar { position: relative; height: 26px; border-radius: 13px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.beanbar i { position: absolute; inset: 0 auto 0 0; background: repeating-linear-gradient(115deg, var(--bean) 0 10px, color-mix(in srgb, var(--bean) 82%, #000) 10px 12px); transition: width .25s ease-out; border-radius: 13px; }
.beanbar.full i { background: var(--bean); }
.beanbar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; color: var(--ink); mix-blend-mode: normal; text-shadow: 0 0 6px var(--surface); }
.warns { display: flex; flex-direction: column; gap: 6px; }
.note { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-s); display: flex; gap: 8px; align-items: flex-start; }
.note.w-danger { background: var(--cherry-soft); color: var(--cherry); font-weight: 500; }
.note.w-warn { background: var(--honey-soft); color: var(--honey); }
.note.w-info { background: var(--sky-soft); color: var(--sky); }
.note b { flex: none; }

.cust-card { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; background: var(--surface-2); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cust-card.bom { border-color: var(--cherry); background: var(--cherry-soft); }

/* Dòng sản phẩm trong đơn */
.lines { display: flex; flex-direction: column; gap: 6px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 92px 112px 120px 110px 32px; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; }
.line .nm b { display: block; font-weight: 600; }
.line .nm small { color: var(--ink-3); font-size: 12px; }
.line .nm small.short { color: var(--cherry); font-weight: 600; }
.line .amt { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-head { display: grid; grid-template-columns: minmax(0, 1fr) 92px 112px 120px 110px 32px; gap: 8px; padding: 0 10px; font-size: 12px; color: var(--ink-3); }
.line-head span:nth-child(n+2) { text-align: right; }
.picker { position: relative; }
.picker .list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); box-shadow: var(--shadow); z-index: 5; max-height: 320px; overflow-y: auto; }
.picker .opt { padding: 8px 12px; display: flex; gap: 10px; align-items: center; cursor: pointer; }
.picker .opt[aria-selected="true"] { background: var(--sky-soft); }
.picker .opt .stock { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.picker .opt .stock.zero { color: var(--cherry); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { all: unset; cursor: pointer; border: 1px solid var(--line); background: var(--surface); padding: 5px 10px; border-radius: 99px; font-size: 13px; }
.chip:hover { border-color: var(--roast); color: var(--roast); }
.chip:focus-visible { outline: 2px solid var(--focus); }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow); }
.login h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.login p { margin: 0; color: var(--ink-2); }
.login .err { color: var(--cherry); font-weight: 500; }

/* ---------- Thông báo ---------- */
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; align-items: center; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius-m); box-shadow: var(--shadow); font-weight: 500; max-width: min(560px, 92vw); animation: rise .18s ease-out; }
.toast.err { background: var(--cherry); color: #fff; }
.toast.ok { background: var(--bean); color: #fff; }
#offline { position: fixed; top: 0; left: 0; right: 0; background: var(--cherry); color: #fff; text-align: center; padding: 8px; z-index: 60; font-weight: 600; }

.skeleton { height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

/* ---------- Màn hình hẹp ---------- */
@media (max-width: 980px) {
  .sheet > .cols { grid-template-columns: 1fr; overflow-y: auto; }
  .sheet .left { overflow: visible; }
  .receipt { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: sticky; top: 0; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; z-index: 10; }
  .brand, .rail .who { display: none; }
  .main { padding: 16px 16px 60px; }
  .sheet { inset: 0; border-radius: 0; }
  .line, .line-head { grid-template-columns: 1fr 80px 100px 32px; }
  .line .grind, .line .amt, .line-head span:nth-child(3), .line-head span:nth-child(5) { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .t .hide-sm { display: none; }
}
@media print {
  .rail, .page-head .actions, .filters, .tabs, .drawer footer, .x { display: none !important; }
  .drawer { position: static; width: auto; box-shadow: none; }
  .scrim { display: none; }
}

/* ===================== Tab Báo cáo ===================== */
:root { --c-rev: #B5652F; --c-profit: #1D7DB0; --c-muted-mark: #A3AA9C; --c-grid: #E4E7E0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --c-rev: #C98048; --c-profit: #3F98CC; --c-muted-mark: #5E685A; --c-grid: #2C352E; } }
.rep-bar { position: sticky; top: 0; z-index: 6; background: var(--bg); padding: 10px 0 12px; margin: -6px 0 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.rep-bar .row1, .rep-bar .row2 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rep-bar .range { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.rep-bar .range .btn { padding: 6px 10px; }
.rep-bar select.in, .rep-bar input[type=date] { width: auto; padding: 6px 8px; font-size: 13px; }
.rep-bar .meta { margin-left: auto; color: var(--ink-2); font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.rep-note { font-size: 13px; color: var(--honey); background: var(--honey-soft); padding: 6px 10px; border-radius: var(--radius-s); }
.rep-body { transition: opacity .15s; }
.rep-body.loading { opacity: .55; pointer-events: none; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { all: unset; box-sizing: border-box; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi:hover { border-color: var(--ink-3); }
.kpi:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.kpi .lbl { color: var(--ink-2); font-size: 12.5px; }
.kpi .val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi .sub { font-size: 12.5px; color: var(--ink-2); }
.kpi .delta { font-weight: 600; }
.kpi .delta.good { color: var(--bean); } .kpi .delta.bad { color: var(--cherry); } .kpi .delta.flat { color: var(--ink-3); }
.kpi svg { margin-top: 4px; }
.rep-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; margin-bottom: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; min-width: 0; scroll-margin-top: 140px; }
.panel > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.panel > header h2 { margin: 0; font-size: 15px; font-weight: 600; }
.panel > header .hint { color: var(--ink-3); font-size: 12.5px; }
.panel > header .tools { margin-left: auto; display: flex; gap: 6px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.lk { height: 2px; border-radius: 1px; vertical-align: 3px; width: 16px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .lbl-strong { fill: var(--ink); font-weight: 600; }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12.5px; padding: 8px 10px; border-radius: 8px; box-shadow: var(--shadow); white-space: nowrap; z-index: 3; transform: translate(-50%, -100%); }
.tip b { display: block; margin-bottom: 2px; }
.tip .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.tip.hidden { display: none; }
table.t th.sort { cursor: pointer; user-select: none; }
table.t th.sort[aria-sort]::after { content: " ▾"; }
table.t th.sort[aria-sort="ascending"]::after { content: " ▴"; }
.delta-cell.good { color: var(--bean); } .delta-cell.bad { color: var(--cherry); }
tr.inactive td { font-weight: 600; }
.ai-box { line-height: 1.6; }
.ai-box ul { margin: 6px 0; padding-left: 20px; }
.ai-box h4 { margin: 10px 0 2px; font-size: 14px; }
.sk { height: 120px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } .rep-grid { grid-template-columns: 1fr; } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi .val { font-size: 22px; } .rep-bar { position: static; } }
@media print {
  .rep-bar .row1 .btn, .rep-bar select, .rep-bar input, .rep-bar .meta button, .panel .tools, #aiBtn { display: none !important; }
  .rep-bar { position: static; border: 0; }
  .panel, .kpi { break-inside: avoid; }
  body { background: #fff; }
  .main { padding: 0; }
}
.rep-bar .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.rep-bar .seg button { white-space: nowrap; flex: none; }
.auto-msg { white-space: pre-wrap; font: 13px/1.55 var(--font); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; margin: 6px 0 0; max-height: 420px; overflow: auto; }

/* Logo Dena (vàng nhạt, nền trong suốt) đặt trên dải nâu rang ở đầu khung đăng nhập */
.login form { overflow: hidden; }
.login-brand { margin: -28px -28px 6px; padding: 30px 28px 26px; background: #4A2A1A; display: flex; justify-content: center; }
.login-brand img { display: block; width: min(220px, 70%); height: auto; }
/* Logo Dena trên thanh menu tối */
.brand.brand-logo { flex-direction: column; align-items: flex-start; gap: 6px; padding: 6px 10px 20px; }
.brand.brand-logo img { display: block; width: 150px; max-width: 100%; height: auto; }
.brand.brand-logo small { margin: 0; color: #C9C08A; letter-spacing: .02em; }
