:root {
  --bg: #faf6f1; --card: #ffffff; --ink: #2a2320; --muted: #7a6f68; --line: #ece3da;
  --brand: #7b1e2b; --brand-2: #9e2a3a; --brand-soft: #f6e6e6; --gold: #c89b3c;
  --good: #2f7d4f; --good-soft: #e5f3ea; --warn: #b7791f; --warn-soft: #fbf1dc; --bad: #b42318; --bad-soft: #fde8e6;
  --info: #2c5d8a; --info-soft: #e5eef7;
  --radius: 12px; --shadow: 0 1px 2px rgba(60, 30, 20, .06), 0 4px 16px rgba(60, 30, 20, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* Khung */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #fff; border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; color: var(--brand); padding: 4px 8px 14px; }
.logo small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 8px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink); }
.nav a:hover { background: var(--brand-soft); text-decoration: none; }
.nav a.on { background: var(--brand); color: #fff; }
.nav a .ic { width: 20px; text-align: center; }
.main { padding: 20px 28px 90px; max-width: 1240px; width: 100%; }
.top { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.top .spacer { min-width: 10px; }
.bell { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; cursor: pointer; font-size: 17px; }
.bell b { position: absolute; top: -4px; right: -4px; background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 5px; }

/* Thẻ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.brand { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.brand .l, .kpi.brand .s { color: #f2d9d9; }

/* Nút */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 8px; cursor: pointer; font: inherit; font-size: 14px; white-space: nowrap; }
.btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand-2); color: #fff; }
.btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { color: var(--bad); }
.btn.ok { background: var(--good-soft); border-color: #bfe0cb; color: var(--good); }
.btn:disabled { opacity: .5; cursor: default; }

/* Nhãn */
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #f1ece6; color: var(--muted); white-space: nowrap; }
.tag.good { background: var(--good-soft); color: var(--good); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.info { background: var(--info-soft); color: var(--info); }
.tag.brand { background: var(--brand-soft); color: var(--brand); }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 9px 12px; border-radius: 9px; margin-bottom: 6px; font-size: 14px; }
.alert.danger { background: var(--bad-soft); }
.alert.warn { background: var(--warn-soft); }
.alert.info { background: var(--info-soft); }
.alert a { color: inherit; }

/* Bảng */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); padding: 7px 8px; white-space: nowrap; background: #fcfaf7; position: sticky; top: 0; }
.tbl td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.tbl th.num { text-align: right; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #fdf7f3; }
.tbl tr.past td { color: #a49a93; }
.tbl tr.now td { background: #fff7e8; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); }

/* Danh sách lịch */
.day { margin-bottom: 12px; }
.day-h { font-weight: 600; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.occ { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; margin-bottom: 6px; }
.occ .ic { font-size: 18px; }
.occ .t { flex: 1; min-width: 0; }
.occ .t b { font-weight: 600; }
.occ .t .muted { font-size: 12.5px; }
.occ.paid { opacity: .55; }
.occ.overdue { border-color: #f3b8b1; background: #fff8f7; }
.amt-out { color: var(--bad); font-weight: 600; }
.amt-in { color: var(--good); font-weight: 600; }

/* Form */
.modal-bg { position: fixed; inset: 0; background: rgba(30, 15, 10, .45); display: flex; align-items: flex-start; justify-content: center; z-index: 50; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 760px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { max-width: 1100px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; border-radius: 14px 14px 0 0; z-index: 2; }
.modal-h h2 { margin: 0; flex: 1; }
.modal-b { padding: 16px 18px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; border-radius: 0 0 14px 14px; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld label { font-size: 13px; font-weight: 600; }
.fld label .req { color: var(--bad); }
.fld .help { font-size: 12px; color: var(--muted); }
input, select, textarea { font: inherit; font-size: 14px; border: 1px solid #dccfc4; border-radius: 8px; padding: 7px 10px; background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #e8c3c7; border-color: var(--brand); }
textarea { min-height: 72px; resize: vertical; }
input.money { text-align: right; font-variant-numeric: tabular-nums; }
input[type=checkbox] { width: auto; }
.rows-ed { border: 1px solid var(--line); border-radius: 9px; overflow-x: auto; }
.rows-ed table { width: 100%; border-collapse: collapse; }
.rows-ed th { font-size: 12px; color: var(--muted); text-align: left; padding: 6px 8px; background: #fcfaf7; font-weight: 600; white-space: nowrap; }
.rows-ed td { padding: 4px 6px; border-top: 1px solid var(--line); min-width: 110px; }
.rows-ed td.x { min-width: 0; width: 30px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.file { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px; font-size: 13px; background: #fcfaf7; max-width: 100%; }
.file a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.file img { width: 34px; height: 34px; object-fit: cover; border-radius: 5px; }

/* Chi tiết */
.dl { display: grid; grid-template-columns: 200px 1fr; gap: 6px 14px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; word-break: break-word; white-space: pre-wrap; }

/* Ma trận BH */
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }
.cell-ok { background: var(--good-soft); }
.cell-dup { background: var(--warn-soft); }
.cell-none { color: #c9bdb4; }

/* Biểu đồ */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar { width: 70%; max-width: 38px; border-radius: 5px 5px 0 0; background: var(--brand); min-height: 2px; }
.bar.hot { background: var(--bad); }
.bar-col .lb { font-size: 11px; color: var(--muted); margin-top: 4px; }
.bar-col .vl { font-size: 10.5px; color: var(--muted); margin-bottom: 2px; white-space: nowrap; }
.meter { height: 10px; background: #f1ece6; border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.meter.warn > i { background: var(--warn); }
.meter.bad > i { background: var(--bad); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--brand); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 36px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #2a2320; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; font-size: 14px; box-shadow: var(--shadow); }
.toast.err { background: var(--bad); }
.notif-panel { position: fixed; top: 60px; right: 16px; width: 420px; max-width: calc(100vw - 32px); max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .18); z-index: 40; padding: 8px; }
.notif-head { padding: 8px 12px 10px; font-weight: 600; font-size: 15px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.5; font-weight: 400; color: #4a403b; border-bottom: 1px solid #f4eee8; }
.notif:last-child { border-bottom: 0; }
.notif .ni { font-size: 15px; line-height: 1.4; flex: none; }
.notif .nt { flex: 1; min-width: 0; }
.notif .nb { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.notif .nd { display: block; color: #b3a79f; font-size: 11.5px; margin-top: 3px; }
.notif:hover { background: var(--brand-soft); text-decoration: none; }
.notif.unread { background: #fdf6f2; color: var(--ink); }
.notif.unread .nt::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 6px; vertical-align: middle; }

/* Đăng nhập */
.auth { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.auth .card { padding: 26px; }
.auth .logo { justify-content: center; font-size: 24px; }

.bottom-nav { display: none; }

@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
  .side.open { transform: none; }
  .main { padding: 14px 16px 90px; }
  .form { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 0 0; }
  .dl dt { margin-top: 8px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 30; padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); padding: 4px 0; background: none; border: 0; font-family: inherit; }
  .bottom-nav .ic { font-size: 19px; }
  .bottom-nav .on { color: var(--brand); }
  .kpi .v { font-size: 18px; }
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .hide-m { display: none; }
}
@media print {
  .side, .bottom-nav, .top .btn, .bell, .no-print { display: none !important; }
  .app { display: block; }
  .main { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* Bảng: STT + tìm + lọc */
.tbl th.stt, .tbl td.stt { width: 42px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.tbl-tools { display: flex; gap: 10px; align-items: center; margin: 0 0 8px; flex-wrap: wrap; }
.tbl-tools input { max-width: 420px; flex: 1; min-width: 180px; }
.flt-btn { border: 0; background: transparent; color: #b9aca2; cursor: pointer; font-size: 11px; padding: 0 2px; margin-left: 3px; }
.flt-btn:hover { color: var(--brand); }
th.flt-on .flt-btn { color: #fff; background: var(--brand); border-radius: 4px; }
.flt-pop { position: absolute; z-index: 80; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.18); padding: 10px; }
.flt-list { max-height: 260px; overflow-y: auto; margin-top: 6px; font-size: 13.5px; }
.flt-list label { display: flex; gap: 6px; align-items: flex-start; padding: 3px 2px; cursor: pointer; }
.flt-list label:hover { background: var(--brand-soft); }
.flt-list input { width: auto; margin-top: 3px; }

/* Chuông + người dùng */
.notif-head { display: flex; align-items: center; gap: 8px; }
.notif { position: relative; }
.nread { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 50%; width: 24px; height: 24px; flex: none; cursor: pointer; font-size: 12px; line-height: 1; }
.nread:hover { color: var(--good); border-color: var(--good); }
.userchip { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 3px 14px 3px 3px; cursor: pointer; font: inherit; }
.userchip:hover { border-color: var(--brand); }
.av { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-soft); flex: none; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.av-txt { color: var(--brand); font-weight: 700; }
.av.big { width: 44px; height: 44px; font-size: 18px; }
.un { font-weight: 600; font-size: 14px; }
.user-menu { position: fixed; top: 60px; right: 16px; width: 280px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.18); z-index: 41; padding: 8px; }
.um-head { display: flex; gap: 10px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.um-item { display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; }
.um-item:hover { background: var(--brand-soft); text-decoration: none; }

/* ───────── Hướng dẫn ───────── */
.help-btn { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); display: inline-flex; gap: 4px; align-items: center; }
.help-btn:hover { border-color: var(--brand); color: var(--brand); }
.hdsd { font-size: 14px; line-height: 1.55; }
.hdsd h3 { margin: 20px 0 8px; color: var(--brand); font-size: 15px; }
.hd-flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; background: #fcf7f3; border: 1px dashed #e3cfc2; border-radius: 12px; padding: 12px; }
.hd-step { flex: 1 1 110px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; }
.hd-ic { font-size: 22px; }
.hd-st { font-weight: 600; font-size: 13px; }
.hd-sd { color: var(--muted); font-size: 11.5px; }
.hd-arr { align-self: center; color: var(--brand); font-weight: 700; }
.hd-fig { margin: 8px 0; }
.hd-fig figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.hd-win { border: 1px solid #ddd0c5; border-radius: 10px; overflow: hidden; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.hd-bar { background: #f3ece6; padding: 5px 10px; font-size: 12px; color: var(--muted); display: flex; gap: 5px; align-items: center; }
.hd-bar i { width: 8px; height: 8px; border-radius: 50%; background: #d9c9bd; display: inline-block; }
.hd-bar span { margin-left: 6px; }
.hd-body { padding: 12px; }
.hd-n { display: inline-flex; width: 18px; height: 18px; border-radius: 50%; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; align-items: center; justify-content: center; vertical-align: middle; margin-left: 3px; flex: none; }
.hd-btn { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); border-radius: 7px; padding: 3px 9px; font-size: 12.5px; background: #fff; margin: 2px; }
.hd-btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); }
.hd-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.hd-lb { font-size: 12px; font-weight: 600; }
.hd-in { border: 1px solid #e0d4ca; border-radius: 6px; padding: 4px 8px; font-size: 12.5px; color: #6b5f58; background: #fffdfb; }
.hd-tb { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.hd-tb th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 4px 6px; background: #fcfaf7; }
.hd-tb td { border-bottom: 1px solid var(--line); padding: 5px 6px; }
.hd-tb tr.hl td { background: var(--bad-soft); }
.hd-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.hd-kpi { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 11.5px; color: var(--muted); }
.hd-kpi b { display: block; color: var(--ink); font-size: 15px; }
.hd-kpi.brand { background: var(--brand); color: #f2d9d9; }
.hd-kpi.brand b { color: #fff; }
.hd-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0; }
.hd-notes { list-style: none; padding: 0; margin: 6px 0 4px; }
.hd-notes li { margin: 4px 0; font-size: 13.5px; }
.hd-notes .hd-n { margin: 0 4px 0 0; }
.hd-tip { background: var(--info-soft); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-top: 10px; }
.hd-alert { background: var(--warn-soft); border-radius: 7px; padding: 5px 8px; font-size: 12.5px; margin: 8px 0; }
.hd-occ { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 12.5px; margin-top: 6px; }
.hd-occ div { flex: 1; }
.hd-occ small { display: block; color: var(--muted); }
.hd-occ em { color: var(--bad); font-style: normal; font-weight: 600; }
.hd-tag { font-size: 11px; background: #f1ece6; border-radius: 999px; padding: 0 6px; color: var(--muted); }
.hd-tag.bad { background: var(--bad-soft); color: var(--bad); }
.hd-tag.warn { background: var(--warn-soft); color: var(--warn); }
.hd-bars { display: flex; align-items: flex-end; gap: 4px; height: 80px; }
.hd-bars i { flex: 1; background: var(--brand); border-radius: 3px 3px 0 0; }
.hd-bars i.hot { background: var(--bad); }
.hd-card { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-top: 8px; font-size: 13px; }
.hd-card small { display: block; color: var(--muted); }
.hd-meter { display: flex; gap: 8px; align-items: center; font-size: 12.5px; margin: 5px 0; }
.hd-meter span { width: 80px; }
.hd-meter i { display: block; height: 8px; border-radius: 99px; background: var(--good); }
.hd-meter.warn i { background: var(--warn); }
.hd-meter em { font-style: normal; color: var(--muted); margin-left: auto; }
@media (max-width: 760px) { .hd-form { grid-template-columns: 1fr; } .hd-kpis { grid-template-columns: 1fr 1fr; } .hd-arr { display: none; } }

/* Modal: chỉ phần nội dung cuộn, tiêu đề và nút cố định (không bị chữ chạy lên trên tiêu đề) */
.modal-bg { align-items: center; overflow: hidden; }
.modal { max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden; }
.modal-h, .modal-f { position: static; flex: none; }
.modal-b { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
@media (max-width: 760px) { .modal { max-height: 100vh; height: 100vh; } }

/* Cần chú ý: chữ nhỏ, nhẹ; dòng chính + dòng phụ mờ */
.alert { gap: 9px; padding: 7px 11px; margin-bottom: 5px; font-size: 13px; line-height: 1.45; font-weight: 400; }
.alert a { text-decoration: none; display: block; }
.alert .al-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; background: var(--info); }
.alert.danger .al-dot { background: var(--bad); } .alert.warn .al-dot { background: var(--warn); }
.alert .al-h { color: var(--ink); }
.alert .al-d { color: var(--muted); font-size: 12px; margin-top: 1px; }
.al-more > summary { cursor: pointer; font-size: 12.5px; color: var(--muted); padding: 4px 2px 6px; }

/* Tổng quan: hàng 2 — bảng khoản chờ (rộng) + ô tóm tắt */
.dash2 { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); margin-top: 14px; align-items: start; }
@media (max-width: 1100px) { .dash2 { grid-template-columns: 1fr; } }
.tbl.pend td { vertical-align: top; font-size: 13.5px; }
.tbl.pend .row-late td { background: #fff8f7; }
.nowrap { white-space: nowrap; }
table.mini { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.mini td { padding: 6px 2px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.mini td.num { text-align: right; white-space: nowrap; }
table.mini tr.tot td { font-weight: 600; border-bottom: 0; }
.mini-kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; padding: 5px 0; border-top: 1px dashed var(--line); }
.mini-kv span { color: var(--muted); } .mini-kv b { font-weight: 600; text-align: right; }
.dash-side { position: sticky; top: 12px; }
@media (max-width: 1100px) { .dash-side { position: static; } }

/* Thanh "Lưu thay đổi" nổi ở đáy khi tick tạm trong bảng */
.save-bar { position: sticky; bottom: 12px; z-index: 30; display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 14px; background: #fff7e0; border: 1px solid #f0d58a; border-radius: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.12); font-size: 13.5px; }
.save-bar[hidden] { display: none; }
.save-bar .msg { flex: 1; min-width: 0; }
.tbl tr.row-pending td { background: #fff7e0 !important; }

/* Đầu trang: chuông + avatar luôn ở góc phải hàng trên; nhiều nút thao tác → hàng riêng bên dưới */
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; column-gap: 12px; }
.top .spacer { display: none; }
.top .top-r { flex-wrap: nowrap; justify-content: flex-end; }
.top .top-acts { grid-column: 1 / -1; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
@media (max-width: 760px) { .top { grid-template-columns: 1fr; } .top .top-r { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; } }

/* Cơ cấu tài sản: dòng bấm mở chi tiết */
details.atype { border-bottom: 1px solid var(--line); }
details.atype > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 7px 4px; cursor: pointer; font-size: 13.5px; border-radius: 8px; }
details.atype > summary::-webkit-details-marker { display: none; }
details.atype > summary::before { content: '▸'; color: var(--muted); width: 10px; transition: transform .15s; }
details.atype[open] > summary::before { transform: rotate(90deg); }
details.atype > summary:hover { background: #faf6f1; }
details.atype .at-k { width: 200px; flex: none; }
details.atype .at-v { width: 150px; flex: none; text-align: right; }
details.atype .at-p { width: 44px; flex: none; text-align: right; }
details.atype .at-body { padding: 4px 8px 12px 24px; }
@media (max-width: 760px) { details.atype .at-k { width: 120px; } details.atype .at-v { width: 110px; } }

/* Bảng con trong trang chi tiết (lãi theo thời gian, kỳ trả NH…): tiêu đề cột thẳng hàng với số */
.tbl.sub-rows th.num, .tbl.sub-rows td.num { text-align: right; white-space: nowrap; }
.tbl.sub-rows td, .tbl.sub-rows th { padding-left: 14px; padding-right: 14px; }

/* Thương hiệu Nestvi */
.nv-lock { gap: 10px; padding-bottom: 4px; }
.nv-mark { width: 38px; height: 38px; flex: none; border-radius: 10px; box-shadow: 0 2px 6px rgba(123,30,43,.25); }
.nv-word b { display: block; font-weight: 800; letter-spacing: .14em; font-size: 19px; line-height: 1.05; color: var(--brand); }
.nv-word span { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); margin-top: 2px; letter-spacing: 0; }
.nv-hh { font-size: 12px; color: var(--muted); padding: 2px 8px 14px 56px; }
.nv-big { justify-content: center; }
.nv-big .nv-mark { width: 60px; height: 60px; border-radius: 15px; }
.nv-big .nv-word b { font-size: 30px; }
.nv-big .nv-word span { font-size: 13.5px; }
.nv-slogan { text-align: center; color: var(--muted); font-style: italic; font-size: 13px; margin: -4px 0 14px; }

/* Thanh bên thu gọn / mở rộng */
.side { display: flex; flex-direction: column; }
.side .nav, .side .nav-group, .side .logo, .side .nv-hh { flex: none; }
.side-toggle { margin-top: auto; flex: none; display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; margin-bottom: 2px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--muted); font: inherit; font-size: 13.5px; cursor: pointer; position: sticky; bottom: 0; box-shadow: 0 -8px 12px #fff; }
.side-toggle:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.side-toggle .ic { font-size: 16px; width: 22px; text-align: center; }
.app { transition: grid-template-columns .18s; }
.app.side-min { grid-template-columns: 68px 1fr; }
.app.side-min .main { max-width: 1560px; }
.side-min .side { padding: 14px 8px; overflow-x: hidden; }
.side-min .side .lb, .side-min .nv-word, .side-min .nv-hh { display: none; }
.side-min .side .logo { justify-content: center; padding: 4px 0 14px; }
.side-min .nav-group { height: 1px; background: var(--line); margin: 10px 6px; }
.side-min .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
.side-min .side-toggle { justify-content: center; padding: 9px 0; }
@media (max-width: 760px) { .side-toggle { display: none; } .app.side-min { grid-template-columns: 1fr; } .side-min .side .lb, .side-min .nv-word, .side-min .nv-hh { display: revert; } }

/* Nút Thu gọn: rõ ràng, màu thương hiệu */
.side-toggle { gap: 10px; padding: 8px 12px 8px 8px; border: 1px solid #ecc9cd; background: var(--brand-soft); color: var(--brand); font-weight: 600; font-size: 14px; border-radius: 12px; box-shadow: 0 -10px 14px #fff; transition: background .15s, color .15s, border-color .15s; }
.side-toggle .st-ic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; flex: none; transition: transform .2s, background .15s, color .15s; }
.side-toggle:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.side-toggle:hover .st-ic { background: #fff; color: var(--brand); }
.side-min .side-toggle { padding: 8px 0; background: transparent; border-color: transparent; box-shadow: none; }
.side-min .side-toggle .st-ic { transform: rotate(180deg); width: 32px; height: 32px; }
.side-min .side-toggle:hover { background: transparent; }
.side-min .side-toggle:hover .st-ic { background: var(--brand-2); color: #fff; }

/* Logo Nestvi (ảnh chị gửi) */
.nv-mark { box-shadow: none; border-radius: 0; }
.nv-full-wrap { text-align: center; margin: 0 0 6px; }
.nv-full { width: 100%; max-width: 380px; height: auto; background: #fff; border-radius: 18px; padding: 6px 10px; box-shadow: 0 4px 18px rgba(123,30,43,.08); }
.nv-word b { font-weight: 900; letter-spacing: .03em; font-size: 21px; background: linear-gradient(180deg, #d01c34, #7b1e2b); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* Tên gia đình dưới logo — icon tài khoản Nestvi */
.nv-hh { display: flex; align-items: center; gap: 8px; padding: 2px 8px 14px 56px; font-size: 15px; font-weight: 600; color: #4a403b; }
.nv-hh-ic { width: 26px; height: 26px; flex: none; }
.side-min .nv-hh { display: flex; justify-content: center; padding: 0 0 12px; }
.side-min .nv-hh-ic { width: 30px; height: 30px; }
/* Icon tài khoản: chỉ là icon nhỏ cạnh tên, không lấn logo */
.nv-hh { gap: 6px; font-size: 14px; padding: 0 8px 14px 56px; }
.nv-hh-ic { width: 17px; height: 17px; }
.side-min .nv-hh-ic { width: 22px; height: 22px; }

/* Thanh bên: dùng nguyên ảnh logo của chị (đúng font, slogan dàn hết chiều dài chữ NESTVI) */
.nv-side-logo { display: block; padding: 2px 4px 8px; }
.nv-side-logo .nv-lockup { display: block; width: 100%; max-width: 204px; height: auto; }
.nv-side-logo .nv-mark { display: none; width: 40px; height: 40px; }
.side-min .nv-side-logo { display: flex; justify-content: center; padding: 4px 0 12px; }
.side-min .nv-side-logo .nv-lockup { display: none; }
.side-min .nv-side-logo .nv-mark { display: block; }
.nv-hh { gap: 6px; font-size: 14px; padding: 0 8px 14px 12px; }
.nv-hh-ic { width: 14px; height: 14px; }
.side-min .nv-hh-ic { width: 20px; height: 20px; }
/* Icon + tên tài khoản: căn giữa đúng dưới dòng slogan (slogan chiếm 28,1% → 99,4% chiều rộng ảnh logo) */
.nv-hh { box-sizing: border-box; width: calc(100% - 8px); max-width: 204px; margin: 0 4px; padding: 0 0.6% 14px 28.1%; justify-content: center; }
.side-min .nv-hh { width: auto; max-width: none; margin: 0; padding: 0 0 12px; }
/* Nội dung trải hết chiều rộng màn hình (không chừa khoảng trống bên phải) */
.main, .app.side-min .main { max-width: none; }
/* Logo bấm được → về Tổng quan */
#homeLogo { cursor: pointer; border-radius: 10px; }
#homeLogo:hover { opacity: .9; }
/* Tên tài khoản: viên nhãn đỏ đô nổi bật */
.nv-hh .lb { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: 13.5px; letter-spacing: .02em; border: 1px solid #ecc9cd; }
.nv-hh { gap: 5px; }
/* Ma trận bảo hiểm: dòng tổng cả nhà */
.tbl.matrix tfoot td { background: var(--brand-soft); border-top: 2px solid var(--brand); text-align: center; vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.tbl.matrix tfoot td:first-child { text-align: center; }
.tbl.matrix tfoot td.num { text-align: right; }
.tbl.matrix tfoot b { color: var(--brand); }
/* Bảng rộng chỉ cuộn ngang TRONG khung bảng — không nong cả trang làm trôi thanh bên */
.app { grid-template-columns: 232px minmax(0, 1fr); }
.app.side-min { grid-template-columns: 68px minmax(0, 1fr); }
.main { min-width: 0; }
.card { min-width: 0; }
.tbl-wrap { max-width: 100%; }
@media (max-width: 760px) { .app, .app.side-min { grid-template-columns: minmax(0, 1fr); } }
