/* =========================================================
   Quay Số – Chia nhóm & Bốc thăm
   ========================================================= */
:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e3e6ec;
  --border-strong: #d2d6df;
  --text: #171a23;
  --text-2: #3d4350;
  --muted: #6b7280;
  /* Tông thương hiệu ManhTool: xanh lá ngọc → xanh chanh */
  --primary: #0a8459;
  --primary-hover: #087350;
  --primary-soft: #e7f5ee;
  --primary-text: #07704b;
  --navy: #0f2a20;
  --navy-2: #17402f;
  --glow: rgba(101, 199, 40, .3);
  --rose: #e5484d;
  --rose-soft: #feebec;
  --danger: #dc3e42;
  --danger-soft: #feebec;
  --success: #2b9a66;
  --success-soft: #e6f6eb;
  --warn: #ab6400;
  --warn-soft: #fff7e6;
  --gold: #c27c0e;
  --gold-soft: #fef3d7;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 64px rgba(16, 24, 40, .2);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1c1f27;
  --surface-3: #252933;
  --border: #2a2f3a;
  --border-strong: #3a404d;
  --text: #edeef0;
  --text-2: #c5c9d1;
  --muted: #9097a3;
  --primary: #12945f;
  --primary-hover: #18a96d;
  --primary-soft: #11281e;
  --primary-text: #5fe0a8;
  --navy: #0b1e16;
  --navy-2: #143226;
  --glow: rgba(101, 199, 40, .22);
  --rose: #ec5d5e;
  --rose-soft: #3b1219;
  --danger: #ff6369;
  --danger-soft: #3b1219;
  --success: #3dd68c;
  --success-soft: #132d21;
  --warn: #ffca16;
  --warn-soft: #2e2311;
  --gold: #ffc53d;
  --gold-soft: #302008;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1c1f27;
    --surface-3: #252933;
    --border: #2a2f3a;
    --border-strong: #3a404d;
    --text: #edeef0;
    --text-2: #c5c9d1;
    --muted: #9097a3;
    --primary: #12945f;
    --primary-hover: #18a96d;
    --primary-soft: #11281e;
    --primary-text: #5fe0a8;
    --navy: #0b1e16;
    --navy-2: #143226;
    --glow: rgba(101, 199, 40, .22);
    --rose: #ec5d5e;
    --rose-soft: #3b1219;
    --danger: #ff6369;
    --danger-soft: #3b1219;
    --success: #3dd68c;
    --success-soft: #132d21;
    --warn: #ffca16;
    --warn-soft: #2e2311;
    --gold: #ffc53d;
    --gold-soft: #302008;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .2);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
code {
  background: var(--surface-3);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: .9em;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mt { margin-top: 22px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .02em; }

/* ---------------- Icon ---------------- */
.i {
  width: 18px; height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.i-sm { width: 15px; height: 15px; }
.i-lg { width: 22px; height: 22px; }

/* ---------------- Layout ---------------- */
.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px; }
.logo {
  width: 38px; height: 38px;
  flex: none;
  display: grid; place-items: center;
  overflow: hidden;
  border-radius: 11px;
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--primary) 40%, transparent);
}
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-text b { display: block; font-size: 16.5px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.brand-text small { color: var(--muted); font-size: 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 12px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
}
.nav-label:first-child { padding-top: 0; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-2);
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-item .i { color: var(--muted); transition: color .15s; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-text); font-weight: 600; }
.nav-item.active .i { color: var(--primary); }
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
.nav-item.active .nav-badge { background: var(--surface); color: var(--primary-text); }

