/* Link Maps — CSS thuần, mobile-first. Màu chỉ ở :root. */
:root {
  --bg: #f4faf6;
  --surface: #fff;
  --surface-2: #eef0ef;
  --text: #14231a;
  --muted: #555e59;
  --line: #d7eadf;
  --brand: #2a7a52;
  --brand-hover: #276749;
  --brand-soft: #e6f4ec;
  --on-brand: #fff;
  --ok: #0f5a32;
  --ok-soft: #d4f2df;
  --warn: #7a4b00;
  --warn-soft: #fdf3dc;
  --err: #b42318;
  --err-soft: #fdeceb;
  --task-done: #a16207;
  --task-wait: #1d4ed8;
  --task-fail: #9b1c1c;
  --info: #1f5e3d;
  --info-soft: #e6f4ec;
  --scrim: rgba(0, 0, 0, .78);   /* nền tối sau popup ảnh */
  --photo-bg: #111;
  --shadow: 0 1px 2px rgba(16, 40, 24, .06), 0 1px 3px rgba(16, 40, 24, .04);
  --r: 14px;
  --r-sm: 9px;
  --gap: 1rem;
  --tabbar: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1a14;
    --surface: #16251c;
    --surface-2: #232a27;
    --text: #e5efe9;
    --muted: #a3b0a8;
    --line: #2a3d32;
    --brand: #5fbf8a;
    --brand-hover: #7fcfa2;
    --brand-soft: #1a3326;
    --on-brand: #0b1710;
    --ok: #a6ecc0;
    --ok-soft: #123524;
    --warn: #f3c56b;
    --warn-soft: #3a2e14;
    --err: #ff9b92;
    --err-soft: #3d1b1a;
    --task-done: #facc15;
    --task-wait: #93c5fd;
    --task-fail: #f2928a;
    --info: #8fd6ae;
    --info-soft: #1a3326;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

/* Nền tảng */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: var(--brand-hover); }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; line-height: 1.3; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .3rem; }
p { margin: .4rem 0; }
ul, ol { padding-left: 1.2rem; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.icon { flex: none; width: 20px; height: 20px; vertical-align: -4px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.center { text-align: center; }
.hint { color: var(--muted); font-size: .9rem; margin: .3rem 0; }
.skip { position: absolute; left: -999px; top: 0; z-index: 100; padding: .6rem 1rem; background: var(--surface); }
.skip:focus { left: .5rem; top: .5rem; }

/* Khung trang */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: .75rem;
  min-height: 56px;
  padding: .4rem max(1rem, env(safe-area-inset-right)) .4rem max(1rem, env(safe-area-inset-left));
  padding-top: max(.4rem, env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: .45rem; margin-right: auto; font-weight: 700; color: var(--text); text-decoration: none; min-height: 44px; }
.brand .icon { color: var(--brand); }
.container {
  width: 100%;
  margin: 0 auto;
  padding: var(--gap) max(1rem, env(safe-area-inset-right)) calc(var(--gap) * 2) max(1rem, env(safe-area-inset-left));
}
.c-user { max-width: 540px; padding-bottom: calc(var(--tabbar) + 1.5rem + env(safe-area-inset-bottom)); }
.c-auth { max-width: 460px; }

/* Tab bar: đáy màn hình trên điện thoại, header trên màn hình lớn */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar); font-size: .78rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.tabs a[aria-current="page"] { color: var(--brand); }
.tabs a[aria-current="page"] .icon { stroke-width: 2.4; }
.tabs .icon { width: 24px; height: 24px; }

/* Thành phần */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: var(--gap);
}
.card > h2:first-child, .card > h1:first-child { margin-top: 0; }
.auth { margin-top: 1.5rem; padding: 1.25rem; }
.auth h1 { margin-bottom: 1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .5rem 1rem;
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { color: var(--on-brand); background: var(--brand); border-color: var(--brand); }
.btn-primary:hover { color: var(--on-brand); background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { min-height: 36px; padding: .3rem .75rem; font-size: .9rem; }
.btn-block { display: flex; width: 100%; }
form.inline { display: inline; }

.badge {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 .6rem;
  border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-ok::before { content: "✓"; margin-right: .3em; }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.tag { display: inline-block; font-size: .78rem; padding: .05rem .45rem; border-radius: 6px; background: var(--surface-2); color: var(--muted); font-weight: 500; }

/* Thông báo dạng thẻ có icon */
.alert {
  display: flex; gap: .65rem; align-items: flex-start;
  padding: .8rem 1rem; margin: 0 0 var(--gap);
  border-radius: var(--r); border: 1px solid transparent;
}
.alert > .icon { margin-top: 2px; }
.alert > div { flex: 1; min-width: 0; }
.alert ul { margin: .3rem 0 0; }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert-error { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 20%, transparent); }
.alert a { color: inherit; font-weight: 600; }
/* Khung đếm ngược tới lượt nhận link: vàng nhạt, chữ tối — giữ nguyên cả ở chế độ tối cho dễ đọc */
.tasks { display: flex; flex-direction: column; gap: 1.25rem; }
.task-h { margin: 0 0 .45rem; font-size: 1.2rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; color: var(--text); }
.task-done { font-size: 2.4rem; line-height: 1.2; color: var(--task-done); }
.task-pending { color: var(--task-wait); }
.task-revoked, .task-expired { color: var(--task-fail); }
.alert-note { background: #fff6cc; color: #3b2f00; border-color: #e6c95a; }

/* Form */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=date], select, textarea {
  width: 100%; min-height: 46px; padding: .6rem .75rem;
  font: inherit; font-size: 16px; font-weight: 400;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm);
}
textarea { min-height: 7rem; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--brand-soft); border-color: var(--brand); outline-offset: 0; }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; accent-color: var(--brand); flex: none; }
input[aria-invalid="true"] { border-color: var(--err); }
.field-error { color: var(--err); font-size: .9rem; font-weight: 500; }
.form .hint { font-weight: 400; }

