/* Khung Dashboard: sidebar trái kiểu macOS, thanh tiêu đề + chọn khung giờ, vùng nội dung cuộn, thanh trạng thái dưới.
   Điện thoại: sidebar thành dải mục cuộn ngang ở trên. */
.dash { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { background: var(--side); border-right: 1px solid var(--side-line); display: flex; flex-direction: column; padding: 14px 10px 12px; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 14px; color: var(--ink); text-decoration: none; }
.side-brand svg { width: 26px; height: 26px; flex: none; }
.side-brand .bm-side { fill: var(--blue); } .side-brand .bm-top { fill: color-mix(in srgb, var(--blue) 55%, white); } .side-brand .bm-front { fill: color-mix(in srgb, var(--blue) 80%, black); }
.side-brand b { display: block; font-size: 13.5px; font-weight: 700; }
.side-brand small { display: block; font-size: 11px; color: var(--ink-2); }
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-sec { font-size: 11px; font-weight: 600; color: var(--ink-3); padding: 14px 8px 5px; }
.side-nav a { display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: 7px; color: var(--ink); text-decoration: none; font-size: 13px; }
.side-nav a:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.side-nav a[aria-current="page"] { background: var(--sel); color: var(--on-sel); }
.side-nav a .val { margin-left: auto; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.side-nav a[aria-current="page"] .val { color: rgba(255, 255, 255, 0.85); }
.side-nav a .val.is-bad { color: var(--red); font-weight: 600; }
.side-nav a[aria-current="page"] .val.is-bad { color: #fff; }
.nav-chip { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; background: var(--c, var(--gray)); flex: none; }
.nav-chip svg { width: 13px; height: 13px; fill: none; stroke: #fff; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.side-foot { margin-top: auto; padding: 14px 8px 0; font-size: 11.5px; color: var(--ink-2); }
.side-foot b { display: block; color: var(--ink); font-size: 12px; font-weight: 600; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100vh; height: 100dvh; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px 12px; }
.head-title { min-width: 0; }
.head-title b { display: block; font-size: 15px; font-weight: 700; }
.head-title span { display: block; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.seg { display: inline-flex; background: var(--seg-bg); border-radius: 8px; padding: 2px; gap: 1px; }
.seg[hidden] { display: none; }
.seg button { white-space: nowrap; border: 0; background: transparent; font: inherit; font-size: 12px; padding: 3px 11px; border-radius: 6px; color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--seg-on); color: var(--ink); box-shadow: var(--seg-shadow); font-weight: 600; }
/* Ô "Phạm vi": lọc toàn dashboard theo khu / tài khoản, nhóm nghiệp vụ, hệ thống */
.scope-pick { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 26px 0 9px; border-radius: 8px; background: var(--seg-bg); color: var(--ink); max-width: 300px; }
.scope-pick::after { content: ''; position: absolute; right: 10px; top: 11px; width: 5px; height: 5px; border-right: 1.6px solid var(--ink-2); border-bottom: 1.6px solid var(--ink-2); transform: rotate(45deg); pointer-events: none; }
.scope-pick svg { width: 14px; height: 14px; fill: none; stroke: var(--ink-2); stroke-width: 1.8; stroke-linejoin: round; flex: none; }
.scope-pick select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font: inherit; font-size: 12.5px; font-weight: 600; color: inherit; outline: none; cursor: pointer; min-width: 0; max-width: 250px; text-overflow: ellipsis; }
.scope-pick[hidden] { display: none; }
.scope-pick.is-scoped { background: var(--blue-s); color: var(--blue); }
.scope-pick.is-scoped svg { stroke: var(--blue); }
.scope-pick.is-scoped::after { border-color: var(--blue); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }
.tools { display: inline-flex; background: var(--seg-bg); border-radius: 8px; padding: 2px; gap: 1px; }
.tool { width: 30px; height: 24px; border: 0; border-radius: 6px; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.tool[hidden] { display: none; }
.tool:hover { background: var(--seg-on); }
.tool svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool.is-busy svg { animation: dash-spin 0.9s linear infinite; }
@keyframes dash-spin { to { transform: rotate(360deg); } }
.role { font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--gray-s); color: var(--ink-2); }
.role.is-admin { background: var(--blue-s); color: var(--blue); }
.page { flex: 1; overflow-y: auto; padding: 4px 24px 28px; }
.statusbar { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 6px 18px; padding: 7px 20px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--ink-2); }
.statusbar[hidden] { display: none; }
.statusbar i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--c); }
.statusbar b { color: var(--ink); font-weight: 600; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* Cổng vào (ui-gate.js) + màn chờ */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--win); z-index: 50; transition: opacity 0.3s; }
.boot.is-done { opacity: 0; pointer-events: none; }
.boot-card { display: flex; flex-direction: column; gap: 8px; max-width: 380px; padding: 22px 24px; border-radius: 14px; background: var(--card); text-align: center; }
.boot-card b { font-size: 14px; }
.boot-card span { color: var(--ink-2); }
.boot.is-error .boot-card span { color: var(--red); }
.gate-error { color: var(--red) !important; }
.gate-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.gate-actions summary { cursor: pointer; color: var(--ink-2); }
.handle-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; text-align: left; }
.handle-form input { font: inherit; padding: 7px 9px; border-radius: 7px; border: 1px solid var(--line); background: var(--win); color: var(--ink); }
.btn { font: inherit; font-size: 12.5px; font-weight: 600; padding: 6px 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--tile); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { background: var(--card-hover); }
.btn.primary { background: var(--sel); border-color: var(--sel); color: var(--on-sel); }
.btn.danger { color: var(--red); }
.new-build { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 40; display: flex; gap: 10px; align-items: center; padding: 8px 10px 8px 14px; border-radius: 10px; background: var(--card); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18); }

@media (max-width: 760px) {
  .dash { display: block; height: auto; }
  .side { position: sticky; top: 0; z-index: 10; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--side-line); overflow-x: auto; overflow-y: hidden; }
  .side-brand { padding: 0 4px 0 0; } .side-brand span, .side-sec, .side-foot { display: none; }
  .side-nav { flex-direction: row; gap: 4px; }
  .side-nav a { white-space: nowrap; padding: 5px 9px; } .side-nav a .val { display: none; }
  .main { height: auto; }
  .head { flex-wrap: wrap; padding: 12px 16px 8px; }
  .page { overflow: visible; padding: 4px 16px 24px; }
  .role { display: none; }
  .head-tools { flex-wrap: wrap; width: 100%; min-width: 0; }
  .scope-pick { flex: 1 1 100%; max-width: none; }
  .scope-pick select { max-width: none; width: 100%; }
}
