/* =====================================================================
   V2 – khung trang theo route, đăng nhập, bảng, biểu đồ (dùng chung cho mọi trang)
   Mọi màu qua biến của app.css (--panel, --line, --text, --fb…). --brand = đỏ Betacom (nhận diện, không dùng cho nút thường).
   ===================================================================== */
:root { --brand: #e41e3f; }
.view:focus { outline: none; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head .ph-t { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.page-head .ph-s { color: var(--text-2); font-size: 12.25px; margin-top: 2px; }
.page-head .ph-a { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; align-items: start; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* breadcrumb trên thanh trên */
.crumbs { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 12.25px; color: var(--text-2); overflow: hidden; white-space: nowrap; }
.crumbs a { text-decoration: none; color: var(--text-2); }
.crumbs a:hover { color: var(--fb-text); text-decoration: underline; }
.crumbs .sep { display: inline-grid; color: var(--muted); }
.crumbs .cur { color: var(--text); font-weight: 600; font-size: 15.75px; overflow: hidden; text-overflow: ellipsis; }
a.brand { text-decoration: none; color: inherit; }
a.mode { text-decoration: none; }

/* menu tài khoản (popover nhỏ – không phải luồng nghiệp vụ) */
.user-menu { position: relative; }
.user-chip { display: inline-flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
.user-chip:hover { background: var(--hover); }
.user-chip .uc-av { flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--fb-tint); color: var(--fb-text); font-weight: 700; }
.user-chip .uc-t { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; line-height: 1.3; }
.user-chip .n1 { font-weight: 600; font-size: 11.5px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-pill { font-size: 9.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--text-2); }
.role-pill.r-OWNER { color: var(--brand); }
.role-pill.r-ADMIN { color: var(--fb-text); }
.user-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; }
.user-pop .up-h { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-pop .n2 { color: var(--muted); font-size: 11px; }
.user-pop a, .user-pop button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; font-size: 12.25px; color: var(--text); }
.user-pop a:hover, .user-pop button:hover { background: var(--hover); }

/* bảng: hàng bấm được, phân trang, bộ lọc */
table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr.clickable:focus-visible { outline: 2px solid var(--fb); outline-offset: -2px; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters .search { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
.filters .dd-btn { width: auto; min-width: 150px; max-width: 260px; }
a.lnk { color: var(--fb-text); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
a.lnk:hover { text-decoration: underline; }
a.btn { text-decoration: none; }

/* trạng thái tải / lỗi / N/A / nguồn đo */
.loading { display: flex; align-items: center; gap: 8px; color: var(--text-2); padding: 24px; justify-content: center; }
.empty.err .e-ic { color: var(--red); }
.na { color: var(--muted); font-weight: 600; }
.na .na-r { font-weight: 400; font-size: 11px; }
.stat .ss { color: var(--muted); font-size: 10.5px; margin-top: 2px; }
.src { color: var(--muted); font-size: 10.5px; }
.badge-est, .badge-meas, .badge-cfg { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .04em; padding: 1px 6px; border-radius: 999px; vertical-align: middle; }
.badge-est { background: color-mix(in srgb, var(--amber) 16%, transparent); color: var(--amber); }
.badge-meas { background: color-mix(in srgb, var(--green) 14%, transparent); color: var(--green); }
.badge-cfg { background: var(--fb-tint); color: var(--fb-text); }

/* nút xác nhận 2 bước tại chỗ */
.confirm-btn { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.confirm-btn .cq { font-size: 11.5px; font-weight: 600; color: var(--text-2); }

/* biểu đồ */
.chart-wrap { display: flex; flex-direction: column; gap: 6px; }
.ch-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--text-2); }
.ch-legend i, .ch-tip i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.ch-box { position: relative; }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid line { stroke: var(--line); stroke-width: 1; }
.ch-grid text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.ch-line { fill: none; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.ch-vline { stroke: var(--line-2); stroke-dasharray: 3 3; }
.ch-tip { position: absolute; top: 4px; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: var(--shadow-lg); padding: 6px 8px; font-size: 11px; min-width: 150px; pointer-events: none; }
.ch-tip .tt { color: var(--muted); margin-bottom: 2px; }
.ch-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 11.5px; }
.ch-empty.hidden, .ch-tip.hidden { display: none; }

/* trang không có khung (đăng nhập, khởi tạo, đổi mật khẩu) */
.bare { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card.wide { width: min(540px, 100%); }
.auth-card h1 { margin: 0; font-size: 21px; }
.auth-card .auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-card .auth-brand .brand-name { color: var(--brand); font-weight: 800; letter-spacing: .04em; }
.auth-card .auth-brand .brand-sub { color: var(--text-2); font-size: 10.5px; font-weight: 600; letter-spacing: .08em; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; }
.auth-foot { color: var(--muted); font-size: 11px; text-align: center; }
.form-err { color: var(--red); font-size: 12px; }
.form-err:empty { display: none; }

/* biểu mẫu trang */
.form-card .card-b { display: flex; flex-direction: column; gap: 14px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 4px; }
.field .req { color: var(--red); }
.field .hint { color: var(--muted); font-size: 11px; }
.field.invalid .input { border-color: var(--red); }
.field .ferr { color: var(--red); font-size: 11px; }
.field .ferr:empty { display: none; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { width: 34px; height: 20px; appearance: none; -webkit-appearance: none; border-radius: 999px; background: var(--panel-3h); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s var(--ease); }
.switch input:checked { background: var(--fb); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--fb); outline-offset: 2px; }

/* bộ lọc: ô ngày không giãn hết hàng */
.filters-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.filters-range { display: inline-flex; align-items: center; gap: 8px; }
.filters .dp { width: auto; flex: 0 0 auto; }
.filters .dp-btn { min-width: 150px; }
.filters .chips { flex-wrap: wrap; }

.crumbs { flex: 0 1 auto; min-width: 140px; }
