:root {
  /* KTB88 Brandkit R1 — màu chuẩn thương hiệu */
  --bg: #F5F7FB;
  --panel: #FFFFFF;
  --sidebar: #0B1220;
  --navy: #10213D;
  --ink: #0F172A;
  --muted: #64748B;
  --line: #E2E8F0;
  --brand: #2563EB;
  --brand-ink: #1D4ED8;
  --hover: #EAF2FF;
  --green: #0F9F6E;
  --green-bg: #e6f6ef;
  --red: #DC2626;
  --red-bg: #fdecec;
  --blue: #0284C7;
  --orange: #D97706;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.04);
  font-family: "Inter", "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
body { font-variant-numeric: tabular-nums; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
button { cursor: pointer; font-family: inherit; }
a { color: var(--brand); }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card { background: #fff; padding: 32px; border-radius: 16px; width: 348px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-card .brand { font-size: 30px; font-weight: 800; color: var(--brand-ink); letter-spacing: 1px; }
.login-card .brand-sub { color: var(--muted); margin-top: -8px; margin-bottom: 8px; }
.login-card label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.login-card input { padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; }
.login-card button { background: var(--brand); color: #fff; border: 0; padding: 11px; border-radius: 8px; font-size: 15px; font-weight: 600; }
.login-card .err { color: var(--red); font-size: 13px; min-height: 16px; }
.login-card .hint { color: var(--muted); font-size: 11px; text-align: center; }

/* ── Layout ── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #aeb9cf; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.logo { display: flex; align-items: center; gap: 11px; padding: 2px 8px 18px; }
.logo-mark { width: 38px; height: 38px; flex: 0 0 38px; }
.logo-txt { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: .5px; line-height: 1.05; }
.logo-txt span { display: block; font-size: 11px; font-weight: 400; color: #6b7a99; letter-spacing: 0; margin-top: 2px; }
#nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
#nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
#nav a { color: #aeb9cf; text-decoration: none; padding: 9px 11px; border-radius: 9px; font-size: 13.5px; display: flex; gap: 11px; align-items: center; transition: .12s; }
#nav a:hover { background: rgba(255,255,255,.06); color: #e7ecf5; }
#nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
#nav a.active .nav-ico { opacity: 1; }
.nav-ico { width: 18px; height: 18px; flex: 0 0 18px; opacity: .82; }
.nav-header { color: #5b6884; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; padding: 14px 11px 5px; font-weight: 600; }
.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 14px; margin-top: 8px; }
.user-box { font-size: 13px; margin-bottom: 10px; color: #aeb9cf; display: flex; gap: 9px; align-items: center; }
.user-box .ava { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 30px; }
.user-box b { color: #fff; display: block; font-size: 13px; }
.user-box small { color: #6b7a99; }
.ghost { background: transparent; border: 1px solid rgba(255,255,255,.14); color: #aeb9cf; padding: 8px 12px; border-radius: 9px; font-size: 13px; width: 100%; }
.ghost:hover { background: rgba(255,255,255,.06); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; flex-direction: column; align-items: stretch; gap: 10px; position: sticky; top: 0; z-index: 5; }
/* Thanh chọn Job (Job-first) */
.jobbar { display: flex; gap: 8px; align-items: stretch; overflow-x: auto; padding-bottom: 2px; }
.jobtab { border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 11px 16px; min-width: 150px; cursor: pointer; text-align: left; flex: 0 0 auto; transition: .12s; }
.jobtab:hover { border-color: var(--brand); box-shadow: 0 2px 8px rgba(37,99,235,.08); }
.jobtab.active { border-color: var(--brand); background: #eef3fe; box-shadow: inset 0 0 0 2px var(--brand); }
.jobtab .jt-name { font-weight: 700; font-size: 14.5px; }
.jobtab .jt-num { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.act-table td { vertical-align: top; }
.act-table td:first-child { white-space: nowrap; }
.jobtab.system { background: #10203f; border-color: #10203f; color: #fff; }
.jobtab.system.active { box-shadow: inset 0 0 0 2px var(--brand); }
.jobtab.system .jt-num { color: #9fb0d0; }
.jobtab.add { min-width: auto; display: flex; align-items: center; color: var(--brand); font-weight: 600; border-style: dashed; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters select, .filters input, .filters button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.filters .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.filters .seg button { border: 0; border-right: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); font-weight: 500; padding: 8px 14px; font-size: 13px; }
.filters .seg button:last-child { border-right: 0; }
.filters .seg button:hover { background: var(--hover); }
.filters .seg button.active { background: var(--brand); color: #fff; }
.only-mobile { display: none !important; width: auto; }
.only-desktop { display: inline-flex !important; }
.topbar-row { display: flex; align-items: center; gap: 12px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); width: 38px; height: 38px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: 0 0 38px; }
.icon-btn:hover { background: var(--hover); color: var(--brand); border-color: var(--brand); }

/* ── Thu gọn sidebar ── */
.app.collapsed { grid-template-columns: 72px 1fr; }
.app.collapsed .logo-txt, .app.collapsed #nav a span, .app.collapsed .nav-header,
.app.collapsed .user-box span, .app.collapsed .side-foot .ghost span { display: none; }
.app.collapsed .logo { justify-content: center; padding: 2px 0 18px; }
.app.collapsed #nav a { justify-content: center; padding: 10px 0; position: relative; }
.app.collapsed .user-box { justify-content: center; }
.app.collapsed .ghost { padding: 8px 0; }
.app.collapsed #nav a:hover::after { content: attr(data-tip); position: absolute; left: 60px; top: 50%; transform: translateY(-50%); background: var(--ink); color: #fff; padding: 5px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; z-index: 30; box-shadow: var(--shadow); }

/* ── Drawer backdrop (mobile) ── */
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 39; }
.drawer-backdrop.show { display: block; }

.view { padding: 26px 30px; max-width: 1680px; }
.page-title { font-size: 27px; font-weight: 700; margin: 0 0 5px; letter-spacing: -.3px; }
.page-sub { color: var(--muted); font-size: 14px; margin: 0 0 18px; }

/* ── Cards & grids ── */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.clickable { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.card.clickable:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.card .k { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.card .v { font-size: 25px; font-weight: 700; margin-top: 8px; letter-spacing: -.4px; }
.card .s { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.chip.green { background: var(--green-bg); color: var(--green); }
.chip.red { background: var(--red-bg); color: var(--red); }
.chip.gray { background: #eef1f6; color: var(--muted); }
.chip.blue { background: #e7effe; color: var(--brand-ink); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; overflow-x: auto; }
.panel h3 { margin: 0 0 14px; font-size: 14.5px; font-weight: 600; }
.panel .chart-box { position: relative; height: 280px; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 12px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; background: #fbfcfe; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field label { color: var(--muted); font-size: 12px; }
/* Nhãn dạng <label>Text<input></label> (bọc input) — bố cục cột, chữ nhãn mờ */
.form-grid > label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
/* Ô nhập/select/textarea đồng bộ trong mọi form & modal */
.field input, .field select, .field textarea,
.form-grid input, .form-grid select, .form-grid textarea,
.mbody input[type="text"], .mbody input[type="number"], .mbody input:not([type]), .mbody select, .mbody textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit;
  color: var(--ink); background: #fff; width: 100%; box-sizing: border-box; transition: border-color .12s, box-shadow .12s;
}
.field input:focus, .field select:focus, .field textarea:focus,
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus,
.mbody input:focus, .mbody select:focus, .mbody textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
/* Select tùy biến mũi tên cho gọn, hiện đại */
.field select, .form-grid select, .mbody select {
  appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.btn { background: var(--brand); color: #fff; border: 0; padding: 10px 18px; border-radius: 9px; font-size: 14px; font-weight: 600; transition: .12s; text-decoration: none; display: inline-block; }
.btn:hover { background: var(--brand-ink); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.outline { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.danger { background: var(--red); }
.btn.gray { background: #eef1f6; color: var(--ink); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.btn.xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; }
.btn.green { background: var(--green); }
.btn.green:hover { filter: brightness(.94); }

/* ── R1.6 Đề nghị chi & Thanh toán ── */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-head h3, .panel-head h4 { margin: 0; }
.panel.sub { background: var(--hover); box-shadow: none; margin-top: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl.sm th, .tbl.sm td { padding: 7px 9px; }
.card .v.warn { color: #b7791f; }
.badge { font-size: 11.5px; padding: 3px 9px; border-radius: 20px; font-weight: 600; display: inline-block; }
.badge.gray { background: #eef1f6; color: #64748b; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.green { background: #d1fae5; color: #047857; }
.badge.red { background: #fee2e2; color: #b91c1c; }
/* Ô thao tác trong bảng: GIỮ là table-cell (không dùng flex trên <td> để tránh vỡ hàng/tràn panel). */
.row-act { white-space: nowrap; text-align: right; vertical-align: middle; }
.row-act > .btn + .btn, .row-act > button + button { margin-left: 6px; }
.row-act > .btn, .row-act > button { vertical-align: middle; }
.col2 { grid-column: 1 / -1; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.kv span { color: var(--muted); }
.kv code { font-size: 12px; word-break: break-all; }
.warn-box { background: #fff8e6; border: 1px solid #f3e2b0; color: #8a6d1a; padding: 9px 11px; border-radius: 8px; font-size: 12.5px; margin-top: 10px; }
/* R2.2 §9 — Shared Payment Component */
.pay-sum { background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; }
.pay-sum .kv { font-size: 13px; padding: 4px 0; }
/* R2.3 USDT-first shared components */
.money-wrap { margin: 2px 0; }
.money-box { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.money-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.money-input { flex: 1; border: 0 !important; box-shadow: none !important; font-size: 18px; font-weight: 600; padding: 10px 12px; text-align: right; letter-spacing: .3px; }
.money-wrap.big .money-input { font-size: 24px; padding: 12px 14px; }
.money-unit { padding: 0 14px; font-weight: 700; color: var(--muted); border-left: 1px solid var(--line); align-self: stretch; display: flex; align-items: center; background: var(--hover); }
.money-sub { font-size: 12px; text-align: right; margin-top: 3px; min-height: 15px; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-btn { padding: 8px 20px; font-size: 14px; font-weight: 600; background: #fff; color: var(--muted); border: 0; cursor: pointer; }
.seg-btn.active { background: var(--brand); color: #fff; }
.fund-select { width: 100%; }
.pay-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.pay-row:last-child { border-bottom: 0; }
.pay-row.strong { font-weight: 700; font-size: 15px; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.crumb-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--hover); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; margin-bottom: 10px; }
.crumb-bar .crumb-path { font-weight: 600; }
.crumb-bar .sep { color: var(--muted); margin: 0 2px; }
.paste-summary { align-items: center; justify-content: space-between; gap: 10px; background: #eef6ff; border: 1px solid #cfe1fb; border-radius: 10px; padding: 8px 14px; font-size: 13px; }
/* R2.3 payment modal — 2 cột: nhập bên trái, tóm tắt cố định bên phải */
.pay-cols { display: flex; gap: 16px; margin-top: 12px; align-items: flex-start; }
.pay-cols .pay-left { flex: 1.4; min-width: 0; }
.pay-cols .pay-right { flex: 1; min-width: 240px; position: sticky; top: 0; }
.pay-fixed { background: var(--hover); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.pf-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13.5px; }
.pf-row.strong { font-weight: 700; font-size: 15px; }
.pf-sep { border-top: 1px solid var(--line); margin: 6px 0; }
.linkish { color: var(--brand); cursor: pointer; font-weight: 600; }
.pay-cols .field { margin-bottom: 8px; }
@media (max-width: 720px) { .pay-cols { flex-direction: column; } .pay-cols .pay-right { width: 100%; } }
.pay-preview { background: #eef3fe; border: 1px solid #c9d8fb; border-radius: 8px; padding: 6px 12px; margin-top: 8px; }
.pay-preview .kv { border-bottom: 1px dashed #c9d8fb; font-size: 12.5px; padding: 3px 0; }
.pay-preview .kv:last-child { border-bottom: 0; }
.pay-confirm { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
/* R2.3 — form đề nghị 3 bước: Phạm vi → Bộ phận → Hạng mục */
.step-lbl { font-size: 12.5px; font-weight: 700; color: var(--brand); margin: 14px 0 6px; }
.cc-row { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-btn { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 15px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: #24365e; transition: .12s; }
.cc-btn:hover { border-color: var(--brand); }
.cc-btn.active { border-color: var(--brand); background: #eef3fe; box-shadow: inset 0 0 0 2px var(--brand); }
.cat-chip { border: 1px solid var(--line); background: var(--hover); border-radius: 16px; padding: 6px 13px; cursor: pointer; font-size: 12.5px; color: #24365e; transition: .12s; }
.cat-chip:hover { border-color: var(--brand); color: var(--brand); }
.cat-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.cat-chip.more { background: #fff; color: var(--muted); border-style: dashed; }
.crumb { background: #eef3fe; border: 1px solid #c9d8fb; border-radius: 8px; padding: 7px 13px; font-weight: 700; color: #1b3aa0; font-size: 13.5px; margin-top: 12px; }
.crumb .sep { color: #94a3b8; margin: 0 8px; font-weight: 400; }
.single-amt { font-size: 18px !important; font-weight: 700; padding: 12px 14px !important; }
.alloc-block { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
/* R2.2 §14.1 — autosave status */
.savestate { font-size: 12.5px; }
.savestate .sv-ing { color: #8a6d1a; }
.savestate .sv-ok { color: #12855a; }
.savestate .sv-err { color: #d0342c; }
.lnk { color: var(--brand); cursor: pointer; text-decoration: none; font-weight: 600; }
.lnk:hover { text-decoration: underline; }
.checklist { display: flex; flex-direction: column; gap: 6px; }
.chk-item { font-size: 13.5px; padding: 6px 10px; border-radius: 8px; }
.chk-item.ok { background: #ecfdf3; color: #067647; }
.chk-item.no { background: #fef3f2; color: #b42318; }
.chk-mark { font-weight: 700; margin-right: 6px; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 20px; font-size: 13px; cursor: pointer; }
.chip-check:has(input:checked) { border-color: var(--brand); background: var(--hover); color: var(--brand); font-weight: 600; }
.todo-panel { border-left: 3px solid var(--brand); }
.todo-list { display: flex; flex-direction: column; gap: 6px; }
.todo-item { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; cursor: pointer; color: var(--ink); }
.todo-item:hover { border-color: var(--brand); color: var(--brand); }
.todo-count { background: var(--brand); color: #fff; min-width: 22px; height: 22px; border-radius: 11px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; padding: 0 6px; }
.todo-go { margin-left: auto; opacity: .5; }
.quick-cats { display: inline-flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.chip-btn { background: var(--hover); border: 1px solid var(--line); border-radius: 14px; padding: 3px 10px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.chip-btn:hover { border-color: var(--brand); color: var(--brand); }
/* Tab trong modal — 4 tab đều hàng, không cuộn ngang */
.mtabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0; }
.mtab { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 9px 8px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: center; }
.mtab:hover { border-color: var(--brand); }
.mtab.active { border-color: var(--brand); background: #eef3fe; color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
/* Thẻ lựa chọn (radio) trực quan */
.opt-card { display: flex; align-items: flex-start; gap: 9px; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; margin: 5px 0; cursor: pointer; font-size: 13px; }
.opt-card:hover { border-color: var(--brand); }
.opt-card:has(input:checked) { border-color: var(--brand); background: var(--hover); }
.opt-card input[type="radio"] { width: auto; margin-top: 3px; flex: 0 0 auto; }

/* ── R1.7 Cơ chế chia & thanh toán ── */
.mech-cards .card.mech { border-left: 3px solid var(--brand); }
.card.mech .v { font-size: 20px; }
.card.mech.muted-card { border-left-color: var(--line); }
.card.mech.muted-card .v { color: var(--muted); font-weight: 600; }
.calc td.lbl { color: var(--muted); }

.modal-bg { position: fixed; inset: 0; background: rgba(15,25,50,.45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; padding: 22px; width: min(640px, 96vw); max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
/* R2.2 §6.1 — form dài dùng modal rộng, chân form cố định */
.modal.wide { width: min(960px, 96vw); }
.modal.wide .actions { position: sticky; bottom: -22px; background: #fff; padding: 12px 0 2px; margin: 8px -22px -2px; padding-left: 22px; padding-right: 22px; border-top: 1px solid var(--line); }
/* R2.2 §6.2/§7.3 — nhãn độ tin cậy nhận diện */
.cf-tag { font-size: 10.5px; font-weight: 600; padding: 1px 7px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.cf-ok { background: #d1fae5; color: #047857; }
.cf-check { background: #fef3c7; color: #b45309; }
.cf-none { background: #eef1f6; color: #64748b; }
.field-check input, .field-check select { border-color: #f0c471 !important; background: #fffdf5; }
/* R2.2 §6.7 — khối ngân sách thông minh */
.budget-math { background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 6px; font-size: 12.5px; }
.budget-math .kv { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.budget-math .kv:last-child { border-bottom: 0; }
.budget-math.over { background: #fff1f0; border-color: #f3b4ae; }
.modal h3 { margin: 0 0 14px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.muted { color: var(--muted); }
.tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #eef1f6; color: var(--muted); }
.notice { background: #fff8e6; border: 1px solid #f3e2b0; color: #8a6d1a; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ── Skeleton loading ── */
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel { background: #eef1f6; background-image: linear-gradient(90deg, #eef1f6 0px, #f6f8fb 200px, #eef1f6 400px); background-size: 800px 100%; animation: shimmer 1.2s infinite linear; border-radius: 8px; }
.skel-line { height: 12px; margin: 8px 0; }
.skel-card { height: 96px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 18px; }
.skel-card .skel { height: 12px; margin-bottom: 12px; width: 55%; }
.skel-card .skel.big { height: 26px; width: 75%; }
.kpi-row { display: flex; gap: 20px; flex-wrap: wrap; }
.kpi-row .k { font-size: 12px; color: var(--muted); }
.kpi-row .v { font-size: 18px; font-weight: 700; }
.progress { height: 8px; background: #eef1f6; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.progress > i { display: block; height: 100%; background: var(--green); }

/* ── Đối soát ngày (2 cột + tóm tắt cố định) ── */
.ds-2col { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.ds-summary { position: sticky; top: 120px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.ds-summary h3 { margin: 0 0 10px; font-size: 14px; }
.ds-summary h4 { margin: 0; }
@media (max-width: 1100px) { .ds-2col { grid-template-columns: 1fr; } .ds-summary { position: static; } }
/* ── Đối soát ngày ── */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.step { flex: 1; min-width: 120px; padding: 8px 10px; border-radius: 8px; background: #eef1f6; color: var(--muted); font-size: 12px; text-align: center; border: 1px solid var(--line); position: relative; }
.step.done { background: var(--green-bg); color: var(--green); border-color: #bfe6d2; }
.step.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 600; }
.step b { display: block; font-size: 16px; }
.ds-block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.ds-block > h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.ds-block .num-badge { background: var(--brand); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; }
.calc { width: 100%; }
.calc td { padding: 7px 6px; border-bottom: 1px dashed var(--line); }
.calc tr:last-child td { border-bottom: 0; }
.calc .lbl { color: var(--muted); }
.calc .big td { font-size: 16px; font-weight: 700; border-top: 2px solid var(--line); }
.diff-banner { padding: 12px 14px; border-radius: 8px; font-weight: 600; margin: 8px 0; display: flex; justify-content: space-between; align-items: center; }
.diff-green { background: var(--green-bg); color: var(--green); }
.diff-red { background: var(--red-bg); color: var(--red); }
.diff-orange { background: #fff3e0; color: var(--orange); }
.diff-gray { background: #eef1f6; color: var(--muted); }
.alloc-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.alloc-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.alloc-card .t { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.alloc-card .a { font-size: 20px; font-weight: 700; margin-top: 4px; }
.alloc-card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.ds-actions { display: flex; gap: 10px; flex-wrap: wrap; }
textarea.bot { width: 100%; min-height: 120px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace, "Consolas", monospace; font-size: 13px; resize: vertical; }

@media (max-width: 900px) {
  .alloc-cards { grid-template-columns: 1fr; }
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); transition: .2s; width: 236px; }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .only-mobile { display: inline-flex; }
  .only-desktop { display: none; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .view { padding: 18px; }
  .page-title { font-size: 22px; }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: 1fr; }
}

/* ── A12 Phase 6: Dashboard redesign (KPI read-model, scope badge, drill-down) ── */
.dash-section { margin: 18px 0 10px; font-size: 13px; color: var(--muted); letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.scope-badge { font-size: 10px; font-weight: 600; padding: 1px 7px; border-radius: 9px; background: var(--hover); color: var(--muted); letter-spacing: .2px; vertical-align: middle; }
.kpi-row .kpi-big { transition: .12s; }
.card.kpi-big:hover, .kpi-cluster[data-drill]:hover { border-color: var(--accent, #2563EB); box-shadow: var(--shadow); }
.card.kpi-big .v { font-size: 22px; }
.kpi-cluster .panel-head { display: flex; justify-content: space-between; align-items: center; }
.kpi-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px; }
.kpi-3 .k { font-size: 11.5px; color: var(--muted); }
.kpi-3 .v { font-size: 17px; font-weight: 700; margin-top: 2px; }
.kpi-split { display: flex; gap: 18px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.ex-strip { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.ex-chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 20px; cursor: pointer; border: 1px solid var(--line); }
.ex-chip.ok { color: #16A34A; background: #F0FDF4; border-color: #BBF7D0; cursor: default; }
.ex-chip.warn { color: #B45309; background: #FFFBEB; border-color: #FDE68A; }
.ex-chip.danger { color: #B91C1C; background: #FEF2F2; border-color: #FECACA; }

/* ── A1 Phase 7: modal blocker khóa kỳ ── */
.lock-blockers { display: flex; flex-direction: column; gap: 8px; }
.lock-blocker { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.lock-blocker .dot { font-size: 10px; }
.lock-blocker .dot.neg { color: #B91C1C; }
.lock-blocker .dot.muted { color: var(--muted); }

/* ── MasterSpec P2: chọn kỳ (tháng/năm) + snapshot đóng kỳ ── */
.mperiod { display: inline-flex; align-items: center; gap: 2px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px 6px; }
.mperiod .mp-ico { font-size: 13px; padding: 0 2px; opacity: .7; }
.mperiod select { border: 0; background: transparent; font-size: 14px; font-weight: 600; color: var(--ink); padding: 5px 6px; border-radius: 7px; cursor: pointer; }
.mperiod select:hover { background: var(--hover); }
.mperiod select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }

.snap { font-size: 13.5px; }
.snap-hero { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: linear-gradient(180deg,#f8fafd,#eef3fb); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 14px; flex-wrap: wrap; }
.snap-hero .asof { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.snap-hero .asof b { color: var(--ink); }
.snap-hero .net { text-align: right; margin-left: auto; }
.snap-hero .net .lbl { display: block; color: var(--muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; }
.snap-hero .net .val { font-size: 21px; font-weight: 800; line-height: 1.2; }
/* Modal snapshot rộng hơn để 2 cột số THẬT (âm/nhiều chữ số) không tràn ngang. */
.modal.snap { width: min(760px, 96vw); }
.snap-grid { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
@media (max-width: 620px) { .snap-grid { grid-template-columns: 1fr; } }
.snap-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; min-width: 0; }
.snap-card h4 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700; }
.snap-kv { width: 100%; border-collapse: collapse; }
.snap-kv td { padding: 5px 0; border-bottom: 1px dashed var(--line); }
.snap-kv tbody tr:last-child td, .snap-kv tbody tr:last-child td { border-bottom: 0; }
.snap-kv td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 10px; }
.snap-kv tr.total td { font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; padding-top: 8px; }
.snap-foot { margin-top: 14px; background: var(--green-bg); border: 1px solid #cfead9; border-radius: 10px; padding: 11px 14px; font-size: 13px; }
.snap-foot.warn { background: #fff7ed; border-color: #fed7aa; }
.snap-foot b { font-size: 15px; }
