:root {
  --ink: #0e1626;
  --panel: #152038;
  --panel-2: #1b2a47;
  --line: #2a3a58;
  --text: #e6ebf5;
  --muted: #92a2c0;
  --amber: #f4b942;
  --amber-ink: #2b1d00;
  --home: #35b8a6;
  --away: #e8705c;
  --draw: #8d9bb8;
  --good: #4cc38a;
  --bad: #ff6b7a;
  --warn-bg: #3a2f12;
  --err-bg: #4a1d27;
  --radius: 10px;
  --font-display: "Bahnschrift", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  --font-body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--text); font: 15px/1.55 var(--font-body);
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); } .pad { padding: 1rem; } small, .small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-display); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- khung ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); background: rgba(14, 22, 38, .96);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; color: var(--amber); }
.nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.nav a { padding: .4rem .7rem; border-radius: 8px; color: var(--muted); }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--amber); }
.tools { display: flex; gap: .5rem; align-items: center; }
select, input[type=text], input[type=search], input[type=date], input[type=password] {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem;
  font: inherit; min-height: 40px; max-width: 100%;
}
input::placeholder { color: #6f7f9e; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: .5rem .9rem; min-height: 40px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn-accent { background: var(--amber); color: var(--amber-ink); border-color: var(--amber); }
.btn-accent:hover { filter: brightness(1.07); }
.btn-small { min-height: 32px; padding: .2rem .65rem; font-size: .85rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1rem 1rem 3rem; outline: none; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; }

/* ---------- banner, thông báo ---------- */
.banner { padding: .65rem 1rem; font-size: .93rem; border-bottom: 1px solid var(--line); }
.banner b { font-weight: 700; }
.banner-test { background: #7a1426; color: #fff; text-align: center; }
.banner-warn { background: var(--warn-bg); color: #ffe3a3; }
.banner a { text-decoration: underline; }
#toasts { position: fixed; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 50; display: grid; gap: .5rem; max-width: min(92vw, 380px); }
.toast { padding: .7rem .9rem; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0,0,0,.35); }
.toast.ok { border-left: 4px solid var(--good); } .toast.error { border-left: 4px solid var(--bad); }
.notice { padding: .8rem 1rem; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.notice.warn { background: var(--warn-bg); border-color: #6b5518; }
.notice.error { background: var(--err-bg); border-color: #7b2c3a; }
.empty { padding: 1.4rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }
.loading { color: var(--muted); padding: 2rem 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: .4rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- bộ lọc ---------- */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.filters input[type=search] { flex: 1 1 180px; }

/* ---------- danh sách trận ---------- */
.section { margin-bottom: 1.8rem; }
.section > h2 { margin-bottom: .6rem; display: flex; align-items: center; gap: .6rem; }
.count { font-size: .8rem; color: var(--muted); font-family: var(--font-body); font-weight: 400; }
.league-group { margin-bottom: .9rem; }
.league-name { font-size: .88rem; color: var(--muted); padding: .2rem .2rem .35rem; }
.mlist { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.mrow { display: grid; grid-template-columns: 74px 1fr auto; gap: .8rem; align-items: center; padding: .65rem .9rem; border-top: 1px solid var(--line); }
.mrow:first-child { border-top: 0; }
.mrow:hover { background: var(--panel-2); }
.mtime { font-family: var(--font-display); font-size: 1.05rem; line-height: 1.1; }
.mtime small { display: block; font-family: var(--font-body); color: var(--muted); font-size: .76rem; margin-top: .2rem; }
.mteams { display: grid; gap: .25rem; min-width: 0; }
.mteam { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.mteam span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mteam .score { margin-left: auto; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; padding-left: .6rem; }
.mteam.win .name { font-weight: 700; }
.crest { width: 22px; height: 22px; object-fit: contain; flex: none; }
.crest-fallback { width: 22px; height: 22px; flex: none; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .6rem; color: var(--muted); }
.mside { display: grid; gap: .3rem; justify-items: end; text-align: right; }
.status { font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.status.live { color: var(--amber-ink); background: var(--amber); border-color: var(--amber); font-weight: 700; }
.status.done { color: var(--text); } .status.warn { color: #ffd37a; border-color: #6b5518; }
.go { font-size: .8rem; color: var(--amber); }
.tag-test { font-size: .7rem; color: #fff; background: #7a1426; border-radius: 4px; padding: 0 .35rem; margin-left: .4rem; }

/* ---------- trang trận ---------- */
.match-head { padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 1rem; }
.match-head .meta { color: var(--muted); font-size: .9rem; margin-bottom: .8rem; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: center; }
.vteam { display: flex; flex-direction: column; align-items: center; gap: .4rem; text-align: center; }
.vteam .crest, .vteam .crest-fallback { width: 52px; height: 52px; font-size: .9rem; }
.vteam .role { font-size: .78rem; color: var(--muted); }
.vteam.home .role { color: var(--home); } .vteam.away .role { color: var(--away); }
.vscore { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; min-width: 90px; text-align: center; }
.vscore small { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); font-family: var(--font-body); }
.block { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 1rem; margin-bottom: 1rem; }
.block > h2 { margin-bottom: .75rem; }
.block-sub { color: var(--muted); font-size: .85rem; margin: -.4rem 0 .8rem; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; background: transparent; color: var(--muted); border: 0; padding: .3rem .8rem; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--amber); }

/* Dải xác suất — điểm nhấn của trang phân tích */
.pstrip { display: flex; height: 46px; border-radius: 8px; overflow: hidden; margin: .4rem 0 .5rem; font-family: var(--font-display); font-weight: 700; }
.pstrip div { display: flex; align-items: center; justify-content: center; min-width: 0; color: #06201c; font-size: 1.05rem; }
.pstrip .h { background: var(--home); } .pstrip .d { background: var(--draw); color: #111a2c; } .pstrip .a { background: var(--away); color: #2a0b05; }
.plabels { display: flex; justify-content: space-between; gap: .5rem; font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin: .8rem 0 1rem; }
.fact-box { background: var(--panel-2); border-radius: 8px; padding: .55rem .75rem; }
.fact-box .v { font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.fact-box .l { font-size: .78rem; color: var(--muted); }
.matrix { border-collapse: separate; border-spacing: 3px; margin: .4rem 0; font-family: var(--font-display); font-size: .82rem; }
.matrix th { color: var(--muted); font-weight: 400; padding: 0 .3rem; }
.matrix td { width: 44px; height: 34px; text-align: center; border-radius: 5px; background: rgba(244, 185, 66, calc(var(--p) * 5)); }
.matrix td.pick { outline: 2px solid var(--amber); }
.matrix-wrap { overflow-x: auto; }
.axis-note { font-size: .78rem; color: var(--muted); }
.factors { margin: .5rem 0 0; padding-left: 1.1rem; } .factors li { margin-bottom: .3rem; }
.factors li.up::marker { color: var(--good); } .factors li.down::marker { color: var(--bad); }

/* chip phong độ & bảng */
.chips { display: flex; gap: .3rem; margin-bottom: .6rem; }
.chip { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 6px; font-size: .78rem; font-weight: 700; color: #07120f; }
.chip.W { background: var(--good); } .chip.D { background: var(--draw); } .chip.L { background: var(--bad); }
.sumgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: .7rem; }
.sumgrid .fact-box .v { font-size: 1.05rem; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: .78rem; padding: .3rem .4rem; border-bottom: 1px solid var(--line); }
table.t td { padding: .4rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr:last-child td { border-bottom: 0; }
.t-scroll { overflow-x: auto; }
.tname { display: flex; align-items: center; gap: .5rem; }
.h2h-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: .4rem 0 .3rem; background: var(--panel-2); }
.h2h-bar .h { background: var(--home); } .h2h-bar .d { background: var(--draw); } .h2h-bar .a { background: var(--away); }

/* kết luận: dữ kiện vs suy luận */
.concl { padding: .7rem 0; border-top: 1px solid var(--line); } .concl:first-of-type { border-top: 0; padding-top: 0; }
.concl h3 { margin-bottom: .35rem; }
.line { display: grid; grid-template-columns: 76px 1fr; gap: .6rem; margin: .25rem 0; }
.line .k { font-size: .76rem; padding: .05rem .4rem; border-radius: 4px; height: fit-content; text-align: center; }
.line.fact .k { background: var(--panel-2); color: var(--text); border-left: 3px solid var(--home); }
.line.infer .k { background: transparent; color: var(--amber); border: 1px dashed var(--amber); }
.line.infer .v { font-style: italic; }
.gaps { margin: .3rem 0 0; padding-left: 1.1rem; color: #ffd9a0; }

/* bài viết */
.article { line-height: 1.7; } .article h1 { font-size: 1.4rem; margin-bottom: .6rem; } .article h2 { font-size: 1.1rem; margin: 1.1rem 0 .4rem; color: var(--amber); }
.article p { margin: .4rem 0; } .article ul { padding-left: 1.2rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* bảng xếp hạng, đội, cài đặt */
.teams-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .5rem; }
.team-card { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.team-card:hover { background: var(--panel-2); }
.team-card .leagues { color: var(--muted); font-size: .78rem; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.form-grid { display: grid; gap: .7rem; max-width: 560px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .3rem .8rem; margin: .5rem 0 .8rem; }
.checks label { display: flex; align-items: center; gap: .5rem; min-height: 32px; }
.steps { padding-left: 1.2rem; } .steps li { margin: .35rem 0; }
code, .code { font-family: Consolas, "Cascadia Mono", monospace; background: var(--panel-2); padding: .05rem .35rem; border-radius: 4px; font-size: .88em; }
.prog { display: grid; gap: .3rem; margin-top: .6rem; }
.prog div { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem .6rem; background: var(--panel-2); border-radius: 6px; font-size: .88rem; }
.prog .ok { color: var(--good); } .prog .error { color: var(--bad); } .prog .running { color: var(--amber); }

/* ---------- điện thoại ---------- */
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .topbar { gap: .5rem; }
  .brand { font-size: 1rem; }
  .tools { margin-left: auto; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-wrap: nowrap; gap: 0; background: #0b1220;
    border-top: 1px solid var(--line); padding: 0 0 env(safe-area-inset-bottom); overflow-x: auto;
  }
  .nav a { flex: 1 0 auto; text-align: center; padding: .85rem .7rem; border-radius: 0; font-size: .82rem; white-space: nowrap; }
  .nav a.active { box-shadow: inset 0 2px 0 var(--amber); }
  #sync-btn { padding: .4rem .6rem; font-size: .85rem; }
  .mrow { grid-template-columns: 58px 1fr auto; gap: .55rem; padding: .6rem .6rem; }
  .cols { grid-template-columns: 1fr; }
  .versus { gap: .4rem; } .vscore { font-size: 1.7rem; min-width: 64px; }
  .line { grid-template-columns: 1fr; gap: .15rem; } .line .k { width: fit-content; }
  #toasts { left: 1rem; right: 1rem; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: none; }
  .matrix td { width: 36px; height: 30px; }
}

/* ---- màn hình đăng nhập (bản web) */
.logged-out .nav, .logged-out .tools { display: none; }
.login { max-width: 360px; margin: 12vh auto 0; padding: 1.4rem; display: grid; gap: .9rem; }
.login label { display: grid; gap: .3rem; font-size: .9rem; }
.login input { padding: .65rem .7rem; font-size: 1rem; }

.mk-row { margin-bottom: .6rem; } .mk-label { font-size: .85rem; color: var(--muted); margin-bottom: .1rem; }
.mk-row .pstrip { height: 34px; margin: .15rem 0; }
