/* Token và nền tảng */
:root {
  --bg: #ffffff;
  --surface: #f6f7f4;
  --text: #10140d;
  --muted: #5c6358;
  --line: #e4e7df;
  --input: #c9cec2;
  --accent: #86d20e;
  --accent-dark: #3f7a00;
  --accent-hover: #78bd0c;
  --button-text: #0e1a05;
  --error: #b42318;
  --warning: #9a5b00;
  --radius: 8px;
  --nav-h: 60px;
}

* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--accent-dark); text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { margin-bottom: 16px; font-size: 24px; font-weight: 700; }
h2 { margin: 24px 0 8px; font-size: 18px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 8px 0; }
button, input, select, textarea, a { touch-action: manipulation; }
button, input, select, textarea { font: inherit; }
:where(a, button, input, select, textarea):focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
/* !important vì quy tắc chung của input (width:100%, padding) có độ ưu tiên cao hơn và làm trang tràn ngang */
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; margin: -1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.account { display: none; }

/* Khung trang và đầu trang */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: 16px; max-width: 1040px; min-height: 52px; margin: 0 auto; padding: 0 16px; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; text-decoration: none; }
.brand-mark { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent); }
.who { display: flex; align-items: center; gap: 16px; margin-left: auto; color: var(--muted); font-size: 14px; }
.who strong { color: var(--text); }
.who > span { display: none; }
main { width: min(100%, 1040px); margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); }
main.admin-main { padding-top: 0; }
.nav-main { display: none; }

