:root {
  /* Bảng màu mặc định "Navy & Xanh chuối": lấy từ áo CLB 66RUN (thân xanh dương, tay xanh chuối) */
  --side: #0d2257;
  --side-deep: #091a45;
  --side-2: rgba(255, 255, 255, 0.08);
  --side-ink: #e8eeff;
  --side-muted: #8fa3cf;
  --side-border: transparent;
  --side-active: linear-gradient(120deg, #c6e85a 0%, #8cc63f 100%);
  --side-active-ink: #0d2257;
  --side-active-shadow: 0 6px 18px rgba(140, 198, 63, .35);
  --side-logo-shadow: none;
  --blue: #1559e0;
  --blue-dark: #0e43b0;
  --teal: #0a8a7a;
  --green: #4f9e1c;
  --lime: #8cc63f;
  --pink: #e0306f;
  --gold: #f2b01e;
  --grad: linear-gradient(120deg, #1559e0 0%, #2b8fd8 45%, #8cc63f 100%);
  --grad-lime: linear-gradient(120deg, #c4e04a 0%, #8cc63f 100%);
  --bg: #f1f5fb;
  --card: #ffffff;
  --ink: #0f2347;
  --ink-2: #44567a;
  --muted: #7a89a6;
  --line: #e0e7f2;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(11, 40, 110, 0.06), 0 6px 24px rgba(11, 40, 110, 0.07);
  --head: 'Barlow Condensed', 'Be Vietnam Pro', sans-serif;
}

/* Bảng màu "Xanh áo CLB" */
.theme-blue {
  --side: #0b4fcf;
  --side-deep: #083fa8;
  --side-2: rgba(255, 255, 255, 0.12);
  --side-ink: #eaf1ff;
  --side-muted: #b3c9f5;
  --side-active: linear-gradient(120deg, #c6e85a 0%, #8cc63f 100%);
  --side-active-ink: #0b2a6b;
  --side-active-shadow: 0 6px 18px rgba(4, 25, 80, .3);
}

/* Bảng màu "Trắng sáng" */
.theme-light {
  --side: #ffffff;
  --side-deep: #ffffff;
  --side-2: #eef3fb;
  --side-ink: #0f2347;
  --side-muted: #7a89a6;
  --side-border: #e0e7f2;
  --side-active: var(--blue);
  --side-active-ink: #ffffff;
  --side-active-shadow: 0 6px 18px rgba(21, 89, 224, .3);
  --side-logo-shadow: 0 2px 8px rgba(15, 35, 71, .12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
}
img { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.1; margin: 0 0 .5em; color: var(--ink); letter-spacing: .2px; }
h1 { font-size: 40px; font-weight: 800; }
h2 { font-size: 30px; font-weight: 800; }
h3 { font-size: 22px; font-weight: 700; }
p { margin: 0 0 1em; }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex: none; }
svg.lucide { width: 18px; height: 18px; flex: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 40;
  background: linear-gradient(180deg, var(--side) 0%, var(--side-deep) 100%); color: var(--side-ink);
  border-right: 1px solid var(--side-border);
  display: flex; flex-direction: column; overflow-y: auto;
  padding: 22px 16px 18px;
  scrollbar-width: thin; scrollbar-color: var(--side-2) transparent;
}
.brand { display: flex; align-items: flex-start; gap: 12px; color: var(--side-ink); padding: 4px 8px 18px; }
.brand:hover { color: var(--side-ink); }
.brand img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 16px; padding: 4px; box-shadow: var(--side-logo-shadow); }
.brand strong { display: block; font-family: var(--head); font-size: 25px; font-weight: 800; line-height: 1; margin-top: 2px; }
.brand em { display: block; font-size: 12.5px; color: var(--side-muted); margin-top: 4px; }
.nav-label { font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--side-muted); margin: 18px 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 2px 0;
  border-radius: 12px; color: var(--side-ink); font-weight: 500; font-size: 15.5px;
  transition: background .15s;
}
.nav-item:hover { background: var(--side-2); color: var(--side-ink); }
.nav-item.active { background: var(--side-active); color: var(--side-active-ink); font-weight: 700; box-shadow: var(--side-active-shadow); }
.nav-item span { flex: 1; }
.nav-item .lock { width: 14px; height: 14px; opacity: .55; }
.sidebar-foot { margin-top: auto; padding: 18px 12px 0; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.sidebar-foot a { color: var(--side-muted); display: inline-flex; align-items: center; gap: 6px; }
.sidebar-foot a:hover { color: var(--side-ink); }
.main { flex: 1; margin-left: 280px; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-brand { display: none; align-items: center; gap: 8px; font-family: var(--head); font-weight: 800; font-size: 20px; color: var(--ink); white-space: nowrap; min-width: 0; }
.topbar-brand img { width: 34px; height: 34px; object-fit: contain; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn.menu-btn { display: none; }
.content { padding: 28px 32px 40px; width: 100%; max-width: 1360px; flex: 1; }
.backdrop { display: none; }

/* Kiểu menu ngang trên cùng (Quản trị → Cài đặt). Dưới 981px vẫn dùng menu trượt như kiểu bên trái. */
button.nav-label { display: flex; align-items: center; justify-content: space-between; width: calc(100% - 24px); padding: 0; background: none; border: 0; font-family: inherit; text-align: left; pointer-events: none; }
button.nav-label [data-lucide], button.nav-label svg { display: none; }
@media (min-width: 981px) {
  .menu-top .app { display: block; }
  .menu-top .main { margin-left: 0; }
  .menu-top .content { margin: 0 auto; }
  .menu-top .sidebar {
    position: sticky; inset: 0 auto auto 0; width: 100%; min-height: 68px; align-items: center; gap: 20px;
    /* Equal side columns keep the menu on the page's centre; the right one leaves room for the account menu on top of it. */
    display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(256px, 1fr);
    padding: 6px 24px; overflow: visible; border-right: 0; border-bottom: 1px solid var(--side-border);
  }
  .menu-top .brand { align-items: center; justify-self: start; padding: 0; }
  .menu-top .brand img { width: 44px; height: 44px; border-radius: 12px; }
  .menu-top .brand strong { font-size: 22px; margin: 0; white-space: nowrap; }
  .menu-top .brand em, .menu-top .sidebar-foot { display: none; }
  .menu-top .sidebar nav { display: flex; align-items: center; gap: 2px; }
  .menu-top .nav-group { position: relative; }
  .menu-top button.nav-label {
    width: auto; gap: 4px; margin: 0; padding: 10px; border-radius: 12px; cursor: pointer; pointer-events: auto; white-space: nowrap;
    color: var(--side-ink); font-size: 15.5px; font-weight: 600; letter-spacing: 0; text-transform: none;
  }
  .menu-top button.nav-label svg, .menu-top button.nav-label [data-lucide] { display: block; width: 16px; height: 16px; }
  .menu-top .nav-group:hover button.nav-label, .menu-top .nav-group.open button.nav-label { background: var(--side-2); }
  .menu-top .nav-group.has-active button.nav-label { background: var(--side-active); color: var(--side-active-ink); box-shadow: var(--side-active-shadow); }
  /* padding-top bridges the gap so the pointer can travel from the label into the panel */
  .menu-top .nav-items { display: none; position: absolute; top: 100%; left: 0; min-width: 250px; padding-top: 8px; }
  .menu-top .nav-group:hover .nav-items, .menu-top .nav-group.open .nav-items { display: block; }
  .menu-top .nav-items::before { content: ''; position: absolute; inset: 8px 0 0; z-index: -1; background: var(--side-deep); border: 1px solid var(--side-border); border-radius: 14px; box-shadow: 0 12px 30px rgba(11, 40, 110, .25); }
  .menu-top .nav-item { margin: 6px 8px; white-space: nowrap; }
  /* Links sitting directly on the bar look like the group labels next to them */
  .menu-top .nav-single .nav-items { display: block; position: static; min-width: 0; padding: 0; }
  .menu-top .nav-single .nav-items::before { display: none; }
  .menu-top .nav-single .nav-item { margin: 0; padding: 10px; font-weight: 600; }
  .menu-top .nav-single .nav-item svg, .menu-top .nav-single .nav-item [data-lucide] { display: none; }
  .menu-top .topbar { position: fixed; top: 0; right: 0; z-index: 41; min-height: 68px; padding: 0 24px; background: none; backdrop-filter: none; border: 0; }
  .menu-top .topbar-right > .icon-btn { display: none; } /* Thông báo already sits on the bar */
  .menu-top .user-name { display: inline-block; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
}
/* The bar holds up to 8 entries: give up the longest extras first as the screen narrows. */
@media (min-width: 981px) and (max-width: 1360px) {
  .menu-top .sidebar { grid-template-columns: minmax(max-content, 1fr) auto minmax(66px, 1fr); }
  .menu-top.guest .sidebar { grid-template-columns: minmax(max-content, 1fr) auto minmax(230px, 1fr); } /* Đăng nhập + Đăng ký */
  .menu-top .user-name { display: none; }
  .menu-top .user-menu summary { gap: 4px; padding-right: 8px; }
}
@media (min-width: 981px) and (max-width: 1200px) {
  .menu-top .brand span { display: none; }
  .menu-top .sidebar { gap: 10px; }
}
@media (min-width: 981px) and (max-width: 1040px) {
  .menu-top button.nav-label, .menu-top .nav-single .nav-item { padding: 8px; font-size: 14.5px; }
  .menu-top .sidebar { padding-left: 16px; }
  .menu-top .topbar { padding: 0 16px; }
}

.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: 0; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn [data-lucide], .icon-btn svg { width: 22px; height: 22px; }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 5px 12px 5px 5px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-weight: 700;
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; background: #fff;
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 50;
}
.user-menu .menu a, .user-menu .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px;
  color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; text-align: left;
}
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--bg); }
.user-menu form { margin: 0; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none;
  display: inline-grid; place-items: center; background: var(--grad); color: #fff; font-weight: 700; font-size: 14px;
}
.avatar.sm { width: 32px; height: 32px; font-size: 12px; }
.avatar.lg { width: 88px; height: 88px; font-size: 30px; }

.footer {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; padding: 24px 32px; border-top: 1px solid var(--line);
  color: var(--ink-2); font-size: 14px; background: #fff;
}
.footer strong { font-family: var(--head); font-size: 20px; color: var(--ink); }
.footer p { margin: 0; }
.footer-contact { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.footer-contact span { display: inline-flex; align-items: center; gap: 6px; }
.footer-copy { grid-column: 1 / -1; color: var(--muted); font-size: 13px; }

/* ---------- Components ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap; line-height: 1.2;
  transition: transform .1s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(21, 89, 224, .28); }
.btn-primary:hover { color: #fff; box-shadow: 0 8px 22px rgba(21, 89, 224, .38); }
.btn-pink { background: var(--pink); color: #fff; }
.btn-pink:hover { color: #fff; background: #c92460; }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); background: var(--bg); }
.btn-glass { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .45); backdrop-filter: blur(4px); }
.btn-glass:hover { color: #fff; background: rgba(255, 255, 255, .24); }
.btn-danger { background: #fff; color: #c62828; border-color: #f2c4c4; }
.btn-danger:hover { background: #fdecec; color: #b71c1c; }
.btn-strava { background: #fc4c02; color: #fff; }
.btn-strava:hover { background: #e34402; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn [data-lucide], .btn svg { width: 17px; height: 17px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.card + .card { margin-top: 20px; }
.layout-side > .card + .card, .grid > .card + .card, .grid > * + .card { margin-top: 0; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title h2, .card-title h3 { margin: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.kicker { font-size: 13px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--green); }

.section { margin-top: 34px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.more { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-family: var(--head); font-size: 19px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }

.alert { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: #e7f6e3; color: #24661a; }
.alert-error { background: #fdecec; color: #a32020; }
.alert-info { background: #e5f2fb; color: #0a5584; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.badge-ongoing { background: #e3f5dd; color: #2f7d16; }
.badge-upcoming { background: #e2f0fb; color: #0a68a8; }
.badge-ended { background: #eceff1; color: #5b6b73; }
.badge-pink { background: #fde6ee; color: #c11f5b; }
.badge-gold { background: #fff3d6; color: #9a6a00; }
.badge-muted { background: var(--bg); color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty [data-lucide], .empty svg { width: 40px; height: 40px; color: #b6c6cd; margin-bottom: 8px; }

/* Căn chỉnh ảnh theo khung khi tải lên */
.crop-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 0; border-radius: var(--radius); padding: 22px; box-shadow: 0 20px 60px rgba(9, 26, 69, .4); color: var(--ink); }
.crop-dialog::backdrop { background: rgba(9, 26, 69, .6); }
.crop-stage { position: relative; width: 100%; margin: 0 auto; overflow: hidden; background: #0d2257; border-radius: 12px; cursor: grab; touch-action: none; user-select: none; }
.crop-stage:active { cursor: grabbing; }
.crop-stage:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.crop-stage img { position: absolute; top: 0; left: 0; max-width: none; pointer-events: none; }
.crop-guide { position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); border: 2px dashed rgba(255, 255, 255, .85); box-shadow: 0 0 0 1px rgba(9, 26, 69, .4); pointer-events: none; }
.crop-guide span { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); padding: 2px 8px; border-radius: 6px; background: rgba(9, 26, 69, .7); color: #fff; font-size: 12px; white-space: nowrap; }
.crop-zoom { margin: 14px 0 8px; }
.crop-zoom input { padding: 0; accent-color: var(--blue); }
.crop-hint { color: #a35c00; margin: 0 0 10px; }
.crop-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.crop-preview img { max-width: 160px; max-height: 90px; border-radius: 8px; display: block; pointer-events: none; }
.crop-current { margin-top: 8px; }

/* ---------- Hero ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; min-height: 440px; color: #fff;
  display: flex; align-items: flex-end; padding: 44px 48px;
  background: #0b4fcf center / cover no-repeat;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(9, 26, 69, .92) 0%, rgba(13, 34, 87, .62) 42%, rgba(13, 34, 87, .06) 78%);
}
.hero > * { position: relative; }
.hero-logo { width: 96px; height: 96px; object-fit: contain; background: #fff; border-radius: 24px; padding: 8px; margin-bottom: 18px; }
.hero .kicker { color: #e3f2b0; }
.hero h1 { color: #fff; font-size: clamp(42px, 6vw, 76px); margin: 6px 0 4px; text-transform: uppercase; }
.hero .tagline { font-family: var(--head); font-style: italic; font-weight: 700; font-size: 26px; color: #c6e85a; margin-bottom: 22px; }
.hero .row { gap: 12px; }

/* ---------- Stats ---------- */
.stats { margin-top: 22px; }
.stat { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px; }
.stat .label { color: var(--ink-2); font-weight: 500; }
.stat .value { font-family: var(--head); font-weight: 800; font-size: 40px; line-height: 1.1; margin: 4px 0; }
.stat .sub { color: var(--muted); font-size: 14px; }
.stat.highlight { background: var(--grad); color: #fff; }
.stat.highlight .label, .stat.highlight .sub { color: rgba(255, 255, 255, .88); }

/* ---------- Cards: challenge, post, album ---------- */
.ch-card, .post-card, .album-card {
  display: flex; flex-direction: column; background: #fff; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); color: var(--ink); transition: transform .15s, box-shadow .15s;
}
.ch-card:hover, .post-card:hover, .album-card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(11, 40, 110, .14); color: var(--ink); }
.cover { position: relative; aspect-ratio: 16 / 9; background: var(--grad); overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .85); }
.cover .placeholder svg, .cover .placeholder [data-lucide] { width: 48px; height: 48px; }
.cover .badge { position: absolute; top: 12px; left: 12px; box-shadow: 0 2px 8px rgba(0, 0, 0, .12); }
.card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-body h3 { margin: 0; font-size: 23px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-2); font-size: 13.5px; }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-meta [data-lucide], .card-meta svg { width: 15px; height: 15px; }
/* Nhà tài trợ & đồng hành: dải logo chạy ngang ở trang chủ */
.logo-section { padding: 16px 0; overflow: hidden; }
.logo-label { padding: 0 22px 10px; font-size: 13px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.logo-marquee { overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
.logo-track { display: flex; width: max-content; animation: logo-scroll var(--logo-duration, 36s) linear infinite; }
.logo-marquee:hover .logo-track, .logo-marquee:focus-within .logo-track { animation-play-state: paused; }
.logo-item { flex: none; display: grid; place-items: center; width: 170px; height: 64px; padding: 0 20px; }
.logo-item img { max-width: 100%; max-height: 56px; object-fit: contain; display: block; }
@keyframes logo-scroll { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) {
  .logo-track { animation: none; width: auto; flex-wrap: wrap; justify-content: center; }
  .logo-item[data-copy] { display: none; }
  .logo-marquee { -webkit-mask-image: none; mask-image: none; }
}
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--grad); border-radius: 99px; }

.ann-list { list-style: none; margin: 0; padding: 0; }
.ann-list li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.ann-list li:last-child { border-bottom: 0; }
.ann-list a { color: var(--ink); font-weight: 600; display: block; }
.ann-list a:hover { color: var(--blue); }
.ann-list .muted { font-size: 13px; }

/* ---------- Tabs & filters ---------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; background: #fff; padding: 6px; border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 20px; width: fit-content; max-width: 100%; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 8px 16px; border-radius: 10px; color: var(--ink-2); font-weight: 600; }
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--blue); color: #fff; }
.tab .count { font-size: 12px; background: rgba(125, 145, 155, .18); padding: 1px 8px; border-radius: 99px; }
.tab.active .count { background: rgba(255, 255, 255, .2); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 18px; }
.card .filters { margin-top: 12px; }
.filters select, .filters input[type=month], .filters input[type=date] { width: auto; min-width: 150px; }
.filters .field { margin: 0; }

/* ---------- Forms ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span, .field > label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); margin-top: 4px; font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=url], input[type=tel], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfdbe1; border-radius: 11px; font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(21, 89, 224, .25); border-color: var(--blue); }
textarea { min-height: 120px; resize: vertical; }
textarea.editor { min-height: 340px; font-size: 15px; line-height: 1.6; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.auth-wrap { max-width: 520px; margin: 10px auto; }
.auth-wrap.wide { max-width: 760px; }
.errors { margin: 0 0 16px; padding: 12px 16px 12px 34px; background: #fdecec; color: #a32020; border-radius: 12px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: #f8fbfc; }
tr.me { background: #eef7ec; }
.who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.who a { color: var(--ink); font-weight: 600; }
.who a:hover { color: var(--blue); }
.who .small { display: block; }
.rank { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 800; background: var(--bg); color: var(--ink-2); font-family: var(--head); font-size: 18px; }
.rank.r1 { background: linear-gradient(135deg, #ffd86b, #f2a70f); color: #5c3b00; }
.rank.r2 { background: linear-gradient(135deg, #e9eef1, #b6c2c8); color: #34454d; }
.rank.r3 { background: linear-gradient(135deg, #f6c79c, #c97b3c); color: #4a2506; }

/* ---------- Podium ---------- */
.podium { display: grid; grid-template-columns: 1fr 1.15fr 1fr; gap: 14px; align-items: end; margin-bottom: 22px; }
.podium .p { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 12px; text-align: center; }
.podium .p.first { padding-top: 26px; background: linear-gradient(180deg, #fff7df, #fff); }
.podium .p .avatar { margin: 0 auto 8px; }
.podium .name { font-weight: 700; }
.podium .km { font-family: var(--head); font-size: 28px; font-weight: 800; color: var(--blue); }

/* ---------- Challenge detail ---------- */
.ch-hero { border-radius: 24px; overflow: hidden; background: linear-gradient(120deg, #0d2257 0%, #123c9c 55%, #1559e0 100%); color: #fff; position: relative; margin-bottom: 20px; }
.ch-hero .bg { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .35; }
.ch-hero .inner { position: relative; padding: 36px 36px 30px; }
.ch-hero h1 { color: #fff; font-size: clamp(32px, 5vw, 56px); margin: 10px 0 8px; }
.ch-hero p { color: rgba(255, 255, 255, .85); max-width: 760px; }
.ch-facts { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 18px; }
.ch-facts div { display: flex; flex-direction: column; }
.ch-facts b { font-family: var(--head); font-size: 26px; font-weight: 800; }
.ch-facts span { font-size: 13px; color: rgba(255, 255, 255, .75); }
.rules { list-style: none; padding: 0; margin: 0; }
.rules li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.rules li:last-child { border: 0; }
.rules [data-lucide], .rules svg { color: var(--green); margin-top: 2px; }
.locked-box { text-align: center; padding: 50px 20px; }
.locked-box [data-lucide], .locked-box svg { width: 44px; height: 44px; color: var(--blue); }

/* ---------- Prose ---------- */
.prose { font-size: 16px; line-height: 1.7; overflow-wrap: anywhere; }
.prose h2 { font-size: 28px; margin-top: 1.2em; }
.prose h3 { font-size: 22px; margin-top: 1.1em; }
.prose img { border-radius: 12px; height: auto; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose blockquote { margin: 1em 0; padding: 10px 18px; border-left: 4px solid var(--green); background: #f4faf2; border-radius: 0 12px 12px 0; }
.prose table { margin: 1em 0; }
.post-cover { width: 100%; max-height: 480px; object-fit: cover; border-radius: var(--radius); margin-bottom: 20px; }

/* ---------- Gallery ---------- */
.photo-grid { columns: 4 240px; column-gap: 12px; }
.photo-grid a { display: block; margin-bottom: 12px; break-inside: avoid; border-radius: 12px; overflow: hidden; background: #dfe8ec; }
.photo-grid img { display: block; width: 100%; height: auto; transition: transform .25s; }
.photo-grid a:hover img { transform: scale(1.03); }
.lightbox { position: fixed; inset: 0; background: rgba(5, 20, 27, .94); z-index: 100; display: none; align-items: center; justify-content: center; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 8px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.lightbox .lb-btn { position: absolute; background: rgba(255, 255, 255, .12); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lightbox .lb-btn:hover { background: rgba(255, 255, 255, .25); }
.lightbox .lb-prev { left: 18px; top: 50%; }
.lightbox .lb-next { right: 18px; top: 50%; }
.lightbox .lb-close { right: 18px; top: 18px; }
.lightbox .lb-bar { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; color: #cfe0e6; }

/* ---------- Bar chart (weekly km) ---------- */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; position: relative; height: 100%; display: flex; align-items: flex-end; cursor: default; }
.bars .b span { display: block; width: 100%; max-width: 26px; margin: 0 auto; background: var(--blue); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b:hover span { background: var(--blue-dark); }
.bars .b .tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  background: var(--ink); color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .1s; z-index: 2;
}
.bars .b:hover .tip { opacity: 1; }
.bars-axis { display: flex; gap: 2px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bars-axis span { flex: 1; text-align: center; }

/* ---------- Hall of fame ---------- */
.fame-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.fame-card .photo { aspect-ratio: 4 / 3; background: linear-gradient(135deg, #ffe08a, #f2a70f); display: grid; place-items: center; overflow: hidden; }
.fame-card .photo img { width: 100%; height: 100%; object-fit: cover; }
.fame-card .photo svg, .fame-card .photo [data-lucide] { width: 56px; height: 56px; color: #fff; }
.fame-card .body { padding: 16px 18px; }
.fame-card .result { font-family: var(--head); font-size: 30px; font-weight: 800; color: var(--blue); line-height: 1; }

/* ---------- Lucky draw ---------- */
.wheel-wrap { position: relative; width: min(520px, 100%); aspect-ratio: 1; margin: 0 auto; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; }
.wheel-pointer { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 18px solid transparent; border-right: 18px solid transparent; border-top: 34px solid var(--pink); filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .3)); z-index: 2; }
.winner-box { text-align: center; padding: 20px; border-radius: var(--radius); background: var(--grad); color: #fff; margin-top: 18px; display: none; }
.winner-box.show { display: block; animation: pop .4s ease-out; }
.winner-box .name { font-family: var(--head); font-size: 44px; font-weight: 800; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Tickets ---------- */
.msg { padding: 14px 16px; border-radius: 14px; background: var(--bg); margin-bottom: 12px; }
.msg.staff { background: #e8f3fb; border-left: 4px solid var(--blue); }
.msg .meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.msg .body { white-space: pre-wrap; }

/* ---------- Admin ---------- */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-nav a { padding: 8px 14px; border-radius: 10px; background: #fff; color: var(--ink-2); font-weight: 600; box-shadow: var(--shadow); display: inline-flex; gap: 6px; align-items: center; }
.admin-nav a.active, .admin-nav a:hover { background: var(--blue); color: #fff; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.thumbs .t { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.thumbs .t img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.thumbs .t .act { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.thumbs .t .act form { margin: 0; display: flex; gap: 4px; }
.thumbs .t input { padding: 5px 8px; font-size: 13px; }
.thumbs .t.is-cover { outline: 3px solid var(--green); }
.dropzone { display: block; border: 2px dashed #b7cbd4; border-radius: var(--radius); padding: 30px; text-align: center; background: #f9fcfd; cursor: pointer; transition: background .15s, border-color .15s; }
.dropzone.drag { background: #eaf5fb; border-color: var(--blue); }
.upload-progress { margin-top: 12px; }
.inline-form { display: inline; margin: 0; }
.wm-preview { max-width: 100%; border-radius: 12px; margin-top: 12px; display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-side { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(5, 20, 27, .5); z-index: 35; }
  .main { margin-left: 0; }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar-brand { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 20px 16px 32px; }
  .footer { padding: 20px 16px; grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  h1 { font-size: 32px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .hero { padding: 28px 22px; min-height: 380px; border-radius: 20px; }
  .hero .tagline { font-size: 21px; }
  .hero-logo { width: 72px; height: 72px; }
  .stat { padding: 14px 16px; }
  .stat .value { font-size: 30px; }
  .user-name { display: none; }
  .topbar-brand span { display: none; }
  .topbar-right .btn { padding: 8px 12px; }
  .ch-hero .inner { padding: 26px 20px; }
  .podium { gap: 8px; }
  .podium .km { font-size: 20px; }
  .card { padding: 16px; }
  .tabs { width: 100%; }
  .tab { padding: 8px 12px; }
  .bars-axis span:nth-child(even) { visibility: hidden; }
}

/* ---------- Editor ---------- */
.editor-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.editor-preview { border: 1px solid #cfdbe1; border-radius: 11px; padding: 14px 18px; min-height: 340px; background: #fff; }

/* ---------- Demo ---------- */
.demo-bar { display: flex; align-items: center; gap: 10px; padding: 10px 32px; background: #fff6d6; color: #6b4e00; font-size: 14px; border-bottom: 1px solid #f3e2a6; }
.demo-bar a { font-weight: 700; }
@media (max-width: 980px) { .demo-bar { padding: 10px 16px; } }

/* ---------- Chọn bảng màu (Cài đặt) ---------- */
.theme-pick { display: flex; flex-wrap: wrap; gap: 10px; }
.theme-opt { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 14px; }
.theme-opt:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21, 89, 224, .2); }
.theme-opt input { accent-color: var(--blue); }
.theme-opt .sw { width: 34px; height: 22px; border-radius: 6px; border: 1px solid var(--line); }

/* ---------- Nút liên hệ nổi (Messenger / Zalo) ---------- */
.chat-widget { position: fixed; right: 22px; bottom: 22px; z-index: 80; display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.chat-fab {
  position: relative; width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--grad); box-shadow: 0 10px 26px rgba(13, 34, 87, .35); transition: transform .15s;
}
.chat-fab:hover { transform: scale(1.06); }
.chat-fab svg { width: 28px; height: 28px; }
.chat-fab .i-close { display: none; }
.chat-widget.open .chat-fab .i-open { display: none; }
.chat-widget.open .chat-fab .i-close { display: block; }
.chat-widget:not(.open) .chat-fab::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; border: 2px solid #8cc63f;
  animation: chat-pulse 2.2s ease-out infinite; pointer-events: none;
}
@keyframes chat-pulse { from { transform: scale(1); opacity: .9; } to { transform: scale(1.55); opacity: 0; } }
.chat-panel {
  width: 300px; max-width: calc(100vw - 32px); background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 18px 48px rgba(13, 34, 87, .25); animation: pop .18s ease-out; position: relative;
}
.chat-panel::after { content: ''; position: absolute; right: 22px; bottom: -8px; width: 16px; height: 16px; background: #fff; transform: rotate(45deg); }
.chat-head { background: linear-gradient(120deg, #0d2257 0%, #1559e0 100%); color: #fff; padding: 16px 18px; font-weight: 700; font-size: 16px; line-height: 1.4; }
.chat-item { display: flex; align-items: center; gap: 14px; padding: 12px 18px; color: var(--ink); border-top: 1px solid var(--line); }
.chat-item:hover { background: var(--bg); color: var(--ink); }
.chat-item strong { display: block; font-size: 15.5px; }
.chat-item small { display: block; color: var(--muted); font-size: 13px; }
.chat-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.chat-ico svg { width: 24px; height: 24px; }
.chat-ico.messenger { background: linear-gradient(135deg, #00b2ff 0%, #006aff 100%); }
.chat-ico.zalo { background: #0068ff; }
.zalo-txt { color: #fff; font: 800 12px/1 'Be Vietnam Pro', sans-serif; letter-spacing: -.2px; }
@media (max-width: 640px) { .chat-widget { right: 14px; bottom: 14px; } .chat-fab { width: 54px; height: 54px; } }
