@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700&display=swap');
:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #1b2533; --muted: #5d6b7e; --line: #e2e7ee; --line2: #cfd7e2;
  --brand: #0f5c4d; --brand2: #13846d; --brand-soft: #e5f4ef; --nav: #10212f; --nav2: #172e40; --nav-ink: #c9d6e2;
  --warn: #9a6200; --warn-bg: #fff6e0; --err: #b3261e; --err-bg: #fdecea; --ok: #1d7a3e; --ok-bg: #e7f6ec; --info: #1d5fa8; --info-bg: #e8f1fc;
  --r: 10px; --sh: 0 1px 2px rgba(16,33,47,.06), 0 4px 16px rgba(16,33,47,.06);
  --font: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand2); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ===== khung ===== */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--nav); color: var(--nav-ink); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 30px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 14px; border-bottom: 1px solid #22394c; margin-bottom: 8px; }
.brand .logo { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #1fae8c, #0f5c4d); display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; }
.brand b { color: #fff; display: block; font-size: 14.5px; line-height: 1.3; }
.brand span { font-size: 11.5px; color: #8fa3b5; display: block; line-height: 1.3; word-break: break-word; }
.navgroup { margin-top: 10px; }
.navgroup > div { font-size: 11px; letter-spacing: .06em; color: #7f95a8; padding: 6px 10px 3px; font-weight: 600; }
.side a { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px; color: var(--nav-ink); text-decoration: none; font-size: 13.5px; }
.side a:hover { background: var(--nav2); color: #fff; }
.side a.on { background: #1f4a3f; color: #fff; font-weight: 600; }
.side a .ic { width: 18px; text-align: center; opacity: .85; flex: none; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 22px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; min-height: 56px; }
.top h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; min-width: 0; line-height: 1.4; }
.top .who { font-size: 12.5px; color: var(--muted); text-align: right; line-height: 1.3; }
.burger { display: none; border: 0; background: none; font-size: 22px; padding: 4px 8px; cursor: pointer; }
.content { padding: 20px 22px 60px; min-width: 0; }
.lockbar { background: var(--info-bg); color: var(--info); font-size: 12.5px; padding: 4px 22px; border-bottom: 1px solid #cfe0f5; }

/* ===== thẻ, lưới ===== */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.card h2 { font-size: 15.5px; margin: 0 0 10px; font-weight: 650; line-height: 1.4; }
.card h3 { font-size: 14px; margin: 14px 0 8px; font-weight: 650; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; box-shadow: var(--sh); min-width: 0; }
.kpi .l { font-size: 12.5px; color: var(--muted); }
.kpi .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.cols2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ===== form ===== */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 14px; }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f.span2 { grid-column: span 2; } .f.span3 { grid-column: span 3; } .f.full { grid-column: 1 / -1; }
.f > label, .lbl { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.f > label .req { color: var(--err); }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=password], input[type=email], input:not([type]), select, textarea {
  width: 100%; min-width: 0; border: 1px solid var(--line2); border-radius: 8px; padding: 7px 10px; background: #fff; outline: none; height: 36px;
}
textarea { height: auto; min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(19,132,109,.15); }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
input[readonly] { background: #f6f8fb; }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13.5px; min-height: 36px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ===== nút ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line2); background: #fff; border-radius: 8px; padding: 0 14px; height: 36px; cursor: pointer; font-weight: 550; white-space: nowrap; text-decoration: none; color: var(--ink); }
.btn:hover { background: #f3f6f9; text-decoration: none; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand2); }
.btn.danger { color: var(--err); border-color: #efc2be; }
.btn.danger:hover { background: var(--err-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { border: 0; background: none; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--muted); }
.iconbtn:hover { background: #eef2f6; color: var(--ink); }

/* ===== bảng ===== */
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 100%; }
table.t { border-collapse: collapse; width: 100%; font-size: 13.2px; }
table.t th { background: #f2f5f9; color: #3b4a5d; font-weight: 600; text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; white-space: nowrap; }
table.t td { padding: 7px 10px; border-bottom: 1px solid #edf0f4; vertical-align: top; white-space: nowrap; }
table.t tr:hover td { background: #fafcfe; }
table.t tr.b td { font-weight: 650; }
table.t tr.tot td { font-weight: 700; background: #f6f8fb; border-top: 2px solid var(--line2); }
table.t tr.click { cursor: pointer; }
table.t td.wrap { white-space: normal; min-width: 220px; }
table.edit td { padding: 4px 5px; }
table.edit input, table.edit select { height: 32px; padding: 5px 7px; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.tag.posted { background: var(--ok-bg); color: var(--ok); } .tag.draft { background: var(--warn-bg); color: var(--warn); } .tag.cancelled { background: #eceff3; color: #6b7686; text-decoration: line-through; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.error { background: var(--err-bg); color: var(--err); } .tag.warn { background: var(--warn-bg); color: var(--warn); } .tag.info { background: var(--info-bg); color: var(--info); }

/* ===== thông báo ===== */
.note { border-radius: 8px; padding: 9px 12px; margin: 8px 0; font-size: 13.2px; border: 1px solid; }
.note.warn { background: var(--warn-bg); color: #6d4600; border-color: #f0dca8; }
.note.error { background: var(--err-bg); color: var(--err); border-color: #f2c4c0; }
.note.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cb; }
.note.info { background: var(--info-bg); color: #164c87; border-color: #c9ddf5; }
.note ul { margin: 4px 0 0; padding-left: 18px; }
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #1b2533; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 6px 24px rgba(0,0,0,.2); font-size: 13.5px; }
.toast.err { background: var(--err); } .toast.ok { background: var(--ok); }

/* ===== hộp thoại ===== */
.modal-bg { position: fixed; inset: 0; background: rgba(16,33,47,.45); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: min(760px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1100px, 100%); }
.modal .mh { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .mh h3 { margin: 0; font-size: 16px; flex: 1; }
.modal .mb { padding: 16px 18px; }
.modal .mf { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ===== chọn có tìm kiếm ===== */
.cb { position: relative; min-width: 0; }
.cb-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); background: #fff; border: 1px solid var(--line2); border-radius: 8px; box-shadow: var(--sh); max-height: 260px; overflow-y: auto; z-index: 70; min-width: 260px; }
.cb-list div { padding: 6px 10px; cursor: pointer; font-size: 13px; }
.cb-list div.act, .cb-list div:hover { background: var(--brand-soft); }
.cb-list div.add { color: var(--brand2); font-weight: 600; border-top: 1px solid var(--line); }

/* ===== tab, bước ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; text-decoration: none; font-weight: 550; }
.tabs a.on { color: var(--brand); border-color: var(--brand); }
.steps { counter-reset: s; }
.step { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.step::before { counter-increment: s; content: counter(s); width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; }
.step b { display: block; }
.drop { border: 2px dashed var(--line2); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); background: #fafcfe; cursor: pointer; }
.drop.over { border-color: var(--brand2); background: var(--brand-soft); }
.bar { height: 8px; background: #edf1f5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand2); }
.chart { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: end; height: 170px; padding-top: 10px; }
.chart .c { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.chart .bars { display: flex; gap: 3px; align-items: flex-end; height: 130px; }
.chart .bars i { width: 14px; border-radius: 4px 4px 0 0; background: var(--brand2); display: block; }
.chart .bars i.p { background: #9fd3c3; }
.chart .bars i.neg { background: #e8a39d; }
.chart small { font-size: 11px; color: var(--muted); }

/* ===== đăng nhập ===== */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: linear-gradient(160deg, #10212f 0%, #0f5c4d 100%); }
.auth .box { background: #fff; border-radius: 14px; padding: 26px 26px 22px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth h1 { font-size: 20px; margin: 0 0 4px; line-height: 1.4; }
.recovery { font-family: Consolas, 'Courier New', monospace; font-size: 15px; background: #f6f8fb; border: 1px dashed var(--line2); padding: 12px; border-radius: 8px; word-break: break-all; letter-spacing: .03em; }

/* ===== in ấn ===== */
.print-only { display: none; }
.doc { font-family: 'Times New Roman', Times, serif; color: #000; font-size: 13.5pt; line-height: 1.5; }
.doc h2 { text-align: center; font-size: 17pt; margin: 10px 0 2px; letter-spacing: .02em; }
.doc .center { text-align: center; }
.doc table { width: 100%; border-collapse: collapse; }
.doc .sig { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); text-align: center; margin-top: 18px; font-size: 12pt; }
.doc .sig.s3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.doc td, .doc th { padding: 3px 6px; }
.doc table.bd td, .doc table.bd th { border: 1px solid #000; }
.rep-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-bottom: 6px; font-size: 12.5px; }
.rep-title { text-align: center; margin: 4px 0 10px; }
.rep-title b { font-size: 16px; display: block; line-height: 1.5; }

@media print {
  body { background: #fff; }
  .side, .top, .noprint, #toasts, .lockbar, .tabs { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .tw { overflow: visible; border: 0; }
  table.t th { position: static; }
  table.t td, table.t th { border: 1px solid #999; }
  .print-only { display: block; }
  @page { size: A4; margin: 14mm 12mm; }
}

/* ===== màn hình vừa & nhỏ ===== */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .f.span3 { grid-column: 1 / -1; }
  .cols3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .burger { display: block; }
  .cols2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .content { padding: 14px 12px 50px; }
  .top { padding: 8px 12px; }
  .top .who { display: none; }
  .grid, .grid.g3, .grid.g2 { grid-template-columns: minmax(0, 1fr); }
  .f.span2, .f.span3 { grid-column: 1 / -1; }
  .kpi .v { font-size: 17px; }
  .card { padding: 14px 12px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .step { grid-template-columns: 30px minmax(0, 1fr); }
  .step > :last-child { grid-column: 2; }
  .chart .bars i { width: 9px; }
  .doc .sig { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .doc { font-size: 11.5pt; }
  .doc table.bd { font-size: 10pt; }
  .doc table.bd td, .doc table.bd th { padding: 2px 3px; }
}
@media screen { .doc { overflow-x: auto; } }
.lockbar.warnbar { background: var(--warn-bg); color: var(--warn); border-bottom-color: #f0dcae; }
.jsonbox { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-word; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin: 0; max-width: 100%; overflow-x: auto; }
.side .brand .small { display: block; opacity: .75; }
.tag.bad { background: var(--err-bg); color: var(--err); }
.lgitem { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 6px; min-width: 0; }
.lgitem:first-of-type { border-top: 0; }
.lghead { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.lgtitle { font-weight: 600; }
.lgcmp { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: start; }
.lgarrow { color: var(--muted); padding-top: 18px; }
.lgval { min-width: 0; }
.lgact { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .lgcmp { grid-template-columns: minmax(0, 1fr); } .lgarrow { display: none; } .lgact { justify-content: flex-start; } }
.auth-sub { margin: -4px 0 10px; font-weight: 600; color: var(--brand); letter-spacing: .01em; }