/* Điều hướng */
.tabbar { position: fixed; right: 0; bottom: 0; left: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); }
.tabbar a { display: flex; min-height: var(--nav-h); align-items: center; justify-content: center; flex-direction: column; gap: 4px; border-top: 2px solid transparent; color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none; }
.tabbar svg { width: 22px; height: 22px; stroke-width: 1.5; }
.tabbar a[aria-current="page"] { border-top-color: var(--accent); color: var(--text); font-weight: 700; }
.admin-nav { display: flex; gap: 24px; margin: 0 0 16px; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.admin-nav::-webkit-scrollbar { display: none; }
.admin-nav a { flex: none; padding: 12px 0 10px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.admin-nav a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
.admin-logout { margin-left: auto !important; }

/* Nút và biểu mẫu */
form { margin: 16px 0 24px; padding-top: 16px; border-top: 1px solid var(--line); }
form.compact { margin: 0; padding: 0; border: 0; }
label { display: block; margin: 16px 0 6px; font-size: 14px; font-weight: 600; }
label.inline { display: flex; align-items: flex-start; gap: 8px; font-weight: 500; }
label.inline input { width: auto; min-height: 0; margin: 4px 0 0; }
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select, textarea { display: block; width: 100%; min-height: 48px; margin-top: 8px; padding: 11px 12px; border: 1px solid var(--input); border-radius: var(--radius); background: var(--bg); color: var(--text); font-size: 16px; }
textarea { min-height: 120px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input[type="file"] { height: auto; padding: 16px 12px; border-style: dashed; background: var(--surface); }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; accent-color: var(--accent-dark); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); }
button, .button-link { display: inline-flex; width: 100%; min-height: 48px; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent); color: var(--button-text); font-weight: 600; text-decoration: none; cursor: pointer; transition: background-color 150ms, border-color 150ms, color 150ms, opacity 150ms; }
button:hover, .button-link:hover { border-color: var(--accent-hover); background: var(--accent-hover); }
button:active, .button-link:active { opacity: .8; }
button:disabled { cursor: not-allowed; opacity: .5; }
.secondary, .copy { border-color: var(--text); background: transparent; color: var(--text); }
.secondary:hover, .copy:hover { border-color: var(--text); background: var(--surface); }
.danger { border-color: var(--error); background: transparent; color: var(--error); }
.danger:hover { border-color: var(--error); background: var(--surface); }
.logout { width: auto; min-height: 48px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.logout:hover { border-color: transparent; background: transparent; color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions button, .actions .button-link { flex: 1 1 180px; }
.form-submit { margin-top: 24px; }
.pw { position: relative; }
.pw input { padding-right: 80px; }
.pw button { position: absolute; top: 4px; right: 4px; width: auto; min-height: 48px; padding: 0 12px; border-color: transparent; background: transparent; color: var(--muted); font-size: 14px; }
.pw button:hover { border-color: transparent; background: transparent; color: var(--text); }

/* Phản hồi và khối nội dung */
.muted { color: var(--muted); font-size: 14px; }
.error, .notice, .feedback { margin: 16px 0; padding: 8px 0 8px 12px; border-left: 3px solid; }
.error { border-left-color: var(--error); color: var(--error); font-weight: 600; }
.notice { border-left-color: var(--warning); color: var(--warning); }
.feedback { border-left-color: var(--accent); background: var(--surface); }
.feedback.ok, .ok { color: var(--accent-dark); }
.status { min-height: 24px; color: var(--muted); font-weight: 600; }
.card { margin: 24px 0; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.card h2:first-child { margin-top: 0; }
.page-message { padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-title { margin-top: 40px; }
.pagination { display: flex; gap: 24px; margin: 24px 0; }

/* Đăng nhập */
.auth { max-width: 600px; padding-top: 16px; }
.auth-intro > p:first-child { color: var(--accent-dark); font-size: 14px; font-weight: 600; }
.auth-intro h1 { max-width: 18ch; margin: 8px 0 16px; }
.auth-intro h1 b { font-weight: inherit; }
.auth-intro > p:last-child { max-width: 48ch; color: var(--muted); }
.auth form { max-width: 440px; margin-top: 32px; padding-top: 0; border: 0; }
.auth-help { margin-top: 16px; color: var(--muted); font-size: 14px; }

/* Tổng quan */
.score { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.points { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.points strong { font-size: 48px; line-height: 1; font-variant-numeric: tabular-nums; }
.points span { color: var(--muted); font-weight: 600; }
.day-badge { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 600; white-space: nowrap; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 16px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats li { padding: 10px 8px 10px 0; }
.stats li + li { padding-left: 12px; border-left: 1px solid var(--line); }
.stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.stats span { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.cta { margin-top: 16px; }
.today-state { margin: 16px 0 0; padding: 12px 0; color: var(--warning); font-weight: 600; }
.today-state.ok { color: var(--accent-dark); }
.journey { margin-top: 24px; }
.journey-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.journey-head h2 { flex: none; margin: 0; }
.journey-head progress.bar { margin: 0; }
.summary-list { margin: 0; border-bottom: 1px solid var(--line); }
.summary-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: baseline; padding: 10px 0; border-top: 1px solid var(--line); }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
form.logout-form { margin-top: 24px; }
.secondary.button-link { margin-top: 12px; }
.lead { margin: 0 0 8px; }
.rules { margin: 0; padding-left: 20px; }
.rules li { margin: 6px 0; }

/* Tiến độ và lưới ngày */
progress.bar { display: block; width: 100%; height: 4px; margin-top: 24px; overflow: hidden; border: 0; border-radius: 2px; background: var(--line); appearance: none; -webkit-appearance: none; }
progress.bar::-webkit-progress-bar { background: var(--line); }
progress.bar::-webkit-progress-value { background: var(--accent); }
progress.bar::-moz-progress-bar { background: var(--accent); }
.day-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.day-cell { display: grid; min-width: 0; height: 44px; place-items: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; text-decoration: none; }
.day-cell.approved, .day-cell.done { border-color: var(--accent); background: var(--accent); color: var(--button-text); font-weight: 700; }
.day-cell.pending { border: 1.5px dashed var(--warning); color: var(--warning); }
.day-cell.missed { background: var(--surface); color: var(--muted); text-decoration: line-through; }
.day-cell.today { border: 2px solid var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--line); border-radius: 4px; }
.legend .l-ok { border-color: var(--accent); background: var(--accent); }
.legend .l-wait { border: 1.5px dashed var(--warning); }
.legend .l-miss { background: var(--surface); }
.legend .l-today { border: 2px solid var(--text); }

/* Trang ngày và điểm danh */
.post { margin: 0; padding: 12px 0; border-bottom: 1px solid var(--line); }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.post-head h2 { margin: 0; color: var(--muted); font-size: 14px; font-weight: 600; }
.post-body { white-space: pre-line; }
.post-head.tag { padding: 4px 0; border-bottom: 1px solid var(--line); }
.hashtag { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.copy-icon { display: inline-grid; width: 44px; min-height: 44px; padding: 0; place-items: center; border: 0; background: transparent; color: var(--muted); }
.copy-icon:hover { border: 0; background: var(--surface); color: var(--text); }
.copy-icon svg { grid-area: 1 / 1; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.copy-icon .i-done { opacity: 0; }
.copy-icon.copied { color: var(--accent-dark); }
.copy-icon.copied .i-copy { opacity: 0; }
.copy-icon.copied .i-done { opacity: 1; }
.content-image { display: block; max-width: 100%; margin-top: 12px; border-radius: var(--radius); }
.picker { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 16px; border: 1px dashed var(--input); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: center; }
.picker-title { font-size: 16px; font-weight: 600; }
.picker:has(+ input:focus-visible) { outline: 2px solid var(--text); outline-offset: 2px; }
.previews { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 8px; }
.previews:empty { display: none; }
.previews img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border: 1px solid var(--line); border-radius: var(--radius); }
details.more { margin-top: 12px; }
details.more summary { display: flex; min-height: 44px; align-items: center; color: var(--accent-dark); font-size: 14px; font-weight: 600; cursor: pointer; }
form[data-upload-form] button[type="submit"] { margin-top: 8px; }

/* Bảng xếp hạng */
.board { margin: 12px 0 0; padding: 0; list-style: none; }
.board li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.board li:first-child { border-top: 1px solid var(--line); }
.board .rank, .board .pts { font-variant-numeric: tabular-nums; }
.board .rank { color: var(--muted); font-weight: 600; text-align: center; }
.board li:nth-child(-n+3) .rank { color: var(--text); font-weight: 700; }
.board .code { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.board .pts { font-weight: 700; text-align: right; }
.board .pts small, .you { margin-left: 4px; color: var(--muted); font-size: 12px; font-weight: 500; }
.board li.me { padding-left: 13px; border-left: 3px solid var(--accent); background: var(--surface); }
.empty { margin-top: 12px; color: var(--muted); }

/* Màn hình rộng */
@media (min-width: 720px) {
  main { padding-top: 48px; padding-bottom: 48px; }
  h1 { font-size: 28px; }
  .auth { padding-top: 48px; }
  .auth-intro h1 { font-size: 40px; }
  .tabbar { display: none; }
  .account { display: flex; align-items: center; gap: 16px; margin-left: auto; color: var(--muted); font-size: 14px; font-weight: 600; }
  .nav-main { display: flex; align-self: stretch; gap: 24px; margin-left: 24px; }
  .nav-main a { display: flex; align-items: center; border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
  .nav-main a[aria-current="page"] { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }
  .who > span { display: inline; }
  button, .button-link { width: auto; }
  .auth button[type="submit"] { min-width: 180px; }
  .cta .button-link { padding-right: 28px; padding-left: 28px; }
  .day-grid { grid-template-columns: repeat(10, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

/* Chuyển trang mượt (View Transitions giữa các trang). Trình duyệt chưa hỗ trợ thì chuyển trang như cũ. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 150ms; }
}
/* Header và thanh điều hướng đứng yên khi chuyển trang, chỉ phần nội dung đổi. */
.topbar { view-transition-name: topbar; }
.tabbar { view-transition-name: tabbar; }

/* Giao diện đại lý v2: nền xám nhạt, thẻ trắng bo góc, khối điểm màu đậm. Mobile trước, rộng dần từ 720px. */
:root { --page: #f1f4ea; --card: #ffffff; --hero-a: #12290a; --hero-b: #2f6606; --lime: #c6f26b; --radius-lg: 16px; --shadow: 0 1px 2px rgba(16,20,13,.05), 0 8px 24px rgba(16,20,13,.06); }
body:not(.admin) { background: var(--page); }
.topbar { background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
.topbar-in { max-width: 1120px; min-height: 56px; }
.brand { font-size: 17px; }
.brand-mark { width: 12px; height: 12px; box-shadow: 0 0 0 4px rgba(134,210,14,.25); }
main { width: min(100%, 1120px); }
.panel { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow); }
.panel > h2:first-child { margin-top: 0; }
.panel.error, .panel.notice { margin: 0; padding: 16px 18px; border-left-width: 4px; }
form.panel { margin: 0; }
.page-head { margin: 4px 0 16px; }
.page-head h1 { margin: 0; font-size: 26px; }
.page-head .muted, .page-head .lead { margin: 4px 0 0; }
.back { display: inline-block; margin-bottom: 4px; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.back:hover { color: var(--text); }

/* Tổng quan */
.home-grid { display: grid; gap: 16px; }
.hero { position: relative; overflow: hidden; padding: 20px; border-radius: 20px; color: #fff; background: radial-gradient(120% 90% at 100% 0, rgba(134,210,14,.38), transparent 60%), linear-gradient(150deg, var(--hero-a), var(--hero-b)); box-shadow: var(--shadow); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hero-label { font-size: 13px; font-weight: 600; letter-spacing: .03em; opacity: .8; text-transform: uppercase; }
.hero .day-badge { border-color: transparent; background: rgba(255,255,255,.16); color: #fff; }
.hero .points { margin: 14px 0 4px; }
.hero .points strong { color: var(--lime); font-size: 64px; letter-spacing: -.02em; }
.hero .points span { color: rgba(255,255,255,.78); font-size: 18px; }
.hero .stats { gap: 8px; margin-top: 18px; border: 0; }
.hero .stats li, .hero .stats li + li { padding: 10px 12px; border: 0; border-radius: 12px; background: rgba(255,255,255,.12); }
.hero .stats b { font-size: 22px; }
.hero .stats span { color: rgba(255,255,255,.78); font-size: 12px; }
.hero .cta { width: 100%; min-height: 52px; margin-top: 18px; border-color: var(--lime); background: var(--lime); font-size: 16px; }
.hero .cta:hover { border-color: #fff; background: #fff; }
.hero .today-state { margin: 18px 0 0; padding: 12px 14px; border-radius: 12px; background: rgba(255,255,255,.12); color: #fff; }
.hero .today-state.ok { color: var(--lime); }
.hero .notice { margin: 16px 0 0; border-left-color: #ffd37a; color: #ffe3a3; }
.journey { margin-top: 0; }
.journey-head h2 { font-size: 17px; }
.journey-head progress.bar { height: 6px; border-radius: 3px; }
.day-grid { gap: 8px; }
.day-cell { height: 48px; border-radius: 12px; font-size: 15px; }
.day-cell.today { border: 2px solid var(--text); box-shadow: 0 0 0 3px rgba(134,210,14,.35); }
.live h2 { margin-bottom: 4px; font-size: 17px; }
.live-list { margin: 0; padding: 0; list-style: none; }
.live-list li + li { border-top: 1px solid var(--line); }
.live-list a { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); font-weight: 600; text-decoration: none; }
.live-list svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent-dark); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Trang ngày */
.day-layout { display: grid; gap: 16px; }
.day-side { display: grid; gap: 16px; }
.steps { display: grid; gap: 14px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li { display: flex; align-items: flex-start; gap: 12px; counter-increment: step; }
.steps li::before { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 50%; background: var(--accent); color: var(--button-text); content: counter(step); font-size: 14px; font-weight: 700; }
form[data-upload-form] { padding: 18px; }
form[data-upload-form] > label:first-of-type { margin-top: 0; }

/* Cá nhân, BXH, thể lệ */
.me-grid, .rules-grid { display: grid; gap: 16px; align-items: stretch; }
.rules-grid .panel h2 { font-size: 17px; }
.profile-id { display: flex; align-items: center; gap: 14px; }
.profile-id p { margin: 0; }
.profile-id strong { font-size: 20px; }
.avatar { display: grid; width: 52px; height: 52px; flex: none; place-items: center; border-radius: 50%; background: linear-gradient(150deg, var(--hero-a), var(--hero-b)); color: var(--lime); font-size: 22px; font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.tiles li { padding: 12px; border-radius: 12px; background: var(--surface); }
.tiles b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.tiles span { color: var(--muted); font-size: 12px; }
.me-grid .secondary.button-link { margin-top: 8px; }
.me-grid form.logout-form { margin-top: 12px; }
.board-panel { padding: 4px 16px; }
.board { margin: 0; }
.board li:first-child { border-top: 0; }
.board li:last-child { border-bottom: 0; }
.board .rank { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; }
.board li:nth-child(-n+3) .rank { background: var(--lime); color: var(--button-text); }
.board li.me { margin: 0 -16px; padding: 12px 16px 12px 13px; }
.empty { margin: 16px 0; }

/* Đăng nhập */
.auth:not(.admin-auth) { display: grid; max-width: 520px; gap: 16px; padding-top: 4px; }
.auth:not(.admin-auth) .auth-intro { padding: 24px 20px; border-radius: 20px; color: #fff; background: radial-gradient(120% 90% at 100% 0, rgba(134,210,14,.38), transparent 60%), linear-gradient(150deg, var(--hero-a), var(--hero-b)); box-shadow: var(--shadow); }
.auth:not(.admin-auth) .auth-intro > p:first-child { margin-top: 0; color: var(--lime); }
.auth:not(.admin-auth) .auth-intro > p:last-child { margin-bottom: 0; color: rgba(255,255,255,.82); }
.auth:not(.admin-auth) .auth-intro h1 { color: #fff; font-size: 30px; }
.auth:not(.admin-auth) form { max-width: none; margin: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow); }
.auth:not(.admin-auth) form label:first-of-type { margin-top: 0; }

@media (min-width: 720px) {
  main { padding-top: 32px; }
  .page-head h1 { font-size: 30px; }
  .panel { padding: 24px; }
  .hero { padding: 28px; }
  .day-cell { height: 56px; }
  .day-layout, .me-grid { grid-template-columns: minmax(280px, 380px) 1fr; }
  .rules-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth:not(.admin-auth) { max-width: 960px; grid-template-columns: 1fr 420px; gap: 24px; align-items: stretch; padding-top: 32px; }
  .auth:not(.admin-auth) .auth-intro { display: flex; flex-direction: column; justify-content: flex-end; padding: 40px; }
  .auth:not(.admin-auth) .auth-intro h1 { font-size: 38px; }
  .auth:not(.admin-auth) form { align-self: center; padding: 28px; }
}
@media (min-width: 960px) {
  .home-grid { grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); grid-template-areas: "hero journey" "rewards rewards" "vip vip" "live live"; align-items: stretch; }
  .journey { display: flex; flex-direction: column; }
  .journey .day-grid { flex: 1; grid-template-columns: repeat(6, 1fr); grid-auto-rows: 1fr; }
  .journey .day-cell { height: auto; min-height: 56px; }
  .hero { grid-area: hero; }
  .journey { grid-area: journey; }
  .live { grid-area: live; }
  .day-grid { grid-template-columns: repeat(6, 1fr); }
  .day-cell { height: 64px; font-size: 17px; }
  .hero .points strong { font-size: 76px; }
}
@media (min-width: 1120px) { .day-grid { grid-template-columns: repeat(10, 1fr); } }

/* Hình minh hoạ (SVG nội tuyến, thay bằng banner MKT khi có) */
.hero-art { position: absolute; top: 54px; right: -4px; width: 108px; opacity: .95; pointer-events: none; }
.hero-art svg, .auth-art svg, .banner-art svg { display: block; width: 100%; height: auto; }
.hero > :not(.hero-art) { position: relative; }
.hero .points { max-width: 60%; }
.auth-art { position: absolute; top: -14px; right: -18px; width: 170px; pointer-events: none; }
.auth:not(.admin-auth) .auth-intro { position: relative; overflow: hidden; }
.auth:not(.admin-auth) .auth-intro > :not(.auth-art) { position: relative; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; overflow: hidden; padding: 20px; border-radius: 20px; color: #fff; background: radial-gradient(120% 90% at 100% 0, rgba(134,210,14,.38), transparent 60%), linear-gradient(150deg, var(--hero-a), var(--hero-b)); box-shadow: var(--shadow); }
.banner h1 { color: #fff; }
.banner .muted, .banner .lead { color: rgba(255,255,255,.82); }
.banner-art { width: 96px; flex: none; }
.rewards h2 { margin-bottom: 4px; font-size: 17px; }
.reward-list { margin: 0; padding: 0; list-style: none; }
.reward-list li { display: flex; align-items: center; gap: 14px; padding: 12px 0; }
.reward-list li + li { border-top: 1px solid var(--line); }
.reward-icon { display: grid; width: 52px; height: 52px; flex: none; place-items: center; border-radius: 14px; background: var(--surface); }
.reward-icon svg { width: 36px; height: 36px; }
.reward-list strong { display: block; }
.reward-list small { color: var(--muted); font-size: 13px; line-height: 1.35; }
@media (min-width: 720px) {
  .hero-art { width: 170px; top: 40px; right: -14px; }
  .auth-art { width: 210px; top: 8px; right: 12px; }
  .auth:not(.admin-auth) .auth-intro { min-height: 400px; }
  .banner { padding: 28px 36px; }
  .banner-art { width: 150px; margin: -8px 0; }
}
@media (min-width: 960px) {
  .rewards { grid-area: rewards; }
  .reward-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .reward-list li, .reward-list li + li { padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
  .reward-icon { background: var(--card); }
  .rules-grid .panel:first-child { grid-row: span 2; }
}
/* Ảnh đại diện */
.profile-top { display: flex; align-items: center; gap: 16px; }
.avatar-wrap { position: relative; flex: none; }
.avatar-lg { width: 84px; height: 84px; overflow: hidden; font-size: 34px; box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.avatar-edit { position: absolute; right: -4px; bottom: -4px; display: grid; width: 32px; height: 32px; margin: 0; place-items: center; border: 2px solid var(--card); border-radius: 50%; background: var(--accent); color: var(--button-text); cursor: pointer; }
.avatar-edit svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.avatar-wrap:has(input:focus-visible) .avatar-edit { outline: 2px solid var(--text); outline-offset: 2px; }
.profile-name { display: grid; min-width: 0; gap: 2px; }
.profile-name strong { font-size: 20px; overflow-wrap: anywhere; }
.profile-name span { color: var(--muted); font-size: 14px; }
.link-button { width: auto; min-height: 32px; justify-self: start; padding: 0; border: 0; background: transparent; color: var(--accent-dark); font-size: 13px; font-weight: 600; }
.link-button:hover { border: 0; background: transparent; text-decoration: underline; }
.profile .status { min-height: 0; margin: 8px 0 0; font-size: 13px; }
.me-grid h2 { font-size: 17px; }
.me-grid .summary-list + h2 { margin-top: 24px; }
.me-grid .actions { margin-top: 16px; }
.me-grid .actions form.logout-form { margin: 0; }
.me-grid .actions .secondary.button-link { margin: 0; }

.avatar-sm { width: 36px; height: 36px; flex: none; overflow: hidden; font-size: 15px; }
.board .code { display: flex; align-items: center; gap: 10px; }
.board .code-text { min-width: 0; }

.vip { display: flex; align-items: flex-start; gap: 14px; border-color: #d9e8b4; background: linear-gradient(135deg, #f6fbe7, #ffffff 70%); }
.vip h2 { margin: 0 0 4px; font-size: 17px; }
.vip p { margin: 0; color: var(--muted); }
.vip strong { color: var(--text); }
.vip-icon { display: grid; width: 44px; height: 44px; flex: none; place-items: center; border-radius: 14px; background: var(--accent); color: var(--button-text); }
.vip-icon svg { width: 22px; height: 22px; fill: currentColor; }
@media (min-width: 960px) { .vip { grid-area: vip; } }

/* Mobile gọn: mỗi trang đại lý chỉ dài khoảng 1,5 màn hình */
@media (max-width: 719px) {
  main { padding: 10px 12px calc(var(--nav-h) + 12px + env(safe-area-inset-bottom)); }
  .topbar-in { min-height: 48px; }
  .page-head { margin: 0 0 10px; }
  .page-head h1 { font-size: 22px; }
  .panel { padding: 14px; border-radius: 14px; }
  .home-grid, .day-layout, .me-grid, .rules-grid, .day-side { gap: 10px; }
  .hide-sm { display: none; }
  .hero { padding: 14px 16px; border-radius: 16px; }
  .hero-label { font-size: 12px; }
  .hero .points { margin: 4px 0 0; }
  .hero .points strong { font-size: 44px; }
  .hero .points span { font-size: 15px; }
  .hero-art { top: 38px; width: 78px; }
  .hero .stats { gap: 6px; margin-top: 10px; }
  .hero .stats li, .hero .stats li + li { padding: 7px 10px; }
  .hero .stats b { font-size: 17px; }
  .hero .stats span { font-size: 11px; }
  .hero .cta { min-height: 46px; margin-top: 10px; font-size: 15px; }
  .hero .today-state { margin-top: 10px; padding: 9px 12px; }
  .hero .notice { margin-top: 10px; font-size: 13px; }
  .journey-head { margin-bottom: 8px; }
  .journey-head h2 { font-size: 15px; }
  .day-grid { grid-template-columns: repeat(10, 1fr); gap: 4px; }
  .day-cell { height: 32px; border-radius: 8px; font-size: 12px; }
  .day-cell.today { border-width: 2px; box-shadow: 0 0 0 2px rgba(134,210,14,.35); }
  .legend { margin-top: 8px; gap: 4px 10px; font-size: 11px; }
  .rewards h2, .live h2 { font-size: 15px; }
  .reward-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
  .reward-list li { flex-direction: column; gap: 6px; padding: 8px 4px; border-radius: 12px; background: var(--surface); text-align: center; }
  .reward-list li + li { border-top: 0; }
  .reward-icon { width: 40px; height: 40px; background: var(--card); }
  .reward-icon svg { width: 28px; height: 28px; }
  .reward-list strong { font-size: 13px; }
  .reward-list small { display: none; }
  .vip { gap: 10px; padding: 12px; }
  .vip-icon { width: 36px; height: 36px; border-radius: 10px; }
  .vip h2 { font-size: 15px; margin-bottom: 2px; }
  .vip p { display: -webkit-box; overflow: hidden; font-size: 13px; line-height: 1.4; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .live-list a { min-height: 40px; }
  .banner { padding: 14px 16px; border-radius: 16px; }
  .banner-art { width: 56px; }
  .banner .lead, .banner .muted { font-size: 13px; }
  .page-head.banner { margin-bottom: 10px; }
  .steps { gap: 8px; margin-top: 8px; }
  .steps li { font-size: 14px; line-height: 1.35; }
  .steps li::before { width: 22px; height: 22px; font-size: 12px; }
  .day-layout .panel h2 { font-size: 15px; margin-bottom: 0; }
  form[data-upload-form] { padding: 14px; }
  .picker { padding: 12px; }
  .picker-title { font-size: 15px; }
  .previews img { aspect-ratio: 1; }
  label { margin: 12px 0 4px; }
  .board li { padding: 8px 0; gap: 8px; }
  .board-panel { padding: 2px 12px; }
  .board li.me { margin: 0 -12px; padding: 8px 12px 8px 9px; }
  .avatar-sm { width: 30px; height: 30px; font-size: 13px; }
  .profile-top { gap: 12px; }
  .avatar-lg { width: 64px; height: 64px; font-size: 26px; }
  .tiles { margin-top: 10px; }
  .tiles li { padding: 8px 10px; }
  .tiles b { font-size: 20px; }
  .summary-list > div { padding: 7px 0; }
  .me-grid h2 { margin: 14px 0 6px; }
  .me-grid .panel > h2:first-child { margin-top: 0; }
  .rules-grid .summary-list > div { padding: 5px 0; font-size: 14px; }
  .rules-grid .panel p.muted { font-size: 12px; margin: 6px 0 0; }
  .rules li { margin: 3px 0; font-size: 14px; }
  .auth:not(.admin-auth) .auth-intro { padding: 16px; }
  .auth:not(.admin-auth) .auth-intro h1 { font-size: 24px; margin: 4px 0 8px; }
  .auth-art { width: 84px; }
}

/* Giao diện quản trị */
body.admin { min-height: 100vh; background: var(--surface); }
body.admin.admin-menu-open { overflow: hidden; }
.admin-mobilebar { position: sticky; top: 0; z-index: 40; display: grid; height: 56px; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--bg); }
.admin-mobilebar strong { min-width: 0; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.admin-menu-button, .admin-menu-close { display: inline-grid; width: 44px; min-height: 44px; padding: 0; place-items: center; border: 0; background: transparent; color: var(--text); }
.admin-menu-button:hover, .admin-menu-close:hover { border: 0; background: var(--surface); }
.admin-menu-button svg, .admin-menu-close svg, .admin-sidebar svg, .admin-kpi svg, .admin-alert svg, .admin-empty svg, .admin-search svg, .admin-duplicate svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.admin-sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; display: flex; width: 240px; flex-direction: column; padding: 16px 12px; transform: translateX(-100%); border-right: 1px solid var(--line); background: var(--bg); transition: transform 200ms ease; }
.admin-menu-open .admin-sidebar { transform: translateX(0); }
.admin-sidebar-head { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px 16px; }
.admin-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; font-weight: 700; line-height: 1.25; text-decoration: none; }
.admin-brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.admin-brand-dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--accent); }
.admin-nav { display: flex; flex: 1; flex-direction: column; gap: 4px; margin: 8px 0; overflow: visible; border: 0; }
.admin-nav a { position: relative; display: flex; min-height: 44px; align-items: center; gap: 12px; padding: 0 10px; border: 0; border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 500; text-decoration: none; }
.admin-nav a:hover { background: var(--surface); color: var(--text); }
.admin-nav a[aria-current="page"] { border: 0; background: var(--surface); color: var(--text); font-weight: 700; }
.admin-nav a[aria-current="page"]::before { position: absolute; top: 9px; bottom: 9px; left: -12px; width: 2px; background: var(--accent-dark); content: ""; }
.admin-nav svg { width: 19px; height: 19px; flex: none; }
.admin-nav-count { display: inline-grid; min-width: 22px; height: 22px; margin-left: auto; padding: 0 6px; place-items: center; border-radius: 999px; background: var(--accent); color: var(--button-text); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.admin-account { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 16px 4px 0; border-top: 1px solid var(--line); }
.admin-account-copy { min-width: 0; line-height: 1.25; }
.admin-account-copy strong, .admin-account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-account-copy strong { font-size: 13px; }
.admin-account-copy small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.admin-avatar { display: inline-grid; width: 36px; height: 36px; flex: none; place-items: center; border-radius: 50%; background: #edf2e8; color: var(--accent-dark); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.admin-logout { width: auto; min-height: 36px; padding: 0 4px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.admin-logout:hover { border: 0; background: transparent; color: var(--text); }
.admin-overlay { position: fixed; inset: 0; z-index: 50; display: block; width: 100%; min-height: 100%; padding: 0; border: 0; border-radius: 0; background: rgba(16, 20, 13, .35); opacity: 0; pointer-events: none; transition: opacity 200ms ease; }
.admin-overlay:hover { border: 0; background: rgba(16, 20, 13, .35); }
.admin-menu-open .admin-overlay { opacity: 1; pointer-events: auto; }
body.admin main.admin-main { width: 100%; max-width: none; margin: 0; padding: 20px 16px 48px; }
.admin-page-head { display: flex; min-height: 60px; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.admin-page-head h1 { margin: 0 0 4px; font-size: 24px; }
.admin-page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.admin-page-head > form { flex: none; margin: 0; padding: 0; border: 0; }
.admin-back { display: inline-block; margin-bottom: 8px; color: var(--muted); font-size: 13px; text-decoration: none; }
.admin-panel { margin: 0 0 16px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: 0 1px 2px rgba(16, 20, 13, .04); }
.admin-panel h2 { margin: 0; font-size: 16px; font-weight: 600; }
.admin-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.admin-panel-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.admin-panel-head > a { flex: none; font-size: 13px; font-weight: 600; text-decoration: none; }
.admin-panel form, .admin-panel-form { margin: 0; padding: 0; border: 0; }
.admin-panel-form label:first-of-type { margin-top: 0; }
body.admin button, body.admin .button-link { min-height: 44px; }
body.admin .secondary { border-color: var(--line); background: var(--bg); color: var(--text); }
body.admin .secondary:hover { border-color: var(--input); background: var(--surface); }
.admin-kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-kpi { display: grid; min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: 0 1px 2px rgba(16, 20, 13, .04); }
.admin-kpi-icon { display: inline-grid; width: 32px; height: 32px; margin-bottom: 16px; place-items: center; border-radius: 8px; background: #f0f5ea; color: var(--accent-dark); }
.admin-kpi-icon svg { width: 17px; height: 17px; }
.admin-kpi-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.admin-kpi strong { margin: 3px 0; font-size: 27px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.admin-kpi small, .admin-kpi a { color: var(--muted); font-size: 11px; }
.admin-kpi a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.admin-kpi-pending { border-color: #d7eab8; }
.admin-dashboard-grid, .admin-detail-grid, .admin-content-grid { display: grid; gap: 16px; }
.admin-progress-row { display: flex; align-items: baseline; gap: 8px; }
.admin-progress-row strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.admin-progress-row span { color: var(--muted); font-size: 13px; }
.admin-progress { width: 100%; height: 7px; margin: 14px 0; overflow: hidden; border: 0; border-radius: 999px; background: var(--surface); appearance: none; }
.admin-progress::-webkit-progress-bar { background: var(--surface); }
.admin-progress::-webkit-progress-value { border-radius: 999px; background: var(--accent); }
.admin-progress::-moz-progress-bar { border-radius: 999px; background: var(--accent); }
.admin-progress-stats { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); font-size: 12px; }
.admin-progress-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.admin-task-list { margin: 0; padding: 0; list-style: none; }
.admin-task-list li + li { border-top: 1px solid var(--line); }
.admin-task-list a { display: flex; min-height: 48px; align-items: center; justify-content: space-between; gap: 12px; color: var(--text); font-size: 13px; text-decoration: none; }
body.admin .badge { display: inline-flex; min-height: 24px; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.2; white-space: nowrap; }
body.admin .badge-ok { background: #edf7df; color: #3f7a00; }
body.admin .badge-wait { background: #fff4d6; color: #8a5200; }
body.admin .badge-error { background: #ffebe8; color: #b42318; }
body.admin .badge-neutral { background: var(--surface); color: var(--muted); }
body.admin .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.admin-activity-list { margin: 0 -16px -16px; }
.admin-activity-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 60px; padding: 10px 16px; border-top: 1px solid var(--line); }
.admin-activity-item > span:nth-child(2) { min-width: 0; }
.admin-activity-item strong, .admin-activity-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-activity-item strong { font-size: 13px; }
.admin-activity-item small, .admin-activity-item time { color: var(--muted); font-size: 12px; }
.admin-activity-device { display: none; color: var(--muted); font-size: 12px; }
.admin-activity-item time { font-variant-numeric: tabular-nums; }
.admin-alert { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 14px; }
.admin-alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.admin-alert-error { border-color: #f4c7c2; background: #fff8f7; color: var(--error); }
.admin-alert-ok { border-color: #d7eab8; background: #f7fbea; color: var(--accent-dark); }
.admin-empty { display: flex; min-height: 140px; align-items: center; justify-content: center; flex-direction: column; gap: 5px; padding: 24px; color: var(--muted); text-align: center; }
.admin-empty svg { width: 28px; height: 28px; margin-bottom: 6px; color: var(--input); }
.admin-empty strong { color: var(--text); font-size: 14px; }
.admin-empty span { font-size: 13px; }
.admin-review-grid { display: grid; gap: 16px; }
.admin-review-card { margin: 0; }
.admin-review-meta { display: flex; align-items: center; gap: 10px; }
.admin-review-meta > span:nth-child(2) { min-width: 0; flex: 1; }
.admin-review-meta strong, .admin-review-meta small { display: block; }
.admin-review-meta strong { font-size: 14px; }
.admin-review-meta small { color: var(--muted); font-size: 12px; }
.admin-duplicate { display: flex; align-items: center; gap: 7px; margin: 14px 0 0; padding: 8px 10px; border-radius: 8px; background: #fff4d6; color: #8a5200; font-size: 12px; font-weight: 600; }
.admin-duplicate svg { width: 16px; height: 16px; flex: none; }
.admin-review-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.admin-review-images img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.admin-review-tiktok { margin: 10px 0 0; font-size: 13px; }
.admin-review-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.admin-review-actions button { width: 100%; }
.admin-review-reject summary { display: flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--input); border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; list-style: none; }
.admin-review-reject summary::-webkit-details-marker { display: none; }
.admin-review-reject[open] { grid-column: 1 / -1; }
.admin-review-reject form { margin-top: 10px; }
.admin-review-reject label { margin-top: 0; }
.admin-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px !important; padding: 0 !important; border: 0 !important; }
.admin-search { position: relative; min-width: min(100%, 280px); flex: 1; margin: 0; }
.admin-search svg { position: absolute; top: 50%; left: 12px; z-index: 1; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.admin-search input { min-height: 40px !important; margin: 0 !important; padding: 8px 12px 8px 38px !important; font-size: 14px !important; }
.admin-toolbar select { width: auto; min-width: 190px; min-height: 40px; margin: 0; padding: 8px 34px 8px 10px; font-size: 14px; }
.admin-toolbar button { min-height: 40px; }
.admin-record-count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.admin-table-wrap { width: calc(100% + 32px); margin: 0 -16px; overflow-x: auto; }
.admin-table-wrap table { width: 100%; min-width: 680px; border-collapse: collapse; background: var(--bg); font-size: 13px; font-variant-numeric: tabular-nums; }
.admin-table-wrap th, .admin-table-wrap td { height: 50px; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table-wrap th { background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; }
.admin-table-wrap tbody tr:hover { background: #fafbf8; }
.admin-table-wrap tr:last-child td { border-bottom: 0; }
.admin-customer-cell { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.admin-customer-cell > span:last-child { min-width: 0; }
.admin-customer-cell strong, .admin-customer-cell small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-customer-cell strong { font-size: 13px; }
.admin-customer-cell small, .admin-table-note { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.admin-action-cell { text-align: right; }
.admin-action-cell form { justify-content: flex-end; }
.admin-table-wrap td form button { min-height: 36px; padding: 0 12px; }
.admin-table-form { display: flex; flex-wrap: nowrap; }
.admin-table-form select { min-height: 36px; margin: 0; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }
.admin-pagination { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; }
.admin-pagination a, .admin-pagination span { display: inline-flex; min-height: 40px; align-items: center; color: var(--muted); text-decoration: none; }
.admin-pagination a:last-child, .admin-pagination span:last-child { justify-content: flex-end; }
.admin-pagination b { font-weight: 600; }
.admin-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.admin-form-grid { display: grid; gap: 0 12px; }
.admin-content-days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
.admin-day { display: grid; min-width: 0; height: 40px; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.admin-day:hover { border-color: var(--input); background: var(--surface); }
.admin-day.is-ready { border-color: #d7eab8; background: #edf7df; color: var(--accent-dark); }
.admin-draw-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.admin-draw-result { font-size: 16px; font-weight: 600; }
.admin-countdown { min-height: 48px; margin: 8px 0 0; font-size: 36px; font-weight: 700; font-variant-numeric: tabular-nums; }
.admin-inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.admin-inline-form label { min-width: 240px; flex: 1; margin: 0; }

.admin-login { min-height: 100vh; background: var(--surface); }
.admin-login .topbar { display: none; }
.admin-login main { display: grid; width: 100%; max-width: none; min-height: 100vh; padding: 24px 16px; place-items: center; }
.admin-auth { width: min(100%, 440px); padding: 24px; }
.admin-auth .auth-intro h1 { margin-bottom: 8px; font-size: 28px; }
.admin-auth .auth-intro > p:last-child { color: var(--muted); font-size: 14px; }
.admin-auth form { max-width: none; margin: 24px 0 0; }
.admin-auth button[type="submit"] { width: 100%; }

@media (max-width: 719px) {
  body.admin main.admin-main { padding-right: 12px; padding-left: 12px; }
  .admin-page-head { align-items: stretch; flex-direction: column; }
  .admin-page-head > form button { width: 100%; }
  .admin-panel { padding: 14px; }
  .admin-toolbar select, .admin-toolbar button { width: 100%; }
  .admin-record-count { width: 100%; margin-left: 0; }
  .admin-table-wrap { width: 100%; margin: 0; overflow: visible; }
  .admin-table-wrap table, .admin-table-wrap tbody { display: block; min-width: 0; }
  .admin-table-wrap thead { display: none; }
  .admin-table-wrap tr { display: flex; flex-wrap: wrap; gap: 7px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .admin-table-wrap tbody tr:first-child { border-top: 1px solid var(--line); }
  .admin-table-wrap td { display: inline-flex; width: auto; height: auto; align-items: baseline; gap: 5px; padding: 0; border: 0; font-size: 13px; text-align: left; }
  .admin-table-wrap td::before { color: var(--muted); font-size: 11px; font-weight: 500; content: attr(data-label); }
  .admin-table-wrap td:first-child { display: flex; width: 100%; align-items: center; margin-bottom: 3px; }
  .admin-table-wrap td:first-child::before, .admin-table-wrap td[data-label=""]::before { content: none; }
  .admin-table-wrap td[data-label=""], .admin-table-wrap td:has(form) { display: block; width: 100%; }
  .admin-table-wrap .admin-customer-cell { min-width: 0; }
  .admin-action-cell form { justify-content: flex-start; }
  .admin-form-actions button { flex: 1; }
  .admin-draw-kpis .admin-kpi { padding: 12px; }
  .admin-draw-kpis .admin-kpi strong { font-size: 22px; }
}

@media (min-width: 720px) {
  .admin-form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .admin-content-days { grid-template-columns: repeat(10, 1fr); }
  .admin-activity-device { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-activity-item { grid-template-columns: 36px minmax(0, 1fr) minmax(120px, 220px) 44px; }
}

@media (min-width: 1024px) {
  body.admin { overflow-x: hidden; }
  .admin-mobilebar, .admin-menu-close, .admin-overlay { display: none; }
  .admin-sidebar { transform: none; }
  body.admin main.admin-main { width: calc(100% - 240px); margin-left: 240px; padding: 28px 32px 56px; }
  .admin-page-head { margin-bottom: 24px; }
  .admin-page-head h1 { font-size: 24px; }
  .admin-panel { padding: 20px; }
  body.admin button, body.admin .button-link { min-height: 40px; }
  .admin-kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .admin-dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-detail-grid, .admin-content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-review-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-table-wrap { width: calc(100% + 40px); margin: 0 -20px; }
  .admin-table-wrap th, .admin-table-wrap td { padding-right: 20px; padding-left: 20px; }
}

@media (min-width: 1440px) {
  .admin-review-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar, .admin-overlay { transition: none; }
}

/* Kênh bán hàng */
.ch-form { padding: 8px 24px 24px; }
.ch-cols, .ch-row { display: grid; grid-template-columns: 90px 220px minmax(0, 1fr); align-items: center; gap: 16px; }
.ch-cols { padding: 14px 0 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.ch-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.ch-name { font-weight: 600; }
.ch-row.is-main .ch-name { color: var(--accent-dark); }
.ch-row.is-main .ch-name::before { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--accent); content: ""; }
.ch-row select, .ch-row input { width: 100%; height: 48px; min-height: 0; margin: 0; padding: 0 14px; box-sizing: border-box; }
.ch-foot { display: flex; justify-content: flex-end; padding-top: 20px; }
.ch-save { min-width: 180px; min-height: 50px; padding: 0 28px; border: 0; border-radius: 12px; background: #12290a; color: var(--lime); font-size: 16px; font-weight: 600; cursor: pointer; }
.ch-save:hover { background: #1d3a0e; }
.ch-lock { margin: 20px 0 0; color: var(--muted); }
@media (max-width: 719px) {
  .ch-form { padding: 4px 16px 18px; }
  .ch-cols { display: none; }
  .ch-row { grid-template-columns: 1fr; gap: 8px; }
  .ch-save { width: 100%; }
}
