:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --ink: #1b2a26;
  --ink-2: #3a4a45;
  --muted: #66756f;
  --line: #dfe6e3;
  --brand: #0f5c4d;
  --brand-2: #13806b;
  --brand-soft: #e3f1ed;
  --accent: #c93d6e;
  --accent-soft: #fbe9f0;
  --ok: #2e9e6a;
  --warn: #c98a0f;
  --warn-soft: #fdf3dc;
  --danger: #d6453b;
  --danger-soft: #fbe7e5;
  --purple: #7b4bc4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 40, 34, .06), 0 2px 8px rgba(16, 40, 34, .05);
  font-family: "Be Vietnam Pro", "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  font-size: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-2); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
table { border-collapse: collapse; width: 100%; }

/* ---------- Khung ---------- */
.demo-banner {
  background: #10362e; color: #d8efe8; font-size: 12.5px; padding: 6px 16px;
  display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center;
}
.demo-banner b { color: #fff; }
.demo-banner button { background: transparent; border: 1px solid #5d8f82; color: #d8efe8; border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 12px; }

.app { display: grid; grid-template-columns: 248px 1fr; min-height: calc(100vh - 31px); }
.sidebar { background: var(--brand); color: #e2f1ec; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; gap: 10px; align-items: center; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; background: #fff; display: grid; place-items: center; flex: none; }
.brand-title { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 11.5px; opacity: .75; }
.nav { padding: 10px 8px 20px; display: flex; flex-direction: column; gap: 1px; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; color: #e2f1ec; text-decoration: none; font-size: 13.5px; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: #fff; color: var(--brand); font-weight: 600; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; padding: 14px 18px; font-size: 11.5px; opacity: .7; border-top: 1px solid rgba(255,255,255,.1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 24px;
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; margin-right: auto; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.seg button.on { background: var(--brand); color: #fff; }
.label-sm { font-size: 11.5px; color: var(--muted); margin-right: 4px; }
.content { padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.menu-toggle { display: none; }

/* ---------- Thành phần ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 16px 10px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; margin-right: auto; }
.card-b { padding: 4px 16px 16px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 14px 16px; }
.kpi .k-label { font-size: 12.5px; color: var(--muted); }
.kpi .k-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .k-sub.up { color: var(--ok); }
.kpi .k-sub.down { color: var(--danger); }
.bar-mini { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar-mini > i { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { border-color: #b9c7c2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0c4d40; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); border-color: #efc2bd; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.input, select.input, textarea.input { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 10px; font-size: 13px; min-width: 0; }
.input:focus { outline: 2px solid #9bd3c5; border-color: var(--brand-2); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }
.field .input { width: 100%; max-width: 100%; }
select.input { max-width: 100%; text-overflow: ellipsis; }
.grid > *, .mini-wrap > *, .kpis > * { min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.tbl-wrap { overflow-x: auto; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 8px 10px; border-bottom: 1px solid #edf1ef; vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f5faf8; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.tag .dot { width: 8px; height: 8px; border-radius: 50%; }
.tag.ok { background: #e4f5ec; border-color: #bfe5cf; color: #1d7a4f; }
.tag.warn { background: var(--warn-soft); border-color: #f1d99d; color: #8d600a; }
.tag.danger { background: var(--danger-soft); border-color: #f1c1bb; color: #a8302a; }
.tag.info { background: var(--brand-soft); border-color: #bfe0d6; color: var(--brand); }
.tag.purple { background: #efe8fa; border-color: #d6c6f1; color: #5e34a3; }

.note { border-left: 3px solid var(--warn); background: var(--warn-soft); padding: 9px 12px; border-radius: 6px; font-size: 12.5px; color: #6f4d08; }
.note.info { border-color: var(--brand-2); background: var(--brand-soft); color: #164a3f; }

.pager { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding-top: 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- Sơ đồ mặt bằng ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend button { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.legend button.off { opacity: .4; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.plan { display: flex; flex-direction: column; gap: 14px; }
.plan-section { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px 12px; background: var(--surface-2); }
.plan-section h4 { font-size: 13px; margin-bottom: 8px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.plan-section h4 span { font-weight: 400; font-size: 12px; color: var(--muted); }
.plan-row { display: flex; align-items: center; gap: 6px; margin-top: 5px; }
.plan-row .rl { width: 18px; font-size: 11px; color: var(--muted); font-weight: 600; flex: none; }
.cells { display: grid; grid-template-columns: repeat(var(--n), minmax(26px, 1fr)); gap: 4px; flex: 1; min-width: 0; overflow-x: auto; padding-bottom: 2px; }
.card, .card-b, .plan-section { min-width: 0; }
.g-report { grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .g-report { grid-template-columns: 1fr; } }
.cell {
  height: 34px; border-radius: 5px; border: 1px solid rgba(0,0,0,.08); cursor: pointer; font-size: 10.5px; font-weight: 600;
  color: #fff; display: grid; place-items: center; padding: 0; min-width: 26px; transition: transform .08s;
}
.cell:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.cell.s-thue { background: #2e9e6a; }
.cell.s-no { background: #d6453b; }
.cell.s-ngung { background: #e0a526; }
.cell.s-tranhchap { background: #7b4bc4; }
.cell.s-trong { background: #fff; color: #8a9893; border: 1.5px dashed #b9c6c1; }
.cell.dim { opacity: .15; }
.cell.sel { outline: 3px solid #111; outline-offset: 1px; }
.cell.kiot { height: 42px; }
.aisle { height: 10px; border-bottom: 1px dashed #cfd9d5; margin: 2px 24px 6px; }
.parking { border: 1px dashed #b9c6c1; border-radius: 10px; padding: 26px; text-align: center; color: var(--muted); background: repeating-linear-gradient(45deg, #f7f9f8, #f7f9f8 10px, #eff3f1 10px, #eff3f1 20px); }

.detail h3 { font-size: 17px; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.empty { padding: 30px 12px; text-align: center; color: var(--muted); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(6, minmax(190px, 1fr)); gap: 10px; overflow-x: auto; padding-bottom: 6px; }
.kcol { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; min-height: 180px; }
.kcol h4 { font-size: 12.5px; padding: 4px 4px 8px; display: flex; justify-content: space-between; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; font-size: 12.5px; box-shadow: var(--shadow); }
.kcard:hover { border-color: #9fbdb4; }
.kcard .t { font-weight: 600; margin: 4px 0; font-size: 13px; }
.kcard.late { border-left: 3px solid var(--danger); }

/* ---------- Modal / drawer / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(12, 30, 26, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(620px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(880px, 100%); }
.modal-h { padding: 16px 20px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-h h3 { font-size: 16px; margin-right: auto; }
.modal-b { padding: 16px 20px; }
.modal-f { padding: 12px 20px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1px solid var(--line); }
.x { border: 0; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: #10362e; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 360px; animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods label { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; text-align: center; font-size: 13px; }
.pay-methods input { display: none; }
.pay-methods input:checked + span { color: var(--brand); font-weight: 700; }
.pay-methods label:has(input:checked) { border-color: var(--brand-2); background: var(--brand-soft); }
.qr-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: center; border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.qr-box svg { width: 170px; height: 170px; }

.receipt { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fffdf8; font-size: 13px; }
.receipt h4 { text-align: center; font-size: 15px; margin-bottom: 2px; }
.receipt .sub { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.receipt .total { font-size: 20px; font-weight: 700; text-align: right; }

/* ---------- Mini app ---------- */
.mini-wrap { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 28px; align-items: start; }
.phone { width: 360px; height: 740px; border-radius: 42px; background: #0d1a17; padding: 12px; box-shadow: 0 30px 60px rgba(0,0,0,.25); margin: 0 auto; }
.screen { width: 100%; height: 100%; border-radius: 32px; background: #f4f6f5; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.notch { height: 26px; display: flex; justify-content: space-between; align-items: center; padding: 0 22px; font-size: 11.5px; font-weight: 600; background: var(--brand); color: #fff; }
.m-head { background: var(--brand); color: #fff; padding: 8px 18px 16px; }
.m-head .hi { font-size: 12.5px; opacity: .8; }
.m-head .nm { font-size: 17px; font-weight: 700; }
.m-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.m-card { background: #fff; border-radius: 14px; padding: 14px; border: 1px solid var(--line); }
.m-due { background: linear-gradient(135deg, #0f5c4d, #13806b); color: #fff; border: 0; }
.m-due .amt { font-size: 26px; font-weight: 800; margin: 4px 0 10px; }
.m-tabs { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 1px solid var(--line); background: #fff; }
.m-tabs button { border: 0; background: transparent; padding: 8px 2px 10px; font-size: 10.5px; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.m-tabs button .i { font-size: 17px; }
.m-tabs button.on { color: var(--brand); font-weight: 700; }
.m-btn { width: 100%; border: 0; border-radius: 12px; padding: 12px; font-weight: 700; cursor: pointer; background: #fff; color: var(--brand); }
.m-btn.solid { background: var(--brand); color: #fff; }
.m-list .it { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #eef2f0; font-size: 13px; }
.m-list .it:last-child { border-bottom: 0; }
.otp { display: flex; gap: 8px; justify-content: center; }
.otp input { width: 40px; height: 48px; text-align: center; font-size: 20px; border: 1.5px solid var(--line); border-radius: 10px; }
.stars button { border: 0; background: none; font-size: 24px; cursor: pointer; color: #d0d7d4; padding: 0 2px; }
.stars button.on { color: #f2b01e; }
.script { counter-reset: s; list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.script li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 13.5px; }
.script li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-weight: 700; display: grid; place-items: center; font-size: 12.5px; }

/* ---------- Biểu đồ ---------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.donut-wrap { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donut-wrap svg { width: 150px; height: 150px; flex: none; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 13px; flex: 1; min-width: 160px; }
.donut-legend div { display: flex; gap: 8px; align-items: center; }
.donut-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }
.report-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.report-list button:hover { background: var(--surface-2); }
.report-list button.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main, .g3 { grid-template-columns: 1fr; }
  .mini-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 264px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 40px; }
  .g2, .form-grid { grid-template-columns: 1fr; }
  .kpi .k-value { font-size: 20px; }
  .phone { width: 100%; max-width: 360px; height: 700px; }
}
@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pay-methods { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media print {
  .sidebar, .topbar, .demo-banner, .no-print { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}
