/* ux.css — các cải tiến trải nghiệm (đi kèm ux.js) */

/* ── A: Toast ─────────────────────────────────────────── */
.tst{pointer-events:auto}
.tst .tst-msg{flex:1;white-space:pre-line;line-height:1.45}
.tst .tst-x{background:transparent;border:none;color:inherit;opacity:.75;font-size:16px;line-height:1;cursor:pointer;padding:0 0 0 6px;font-family:inherit}
.tst .tst-x:hover{opacity:1}
.tst.wa{background:#B45309;color:#fff}

/* ── A2/C3: Chuông thông báo ──────────────────────────── */
.atb-bell::after{display:none}
.atb-bell .ux-bell-badge{position:absolute;top:2px;right:0;min-width:16px;height:16px;padding:0 4px;border-radius:9px;background:#FF4757;color:#fff;font-size:10px;font-weight:800;line-height:16px;text-align:center;border:2px solid #fff;box-sizing:content-box;display:none}
.atb-bell.has-unread .ux-bell-badge{display:block}
.ux-notif{position:fixed;z-index:6000;width:380px;max-width:calc(100vw - 20px);max-height:70vh;display:none;flex-direction:column;background:#fff;border:1px solid #E1E7EF;border-radius:14px;box-shadow:0 12px 40px rgba(13,30,60,.18);overflow:hidden;font-family:inherit}
.ux-notif.open{display:flex}
.ux-notif-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid #EEF2F7;font-weight:800;font-size:14px;color:#0F172A}
.ux-notif-head button{background:none;border:none;color:var(--blue,#0057B8);font-size:12px;font-weight:600;cursor:pointer;font-family:inherit}
.ux-notif-list{overflow:auto;flex:1}
.ux-notif-item{display:flex;gap:10px;padding:10px 14px;border-bottom:1px solid #F3F5F9;cursor:pointer;align-items:flex-start}
.ux-notif-item:hover{background:#F8FAFD}
.ux-notif-item.unread{background:#F0F7FF}
.ux-notif-item .ni-ico{font-size:16px;line-height:20px;flex-shrink:0}
.ux-notif-item .ni-title{font-size:12.5px;font-weight:700;color:#1E293B;line-height:1.35}
.ux-notif-item .ni-body{font-size:11.5px;color:#64748B;margin-top:2px;line-height:1.4;word-break:break-word}
.ux-notif-item .ni-time{font-size:10.5px;color:#94A3B8;margin-top:3px}
.ux-notif-empty{padding:28px 14px;text-align:center;color:#94A3B8;font-size:13px}

/* ── B: Thanh công cụ trong plan ──────────────────────── */
.ux-ptools{display:flex;align-items:center;gap:6px;margin-right:10px;flex-wrap:nowrap}
.ux-chip,.plan-crumb .ux-chip{text-decoration:none;display:inline-flex;align-items:center;gap:5px;padding:5px 10px;border-radius:7px;border:1.5px solid #CBD5E1;background:#fff;color:#475569;font-size:12px;font-weight:600;cursor:pointer;white-space:nowrap;font-family:inherit;line-height:1.2}
.ux-chip:hover,.plan-crumb .ux-chip:hover{border-color:#3B82F6;color:#1D4ED8;background:#EFF6FF}
.ux-chip:disabled,.plan-crumb .ux-chip:disabled{opacity:.45;cursor:default;background:#fff;color:#475569;border-color:#CBD5E1}
.ux-chip.on,.plan-crumb .ux-chip.on{background:#EFF6FF;border-color:#3B82F6;color:#1D4ED8}
.ux-chip.warn,.plan-crumb .ux-chip.warn{border-color:#F59E0B;color:#92400E;background:#FFFBEB}
.ux-chip.okc,.plan-crumb .ux-chip.okc{border-color:#BBF7D0;color:#15803D;background:#F0FDF4;cursor:default}


/* B5: ô thiếu dữ liệu */
.pt tr.rd.ux-miss td:nth-child(1){box-shadow:inset 3px 0 0 #F59E0B}
.pt td.ux-miss-cell{outline:2px solid rgba(245,158,11,.8);outline-offset:-2px}
.pt tr.rd.ux-miss-flash td{animation:uxFlash 1.4s ease}
@keyframes uxFlash{0%,60%{background-color:#FEF3C7}100%{background-color:transparent}}

/* B3: cố định cột (left được tính trong ux.js) */
/* Ô tiêu đề "Vùng" luôn nằm trên các tiêu đề khác khi cuộn ngang (dòng tổng được chèn lên đầu thead nên rule nth-child(1) cũ không còn khớp) */
.pt thead tr.ux-h1 th:nth-child(1){z-index:52!important}
.pt.ux-freeze td.ux-fz-edge,.pt.ux-freeze th.ux-fz-edge{box-shadow:4px 0 6px -3px rgba(15,23,42,.18)}

/* B6: banner lưu/kết nối */
.ux-banner{position:fixed;top:10px;left:50%;transform:translateX(-50%);z-index:7000;display:none;align-items:center;gap:12px;max-width:calc(100vw - 24px);padding:10px 14px;border-radius:10px;background:#7F1D1D;color:#fff;font-size:13px;font-weight:600;box-shadow:0 8px 28px rgba(0,0,0,.25)}
.ux-banner.show{display:flex}
.ux-banner.offline{background:#334155}
.ux-banner button{background:#fff;color:#7F1D1D;border:none;border-radius:7px;padding:6px 12px;font-size:12px;font-weight:700;cursor:pointer;font-family:inherit;white-space:nowrap}
.ux-banner .bx{background:transparent;color:#fff;opacity:.7;padding:0 4px;font-size:16px}
.save-ind.saved{cursor:help}

/* ── C1: Bảng lệnh Ctrl+K ─────────────────────────────── */
.ux-pal-ov{position:fixed;inset:0;z-index:8000;background:rgba(15,23,42,.45);backdrop-filter:blur(3px);display:none;align-items:flex-start;justify-content:center;padding-top:12vh}
.ux-pal-ov.open{display:flex}
.ux-pal{width:600px;max-width:calc(100vw - 24px);background:#fff;border-radius:14px;box-shadow:0 20px 60px rgba(0,0,0,.3);overflow:hidden}
.ux-pal input{width:100%;box-sizing:border-box;border:none;border-bottom:1px solid #EEF2F7;padding:16px 18px;font-size:15px;outline:none;font-family:inherit}
.ux-pal-list{max-height:52vh;overflow:auto;padding:6px}
.ux-pal-grp{font-size:10.5px;font-weight:800;color:#94A3B8;text-transform:uppercase;letter-spacing:.5px;padding:8px 12px 4px}
.ux-pal-it{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:9px;cursor:pointer;font-size:13px;color:#1E293B}
.ux-pal-it .pi{width:22px;text-align:center;flex-shrink:0}
.ux-pal-it .pm{margin-left:auto;font-size:11px;color:#94A3B8;white-space:nowrap}
.ux-pal-it.sel{background:#EFF6FF;color:#1D4ED8}
.ux-pal-foot{display:flex;gap:14px;padding:8px 14px;border-top:1px solid #EEF2F7;font-size:11px;color:#94A3B8}
.ux-kbd{display:inline-block;padding:1px 5px;border:1px solid #CBD5E1;border-bottom-width:2px;border-radius:4px;font-size:10.5px;color:#475569;background:#F8FAFC;font-family:inherit}

.ux-pill{display:inline-block;padding:2px 7px;border-radius:20px;font-size:10.5px;font-weight:700;white-space:nowrap}
.ux-pill.red{background:#FEE2E2;color:#B91C1C}.ux-pill.amb{background:#FEF3C7;color:#92400E}.ux-pill.grn{background:#DCFCE7;color:#15803D}.ux-pill.blu{background:#DBEAFE;color:#1D4ED8}
.ux-hempty{font-size:12px;color:#64748B;padding:6px 8px}

/* ── D: Modal xác nhận / nhập / xem trước sync ────────── */
.ux-modal-ov{position:fixed;inset:0;z-index:9000;background:rgba(15,23,42,.5);backdrop-filter:blur(3px);display:flex;align-items:center;justify-content:center;padding:16px}
.ux-modal{width:440px;max-width:100%;max-height:88vh;display:flex;flex-direction:column;background:#fff;border-radius:16px;box-shadow:0 24px 64px rgba(0,0,0,.3);overflow:hidden;animation:uxPop .16s ease}
.ux-modal.wide{width:720px}
@keyframes uxPop{from{transform:scale(.96);opacity:0}to{transform:none;opacity:1}}
.ux-modal-b{padding:20px 22px 8px;overflow:auto}
.ux-modal-t{font-size:16px;font-weight:800;color:#0F172A;margin-bottom:8px;display:flex;gap:8px;align-items:center}
.ux-modal-m{font-size:13.5px;color:#334155;line-height:1.55;white-space:pre-line}
.ux-modal input.ux-in{width:100%;box-sizing:border-box;margin-top:12px;padding:9px 12px;border:1.5px solid #CBD5E1;border-radius:9px;font-size:14px;font-family:inherit;outline:none}
.ux-modal input.ux-in:focus{border-color:#3B82F6}
.ux-modal-hint{font-size:12px;color:#B91C1C;margin-top:10px}
.ux-modal-f{display:flex;justify-content:flex-end;gap:8px;padding:14px 22px 18px;flex-wrap:wrap}
.ux-btn{padding:9px 16px;border-radius:9px;font-size:13px;font-weight:700;cursor:pointer;font-family:inherit;border:1.5px solid #CBD5E1;background:#fff;color:#334155}
.ux-btn:hover{background:#F8FAFC}
.ux-btn.pri{background:var(--blue,#0057B8);border-color:var(--blue,#0057B8);color:#fff}
.ux-btn.pri:hover{filter:brightness(1.08)}
.ux-btn.dan{background:#DC2626;border-color:#DC2626;color:#fff}
.ux-btn:disabled{opacity:.45;cursor:not-allowed;filter:none}
.ux-diff{border:1px solid #E2E8F0;border-radius:10px;margin-top:10px;overflow:hidden}
.ux-diff-h{display:flex;align-items:center;gap:8px;padding:9px 12px;background:#F8FAFC;font-weight:700;font-size:13px;color:#0F172A;flex-wrap:wrap}
.ux-diff-h .sp{flex:1}
.ux-diff-b{padding:8px 12px;font-size:12px;color:#334155;line-height:1.55;max-height:180px;overflow:auto}
.ux-diff-b ul{margin:2px 0 6px;padding-left:18px}
.ux-diff-b .ch{color:#64748B}
.ux-diff-warn{background:#FEF2F2;color:#B91C1C;padding:8px 12px;font-size:12px;font-weight:600;border-top:1px solid #FECACA}
.ux-sync-tbl{width:100%;border-collapse:collapse;font-size:12.5px;margin:6px 0 10px}
.ux-sync-tbl th{text-align:left;font-size:11px;color:#64748B;font-weight:700;padding:6px 6px;border-bottom:1px solid #E2E8F0}
.ux-sync-tbl td{padding:7px 6px;border-bottom:1px solid #F1F5F9;vertical-align:middle}
.ux-sync-tbl td.st{white-space:nowrap}
.ux-sync-prog{font-size:12.5px;line-height:1.9}

/* ── E: kiểm tra hợp đồng / preset ───────────────────── */
.ux-issues{margin-top:8px;border:1px solid #FDE68A;background:#FFFBEB;border-radius:10px;padding:8px 12px;font-size:12.5px;color:#78350F;max-height:300px;overflow:auto}
.ux-issues li{margin:3px 0}
.ux-preset{display:flex;gap:6px;align-items:center;flex-wrap:wrap;margin-top:8px}
.ux-preset select{padding:7px 10px;border:1.5px solid #CBD5E1;border-radius:8px;font-size:12.5px;font-family:inherit;max-width:240px}

/* ══════════════════════════════════════════════════════════
   ĐIỆN THOẠI (≤768px): giữ giao diện như desktop, tối ưu để xem/nhập
   ══════════════════════════════════════════════════════════ */
@media(min-width:769px){ .ux-ptools .ux-mob{display:none} }
@media(max-width:768px){
  /* Chuông luôn hiện */
  .app-shell .atb-bell{display:flex}
  /* Toast: rộng theo màn hình, ở đáy */
  .tw2{left:10px;right:10px;bottom:10px}
  .tst{max-width:none}

  /* ── Thanh plan: dòng 1 = ← + tên plan; dòng 2 = công cụ (vuốt ngang) ── */
  .plan-crumb{flex-wrap:wrap;row-gap:6px;column-gap:6px;padding:6px 10px!important}
  .plan-crumb > span:not([id]){display:none}
  .plan-crumb > div[style*="flex:1"]{display:none}
  #crumb-back-btn{font-size:0!important;text-decoration:none!important;width:34px;height:30px;border-radius:8px;background:#fff!important;border:1.5px solid #CBD5E1!important;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0}
  #crumb-back-btn::before{content:"←";font-size:17px;color:var(--blue,#0057B8);font-weight:700}
  #crumb-name{flex:1 1 0;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px}
  #crumb-badge{display:none}
  #presence-strip{margin-right:0!important}
  .ux-ptools{order:5;flex:1 1 100%;min-width:0;margin-right:0;flex-wrap:nowrap;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;padding-bottom:1px}
  .ux-ptools::-webkit-scrollbar{display:none}
  .ux-ptools > *{flex-shrink:0}
  .ux-ptools .ux-desk{display:none}
  .plan-crumb .ux-chip{padding:7px 10px;font-size:12px}
  #ux-undo,#ux-redo{min-width:38px;justify-content:center}
  #crumb-actions{order:2}
  #btn-share-plan{font-size:0!important;padding:6px 8px!important}
  #btn-share-plan svg{width:15px;height:15px}
  #btn-comment-toggle{order:3;padding:6px 8px!important}

  /* ── Bảng Plan ── */
  .tw{-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
  /* Cột đầu (Vùng / nút dòng) thu nhỏ để chừa chỗ cho số liệu */
  .pt thead tr.ux-h1 th:nth-child(1),.pt thead tr.plan-total-thead-row td:nth-child(1),.pt tbody td:nth-child(1){width:40px!important;min-width:40px!important;max-width:40px!important;padding:0 2px!important}
  .pt thead tr.ux-h1 th:nth-child(1){font-size:0!important}
  .pt thead tr.ux-h1 th:nth-child(1)::after{content:"Vùng";font-size:9.5px}
  .pt thead tr.plan-total-thead-row{height:28px!important}
  .pt thead tr.plan-total-thead-row td{height:28px!important;line-height:1.2!important;padding:0 6px!important}
  .pt thead tr.ux-h2 th:nth-child(1){left:auto!important;width:auto!important;min-width:72px!important;max-width:none!important}
  /* Tên vùng tràn sang phải trên dòng xám, luôn đọc được khi cuộn */
  .pt tbody tr.rv td:nth-child(1){overflow:visible;font-size:12px!important;padding:0 6px!important;text-shadow:0 0 3px #D5D5D5,0 0 3px #D5D5D5,0 0 6px #D5D5D5}
  /* Dòng cao hơn cho dễ chạm */
  .pt tbody td{height:36px}
  .ce,.tinh-sel,.cmast input{font-size:13px}
  /* Cột Siêu thị gọn, 2 dòng */
  .pt thead th.hst{min-width:118px;width:118px}
  .pt tbody tr.rd .ctxt{max-width:112px!important;white-space:normal;line-height:1.25;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:11px;color:#334155}
  .pt thead th.htinh{min-width:118px}
  .pt tbody td[style*="width:155px"]{min-width:118px!important;width:118px!important}
  /* Ẩn vùng khác / dòng trống (bật tắt bằng nút trên thanh plan) */
  .pt.ux-mine tr.ux-other{display:none}
  .pt.ux-hide-empty tr.rd.ux-empty{display:none}

  /* ── Các màn hình khác ── */
  .budget-stat-grid,#th-summary-cards{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
  #view-budget .budget-stat-card{padding:12px!important;gap:10px!important;align-items:flex-start}
  #view-budget .budget-stat-card .stat-ico-v2{width:38px!important;height:38px!important;font-size:18px}
  #view-budget .budget-stat-card .stat-value,#view-budget .budget-stat-card .budget-stat-value{font-size:16px!important;white-space:normal}
  #th-summary-cards > div{padding:12px 12px!important}
  #th-summary-cards > div > div > div:last-child{width:32px!important;height:32px!important;font-size:16px!important}
  #view-admin .admin-scroll > div{grid-template-columns:minmax(0,1fr)!important}
  #view-admin .admin-scroll{padding-left:0!important;padding-right:0!important}
  .bbnt-builder{grid-template-columns:minmax(0,1fr)!important}
  .bbnt-form-grid{grid-template-columns:minmax(0,1fr)!important}
  .bbnt-form,.bbnt-form *{min-width:0}
  .bbnt-form .acard-sub,.bbnt-form small,.bbnt-form div{white-space:normal}
  .page-head > div:last-child{flex-wrap:wrap}
  .ux-modal-f{justify-content:stretch}
  .ux-modal-f .ux-btn{flex:1}
}
