/* Giao diện phần đăng nhập / quản trị của bản Supabase */
html,body{margin:0}
body{background:var(--bg)}
#exportLite,#exportStatic{display:none!important}

.sbbar{max-width:760px;margin:0 auto 96px;padding:12px 16px;display:flex;flex-wrap:wrap;gap:8px 14px;align-items:center;justify-content:center;font-size:13px;color:var(--muted);text-align:center;box-sizing:border-box}
.sbbar b{color:var(--ink)}
.sbbar code{font-size:12px;background:var(--soft);padding:1px 5px;border-radius:5px}
.sbbar.sbwarn{background:color-mix(in srgb,var(--warn,#B7790A) 12%,var(--surface));border:1px solid color-mix(in srgb,var(--warn,#B7790A) 35%,transparent);border-radius:14px;color:var(--ink);margin:12px auto 96px;width:calc(100% - 32px);line-height:1.5}
.sbbar.sbed{border-top:1px dashed var(--line)}
.sbtools{display:flex;flex-wrap:wrap;gap:6px 14px;justify-content:center}
.sblink{all:unset;cursor:pointer;color:var(--brand);font-weight:600;font-size:13px;text-decoration:underline;text-underline-offset:3px}
.sblink:focus-visible{outline:2px solid var(--brand);outline-offset:3px;border-radius:4px}
.sbempty{position:fixed;left:50%;bottom:18px;transform:translateX(-50%);z-index:70;width:min(560px,calc(100% - 32px));box-sizing:border-box;box-shadow:0 14px 40px rgba(10,20,60,.22);background:var(--surface)!important;display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;justify-content:center;padding:12px 14px;border-radius:14px;background:color-mix(in srgb,var(--brand) 9%,var(--surface));border:1px solid color-mix(in srgb,var(--brand) 30%,transparent);color:var(--ink);font-size:14px}

.sbm{position:fixed;inset:0;z-index:120;background:rgba(8,14,40,.45);-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);display:grid;place-items:center;padding:16px;animation:sbIn .18s ease-out}
.sbm-card{width:min(440px,100%);max-height:calc(100dvh - 32px);overflow:auto;background:var(--bg);color:var(--ink);border-radius:20px;padding:20px;box-shadow:0 24px 60px rgba(8,14,40,.3);display:grid;gap:12px;box-sizing:border-box}
.sbm-card h3{margin:0;font-size:18px}
.sbm-sub{margin:-4px 0 0;font-size:13.5px;color:var(--muted);line-height:1.5}
.sbm-card label{display:grid;gap:5px;font-size:13px;font-weight:600;color:var(--muted)}
.sbm-card input:not([type=file]),.sbm-card textarea{font:inherit;font-size:15px;font-weight:400;color:var(--ink);background:color-mix(in srgb,var(--ink) 5%,var(--bg));border:1px solid var(--line);border-radius:12px;padding:10px 12px;width:100%;box-sizing:border-box}
.sbm-card input:focus,.sbm-card textarea:focus{outline:2px solid var(--brand);outline-offset:1px}
.sbm-row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:flex-end;margin-top:4px}
.sbm-col{display:grid;gap:8px}
.sbm-err{margin:0;font-size:13px;color:var(--accent,#D7263D);line-height:1.45}
.sbprog{height:8px;border-radius:99px;background:var(--soft);overflow:hidden}
.sbprog i{display:block;height:100%;width:0;background:var(--brand);transition:width .25s}
.sbfb{display:grid;gap:8px;max-height:55vh;overflow:auto}
.sbfi{border:1px solid var(--line);border-radius:12px;padding:10px 12px}
.sbfi p{margin:4px 0 6px;font-size:14px;line-height:1.5;white-space:pre-wrap}
.sbfm{font-size:12px;color:var(--muted)}
@keyframes sbIn{from{opacity:0}to{opacity:1}}
@media (prefers-reduced-motion:reduce){.sbm{animation:none}}

/* Phân quyền */
.sbrole{display:grid;gap:10px}
.sbgrp{display:grid;gap:6px;padding:10px 12px;border-radius:12px;background:color-mix(in srgb,var(--ink) 4%,var(--bg))}
.sbgrp>b{font-size:13px;color:var(--ink)}
.sbm-card .sbck{display:flex!important;align-items:flex-start;gap:8px;font-weight:500;color:var(--ink);font-size:14px;line-height:1.4}
.sbm-card .sbck input{width:auto!important;margin-top:3px}
.sbcks{display:grid;grid-template-columns:repeat(auto-fill,minmax(170px,1fr));gap:4px 12px}
/* Tài khoản giới hạn: ẩn nút ngoài phạm vi (máy chủ vẫn chặn nếu cố ghi) */
body.sb-scoped #uiBtn,body.sb-scoped #ecgBtn,body.sb-scoped #upWinBtn,body.sb-scoped #pastWinBtn,body.sb-scoped #facOrd,body.sb-scoped #editSettings,body.sb-scoped [data-seat],body.sb-scoped .seatbar{display:none!important}
body.sb-no-hoatdong #addAct,body.sb-no-hoatdong #addFac,body.sb-no-hoatdong section[data-view="hoatdong"] .admin-only,body.sb-no-hoatdong [data-editact],body.sb-no-hoatdong [data-dupact],body.sb-no-hoatdong [data-newact],body.sb-no-hoatdong [data-editfac]{display:none!important}
body.sb-no-thuvien #addLib,body.sb-no-thuvien section[data-view="thuvien"] .admin-only,body.sb-no-thuvien [data-editlib],body.sb-no-thuvien [data-newlib]{display:none!important}
body.sb-no-tochuc #addMem,body.sb-no-tochuc #addBoard,body.sb-no-tochuc section[data-view="tochuc"] .admin-only,body.sb-no-tochuc [data-editmem],body.sb-no-tochuc [data-addmem],body.sb-no-tochuc [data-editboard]{display:none!important}
body.sb-no-cuocthi section[data-view="thuthach"] .admin-only,body.sb-no-cuocthi #contestRoot .admin-only{display:none!important}

/* Thẻ tên người đang đăng nhập – góc dưới bên phải */
#sbMe{position:fixed;right:calc(16px + env(safe-area-inset-right,0px));bottom:calc(16px + env(safe-area-inset-bottom,0px));z-index:55;max-width:min(320px,calc(100% - 150px))}
.sbme-btn{all:unset;cursor:pointer;touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;display:flex;align-items:center;gap:10px;padding:6px 14px 6px 6px;border-radius:26px;background:var(--surface);color:var(--ink);box-shadow:0 8px 26px rgba(10,20,60,.22),inset 0 0 0 1px var(--line);max-width:100%;box-sizing:border-box}
body.glass .sbme-btn{background:color-mix(in srgb,var(--bg) 82%,transparent);-webkit-backdrop-filter:blur(16px) saturate(1.6);backdrop-filter:blur(16px) saturate(1.6)}
.sbme-btn:focus-visible{outline:2px solid var(--brand);outline-offset:3px}
.sbme-av{width:36px;height:36px;border-radius:50%;flex:none;display:grid;place-items:center;overflow:hidden;background:var(--brand);color:#fff;font-weight:700;font-size:13px;box-shadow:0 0 0 2px var(--surface),0 0 0 3.5px color-mix(in srgb,var(--brand) 45%,transparent)}
.sbme-av img{width:100%;height:100%;object-fit:cover}
.sbme-tx{display:flex;flex-direction:column;min-width:0;line-height:1.25}
.sbme-tx b{font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sbme-tx small{font-size:11.5px;color:var(--muted);display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sbme-rl span+span::before{content:" · "}
.sbme-rl.sb2l{white-space:normal}
.sbme-rl.sb2l span{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sbme-rl.sb2l span+span::before{content:none}
.sbme-menu{position:absolute;right:0;bottom:calc(100% + 8px);min-width:200px;display:none;flex-direction:column;padding:6px;border-radius:14px;background:var(--bg);box-shadow:0 16px 40px rgba(10,20,60,.25),inset 0 0 0 1px var(--line)}
#sbMe.open .sbme-menu{display:flex}
.sbme-menu button{all:unset;cursor:pointer;padding:9px 12px;border-radius:9px;font-size:14px;font-weight:600;color:var(--ink)}
.sbme-menu button:hover,.sbme-menu button:focus-visible{background:color-mix(in srgb,var(--brand) 10%,transparent)}
.sbme-em{padding:6px 12px 8px;font-size:12px;color:var(--muted);border-bottom:1px solid var(--line);margin-bottom:4px;overflow-wrap:anywhere}
body.sb-has-me .sbempty{bottom:calc(76px + env(safe-area-inset-bottom,0px))}
@media (max-width:420px){.sbme-tx b{font-size:12.5px}.sbme-tx small{font-size:11px}.sbme-av{width:32px;height:32px}}

/* Nhập dữ liệu hàng loạt: chỉ tài khoản toàn quyền */
body.sb-scoped #impMem,body.sb-scoped #impPhoto{display:none!important}
body.sb-scoped #mgrOpen{display:none!important}

/* thẻ tên: kéo thả + thu gọn */
#sbMe:not(.drag){transition:left .28s cubic-bezier(.3,1.3,.5,1),top .28s cubic-bezier(.3,1.3,.5,1)}
#sbMe.drag .sbme-btn{cursor:grabbing;transform:scale(1.04);box-shadow:0 14px 34px rgba(10,20,60,.32),inset 0 0 0 1px var(--line)}
.sbme-btn{transition:padding .2s ease,transform .15s ease}
.sbme-av{cursor:pointer}
#sbMe.me-mini .sbme-tx{display:none}
#sbMe.me-mini{width:52px;max-width:none}
#sbMe.me-mini .sbme-btn{width:52px;height:52px;padding:0;border-radius:50%;justify-content:center;box-sizing:border-box}
#sbMe.me-mini .sbme-av{width:42px;height:42px}
#sbMe.me-t .sbme-menu{bottom:auto;top:calc(100% + 8px)}
#sbMe.me-l .sbme-menu{right:auto;left:0}
.sbme-tip{padding:8px 12px 4px;margin-top:4px;border-top:1px solid var(--line);font-size:11.5px;color:var(--muted);line-height:1.4}