/* Trang người dùng */
.page-head { margin: .25rem 0 1rem; }
.eyebrow { margin: 0; color: var(--muted); font-weight: 600; font-size: .92rem; }
.guide { display: flex; gap: .5rem; align-items: flex-start; font-size: .92rem; color: var(--muted); margin: 0 0 .85rem; }
.guide .icon { color: var(--brand); margin-top: 1px; }
.locs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .85rem; }
.loc {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 1rem;
  scroll-margin-top: 72px;
}
.loc-top { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-bottom: .5rem; }
.loc-top .badge { margin-left: auto; }
.loc-sel { margin: 0 0 .85rem; -webkit-user-select: all; user-select: all; cursor: text; overflow-wrap: anywhere; }
.loc-name { margin: 0 0 .35rem; font-size: 1.12rem; font-weight: 650; }
.loc-addr { margin: 0; font-size: 1.3rem; line-height: 1.35; font-weight: 700; }
/* Nhãn bằng ::before: không bị chọn/copy */
.loc:not(.loc-sm) .loc-name::before, .loc:not(.loc-sm) .loc-addr::before {
  display: block; margin: .2rem 0 .1rem;
  font-size: .78rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted);
}
.loc:not(.loc-sm) .loc-name::before { content: "Tên cửa hàng"; }
.loc:not(.loc-sm) .loc-addr::before { content: "Địa chỉ"; }
.copy-form { margin: 0; }
.copy-msg { margin: .5rem 0 0; font-size: .9rem; font-weight: 600; }
.loc-promo { margin-top: .85rem; padding-top: .85rem; border-top: 1px solid var(--line); }
.loc-promo-text { margin: 0 0 .6rem; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.copy-msg:empty { display: none; }
.copy-msg.ok { color: var(--ok); }
.copy-msg.warn { color: var(--warn); }
.loc-sm { padding: .8rem .9rem; box-shadow: none; }
.loc-sm .loc-name { font-size: .92rem; font-weight: 600; color: var(--muted); }
.loc-sm .loc-sel { margin-bottom: .6rem; }
.loc-sm .loc-name { margin-bottom: .1rem; }
.loc-sm .loc-addr {
  font-size: 1.02rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.day { margin-bottom: 1.25rem; }
.day-title {
  position: sticky; top: 56px; z-index: 5;
  margin: 0 -.25rem .6rem; padding: .45rem .25rem;
  font-size: .95rem; color: var(--muted); background: var(--bg);
}
.empty { text-align: center; padding: 2rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r); }
.empty svg { display: block; margin: 0 auto .75rem; }
.empty p { margin: .2rem 0; }
.attribution { text-align: right; margin-top: 1rem; font-size: .8rem; }
.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .75rem; margin: 1.25rem 0; }
.pager .btn { min-height: 48px; }
.pager > :last-child { justify-self: end; }

/* Nộp ảnh nhận điểm */
.proof { margin-top: .85rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.proof-h { margin: 0 0 .4rem; font-weight: 700; font-size: .92rem; }
.proof-row { padding: .45rem 0; }
.proof-row + .proof-row { border-top: 1px solid var(--line); }
.proof-t { flex: 1 1 100%; margin: 0 0 .3rem; font-size: .92rem; display: flex; flex-direction: column; gap: .3rem; }
.proof-t b { color: var(--muted); font-weight: 600; }
.proof-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.proof-form input[type=file] { min-width: 0; max-width: 100%; font: inherit; font-size: .88rem; }
.proof-msg { flex-basis: 100%; font-size: .88rem; font-weight: 600; }
.proof-msg:empty { display: none; }
.proof-msg.ok { color: var(--ok); }
.proof-msg.warn, .warn-msg { color: var(--err); }
.badge-err { background: var(--err-soft); color: var(--err); }
.points-total { display: flex; flex-direction: column; align-items: center; padding: 1.25rem; }
.points-num { font-size: 2.4rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.ledger { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ledger li { display: flex; justify-content: space-between; gap: .75rem; padding: .7rem 1rem; border-top: 1px solid var(--line); }
.ledger li:first-child { border-top: 0; }
.delta { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.pos { color: var(--ok); }
.delta.neg { color: var(--err); }

/* Màn hình lớn */
@media (min-width: 720px) {
  :root { --gap: 1.25rem; }
  h1 { font-size: 1.7rem; }
  .c-user { padding-bottom: 2rem; }
  .tabs { position: static; padding: 0; border: 0; background: none; gap: .25rem; }
  .tabs a { flex: none; flex-direction: row; gap: .4rem; min-height: 44px; padding: 0 .85rem; border-radius: 999px; font-size: .95rem; }
  .tabs a[aria-current="page"] { background: var(--brand-soft); }
  .tabs .icon { width: 20px; height: 20px; }
  .l-user .topbar { padding-left: max(1.5rem, calc((100% - 760px) / 2)); padding-right: max(1.5rem, calc((100% - 760px) / 2)); }
  .day-title { top: 56px; }
  .auth { margin-top: 3rem; padding: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
.pre-line { white-space: pre-line; }
