@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #eef3f8;
  --bg-2: #e7f4f2;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --ink: #081421;
  --ink-2: #26364a;
  --muted: #64748b;
  --line: #dbe5ef;
  --line-2: #edf2f7;
  --nav: #07111f;
  --nav-2: #0e1b30;
  --teal: #0f9f8f;
  --teal-2: #0f766e;
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --gold: #f59e0b;
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-xl: 0 28px 70px rgba(8, 20, 33, .16);
  --shadow-lg: 0 18px 42px rgba(8, 20, 33, .11);
  --shadow-md: 0 10px 26px rgba(8, 20, 33, .08);
  --shadow-sm: 0 5px 14px rgba(8, 20, 33, .06);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Be Vietnam Pro", Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background:
    radial-gradient(900px 420px at 84% -8%, rgba(15, 159, 143, .22), transparent 62%),
    radial-gradient(780px 360px at -10% 10%, rgba(37, 99, 235, .14), transparent 58%),
    linear-gradient(180deg, var(--bg), #f7fafc 58%, #eef3f8);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .32;
  pointer-events: none;
  background-image: linear-gradient(rgba(8,20,33,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(8,20,33,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, #000 0, transparent 72%);
}

button, input, select, textarea { font: inherit; }
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fff, #f8fbfd);
  color: var(--ink-2);
  padding: 0 15px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset, var(--shadow-sm);
  transition: transform .14s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}
button:hover { transform: translateY(-1px); border-color: #bfd0df; box-shadow: var(--shadow-md); }
button:active { transform: translateY(0); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(15, 159, 143, .18); border-color: var(--teal); }
input, select, textarea {
  width: 100%; min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  box-shadow: 0 1px 0 rgba(255,255,255,.8) inset;
}
textarea { min-height: 96px; padding: 10px 12px; resize: vertical; }
select { appearance: auto; }
.hidden { display: none !important; }
.readonly .admin-only { display: none !important; }
.guest .nav:not([data-view="overview"]):not([data-view="finance"]), .guest .toolbar select, .guest #quickFinishBtn, .guest #downloadFinanceCsvBtn { display: none !important; }
.primary { background: linear-gradient(135deg, #19b7a5, #0f766e) !important; border-color: #0b6b64 !important; color: #fff !important; box-shadow: 0 12px 24px rgba(15,159,143,.28) !important; }
.primary:hover { background: linear-gradient(135deg, #21c4b1, #0f766e) !important; color: #fff !important; }
.danger { background: linear-gradient(180deg, #fff7f7, #fff1f2) !important; border-color: #fecdd3 !important; color: #be123c !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, rgba(15,159,143,.2), transparent 34%), linear-gradient(135deg, #081421, #0e1b30 52%, #0f766e); }
.login-panel { width: min(440px, 100%); padding: 30px; border: 1px solid rgba(255,255,255,.28); border-radius: var(--radius-xl); background: rgba(255,255,255,.92); backdrop-filter: blur(18px); box-shadow: var(--shadow-xl); }
.brand-mark { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 18px; background: linear-gradient(135deg, #19b7a5, #0f766e); color: #fff; font-size: 20px; font-weight: 900; box-shadow: 0 16px 30px rgba(15,159,143,.34); }
.login-panel h1 { margin: 18px 0 6px; font-size: 30px; line-height: 1.15; letter-spacing: -.03em; }
.login-panel p { margin: 0 0 20px; color: var(--muted); }
.login-panel label, .modal-form label, .club-builder label { display: grid; gap: 7px; font-weight: 800; color: var(--ink-2); }
.login-panel label { margin-top: 12px; }
.login-panel button { width: 100%; margin-top: 18px; }
.login-panel small, .modal-form label small, .club-builder small, .data-table small { color: var(--muted); font-size: 12px; font-weight: 600; line-height: 1.4; }
.error { margin-top: 10px; color: var(--red); font-weight: 800; }

.app { min-height: 100vh; display: grid; grid-template-columns: 286px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; gap: 18px; padding: 22px; background: linear-gradient(180deg, var(--nav), var(--nav-2) 58%, #102033); color: #dbeafe; box-shadow: 12px 0 40px rgba(8,20,33,.12); }
.sidebar::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(380px 220px at -20% 0%, rgba(15,159,143,.28), transparent 64%), radial-gradient(420px 220px at 120% 100%, rgba(37,99,235,.2), transparent 65%); }
.sidebar > * { position: relative; }
.side-brand { display: flex; align-items: center; gap: 13px; padding: 4px 4px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 18px; font-size: 24px; background: linear-gradient(135deg, #22c7b7, #0f766e); color: #fff; box-shadow: 0 18px 36px rgba(15,159,143,.28); }
.side-brand-text { display: grid; line-height: 1.12; }
.side-brand-text strong { color: #fff; font-size: 16px; font-weight: 900; letter-spacing: -.02em; }
.side-brand-text em { margin-top: 3px; font-style: normal; color: #9fb1c7; font-size: 12px; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
nav { display: grid; gap: 7px; }
.nav { position: relative; min-height: 46px; display: flex; align-items: center; gap: 12px; border: 0; border-radius: 14px; background: transparent; color: #a8b9d1; text-align: left; padding: 0 13px; box-shadow: none; }
.nav-ic { width: 21px; height: 21px; flex: 0 0 auto; stroke: currentColor; }
.nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 850; }
.nav:hover { transform: translateX(2px); background: rgba(255,255,255,.06); color: #fff; box-shadow: none; }
.nav.active { background: linear-gradient(135deg, rgba(25,183,165,.24), rgba(37,99,235,.12)); color: #fff; box-shadow: inset 0 0 0 1px rgba(45,212,191,.24), 0 14px 30px rgba(0,0,0,.18); }
.nav.active::before { content: ""; position: absolute; left: -22px; top: 10px; bottom: 10px; width: 4px; border-radius: 4px; background: #2dd4bf; box-shadow: 0 0 18px rgba(45,212,191,.7); }
.side-note { margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.09); border-radius: var(--radius-lg); background: rgba(255,255,255,.055); display: grid; gap: 10px; }
.side-note span { color: #dbeafe; font-size: 13px; font-weight: 800; }
.side-note button { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #fff; box-shadow: none; }

main { min-width: 0; padding: 28px 32px 42px; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: -28px -32px 24px; padding: 20px 32px 16px; background: rgba(238,243,248,.86); backdrop-filter: blur(14px) saturate(135%); border-bottom: 1px solid rgba(219,229,239,.8); }
.topbar h1 { margin: 0; font-size: 30px; line-height: 1.12; font-weight: 900; letter-spacing: -.04em; color: var(--ink); }
.topbar p { max-width: 820px; margin: 7px 0 0; color: var(--muted); font-size: 13.5px; font-weight: 600; }
.toolbar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar select { width: min(320px, 100%); }
.topbar-clock { min-height: 46px; display: grid; align-content: center; justify-items: flex-end; padding: 6px 14px; border-radius: 15px; background: linear-gradient(135deg, #081421, #102033); color: #fff; box-shadow: var(--shadow-md); }
.topbar-clock b { font-size: 18px; line-height: 1; font-weight: 900; font-variant-numeric: tabular-nums; }
.topbar-clock span { margin-top: 2px; font-size: 11px; color: rgba(255,255,255,.72); font-weight: 800; }
.view { display: none; }
.view.active { display: block; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 16px; }
.metric { min-height: 126px; position: relative; overflow: hidden; border: 1px solid rgba(255,255,255,.72); border-radius: var(--radius-xl); background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(247,250,252,.9)); box-shadow: var(--shadow-md); padding: 22px; transition: transform .18s ease, box-shadow .18s ease; }
.metric::before { content: ""; position: absolute; inset: auto 18px 18px auto; width: 80px; height: 80px; border-radius: 50%; background: rgba(37,99,235,.09); }
.metric::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--blue); }
.metric.live::after, .metric.running::after { background: var(--gold); }
.metric.active::after, .metric.published::after { background: var(--teal); }
.metric:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.metric span { position: relative; color: var(--muted); font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { position: relative; display: block; margin-top: 12px; color: var(--ink); font-size: 36px; line-height: 1; font-weight: 900; letter-spacing: -.04em; }
.grid.two { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 16px; }
.panel { margin-bottom: 16px; border: 1px solid rgba(255,255,255,.72); border-radius: var(--radius-xl); background: rgba(255,255,255,.92); box-shadow: var(--shadow-md); padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.panel h2 { margin: 0; font-size: 18px; line-height: 1.25; font-weight: 900; letter-spacing: -.02em; }
.panel h3 { margin: 18px 0 10px; font-size: 15px; font-weight: 900; }
.panel-sub { margin: 5px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.pill, .status { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 4px 11px; font-size: 12px; font-weight: 900; white-space: nowrap; }
.pill { background: #e7f7f4; color: var(--teal-2); }
.pill.live { background: #fff7e6; color: #a85b00; }
.status { background: #edf2f7; color: #334155; }
.status.live, .status.running { background: #fff7e6; color: #a85b00; }
.status.finished, .status.completed, .status.confirmed, .status.active { background: #e7f7ef; color: #047857; }
.status.cancelled, .status.inactive { background: #fff1f2; color: #be123c; }
.status.scheduled, .status.waitlist { background: #eff6ff; color: #1d4ed8; }
.empty { border: 1px dashed #c9d6e2; border-radius: var(--radius-lg); background: rgba(247,250,252,.9); color: var(--muted); padding: 20px; font-weight: 700; }

.table-wrap { width: 100%; overflow: auto; border-radius: var(--radius-lg); border: 1px solid var(--line-2); background: #fff; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line-2); padding: 12px 13px; text-align: left; vertical-align: middle; }
.data-table th { position: sticky; top: 0; z-index: 1; background: linear-gradient(180deg, #f8fbfd, #eef4f8); color: #405066; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.data-table td { background: #fff; }
.data-table tr:hover td { background: #f7fbff; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table button { min-height: 32px; padding: 0 10px; }
.person-cell { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.person-cell > span:last-child { display: grid; min-width: 0; }

.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; color: #fff; font-size: 12px; font-weight: 900; box-shadow: 0 8px 18px rgba(8,20,33,.12); }
.avatar.image { overflow: hidden; background: #e5edf4 !important; }
.avatar.image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.match-list, .ranking-list, .tournament-mini-list, .finance-summary, .finance-categories { display: grid; gap: 12px; }
.match-card { border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: linear-gradient(145deg, #fff, #f7fbff); box-shadow: var(--shadow-sm); padding: 15px; transition: transform .16s ease, box-shadow .16s ease; }
.match-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.match-card.pro { background: linear-gradient(145deg, #fff, #f3fbf9); }
.match-top, .match-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 700; }
.match-top { margin-bottom: 11px; }
.match-meta { margin-top: 11px; }
.versus { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 13px; }
.player-side { display: flex; align-items: center; gap: 10px; min-width: 0; }
.player-side.right { justify-content: flex-end; text-align: right; }
.player-side b, .rank-row b, .member-card h3, .player-card h3 { overflow-wrap: anywhere; }
.player-side small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.player-side.serving b::after { content: " · giao"; color: var(--gold); font-size: 12px; font-weight: 900; }
.score { min-width: 92px; border: 1px solid var(--line) !important; border-radius: 12px !important; background: #fff !important; color: var(--ink) !important; font-size: 18px; font-weight: 900; box-shadow: var(--shadow-sm); }

.rank-row { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; align-items: center; gap: 11px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; padding: 12px; box-shadow: var(--shadow-sm); }
.rank-row > strong:first-child { color: var(--muted); }
.rank-row > div { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-row small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }

.detail-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #f8fbfd; padding: 14px; }
.detail-actions span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.detail-actions > div:last-child { display: flex; gap: 8px; flex-wrap: wrap; }
.tournament-detail.muted { color: var(--muted); }
.config-grid { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(280px,.85fr); gap: 16px; }
.group-board-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.group-board { min-width: 0; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); padding: 12px; }
.group-board h4 { margin: 0 0 9px; font-size: 14px; font-weight: 900; }
.group-board .table-wrap { margin: 0; }
.group-board .data-table { min-width: 0; }
.group-board .data-table th, .group-board .data-table td { padding: 8px 7px; font-size: 12px; }
.bracket-plan { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 14px; margin-bottom: 16px; }
.bracket-slot { position: relative; overflow: hidden; border: 1px solid #d9e6ef; border-radius: var(--radius-lg); background: linear-gradient(145deg, #fff, #f4f9fd); padding: 16px 16px 16px 21px; display: grid; gap: 8px; box-shadow: var(--shadow-sm); }
.bracket-slot::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--blue); }
.bracket-slot b { color: var(--ink); font-size: 13px; text-transform: uppercase; letter-spacing: .05em; }
.bracket-slot span { color: var(--ink-2); font-weight: 800; line-height: 1.35; }
.bracket-slot small { color: var(--muted); font-size: 12px; font-weight: 600; }
.bracket-slot.waiting { border-style: dashed; background: repeating-linear-gradient(135deg, #fbfdff 0, #fbfdff 10px, #f2f7fb 10px, #f2f7fb 20px); }
.bracket-slot.waiting::before { background: var(--gold); }
.bracket-slot.finished { background: linear-gradient(145deg, #f6fbf8, #fff); }
.bracket-slot.finished::before { background: var(--green); }
.tournament-mini { border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; box-shadow: var(--shadow-sm); padding: 14px; display: grid; gap: 5px; }
.tournament-mini b { color: var(--ink); }
.tournament-mini span, .tournament-mini small { color: var(--muted); font-size: 12px; font-weight: 700; }
.podium-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.podium-card { position: relative; overflow: hidden; border: 1px solid var(--line-2); border-radius: var(--radius-xl); background: #fff; padding: 18px; text-align: center; display: grid; gap: 8px; box-shadow: var(--shadow-md); }
.podium-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; background: var(--line); }
.podium-card:nth-child(1) { background: linear-gradient(145deg, #fffdf5, #fff7dd); border-color: #f0d68a; }
.podium-card:nth-child(1)::before { background: linear-gradient(90deg, #f59e0b, #facc15); }
.podium-card:nth-child(2) { background: linear-gradient(145deg, #fff, #eef3f8); border-color: #cbd5e1; }
.podium-card:nth-child(2)::before { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }
.podium-card:nth-child(3) { background: linear-gradient(145deg, #fffaf5, #fbeada); border-color: #e2b98f; }
.podium-card:nth-child(3)::before { background: linear-gradient(90deg, #b87333, #e0a872); }
.podium-card span { font-size: 34px; }
.podium-card b { color: var(--muted); text-transform: uppercase; font-size: 12px; letter-spacing: .06em; }
.podium-card strong { color: var(--ink); font-size: 17px; line-height: 1.3; }
.round-filter-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.round-filter-tabs button { min-height: 34px; padding: 0 13px; border-radius: 999px; background: #fff; }
.round-filter-tabs button.active { background: var(--nav); color: #fff; border-color: var(--nav); }
.finished-frame { border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fbfdff; padding: 8px; }
.rules-box { min-height: 118px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #f8fbfd; padding: 13px; color: var(--ink-2); white-space: pre-wrap; }

.club-roster-panel { padding: 0; overflow: hidden; }
.club-roster-panel .panel-head, .club-roster-panel .member-toolbar, .club-roster-panel .member-stats { margin: 0; padding: 18px 20px; }
.member-toolbar { display: grid; grid-template-columns: minmax(240px,1fr) 140px 170px 160px 150px; gap: 11px; border-top: 1px solid var(--line-2); background: #fbfdff; }
.member-toolbar label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 900; }
.member-bulk-actions, .member-pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 13px 20px; border-top: 1px solid var(--line-2); background: #fff; }
.member-pagination { justify-content: center; color: var(--muted); font-size: 13px; }
.member-stats { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 11px; border-top: 1px solid var(--line-2); }
.member-stats div { border: 1px solid var(--line-2); border-radius: var(--radius-md); background: #f8fbfd; padding: 13px; }
.member-stats span { display: block; color: var(--muted); font-size: 12px; font-weight: 900; }
.member-stats strong { display: block; margin-top: 5px; font-size: 24px; line-height: 1; }
.member-directory { border-top: 1px solid var(--line-2); }
.member-directory-row { display: grid; grid-template-columns: 34px minmax(230px,1.15fr) minmax(210px,.9fr) minmax(230px,1fr) minmax(220px,1fr) auto; gap: 14px; align-items: center; padding: 15px 20px; border-bottom: 1px solid var(--line-2); background: #fff; }
.member-directory-row:hover { background: #f8fbff; }
.member-directory-row.selected { background: #f2fbf8; }
.member-select { display: grid; place-items: center; }
.member-select input, .checkline input { width: 18px; height: 18px; accent-color: var(--teal); }
.member-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.member-person .avatar { width: 46px; height: 46px; font-size: 14px; }
.member-person h3 { margin: 0; font-size: 16px; line-height: 1.25; overflow-wrap: anywhere; }
.member-person p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.member-pillset { display: flex; gap: 7px; flex-wrap: wrap; }
.member-pillset span { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; background: #eaf7f5; color: var(--teal-2); padding: 3px 9px; font-size: 12px; font-weight: 900; }
.member-contact, .member-note { min-width: 0; }
.member-contact b { display: block; font-size: 13px; }
.member-contact span, .member-contact small, .member-note span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.member-note { border-left: 3px solid var(--line); padding-left: 10px; }
.member-row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.club-builder-panel { margin-top: 16px; }
.avatar-upload-row { display: grid; grid-template-columns: 72px minmax(0,1fr); align-items: center; gap: 12px; border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #f8fbfd; padding: 13px; }
.avatar-upload-row .avatar { width: 56px; height: 56px; font-size: 16px; }
.club-builder { display: grid; gap: 13px; }
.club-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.checkline { display: flex !important; align-items: center; gap: 8px; font-weight: 800; }
.checkline input { flex: 0 0 auto; }

.fund-stack { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px; }
.fund-stack > div, .category-row, .finance-ledger { border: 1px solid var(--line-2); border-radius: var(--radius-lg); background: #fff; padding: 14px; box-shadow: var(--shadow-sm); }
.fund-stack span, .category-row small, .finance-ledger span, .finance-ledger small { display: block; color: var(--muted); font-size: 12px; font-weight: 800; }
.fund-stack strong { display: block; margin-top: 7px; font-size: 20px; line-height: 1.2; }
.category-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.category-row small { margin-top: 4px; }
.finance-board { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; }
.finance-ledger { min-height: 118px; display: grid; align-content: space-between; }
.finance-ledger strong { display: block; margin: 8px 0; font-size: 25px; line-height: 1.15; }
.category-row.rich > div { flex: 1; min-width: 0; }
.category-row.rich i { display: block; height: 8px; margin-top: 9px; border-radius: 999px; background: linear-gradient(90deg, var(--teal), #22c7b7); }
.money-in { color: var(--green); }
.money-out { color: var(--red); }
.metrics.compact { grid-template-columns: repeat(4,minmax(0,1fr)); }

.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.score-player { min-height: 166px !important; display: grid !important; place-items: center !important; border: 0 !important; border-radius: 22px !important; background: linear-gradient(145deg, #081421, #102033) !important; color: #fff !important; padding: 16px !important; text-align: center; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: var(--shadow-lg); }
.score-player.right { background: linear-gradient(145deg, #0f766e, #19b7a5) !important; }
.score-player strong { display: block; font-size: 68px; line-height: 1; font-weight: 900; }
.score-player span { display: block; font-weight: 900; }
.score-player small { color: rgba(255,255,255,.76); }
.score-player.serving { outline: 4px solid #f59e0b; outline-offset: -5px; }
.score-title { border: 1px solid var(--line-2); border-radius: var(--radius-md); background: #f8fbfd; padding: 11px 13px; font-weight: 900; }
.score-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.score-actions small { color: var(--muted); }
.score-raw-fields { display: none !important; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.form-grid label { min-width: 0; }
dialog { width: min(540px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); overflow: auto; border: 1px solid rgba(255,255,255,.72); border-radius: var(--radius-xl); background: #fff; box-shadow: var(--shadow-xl); padding: 0; }
dialog::backdrop { background: rgba(8,20,33,.5); backdrop-filter: blur(3px); }
dialog:has(.wide) { width: min(820px, calc(100vw - 28px)); }
.modal-form { display: grid; gap: 13px; padding: 20px; }
.modal-form h3 { margin: 0 0 2px; font-size: 20px; line-height: 1.25; font-weight: 900; }
.modal-form menu { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin: 8px 0 0; padding: 0; }
.modal-form input[type="color"] { padding: 4px; }
.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 260px minmax(0,1fr); }
  main { padding: 22px 18px 34px; }
  .topbar { margin: -22px -18px 18px; padding: 16px 18px 14px; }
  .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .finance-board { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid.two, .config-grid { grid-template-columns: 1fr; }
  .member-directory-row { grid-template-columns: 34px minmax(220px,1fr) minmax(180px,.8fr); }
  .member-contact, .member-note, .member-row-actions { grid-column: 2 / 4; }
  .member-row-actions { justify-content: flex-start; }
}
@media (max-width: 860px) {
  body { padding-bottom: 86px; }
  .app { display: block; }
  .sidebar { display: none; }
  main { padding: 18px 14px 30px; }
  .topbar { align-items: flex-start; flex-direction: column; margin: -18px -14px 16px; padding: 14px; }
  .topbar h1 { font-size: 23px; }
  .toolbar { justify-content: flex-start; width: 100%; }
  .toolbar select { flex: 1 1 220px; }
  .bottom-nav { display: grid; position: fixed; inset: auto 0 0 0; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 4px; padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.96); backdrop-filter: blur(14px); border-top: 1px solid var(--line); box-shadow: 0 -16px 34px rgba(8,20,33,.14); z-index: 50; }
  .bottom-nav .nav { min-height: 54px; display: grid; place-items: center; gap: 2px; border-radius: 14px; padding: 4px 2px; color: var(--muted); }
  .bottom-nav .nav:hover { transform: none; background: #f2faf8; color: var(--teal-2); }
  .bottom-nav .nav.active { background: #e4f6f3; color: var(--teal-2); box-shadow: inset 0 0 0 1px rgba(15,159,143,.18); }
  .bottom-nav .nav.active::before { display: none; }
  .bottom-nav .nav-ic { width: 22px; height: 22px; }
  .bottom-nav .nav-label { font-size: 10.5px; max-width: 100%; text-align: center; white-space: normal; line-height: 1.1; }
}
@media (max-width: 560px) {
  body { font-size: 13px; }
  main { padding: 16px 12px 28px; }
  .topbar h1 { font-size: 21px; }
  .metrics, .fund-stack, .metrics.compact, .finance-board { grid-template-columns: 1fr; }
  .panel { padding: 15px; }
  .panel-head, .detail-actions { align-items: flex-start; flex-direction: column; }
  .podium-grid { grid-template-columns: 1fr; }
  .versus { grid-template-columns: 1fr; gap: 8px; }
  .player-side.right { justify-content: flex-start; text-align: left; flex-direction: row-reverse; }
  .score { width: 100%; text-align: center; }
  .match-top, .match-meta { align-items: flex-start; flex-direction: column; }
  .rank-row { grid-template-columns: 36px minmax(0,1fr); }
  .rank-row > strong:last-child { grid-column: 2; justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .score-player { min-height: 132px !important; padding: 10px !important; border-radius: 18px !important; }
  .score-player strong { font-size: 46px; }
  .score-player small { font-size: 11px; }
  .member-toolbar, .member-stats { grid-template-columns: 1fr; }
  .member-directory-row { grid-template-columns: 28px minmax(0,1fr); align-items: flex-start; }
  .member-pillset, .member-contact, .member-note, .member-row-actions { grid-column: 2; }
  .avatar-upload-row { grid-template-columns: 1fr; }
  .modal-form menu button { flex: 1 1 120px; }
}


/* === Layout redesign overrides === */
#overview .metrics { margin-bottom: 22px; }
#overview .metric { min-height: 118px; padding: 22px 22px 18px; background: linear-gradient(145deg, #ffffff, #f7fbff); }
#overview .metric::before { inset: 18px 18px auto auto; width: 48px; height: 48px; border-radius: 16px; background: linear-gradient(135deg, rgba(15,159,143,.13), rgba(37,99,235,.08)); }
#overview .metric strong { font-size: 34px; margin-top: 14px; }
#overview .grid.two { align-items: start; }
#overview .panel { background: rgba(255,255,255,.96); }
#overview #liveMatches .match-card:first-child,
#overview #runningTournaments .tournament-mini:first-child,
#overview #overviewBracket .bracket-slot:first-child { border-color: rgba(15,159,143,.34); box-shadow: 0 18px 42px rgba(15,159,143,.12); }

/* Give tables a product-like shell instead of raw spreadsheet feel */
#overview .table-wrap, #tournaments .table-wrap, #matches .table-wrap, #finance .table-wrap { box-shadow: inset 0 1px 0 rgba(255,255,255,.9), var(--shadow-sm); }
#overview .data-table th, #tournaments .data-table th, #matches .data-table th, #finance .data-table th { background: #0b1727; color: #dbeafe; }
#overview .data-table tr:hover td, #tournaments .data-table tr:hover td, #matches .data-table tr:hover td, #finance .data-table tr:hover td { background: #f1fbf8; }

/* === UX infra styles: toast, skeleton, confirm, pending === */
.toast-host { position: fixed; right: 18px; bottom: 18px; z-index: 9999; display: grid; gap: 10px; max-width: min(360px, calc(100vw - 36px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: #0b1727; color: #fff; box-shadow: var(--shadow-lg); font-weight: 700; font-size: 13.5px; cursor: pointer; opacity: 0; transform: translateY(10px); transition: opacity .2s ease, transform .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-ic { display: grid; place-items: center; width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; font-size: 13px; font-weight: 900; background: rgba(255,255,255,.16); }
.toast-success { background: linear-gradient(135deg, #0f766e, #15a394); }
.toast-success .toast-ic { background: rgba(255,255,255,.22); }
.toast-error { background: linear-gradient(135deg, #b91c1c, #dc2626); }
.toast-error .toast-ic { background: rgba(255,255,255,.22); }

.confirm-dialog { width: min(440px, calc(100vw - 28px)); }
.confirm-dialog .confirm-text { margin: 0; color: var(--ink-2); font-weight: 600; line-height: 1.55; }

button.is-loading { position: relative; color: transparent !important; pointer-events: none; }
button.is-loading::after { content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; animation: btnspin .6s linear infinite; }
button.is-loading:not(.primary):not(.danger)::after { border-color: rgba(15,159,143,.35); border-top-color: var(--teal); }
@keyframes btnspin { to { transform: rotate(360deg); } }

.skeleton-stack { display: grid; gap: 12px; }
.skeleton-row { height: 46px; border-radius: 12px; }
.skeleton-card { height: 84px; border-radius: var(--radius-lg); }
.metric-skel { height: 118px; border-radius: var(--radius-xl); }
.skeleton-row, .skeleton-card { background: linear-gradient(100deg, #eef3f8 30%, #f6fafd 50%, #eef3f8 70%); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; border: 1px solid var(--line-2); }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
#metrics .metric-skel { display: inline-block; width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .toast, button.is-loading::after, .skeleton-row, .skeleton-card { transition: none; animation: none; }
}

/* === UX level 3: empty state + table scroll hint === */
.empty { display: grid; place-items: center; gap: 8px; text-align: center; padding: 26px 18px; }
.empty-ic { font-size: 30px; line-height: 1; opacity: .7; }
.table-wrap { position: relative; -webkit-overflow-scrolling: touch; }
.table-wrap.scrollable::after { content: "Vuốt ngang để xem thêm →"; position: sticky; right: 0; bottom: 0; display: none; }
@media (max-width: 760px) {
  .table-wrap.is-overflowing { box-shadow: inset -18px 0 18px -18px rgba(8,20,33,.28), var(--shadow-sm); }
  .scroll-hint { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
  .scroll-hint::before { content: "↔"; font-size: 14px; }
}
.scroll-hint { display: none; }
