:root {
  --navy: #0F6E7A;
  --navy-2: #17909F;
  --cream: #FCEFCF;
  --cream-border: #EBD9A8;
  --text-navy: #16305a;
  --grey-bg: #eef0f3;
  --red: #c0392b;
  --green: #1e7e34;
  --muted: #7a869a;
  --brand-orange: #F2994A;
  --brand-yellow: #FFC94D;
  --brand-lime: #8BC63F;
  --brand-pink: #E8467A;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--grey-bg); font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-navy);
}
a { color: inherit; }
.app-shell { display: block; }
.sidenav { display: none; }
.phone {
  max-width: 460px; margin: 0 auto; min-height: 100vh; background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,.12); position: relative; padding-bottom: 70px;
}
header.topbar {
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #fff; padding: calc(16px + env(safe-area-inset-top)) 18px 42px;
}
.topbar-row { display:flex; align-items:center; gap:12px; }
.app-badge {
  width:40px; height:40px; border-radius:50%; background:linear-gradient(135deg, var(--brand-orange), var(--brand-pink));
  display:flex; align-items:center; justify-content:center; font-weight:800; font-size:18px; color:#fff;
  border:2px solid rgba(255,255,255,.6); flex-shrink:0;
}
.app-title { font-size:19px; font-weight:700; }
.user-chip { margin-left:auto; font-size:12px; background:rgba(255,255,255,.12); padding:6px 10px; border-radius:20px; text-decoration:none; color:#fff; }
.stat-row { display:flex; gap:10px; margin: -28px 14px 0; position:relative; z-index:2; }
.stat-card { flex:1; background:#dde3ec; border-radius:14px; padding:12px 8px; text-align:center; box-shadow: 0 4px 10px rgba(0,0,0,.06); }
.stat-num { font-size:19px; font-weight:800; }
.stat-num.red { color: var(--red); } .stat-num.green { color: var(--green); } .stat-num.navy { color: var(--navy); }
.stat-label { font-size:11px; color:var(--muted); margin-top:2px; }
.sheet { background:#fff; border-radius:22px 22px 0 0; margin-top:18px; padding:18px 14px 30px; min-height:55vh; }
.sheet-title { font-size:17px; font-weight:800; color:var(--navy); margin: 4px 4px 14px; }
.module-grid { display:grid; grid-template-columns: repeat(3,1fr); gap:11px; }
.module-card {
  background: var(--cream); border:1px solid var(--cream-border); border-radius:16px; padding:16px 4px 12px;
  text-align:center; text-decoration:none; color:var(--text-navy); font-weight:700; font-size:12.5px; display:block;
}
.module-card .icon { font-size:26px; display:block; margin-bottom:8px; }
.module-card.soon { opacity:.55; }
.bottomnav {
  position:fixed; bottom:0; left:50%; transform:translateX(-50%); width:100%; max-width:460px;
  background:#fff; border-top:1px solid #e6e6ea; display:flex; padding:8px 4px calc(8px + env(safe-area-inset-bottom)); z-index:5;
}
.bottomnav a { flex:1; text-align:center; font-size:11px; color:var(--muted); text-decoration:none; font-weight:600; }
.bottomnav a.active { color: var(--navy); }
.bottomnav .bicon { display:block; font-size:19px; margin-bottom:2px; }
.nav-badge {
  position:absolute; top:2px; right:calc(50% - 22px); min-width:16px; height:16px; padding:0 4px;
  border-radius:9px; background:#a8321c; color:#fff; font-size:10px; font-weight:700; line-height:16px;
}

.section { padding: 14px; }
.card-row { display:flex; gap:12px; }
.pill { display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:700; }
.pill.cho { background:#fff3cd; color:#8a6500; }
.pill.duyet { background:#dbe8ff; color:#1c4ea8; }
.pill.xong { background:#d9f2df; color:#1e7e34; }
.pill.huy { background:#fbdcdc; color:#a8321c; }
.sku-card { display:flex; gap:12px; background:#fff; border:1px solid #eee; border-radius:14px; padding:12px; margin-bottom:10px; align-items:center; text-decoration:none; color:var(--text-navy); }
.sku-img { width:56px; height:56px; border-radius:12px; background:var(--cream); display:flex; align-items:center; justify-content:center; font-size:26px; flex-shrink:0; }
.sku-info { flex:1; min-width:0; }
.sku-title { font-weight:700; font-size:13.5px; }
.sku-sub { font-size:11.5px; color:var(--muted); margin-top:2px; }
.sku-stock { font-weight:800; font-size:14px; }
.sku-stock.low { color: var(--red); }
.tab-row { display:flex; gap:8px; margin-bottom:14px; overflow-x:auto; }
.tab { padding:7px 14px; border-radius:20px; background:#f1f2f5; font-size:12.5px; font-weight:700; white-space:nowrap; text-decoration:none; color:var(--muted); }
.tab.active { background:var(--navy); color:#fff; }
button.tab { border:none; font-family:inherit; cursor:pointer; }
.list-row { display:flex; justify-content:space-between; align-items:center; padding:12px 4px; border-bottom:1px solid #f0f0f2; }
.list-row .lr-title { font-weight:700; font-size:13.5px; }
.list-row .lr-sub { font-size:11.5px; color:var(--muted); margin-top:2px; }
.list-row .lr-amt { font-weight:800; font-size:13.5px; }
.form-box { background:#f8f8fa; border-radius:14px; padding:14px; margin-bottom:14px; }
.form-box label { font-size:12px; font-weight:700; color:var(--muted); display:block; margin-bottom:4px; }
.form-box input, .form-box select { width:100%; padding:9px 10px; border-radius:8px; border:1px solid #ddd; margin-bottom:10px; font-size:13.5px; }
.btn { display:inline-block; background:var(--navy); color:#fff; border:none; padding:10px 16px; border-radius:10px; font-weight:700; font-size:13px; cursor:pointer; text-decoration:none; }
.btn.ghost { background:#fff; color:var(--navy); border:1px solid var(--navy); }
.btn.sm { padding:6px 12px; font-size:12px; }
.kpi-box { background:#fff; border:1px solid #eee; border-radius:14px; padding:14px; margin-bottom:12px; }
.kpi-box h4 { margin:0 0 8px; font-size:13px; color:var(--muted); }
.kpi-box .big { font-size:22px; font-weight:800; color:var(--navy); }
.back-link { font-size:13px; color:var(--muted); text-decoration:none; margin-bottom:10px; display:inline-block; }
.login-card { background:#fff; border:1px solid #eee; border-radius:14px; padding:14px; margin-bottom:10px; display:flex; gap:12px; align-items:center; text-decoration:none; color:var(--text-navy); }
.login-avatar { font-size:26px; width:44px; height:44px; border-radius:50%; background:var(--cream); display:flex; align-items:center; justify-content:center; }
.chat-bubble { background:#f1f2f5; border-radius:12px; padding:9px 12px; margin-bottom:10px; max-width:82%; }
.chat-bubble .cb-meta { font-size:10.5px; color:var(--muted); margin-bottom:3px; font-weight:700; }
.chat-group-card { display:flex; align-items:center; gap:12px; background:#fff; border:1px solid #eee; border-radius:14px; padding:12px; margin-bottom:10px; text-decoration:none; color:var(--text-navy); }
.badge-dept { font-size:10.5px; background:var(--cream); border:1px solid var(--cream-border); padding:2px 8px; border-radius:10px; font-weight:700; }
.linked-note { background:#eaf3ff; border:1px solid #cfe3fb; color:#1c4ea8; font-size:12px; padding:9px 11px; border-radius:10px; margin-bottom:12px; }

/* Kho Hà Nội — thẻ SKU kiểu gian hàng Shopee */
.hn-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap:12px; }
.hn-card { background:#fff; border:1px solid #eee; border-radius:16px; overflow:hidden; display:flex; flex-direction:column; }
.hn-photo-wrap { position:relative; width:100%; aspect-ratio:1/1; background:var(--cream); }
.hn-photo-wrap img, .hn-photo-wrap video { width:100%; height:100%; object-fit:cover; display:block; }
.hn-photo-link { display:block; width:100%; height:100%; }
.hn-add-photo {
  display:flex; align-items:center; justify-content:center; height:100%; font-size:13px; font-weight:700;
  color:var(--navy); background:var(--cream);
}
.hn-icon-btn {
  width:26px; height:26px; border-radius:8px; border:1px solid #eee; background:#fff; display:flex;
  align-items:center; justify-content:center; font-size:12px; cursor:pointer; padding:0;
}
.hn-share-btn {
  position:absolute; top:8px; left:8px; width:30px; height:30px; border-radius:50%; border:none;
  background:rgba(255,255,255,.92); display:flex; align-items:center; justify-content:center; font-size:15px;
  box-shadow:0 2px 6px rgba(0,0,0,.18); cursor:pointer; z-index:2;
}
.hn-body { padding:10px 10px 12px; }
.hn-sku { font-size:11px; font-weight:800; color:var(--navy); }
.hn-ten { font-size:12.5px; font-weight:600; color:var(--text-navy); margin-bottom:8px; line-height:1.3; }
.hn-sizes { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; }
.hn-size-cell { background:var(--grey-bg); border-radius:8px; padding:4px 3px; text-align:center; min-width:44px; flex:1 1 30%; }
.hn-size-label { font-size:9.5px; color:var(--muted); font-weight:700; }
.hn-size-stock { font-size:13px; font-weight:800; color:var(--navy); }
.hn-add-size-form { display:flex; gap:4px; }
.hn-add-size-form input { flex:1; min-width:0; padding:5px 6px; border-radius:7px; border:1px solid #ddd; font-size:11px; margin-bottom:0; }
.hn-add-size-form button { padding:5px 9px; border-radius:7px; border:none; background:var(--navy); color:#fff; font-weight:800; font-size:12px; }
.hn-pager { display:flex; justify-content:center; gap:8px; margin-top:16px; align-items:center; font-size:12.5px; }
.gallery-main { width:100%; aspect-ratio:1/1; border-radius:16px; overflow:hidden; background:var(--cream); margin-bottom:10px; }
.gallery-main img, .gallery-main video { width:100%; height:100%; object-fit:cover; }
.gallery-thumbs { display:flex; gap:8px; overflow-x:auto; margin-bottom:16px; padding-top:4px; }
.gallery-thumb-wrap { position:relative; flex-shrink:0; }
.gallery-thumbs img { width:64px; height:64px; object-fit:cover; border-radius:10px; border:2px solid transparent; cursor:pointer; display:block; }
.gallery-thumbs img.active { border-color:var(--navy); }
.gallery-thumb-video { position:relative; width:64px; height:64px; border-radius:10px; overflow:hidden; border:2px solid transparent; cursor:pointer; }
.gallery-thumb-video.active { border-color:var(--navy); }
.gallery-thumb-video video { width:100%; height:100%; object-fit:cover; pointer-events:none; }
.gallery-thumb-play {
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); color:#fff; font-size:16px;
  text-shadow:0 1px 3px rgba(0,0,0,.6); pointer-events:none;
}
.gallery-thumb-del { position:absolute; top:-6px; right:-6px; margin:0; }
.gallery-thumb-del button {
  width:20px; height:20px; border-radius:50%; border:none; background:var(--red); color:#fff; font-size:11px;
  font-weight:800; line-height:1; cursor:pointer; box-shadow:0 1px 4px rgba(0,0,0,.3);
}
.hc-confirming { background:var(--red) !important; color:#fff !important; border-color:var(--red) !important; }

/* Nhân Sự */
.nv-card { background:#fff; border:1px solid #eee; border-radius:16px; padding:14px; margin-bottom:12px; }
.nv-top { display:flex; gap:12px; align-items:flex-start; }
.nv-avatar { width:52px; height:52px; border-radius:12px; background:var(--navy); color:#fff; display:flex;
  align-items:center; justify-content:center; font-weight:800; font-size:16px; flex-shrink:0; }
.nv-info { flex:1; min-width:0; }
.nv-tags { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:4px; }
.nv-name { font-size:15px; font-weight:800; color:var(--text-navy); margin-top:2px; }
.nv-role { font-size:12.5px; color:var(--muted); margin-top:1px; }
.nv-meta { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); margin-top:10px; padding-top:10px; border-top:1px solid #f0f0f2; }
.nv-salary { display:flex; justify-content:space-between; align-items:center; margin-top:8px; }
.nv-salary .amt { font-size:16px; font-weight:800; color:var(--navy); }
.nv-actions { display:flex; gap:8px; margin-top:12px; }
.nv-actions .btn { flex:1; text-align:center; padding:9px; font-size:12.5px; }
.nv-detail-header { background:linear-gradient(180deg, var(--navy), var(--navy-2)); color:#fff; padding:18px 16px; margin:-18px -14px 16px; border-radius:0 0 18px 18px; }
.nv-detail-header .nv-avatar { background:rgba(255,255,255,.15); }
.nv-box { background:#f8f8fa; border-radius:14px; padding:14px; margin-bottom:14px; }
.nv-box h4 { margin:0 0 10px; font-size:13px; color:var(--navy); }
.nv-grid2 { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.nv-field label { display:block; font-size:11px; color:var(--muted); font-weight:700; margin-bottom:2px; }
.nv-field .val { font-size:13.5px; font-weight:700; color:var(--text-navy); }

/* Brand logo (trang đăng nhập) */
.brand-logo { background:var(--cream); border:1px solid var(--cream-border); border-radius:20px; padding:22px 16px; text-align:center; margin-bottom:18px; }
.brand-logo .bl-tagline { font-size:11px; font-weight:800; letter-spacing:1.5px; color:var(--navy); }
.brand-logo .bl-name { font-size:34px; font-weight:800; line-height:1; margin:6px 0 4px; font-family:"Comic Sans MS", "Segoe Print", "Marker Felt", cursive, sans-serif; }
.brand-logo .bl-name span { display:inline-block; }
.brand-logo .bl-name .c1 { color:var(--brand-orange); }
.brand-logo .bl-name .c2 { color:var(--brand-yellow); }
.brand-logo .bl-name .c3 { color:var(--brand-lime); }
.brand-logo .bl-name .c4 { color:var(--navy); }
.brand-logo .bl-name .c5 { color:var(--brand-pink); }
.brand-logo .bl-closet { display:flex; align-items:center; justify-content:center; gap:10px; margin-top:2px; }
.brand-logo .bl-closet span:not(.bl-word) { flex:1; max-width:60px; height:2px; background:var(--navy); opacity:.5; }
.brand-logo .bl-word { font-size:19px; font-weight:800; letter-spacing:3px; color:var(--navy); }

/* ============ Giao diện máy tính (desktop) ============ */
@media (min-width: 900px) {
  body { padding: 28px 16px; }
  .app-shell {
    display: flex; align-items: flex-start; justify-content: center; gap: 22px;
    max-width: 1180px; margin: 0 auto;
  }
  .sidenav {
    display: flex; flex-direction: column; gap: 2px; width: 230px; flex-shrink: 0;
    background: #fff; border-radius: 18px; padding: 14px; box-shadow: 0 4px 24px rgba(0,0,0,.07);
    position: sticky; top: 28px; max-height: calc(100vh - 56px); overflow-y: auto;
  }
  .sidenav-brand { display:flex; align-items:center; gap:10px; padding:8px 10px 14px; }
  .sidenav-brand .app-title { color: var(--text-navy); }
  .sidenav a {
    display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:11px;
    text-decoration:none; color:var(--text-navy); font-weight:600; font-size:13.5px;
  }
  .sidenav a:hover { background: var(--grey-bg); }
  .sidenav a.active { background: var(--cream); color: var(--navy); font-weight:800; }
  .phone {
    max-width: 760px; width: 100%; min-height: auto; box-shadow: 0 4px 24px rgba(0,0,0,.07);
    border-radius: 20px; padding-bottom: 24px; overflow: hidden;
  }
  header.topbar { border-radius: 20px 20px 0 0; }
  .bottomnav { display: none; }
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .hn-grid { grid-template-columns: repeat(3, 1fr); }
  .card-row { flex-wrap: wrap; }
  .card-row .kpi-box { min-width: 200px; }
}

@media (min-width: 1180px) {
  .module-grid { grid-template-columns: repeat(5, 1fr); }
  .hn-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Marketing — Tính Giá Bán */
.gb-field { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px solid #eee; }
.gb-field:last-child { border-bottom:none; }
.gb-field label { font-size:12px; font-weight:600; color:var(--text-navy); flex:1; line-height:1.35; }
.gb-field .gb-input-wrap { display:flex; align-items:center; gap:6px; flex-shrink:0; }
.gb-field input[type="number"] { width:84px; padding:7px 8px; border-radius:8px; border:1px solid #ddd; font-size:13px; text-align:right; background:#fff; }
.gb-field select { padding:7px 6px; border-radius:8px; border:1px solid #ddd; font-size:11.5px; background:#fff; max-width:96px; }
.gb-field .gb-unit { font-size:11.5px; color:var(--muted); width:14px; }
.gb-reset { display:flex; justify-content:flex-end; margin: 2px 4px 12px; }
.gb-reset button { background:none; border:none; color:var(--muted); font-size:11.5px; text-decoration:underline; cursor:pointer; padding:0; }
.gb-table-wrap { overflow-x:auto; border-radius:14px; border:1px solid #eee; margin-bottom:16px; -webkit-overflow-scrolling:touch; }
table.gb-table { border-collapse:collapse; width:100%; font-size:11.5px; white-space:nowrap; }
table.gb-table th, table.gb-table td { padding:8px 10px; text-align:right; border-bottom:1px solid #f0f0f2; }
table.gb-table th:first-child, table.gb-table td:first-child { text-align:left; position:sticky; left:0; background:#fff; z-index:1; box-shadow:1px 0 0 #f0f0f2; }
table.gb-table thead th { background:var(--grey-bg); font-weight:800; color:var(--navy); }
table.gb-table thead th:first-child { background:var(--grey-bg); }
table.gb-table tr.gb-row-total td { font-weight:800; background:#f8f8fa; }
table.gb-table tr.gb-row-profit td { color:var(--navy); font-weight:800; }
table.gb-table tr.gb-row-profit td.gb-neg { color:var(--red); }
table.gb-table tr.gb-row-suggest td { background:#fff3cd; font-weight:800; }
table.gb-table tr.gb-row-suggest td:first-child { background:#fff3cd; }

/* Tài khoản — phân quyền nhân sự */
.acc-field { display:block; border:none; background:transparent; font-family:inherit; padding:2px 0; width:100%; }
.acc-field:focus { outline:none; background:#f8f8fa; border-radius:6px; }
.acc-field.name { font-size:15px; font-weight:800; color:var(--text-navy); }
.acc-field.role { font-size:12.5px; color:var(--muted); margin-top:1px; }
.acc-dept-select { font-size:12px; margin-top:6px; padding:5px 6px; border-radius:7px; border:1px solid #ddd; background:#fff; max-width:100%; }
.acc-avatar-input { width:52px; height:52px; border-radius:12px; border:1px dashed #ddd; background:#fff; text-align:center; font-size:22px; padding:0; flex-shrink:0; }
.perm-list { display:flex; flex-wrap:wrap; gap:8px; margin:12px 0; }
.perm-item { display:flex; align-items:center; gap:6px; background:#f8f8fa; border:1px solid #eee; border-radius:10px; padding:7px 10px; font-size:12px; font-weight:600; color:var(--text-navy); cursor:pointer; }
.perm-item input { width:15px; height:15px; flex-shrink:0; accent-color:var(--navy); }
.perm-director { background:#fff3cd; border-color:#f0dfa0; font-weight:800; margin-bottom:2px; width:100%; box-sizing:border-box; }

/* ---- Báo cáo AI hiển thị từ markdown (md_nhe.py) ---- */
.md { font-size:13px; line-height:1.65; color:#1d2b45; word-break:break-word; }
.md-box { margin-top:8px; padding:12px 14px; background:#fbfcfd; border:1px solid #e6eaf0; border-radius:10px; }
.dm-ai.md { white-space:normal; }
.md p { margin:6px 0; }
.md .md-h { color:var(--navy); line-height:1.35; margin:16px 0 6px; }
.md h3.md-h { font-size:16px; border-bottom:2px solid #d6e9ec; padding-bottom:4px; }
.md h4.md-h { font-size:14.5px; }
.md h5.md-h, .md h6.md-h { font-size:13px; }
.md > .md-h:first-child { margin-top:2px; }
.md ul.md-l, .md ol.md-l { margin:6px 0; padding-left:20px; }
.md li { margin:3px 0; }
.md li.l1 { margin-left:18px; list-style:circle; }
.md li.l2, .md li.l3 { margin-left:36px; list-style:square; }
.md strong { color:#12304f; }
.md code { background:#eef2f6; padding:1px 5px; border-radius:4px; font-size:12px; }
.md .md-pre { background:#f1f4f8; padding:8px 10px; border-radius:8px; overflow-x:auto; font-size:12px; white-space:pre-wrap; }
.md blockquote { margin:8px 0; padding:6px 12px; border-left:3px solid #F2994A; background:#fffaf0; border-radius:0 6px 6px 0; }
.md hr { border:0; border-top:1px solid #e1e6ee; margin:14px 0; }
.md a { color:#0F6E7A; text-decoration:underline; word-break:break-all; }
.md-tw { overflow-x:auto; margin:8px 0; border:1px solid #e1e6ee; border-radius:10px; }
.md-t { border-collapse:collapse; width:100%; min-width:760px; font-size:12px; line-height:1.5; }
.md-t th { background:#0F6E7A; color:#fff; text-align:left; padding:7px 9px; font-weight:700; white-space:nowrap; }
.md-t td { min-width:80px; padding:7px 9px; border-top:1px solid #edf0f5; vertical-align:top; }
.md-t tbody tr:nth-child(even) td { background:#f7f9fc; }
.md-lb { display:inline-block; padding:1px 7px; border-radius:99px; font-size:10.5px; font-weight:800; white-space:nowrap; vertical-align:1px; }
.md-lb-ok { background:#eafaf0; color:#1e7e34; }
.md-lb-sl { background:#e3f4f6; color:#0F6E7A; }
.md-lb-gd { background:#fff4e0; color:#8a5a00; }
.md-lb-kc { background:#f0f2f5; color:#6b778b; }

/* ---- Ảnh mẫu nổi bật trong bảng báo cáo ---- */
.md-td-anh { width:76px; padding:6px !important; text-align:center; }
.md-thumb { width:64px; height:64px; object-fit:cover; border-radius:8px; border:1px solid #e1e6ee; background:#f1f4f8; display:block; margin:0 auto; }
.md-no-anh { color:#aab3c2; }