/* Liên kết về kho công cụ ManhTool (trang tổng manhtool.id.vn) */
.hub-link {
  display: flex; align-items: center; gap: 10px;
  margin-top: -6px;
  padding: 8px 10px 8px 8px;
  border-radius: 11px;
  border: 1px dashed color-mix(in srgb, var(--primary) 35%, var(--border));
  color: var(--text-2);
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.hub-link:hover { background: var(--primary-soft); border-style: solid; border-color: color-mix(in srgb, var(--primary) 45%, var(--border)); }
.hub-ico {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}
.hub-ico .i { width: 16px; height: 16px; }
.hub-txt { min-width: 0; line-height: 1.25; }
.hub-txt small { display: block; font-size: 11px; color: var(--muted); }
.hub-txt b { display: block; font-size: 13.5px; color: var(--primary-text); }
.hub-go { margin-left: auto; color: var(--muted); transition: transform .15s, color .15s; }
.hub-link:hover .hub-go { color: var(--primary); transform: translateX(-2px); }

.crumbs {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.crumbs a { display: inline-flex; align-items: center; gap: 5px; color: var(--primary-text); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs .i { width: 14px; height: 14px; }
.crumbs [aria-current] { color: var(--text-2); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 4px; }
.donate-card {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--border));
  background: linear-gradient(135deg, var(--primary-soft), var(--surface));
  cursor: pointer;
  text-align: left;
  transition: transform .15s, box-shadow .15s;
}
.donate-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.donate-card.active { border-color: var(--primary); }
.donate-ico {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  color: var(--rose);
}
.donate-ico .i { width: 17px; height: 17px; fill: currentColor; }
.donate-txt b { display: block; font-size: 13.5px; }
.donate-txt small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.setting-btns { display: flex; gap: 6px; }
.icon-btn {
  flex: 1;
  height: 36px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.off { color: var(--muted); opacity: .6; }
.foot-note { margin: 0; font-size: 11.5px; color: var(--muted); padding: 0 2px; }
.select-sm {
  width: auto;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}

.main {
  padding: 32px clamp(16px, 3.2vw, 44px) 64px;
  max-width: 1320px;
  width: 100%;
  min-width: 0;
}
.view { display: none; }
.view.active { display: block; animation: fadeUp .3s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 22px; }
.view-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary-text);
}
.eyebrow .i { width: 15px; height: 15px; }
.eyebrow.rose { color: var(--primary-text); }
.eyebrow.rose .i { color: var(--rose); fill: currentColor; }
.view-head h1, .donate-intro h1 { margin: 0 0 6px; font-size: clamp(23px, 2.6vw, 30px); font-weight: 800; letter-spacing: -.03em; line-height: 1.2; }
.view-head p { margin: 0; color: var(--muted); max-width: 720px; }
.view-head p b { color: var(--text-2); font-weight: 600; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }

/* ---------------- Card ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card + .card, .grid-2 + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.step {
  width: 24px; height: 24px;
  display: inline-grid; place-items: center;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
}
.badge {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 10px; font-size: 13.5px; flex-wrap: wrap; }
.hint { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
.warn-line:empty { display: none; }
.warn-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--warn); background: var(--warn-soft); padding: 7px 11px; border-radius: 9px; }
.lead-txt { color: var(--gold); display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

/* ---------------- Inputs ---------------- */
textarea, input[type="number"], input[type="text"], select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea:hover, select:hover, input[type="text"]:hover { border-color: var(--border-strong); }
textarea { resize: vertical; min-height: 120px; line-height: 1.6; }
textarea:focus, input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
textarea:disabled { opacity: .6; }
select { cursor: pointer; padding: 8px 10px; }

.field-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.field-tools .list-picker { flex: 1 1 auto; width: auto; min-width: 0; font-size: 13.5px; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--surface-3);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: transform .1s, background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; gap: 6px; }
.btn-sm .i { width: 15px; height: 15px; }
.btn-icon { padding: 6px 9px; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: var(--border-strong); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-text); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary) 20%); }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--danger-soft) 85%, var(--danger) 15%); }
.btn-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 30%, transparent); }
.btn-xl { width: 100%; margin-top: 18px; padding: 13px 20px; font-size: 15.5px; border-radius: 11px; }
.btn-xl .i { width: 20px; height: 20px; }
.btn-block { width: 100%; padding: 12px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; padding: 0;
  color: var(--primary-text); font-weight: 600; font-size: 13px; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* Segmented control */
.seg {
  display: flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-3);
  border-radius: 10px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }
.seg-wrap { flex-wrap: wrap; display: inline-flex; margin-bottom: 18px; max-width: 100%; }
.seg-wrap button { flex: 0 0 auto; }

/* Stepper */
.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.stepper-row label { font-weight: 600; }
.stepper {
  display: flex; align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}
.stepper button {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
}
.stepper button:hover { background: var(--surface-3); color: var(--primary); }
.stepper input {
  width: 56px;
  border: 0; border-radius: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: transparent;
  text-align: center;
  font-weight: 700;
  font-size: 16px;
  padding: 7px 0;
  -moz-appearance: textfield;
}
.stepper input:focus { box-shadow: none; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.preview {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  font-size: 13.5px;
  color: var(--muted);
}
.preview b { color: var(--text); }
.preview .err { color: var(--danger); font-weight: 600; }

.check {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 16px;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}
.check input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--primary); flex: none; cursor: pointer; }

details.adv { margin-top: 14px; }
details.adv summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--primary-text); margin-bottom: 8px; }
details.adv textarea { min-height: 80px; }

/* ---------------- Chips ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:empty::before { content: "Chưa có ai trong danh sách"; color: var(--muted); font-size: 13px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary-text); }
.chip:active { transform: scale(.96); }
.chip .i { width: 14px; height: 14px; }
.chip.leader {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold);
  font-weight: 600;
}
.chip-sm { padding: 3px 10px; font-size: 12.5px; }
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--border); color: var(--text-2); }
.chip.out { opacity: .45; text-decoration: line-through; }
.chip .count {
  min-width: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-weight: 700; font-size: 12px; text-align: center;
}

.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; font-size: 13px; }

/* ---------------- Constraints ---------------- */
.cons-block {
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.cons-block + .cons-block { margin-top: 10px; }
.cons-title { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; margin-bottom: 10px; }
.cons-ico { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 8px; }
.cons-ico.red { background: var(--danger-soft); color: var(--danger); }
.cons-ico.green { background: var(--success-soft); color: var(--success); }
.cons-add { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.cons-add select { font-size: 13.5px; min-width: 0; }
.cons-sym { display: grid; place-items: center; }
.cons-sym.red { color: var(--danger); }
.cons-sym.green { color: var(--success); }
.cons-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 13px; }
.cons-list .muted { font-size: 12.5px; }
.cons-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid;
}
.cons-chip.avoid { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); color: var(--danger); }
.cons-chip.together { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 25%, transparent); color: var(--success); }
.cons-chip .i { width: 13px; height: 13px; opacity: .8; }
.cons-chip.stale { opacity: .45; text-decoration: line-through; }
.cons-chip button {
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.cons-chip button:hover { background: color-mix(in srgb, currentColor 15%, transparent); }
.cons-chip button .i { width: 12px; height: 12px; opacity: 1; }

/* ---------------- Group results ---------------- */
.result-card { scroll-margin-top: 20px; }
.spotlight {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 108px;
  padding: 16px;
  border-radius: 12px;
  color: #fff;
  background:
    radial-gradient(500px 140px at 50% -20%, var(--glow), transparent 70%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
  text-align: center;
}
.spot-label { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; opacity: .75; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.spot-name { font-size: clamp(22px, 3.6vw, 34px); font-weight: 800; letter-spacing: -.02em; line-height: 1.25; word-break: break-word; }
.spot-name.pop { animation: pop .35s ease; }
.spot-target {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  font-size: 13px;
  font-weight: 600;
}
.spot-target i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
@keyframes pop { 0% { transform: scale(.85); opacity: .3; } 60% { transform: scale(1.04); } 100% { transform: scale(1); opacity: 1; } }

.note:empty { display: none; }
.note { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; padding: 10px 14px; border-radius: 10px; font-size: 13.5px; background: var(--warn-soft); color: var(--warn); }
.note .i { margin-top: 2px; }
.note.info { background: var(--primary-soft); color: var(--primary-text); }

.groups-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.group-card {
  --c: var(--primary);
  border-radius: 12px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--c);
  background: var(--surface-2);
  overflow: hidden;
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.group-card.hot { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent); transform: translateY(-2px); }
.group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 11px 14px 8px;
}
.group-head b { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head b::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); flex: none; }
.group-head span { font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); flex: none; }
.member-list { list-style: none; margin: 0; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 4px; min-height: 48px; }
.member {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 500;
  animation: slideIn .35s ease;
}
.member .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  color: var(--c);
  font-weight: 700;
  font-size: 12.5px;
}
.member .lead-tag { margin-left: auto; width: 24px; height: 24px; display: grid; place-items: center; color: var(--gold); background: var(--gold-soft); border-radius: 50%; flex: none; }
.member .lead-tag .i { width: 13px; height: 13px; }
.member.is-leader .name { font-weight: 600; }
@keyframes slideIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------------- Wheel ---------------- */
.wheel-layout { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.wheel-card { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 30px 22px 24px; }
.wheel-wrap {
  position: relative;
  width: min(100%, 520px);
  aspect-ratio: 1;
}
.wheel-wrap canvas {
  width: 100%; height: 100%;
  display: block;
  border-radius: 50%;
  box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px var(--border), 0 16px 40px rgba(16, 24, 40, .16);
  cursor: pointer;
}
.wheel-pointer {
  position: absolute;
  top: -12px; left: 50%;
  width: 34px; height: 44px;
  transform: translateX(-50%);
  transform-origin: 50% 20%;
  z-index: 2;
  background: var(--navy);
  clip-path: polygon(50% 100%, 0 0, 100% 0);
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .25));
}
:root[data-theme="dark"] .wheel-pointer { background: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wheel-pointer { background: #fff; } }
.wheel-pointer.bump { animation: bump .12s ease; }
@keyframes bump { 50% { transform: translateX(-50%) rotate(-10deg); } }
.wheel-hub {
  position: absolute;
  top: 50%; left: 50%;
  width: 20%; height: 20%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid #fff;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: clamp(12px, 2vw, 17px);
  letter-spacing: .08em;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3);
  transition: transform .15s, background .15s;
}
.wheel-hub:hover { transform: translate(-50%, -50%) scale(1.05); background: var(--primary); }
.wheel-hub:disabled { cursor: wait; }
.wheel-last { text-align: center; font-size: 14px; color: var(--muted); min-height: 28px; }
.wheel-last .win-text { display: block; font-size: clamp(21px, 2.8vw, 28px); font-weight: 800; color: var(--text); letter-spacing: -.02em; }

.legend { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; max-height: 220px; overflow: auto; padding-right: 4px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.legend-row .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-row .lb { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row .bar { width: 70px; height: 5px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex: none; }
.legend-row .bar i { display: block; height: 100%; border-radius: 99px; }
.legend-row .pc { width: 50px; text-align: right; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }

.recent { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
.recent:empty::before { content: "Chưa có lượt quay nào"; color: var(--muted); font-size: 13px; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.recent li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.recent li span { color: var(--muted); font-size: 12px; flex: none; }

/* ---------------- Draw ---------------- */
.stage { margin-top: 20px; }
.slot {
  display: grid; place-items: center;
  min-height: 124px;
  padding: 16px;
  border-radius: 12px;
  background:
    radial-gradient(500px 140px at 50% -20%, var(--glow), transparent 70%),
    linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #fff;
  font-size: clamp(24px, 4vw, 38px);
  font-weight: 800;
  text-align: center;
  letter-spacing: -.02em;
  word-break: break-word;
  position: relative;
  overflow: hidden;
}
.slot.rolling span { opacity: .7; }
.slot.win span { animation: pop .45s ease; color: #ffd36b; }
.slot .done { display: inline-flex; align-items: center; gap: 10px; font-size: .7em; }
.slot-placeholder { opacity: .3; }
.stage-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.winners { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.winners li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  animation: slideIn .35s ease;
}
.rank {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text-2);
  font-weight: 700;
  font-size: 12.5px;
}
.winners li:nth-child(1) .rank { background: var(--gold-soft); color: var(--gold); }
.winners li:nth-child(2) .rank { background: color-mix(in srgb, #94a3b8 22%, transparent); color: var(--text-2); }
.winners li:nth-child(3) .rank { background: color-mix(in srgb, #c2620c 16%, transparent); color: #b45309; }

/* ---------------- Assign ---------------- */
.assign-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px; align-items: center; }
.assign-bar .stepper-row { margin: 0; }
.assign-bar .preview { margin: 0; }
.assign-bar .btn-xl { margin: 0; width: auto; }
.assign-table { display: flex; flex-direction: column; gap: 6px; }
.assign-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  animation: slideIn .35s ease both;
}
.assign-row .task { font-weight: 600; overflow-wrap: anywhere; }
.assign-row .who { display: flex; flex-wrap: wrap; gap: 6px; }
.assign-row .who .chip { cursor: default; background: var(--primary-soft); color: var(--primary-text); border-color: transparent; font-weight: 600; }

/* ---------------- Lists ---------------- */
.lists-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.list-card { display: flex; flex-direction: column; gap: 12px; margin: 0 !important; }
.list-top { display: flex; align-items: center; gap: 12px; }
.list-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.list-card h4 { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.list-card .meta { font-size: 12.5px; color: var(--muted); }
.list-card .chips { max-height: 120px; overflow: hidden; }
.list-card .actions { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.empty {
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-align: center;
  padding: 50px 20px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty-ico { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-3); color: var(--muted); }
.empty-ico .i { width: 26px; height: 26px; }

/* ---------------- History ---------------- */
.history { display: flex; flex-direction: column; gap: 10px; }
.h-item { padding: 16px 18px; margin: 0 !important; }
.h-top { display: flex; align-items: center; gap: 12px; }
.h-ico { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.h-title { font-weight: 600; overflow-wrap: anywhere; }
.h-time { font-size: 12.5px; color: var(--muted); }
.h-top .actions { margin-left: auto; flex-wrap: nowrap; }
.h-lines { margin: 12px 0 0; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; color: var(--text-2); }

/* ---------------- Donate ---------------- */
.donate {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
  gap: 40px;
  align-items: start;
  max-width: 1040px;
}
.donate-intro .lead { margin: 6px 0 24px; font-size: 15.5px; color: var(--text-2); max-width: 560px; }
.perks { list-style: none; margin: 0 0 24px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.perks li {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.perks b { display: block; font-size: 14.5px; }
.perks small { color: var(--muted); font-size: 13px; }
.perk-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.steps-box {
  padding: 16px 18px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}
.steps-box ol { margin: 8px 0 0; padding-left: 20px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }

.qr-card {
  position: sticky;
  top: 24px;
  padding: 22px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow), 0 30px 60px -30px color-mix(in srgb, var(--primary) 40%, transparent);
}
.qr-head { display: flex; justify-content: center; margin-bottom: 14px; }
.qr-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-text);
  font-size: 12.5px;
  font-weight: 600;
}
.qr-frame {
  position: relative;
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #ebedf0;
}
.qr-frame::before, .qr-frame::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border: 3px solid var(--primary);
  pointer-events: none;
}
.qr-frame::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; border-top-left-radius: 16px; }
.qr-frame::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; border-bottom-right-radius: 16px; }
.qr-frame img { display: block; width: 100%; height: auto; max-width: 300px; margin: 0 auto; }
.acc { margin: 18px 0 16px; display: flex; flex-direction: column; }
.acc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}
.acc-row:last-child { border-bottom: 0; }
.acc-row > div { flex: 1; min-width: 0; }
.acc-row small { display: block; font-size: 12px; color: var(--muted); }
.acc-row b { display: block; font-size: 14.5px; overflow-wrap: anywhere; }
.acc-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 9px; background: var(--surface-3); color: var(--text-2); }
.acc-ico .i { width: 16px; height: 16px; }
.qr-foot { margin: 12px 0 0; text-align: center; font-size: 13px; color: var(--muted); }

/* ---------------- Giới thiệu ---------------- */
:root { --green: #0f9f6e; --green-2: #65c728; --green-text: var(--primary-text); }
:root[data-theme="dark"] { --green: #1fb47a; --green-2: #7fd047; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --green: #1fb47a; --green-2: #7fd047; }
}
.about-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 32px;
  background:
    radial-gradient(600px 260px at 0% 0%, var(--primary-soft), transparent 70%),
    var(--surface);
}
.about-hero h1 { margin: 0 0 10px; font-size: clamp(28px, 3.4vw, 40px); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.about-hero h1 .by { font-size: .45em; font-weight: 600; color: var(--muted); letter-spacing: 0; vertical-align: middle; margin-left: 4px; }
.about-hero .lead { margin: 0 0 20px; font-size: 15.5px; color: var(--text-2); }
.about-hero .lead b { color: var(--text); }
.about-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.about-badges span {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.about-badges .i { color: var(--success); }
.about-tools { display: grid; gap: 10px; }
.about-tool {
  display: flex; align-items: center; gap: 14px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.about-tool:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.about-tool:hover .at-go { transform: translateX(3px); color: var(--primary); }
.at-ico { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 11px; background: color-mix(in srgb, var(--c) 13%, transparent); color: var(--c); }
.at-txt { flex: 1; min-width: 0; }
.at-txt b { display: block; font-size: 14.5px; }
.at-txt small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.at-go { color: var(--muted); transition: transform .15s, color .15s; }

.brand-section { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 18px; margin-top: 18px; align-items: stretch; }
.brand-card { display: flex; align-items: center; gap: 28px; padding: 28px; margin: 0 !important; }
.brand-logo {
  width: 150px; height: 150px; flex: none;
  border-radius: 24px;
  background: #fff;
  border: 1px solid #e8ece9;
  box-shadow: 0 12px 30px -12px color-mix(in srgb, var(--green) 45%, transparent);
  object-fit: contain;
}
.brand-body h2 { margin: 0 0 6px; font-size: 21px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.brand-body p { margin: 0 0 16px; color: var(--text-2); }
.brand-slogan {
  font-size: 16.5px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--green), var(--green-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 10px !important;
}
.eyebrow.green { color: var(--green-text); }
.btn-green {
  color: #fff;
  background: linear-gradient(135deg, var(--green), color-mix(in srgb, var(--green) 70%, var(--green-2)));
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--green) 60%, transparent);
}
.btn-green:hover { filter: brightness(1.05); box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--green) 70%, transparent); }

.hire-card {
  position: relative;
  overflow: hidden;
  display: flex; flex-direction: column; gap: 12px;
  padding: 26px;
  border-radius: var(--radius);
  color: #fff;
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(101, 199, 40, .28), transparent 70%),
    radial-gradient(360px 200px at 0% 100%, rgba(15, 159, 110, .3), transparent 70%),
    linear-gradient(160deg, #10241c, #0c1712);
  border: 1px solid rgba(255, 255, 255, .06);
}
.hire-label {
  align-self: flex-start;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(101, 199, 40, .16);
  color: #a6e77a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
}
.hire-card h2 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: -.02em; line-height: 1.3; }
.hire-card p { margin: 0; color: rgba(255, 255, 255, .75); }
.hire-services { list-style: none; margin: 2px 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.hire-services li { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; }
.hire-services .i { width: 16px; height: 16px; color: #7ddc4a; }
.hire-phone {
  display: flex; align-items: center; gap: 14px;
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--green), #4fb52a);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 14px 30px -12px rgba(79, 181, 42, .65);
  transition: transform .15s, box-shadow .15s;
}
.hire-phone:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -12px rgba(79, 181, 42, .8); }
.hp-ico { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .2); }
.hp-ico .i { width: 20px; height: 20px; animation: ring 2.6s ease-in-out infinite; }
@keyframes ring { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-14deg); } 80% { transform: rotate(12deg); } 85% { transform: rotate(-8deg); } 90% { transform: rotate(6deg); } }
.hire-phone small { display: block; font-size: 12px; opacity: .85; font-weight: 600; }
.hire-phone b { display: block; font-size: 23px; font-weight: 800; letter-spacing: .02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.hire-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost-light { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .16); color: #fff; }
.btn-ghost-light:hover { background: rgba(255, 255, 255, .12); }
.hire-tags { font-size: 12.5px; color: rgba(255, 255, 255, .55) !important; margin-top: auto !important; padding-top: 4px; }
.foot-note a { color: var(--green-text); font-weight: 600; text-decoration: none; }
.foot-note a:hover { text-decoration: underline; }

@media (max-width: 1199px) {
  .about-hero { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .brand-section { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
  .about-hero { padding: 20px 16px; }
  .brand-card { padding: 20px 16px; }
  .hire-card { padding: 20px 16px; }
}
@media (max-width: 560px) {
  .brand-card { flex-direction: column; text-align: center; gap: 16px; }
  .brand-logo { width: 120px; height: 120px; }
  .hire-actions .btn { flex: 1; }
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(10, 12, 20, .5);
  backdrop-filter: blur(4px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(500px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .28s cubic-bezier(.2, .9, .3, 1.15);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.modal-title { margin: 0 0 12px; font-size: 18px; }
.modal-body { color: var(--muted); }
.modal-body label { display: block; font-weight: 600; color: var(--text); margin: 12px 0 6px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.winner-box { text-align: center; padding: 6px 0 0; }
.trophy {
  width: 68px; height: 68px;
  margin: 0 auto;
  display: grid; place-items: center;
  border-radius: 20px;
  background: var(--gold-soft);
  color: var(--gold);
  animation: pop .5s ease;
}
.trophy .i { width: 34px; height: 34px; stroke-width: 1.8; }
.winner-box .wname {
  display: block;
  margin-top: 14px;
  font-size: clamp(24px, 5.5vw, 36px);
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  overflow-wrap: anywhere;
  line-height: 1.2;
}

/* ---------------- Toast ---------------- */
.toasts {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(480px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 11px;
  background: #1c2024;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease;
}
.toast .i { flex: none; }
.toast.error .i { color: #ff8a8e; }
.toast.warn .i { color: #ffc53d; }
.toast.success .i { color: #4cc38a; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 70; }

/* ---------------- Phần tử chỉ dùng trên một số thiết bị ---------------- */
.topbar, .tabbar, .drawer-backdrop, .drawer-close, .speed-btn { display: none; }

/* ---------------- Trợ năng ---------------- */
button:focus-visible, a:focus-visible, summary:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.main { margin: 0 auto; }

/* =========================================================
   RESPONSIVE
   ≥1600    Màn hình lớn     : nội dung rộng hơn, căn giữa
   1200+    Laptop / desktop : thanh bên đầy đủ
   768–1199 Máy tính bảng    : thanh bên thu gọn (icon + nhãn nhỏ)
   ≤767     Điện thoại       : thanh trên + thanh tab dưới + menu trượt
   ========================================================= */

/* ----- Màn hình lớn ----- */
@media (min-width: 1600px) {
  .main { max-width: 1480px; padding: 40px 56px 72px; }
  .grid-2, .wheel-layout { gap: 22px; }
  .groups-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .wheel-wrap { width: min(100%, 580px); }
}
@media (min-width: 2200px) {
  body { font-size: 15.5px; }
  .main { max-width: 1680px; }
}

/* ----- Các khối 2 cột chuyển 1 cột khi hẹp ----- */
@media (max-width: 1199px) {
  .wheel-layout { grid-template-columns: minmax(0, 1fr); }
  .wheel-card { padding: 28px 18px 22px; }
  .donate { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .qr-card { position: static; max-width: 440px; width: 100%; margin: 0 auto; order: -1; }
}
@media (max-width: 1080px) {
  .assign-bar { grid-template-columns: minmax(0, 1fr); }
  .assign-bar .btn-xl { width: 100%; }
}
@media (max-width: 959px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

/* ----- Máy tính bảng: thanh bên thu gọn ----- */
@media (min-width: 768px) and (max-width: 1199px) {
  .app { grid-template-columns: 84px minmax(0, 1fr); }
  .sidebar { align-items: center; padding: 16px 10px; gap: 14px; }
  .brand { padding: 0; justify-content: center; }
  .brand-text, .nav-label, .donate-txt, .setting-row, .foot-note { display: none; }
  .nav { width: 100%; gap: 4px; }
  .nav-item {
    position: relative;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 52px;
    padding: 7px 4px;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
  }
  .nav-item .i { width: 20px; height: 20px; }
  .nav-badge {
    position: absolute;
    top: 4px; right: 6px;
    min-width: 18px;
    padding: 0 5px;
    font-size: 10px;
    line-height: 16px;
  }
  .sidebar-foot { width: 100%; align-items: center; padding: 0; gap: 10px; }
  .donate-card { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 12px; }
  .hub-link { margin-top: 0; padding: 6px; justify-content: center; }
  .hub-txt, .hub-go { display: none; }
  .setting-btns { flex-direction: column; align-items: center; gap: 6px; }
  .icon-btn { flex: none; width: 44px; height: 36px; }
  .speed-btn { display: grid; }
  .main { padding: 28px clamp(18px, 3vw, 32px) 56px; }
}
/* Máy tính bảng / điện thoại xoay ngang có chiều cao thấp: chỉ hiện icon */
@media (min-width: 768px) and (max-width: 1199px) and (max-height: 640px) {
  .nav-item { min-height: 44px; }
  .nav-item span:not(.nav-badge) { display: none; }
  .sidebar { gap: 10px; padding-top: 12px; padding-bottom: 12px; }
  .setting-btns .icon-btn { height: 36px; }
}
/* Laptop màn thấp (vd 1366×650): thu gọn thanh bên */
@media (min-width: 1200px) and (max-height: 720px) {
  .foot-note { display: none; }
  .nav-label { padding-top: 8px; }
  .nav-item { padding-top: 7px; padding-bottom: 7px; }
}

/* ----- Điện thoại ----- */
@media (max-width: 767px) {
  body { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  body.drawer-open { overflow: hidden; }

  /* Thanh trên */
  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: calc(56px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; }
  .topbar .logo { width: 32px; height: 32px; border-radius: 9px; }
  .topbar-actions { display: flex; gap: 6px; }
  .topbar .icon-btn { flex: none; width: 38px; height: 38px; }

  .app { display: block; }

  /* Thanh bên → menu trượt từ trái */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 46;
    width: min(300px, 86vw);
    height: 100%;
    padding: calc(16px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-102%);
    visibility: hidden;
    transition: transform .28s cubic-bezier(.3, .7, .3, 1), visibility 0s linear .28s;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; transition: transform .28s cubic-bezier(.3, .7, .3, 1); }
  .drawer-close { display: grid; flex: none; width: 36px; height: 36px; margin-left: auto; }
  .nav-item { min-height: 44px; }
  .drawer-backdrop {
    display: block;
    position: fixed; inset: 0;
    z-index: 45;
    background: rgba(10, 12, 20, .45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
  }
  body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }

  /* Thanh tab dưới */
  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    height: 62px;
    padding: 0 2px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tab-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-item .i {
    width: 48px; height: 30px;
    padding: 5px 14px;
    border-radius: 999px;
    transition: background .2s, color .2s;
  }
  .tab-item.active { color: var(--primary-text); }
  .tab-item.active .i { background: var(--primary-soft); color: var(--primary); }

  /* Nội dung */
  .main { padding: 18px max(16px, env(safe-area-inset-right)) 28px max(16px, env(safe-area-inset-left)); }
  .view-head { margin-bottom: 16px; }
  .view-head h1, .donate-intro h1 { font-size: 22px; }
  .view-head p { font-size: 14px; }
  .view-head.row { align-items: stretch; }
  .view-head.row > .btn, .view-head.row > .actions { width: 100%; }
  .view-head.row > .actions .btn { flex: 1; }
  .card { padding: 16px; border-radius: 13px; }
  .grid-2 { gap: 14px; }
  .card + .card, .grid-2 + .card { margin-top: 14px; }
  .result-card { scroll-margin-top: 68px; }
  .result-card .card-head .actions { width: 100%; }
  .result-card .card-head .actions .btn { flex: 1 1 auto; }

  /* iOS không tự phóng to khi nhập liệu: cỡ chữ ô nhập ≥ 16px */
  textarea, input[type="number"], input[type="text"], select { font-size: 16px; }
  .field-tools .list-picker, .cons-add select { font-size: 16px; }
  textarea { min-height: 140px; }

  .seg-wrap { display: flex; flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg-wrap::-webkit-scrollbar { display: none; }

  .groups-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }
  .wheel-card { padding: 24px 12px 18px; }
  .wheel-wrap { width: min(100%, 440px); }
  .slot { min-height: 108px; }
  .lists-grid { grid-template-columns: minmax(0, 1fr); }
  .donate { gap: 20px; }
  .donate-intro .lead { font-size: 14.5px; }

  /* Hộp thoại dạng bảng trượt từ dưới lên */
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    width: 100%;
    max-height: 90dvh;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheetIn .3s cubic-bezier(.2, .9, .3, 1);
  }
  .modal::before {
    content: "";
    display: block;
    width: 40px; height: 4px;
    margin: -8px auto 14px;
    border-radius: 99px;
    background: var(--border-strong);
  }
  .modal-actions .btn { flex: 1; padding: 12px; }

  .toasts { bottom: calc(74px + env(safe-area-inset-bottom)); }
}
@keyframes sheetIn { from { transform: translateY(100%); } }

/* Điện thoại xoay ngang (chiều cao thấp) */
@media (max-width: 767px) and (max-height: 500px) {
  body { padding-bottom: calc(48px + env(safe-area-inset-bottom)); }
  .topbar { min-height: calc(48px + env(safe-area-inset-top)); }
  .tab-item { height: 48px; flex-direction: row; gap: 6px; }
  .tab-item .i { width: 20px; height: 20px; padding: 0; background: none !important; }
  .toasts { bottom: calc(60px + env(safe-area-inset-bottom)); }
}
/* Vòng quay luôn nằm gọn trong chiều cao màn hình */
@media (max-height: 760px) {
  .wheel-wrap { width: min(100%, 520px, max(260px, calc(100dvh - 210px))); }
}

/* ----- Điện thoại nhỏ ----- */
@media (max-width: 560px) {
  .cons-add { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .cons-add .btn { grid-column: 1 / -1; }
  .assign-row { grid-template-columns: 30px minmax(0, 1fr); }
  .assign-row .who { grid-column: 1 / -1; }
  .h-top { flex-wrap: wrap; }
  .h-top > div:nth-child(2) { flex: 1; min-width: 0; }
  .qr-card { padding: 16px; }
  .stepper-row { flex-wrap: wrap; }
  .legend-row .bar { width: 48px; }
}
@media (max-width: 380px) {
  .main { padding-left: 12px; padding-right: 12px; }
  .card { padding: 14px; }
  .seg button { padding: 8px 6px; font-size: 12.5px; }
  .tab-item { font-size: 10px; }
  .tab-item .i { width: 42px; padding: 5px 11px; }
  .btn-sm { padding: 6px 9px; }
  .field-tools { flex-wrap: wrap; }
  .field-tools .list-picker { flex-basis: 100%; }
  .acc-row .btn { padding: 6px 8px; }
  .winner-box .wname { font-size: 24px; }
}

/* ----- Màn hình cảm ứng: vùng chạm lớn hơn ----- */
@media (pointer: coarse) {
  .chip { padding: 7px 13px; }
  .chip-sm { padding: 5px 11px; }
  .btn-sm { min-height: 36px; }
  .stepper button { width: 44px; height: 44px; }
  .stepper input { font-size: 17px; }
  .check { padding: 4px 0; }
  .check input { width: 20px; height: 20px; margin-top: 1px; }
  .cons-chip button { width: 26px; height: 26px; }
  .link-btn { padding: 6px 0; }
  .icon-btn { min-height: 38px; }
}
/* Thiết bị không có chuột: tắt hiệu ứng hover gây "dính" trạng thái */
@media (hover: none) {
  .donate-card:hover { transform: none; box-shadow: none; }
  .wheel-hub:hover { transform: translate(-50%, -50%); background: var(--navy); }
  .chip:hover { border-color: var(--border); color: var(--text-2); }
  .chip.leader:hover { border-color: color-mix(in srgb, var(--gold) 45%, transparent); color: var(--gold); }
}

/* ----- Giảm chuyển động theo cài đặt hệ thống ----- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ----- In ấn: chỉ in nội dung và kết quả ----- */
@media print {
  .sidebar, .topbar, .tabbar, .drawer-backdrop, .toasts, #confetti, .modal-backdrop,
  .field-tools, .actions, .btn, .stage-actions, .presets, .cons-add { display: none !important; }
  body { background: #fff; padding: 0; color: #000; }
  .app { display: block; }
  .main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .group-card { break-inside: avoid; }
}
