:root {
  --ink: #162b45;
  --muted: #718096;
  --line: #e1e8f0;
  --paper: #f5f8fb;
  --white: #fff;
  --blue: #1769aa;
  --blue-2: #2ba7ca;
  --blue-soft: #e7f3fb;
  --red: #e13d45;
  --green: #159a75;
  --shadow: 0 12px 32px rgba(18, 52, 86, .10);
  --nav-height: calc(56px + env(safe-area-inset-bottom));
  --nav-offset: 0px;
  --dock-height: 0px;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; overflow-x: hidden; background: var(--paper); }
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(23, 105, 170, .28); outline-offset: 2px; }
[hidden] { display: none !important; }

.app-shell { min-height: 100svh; padding-bottom: calc(var(--nav-offset) + var(--dock-height) + 16px); }
.app-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 16px; color: #fff; background: linear-gradient(118deg, #446de1 0%, #1769aa 48%, #2bb7c5 100%); }
.brand-lockup, .header-actions, .selection-summary, .selection-controls, .toolbar-row, .subnav, .dialog-header { display: flex; align-items: center; }
.brand-lockup { gap: 10px; }
.brand-lockup strong { display: block; font-size: 18px; letter-spacing: .08em; }
.brand-lockup > div:last-child span { display: block; margin-top: 2px; font-size: 11px; color: rgba(255,255,255,.76); }
.brand-mark { position: relative; width: 34px; height: 34px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 6px; border: 1px solid rgba(255,255,255,.55); border-radius: 10px; background: rgba(255,255,255,.16); }
.brand-mark span { border-radius: 3px; background: #fff; opacity: .95; }
.brand-mark span:nth-child(2) { opacity: .6; }
.brand-mark span:nth-child(3) { opacity: .72; }
.header-actions { gap: 10px; }
.mode-pill { padding: 5px 8px; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #eaffff; font-size: 11px; }
.icon-button { width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; color: #fff; background: rgba(255,255,255,.14); font-size: 20px; }

.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: -2px 12px 0; padding: 4px; border-radius: 13px; background: #fff; box-shadow: var(--shadow); }
.mode-button { min-height: 38px; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 700; }
.mode-button.active { color: var(--blue); background: var(--blue-soft); }
.view { padding: 0 14px; }
.access-gate { display: flex; min-height: min(64svh, 540px); flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gate-mark { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 12px; border: 1px solid #b8d7eb; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-size: 13px; }
.access-gate h1, .view-heading h1 { margin: 0; color: var(--ink); font-size: 20px; }
.access-gate p { max-width: 290px; margin: 8px 0 18px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.view-heading { display: flex; align-items: baseline; gap: 9px; margin: 8px 0 12px; }
.view-heading .eyebrow { font-size: 9px; }
.agent-note { margin: -4px 0 12px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.sport-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 4px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sport-tab { display: flex; justify-content: center; align-items: center; gap: 6px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #fff; font-size: 13px; font-weight: 700; }
.sport-tab.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.sport-tab b { min-width: 18px; padding: 1px 4px; border-radius: 8px; color: #fff; background: var(--blue); font-size: 10px; }
.fixture-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 8px; color: var(--muted); font-size: 11px; }
.fixture-controls label { display: flex; align-items: center; gap: 7px; }
.fixture-controls select { min-height: 32px; max-width: 190px; border: 1px solid var(--line); border-radius: 6px; padding: 0 8px; color: var(--ink); background: #fff; font-size: 12px; }
.feed-status { min-height: 16px; margin: 0 0 8px; color: var(--muted); font-size: 10px; }
.toolbar-row { gap: 7px; overflow-x: auto; padding: 2px 0 12px; }
.quick-filter { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: 12px; }
.quick-filter.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); }
.subnav { gap: 22px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.subnav-button { position: relative; padding: 9px 2px 11px; color: var(--muted); background: none; font-size: 14px; }
.subnav-button.active { color: var(--blue); font-weight: 800; }
.subnav-button.active::after { content: ""; position: absolute; bottom: -1px; left: 0; right: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--blue); }
.subnav-button b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin-left: 3px; border-radius: 9px; color: #fff; background: var(--red); font-size: 10px; }
.stack { display: grid; gap: 12px; }
.fixture-card, .order-card { border: 1px solid var(--line); border-radius: 14px; background: #fff; box-shadow: 0 6px 18px rgba(20, 53, 84, .05); overflow: hidden; }
.fixture-top, .order-top { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; background: linear-gradient(90deg, #e7f3fb, #f8fbfd); }
.fixture-meta, .order-meta { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.league-tag { padding: 3px 6px; border-radius: 4px; color: #1d678e; background: #d6edf7; font-weight: 700; }
.cutoff { color: var(--red); font-weight: 700; }
.fixture-body { padding: 12px; }
.teams small { display: inline-block; margin-left: 4px; color: var(--muted); font-size: 9px; font-weight: 500; }
.market-group + .market-group { margin-top: 10px; }
.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; color: var(--ink); font-size: 15px; font-weight: 800; }
.teams span:nth-child(2) { color: #9aaabb; font-size: 11px; font-weight: 500; }
.teams span:last-child { text-align: right; }
.market-label { margin: 12px 0 7px; color: var(--muted); font-size: 11px; }
.market-group .market-label { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.market-state { display: inline-flex; align-items: center; min-height: 20px; padding: 0 7px; border: 1px solid transparent; border-radius: 999px; color: #687c8d; font-size: 10px; font-weight: 700; }
.market-state.single-allowed { border-color: #f0b56c; color: #a9550e; background: #fff1dc; }
.option-row { display: grid; grid-template-columns: repeat(var(--option-columns, 3), minmax(0, 1fr)); gap: 7px; }
.option-button { min-height: 43px; border: 1px solid #dfe8f0; border-radius: 8px; color: var(--ink); background: #fff; text-align: left; padding: 7px 8px; }
.option-button span { display: block; font-size: 11px; color: var(--muted); }
.option-button strong { display: block; margin-top: 2px; font-size: 15px; }
.option-button.selected { border-color: var(--blue); color: #fff; background: var(--blue); box-shadow: 0 4px 10px rgba(23, 105, 170, .2); }
.option-button.selected span { color: rgba(255,255,255,.78); }
.option-button:disabled { cursor: not-allowed; opacity: .45; }
.fixture-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; color: var(--muted); font-size: 10px; }
.fixture-foot strong { color: var(--green); }

.selection-dock { position: fixed; left: 0; right: 0; bottom: var(--nav-offset); z-index: 5; padding: 10px 14px 9px; border-top: 1px solid #d7e2eb; background: rgba(255,255,255,.96); box-shadow: 0 -8px 24px rgba(21, 60, 90, .08); backdrop-filter: blur(12px); }
.selection-summary { justify-content: space-between; gap: 12px; }
.selection-summary > div { min-width: 0; }
.selection-summary span { display: block; color: var(--muted); font-size: 10px; }
.selection-summary strong { display: block; margin-top: 2px; font-size: 16px; }
.selection-summary .amount { margin-left: auto; text-align: right; }
.selection-summary .amount strong { color: var(--red); }
.selection-controls { gap: 8px; margin-top: 9px; }
.free-passes { display: flex; gap: 16px; margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.free-passes label { display: inline-flex; align-items: center; gap: 5px; }
.selection-dock { max-height: min(45svh, 240px); overflow-y: auto; }
.control-field { display: grid; gap: 4px; min-width: 0; color: var(--muted); font-size: 10px; }
.control-field select { min-height: 34px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px; color: var(--ink); background: #fff; font-size: 12px; }
.control-field.compact { width: 82px; }
.stepper { display: grid; grid-template-columns: 25px 1fr 25px; align-items: center; min-height: 34px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.stepper button { height: 32px; color: var(--blue); background: #f2f7fb; font-size: 18px; line-height: 1; }
.stepper output { text-align: center; font-size: 12px; }
.primary-action { min-height: 38px; border-radius: 8px; padding: 0 14px; color: #fff; background: linear-gradient(105deg, var(--blue), var(--blue-2)); font-weight: 800; box-shadow: 0 6px 14px rgba(23, 105, 170, .2); }
.primary-action:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; }
.selection-controls .primary-action { margin-left: auto; align-self: end; white-space: nowrap; }
.dock-note { min-height: 14px; margin: 6px 0 0; color: var(--red); font-size: 10px; line-height: 1.4; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: var(--nav-height); padding: 5px 0 calc(5px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: rgba(255,255,255,.98); }
.bottom-nav-item { display: grid; place-items: center; gap: 1px; color: #a3adba; background: transparent; font-size: 19px; }
.bottom-nav-item small { font-size: 10px; }
.bottom-nav-item.active { color: var(--blue); }

.agent-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 3px 0 15px; }
.agent-summary div { padding: 11px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.agent-summary span { display: block; color: var(--muted); font-size: 10px; }
.agent-summary strong { display: block; margin-top: 4px; color: var(--ink); font-size: 22px; }
.order-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.order-stat { min-width: 0; padding: 11px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.order-stat span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.order-stat strong { display: block; margin-top: 5px; overflow: hidden; color: var(--ink); font-size: 19px; text-overflow: ellipsis; white-space: nowrap; }
.order-stat-amount strong { color: var(--red); font-size: 14px; }
.order-filters { display: flex; gap: 7px; margin: 0 0 12px; overflow-x: auto; }
.order-filter { flex: 0 0 auto; min-height: 30px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; font-size: 11px; }
.order-filter.active { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.order-body { padding: 12px; }
.order-line { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.order-title { margin: 0; font-size: 14px; }
.order-amount { color: var(--red); font-size: 17px; font-weight: 800; }
.order-details { display: grid; gap: 5px; margin: 10px 0; color: var(--muted); font-size: 11px; }
.order-details strong { color: var(--ink); font-weight: 700; }
.order-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.secondary-action { min-height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: 12px; }
.secondary-action.primary { border-color: var(--blue); color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.status-tag { padding: 4px 7px; border-radius: 4px; color: #466174; background: #edf2f6; font-size: 10px; }
.status-tag.warn { color: #9a5c00; background: #fff2d8; }
.status-tag.success { color: #087354; background: #dff6ec; }
.empty-state { padding: 30px 18px; border: 1px dashed #cbd9e4; border-radius: 12px; color: var(--muted); background: rgba(255,255,255,.6); text-align: center; font-size: 13px; line-height: 1.6; }

.login-dialog { width: min(92vw, 390px); max-height: calc(100svh - 24px); overflow: auto; padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 80px rgba(15, 43, 74, .3); }
.login-dialog::backdrop { background: rgba(10, 28, 47, .45); }
.login-form { display: grid; gap: 12px; padding: 20px; }
.dialog-header { justify-content: space-between; align-items: flex-start; }
.eyebrow { display: block; color: var(--blue); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
.dialog-header h2 { margin: 3px 0 0; font-size: 20px; }
.close-button { width: 30px; height: 30px; border-radius: 50%; color: var(--muted); background: #f1f4f7; font-size: 20px; }
.login-form label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; }
.login-form input { width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; color: var(--ink); background: #fff; }
.primary-action.full { width: 100%; margin-top: 2px; }
.form-error { min-height: 16px; margin: 0; color: var(--red); font-size: 11px; }
.dialog-note { margin: 0; color: #91a0ae; font-size: 10px; line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-offset) + var(--dock-height) + 12px); z-index: 20; transform: translate(-50%, 12px); width: max-content; max-width: calc(100vw - 36px); padding: 10px 14px; border-radius: 9px; color: #fff; background: rgba(18, 43, 69, .92); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: 12px; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { display: grid; place-items: start center; padding: 28px; }
  .app-shell { width: min(100%, 760px); min-height: calc(100svh - 56px); border: 1px solid var(--line); border-radius: 22px; background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
  .app-header { padding-left: 24px; padding-right: 24px; }
  .view { padding-left: 24px; padding-right: 24px; }
  .selection-dock, .bottom-nav { left: 50%; width: min(calc(100% - 56px), 760px); transform: translateX(-50%); }
  .bottom-nav { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }

@media (max-width: 390px) {
  .fixture-body { padding: 10px; }
  .teams { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); font-size: 13px; }
  .selection-controls { gap: 6px; }
  .selection-summary { gap: 7px; }
  .selection-summary strong { font-size: 14px; }
  .control-field select { max-width: 130px; }
  .primary-action { padding: 0 9px; }
}

/* Mobile fixture list: keep each match scannable without horizontal scrolling. */
.view-heading { justify-content: space-between; align-items: center; margin: 10px 0 11px; }
.view-heading h1 { margin-top: 2px; font-size: 19px; letter-spacing: .01em; }
.fixture-total { color: var(--blue); font-size: 12px; font-weight: 800; }
.fixture-controls { padding: 0 0 7px; }
.fixture-controls label { flex: 1; min-width: 0; }
.fixture-controls label > span { color: var(--muted); font-size: 11px; }
.fixture-controls select { width: min(100%, 210px); flex: 1; max-width: none; }
.refresh-action { display: inline-flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.toolbar-row { padding: 2px 0 9px; }
.quick-filter { padding: 6px 10px; font-size: 11px; }
.fixture-card { border-radius: 10px; box-shadow: 0 3px 10px rgba(20,53,84,.045); }
.fixture-top { padding: 8px 10px; }
.fixture-meta { gap: 6px; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.fixture-meta > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.league-tag { padding: 3px 5px; font-size: 10px; }
.cutoff { flex: 0 0 auto; margin-left: 8px; font-size: 10px; }
.fixture-body { padding: 10px; }
.teams { grid-template-columns: minmax(0, 1fr) 62px minmax(0, 1fr); gap: 5px; font-size: 13px; }
.teams span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.teams span:nth-child(2) { text-align: center; font-size: 10px; line-height: 1.25; }
.market-group + .market-group { margin-top: 8px; }
.market-label { margin: 10px 0 5px; font-size: 10px; }
.market-state { min-height: 18px; padding: 0 6px; font-size: 9px; }
.option-row { gap: 5px; }
.option-button { min-height: 42px; border-radius: 7px; padding: 6px 7px; }
.option-button span { font-size: 10px; }
.option-button strong { margin-top: 1px; font-size: 14px; }
.fixture-foot { margin-top: 8px; font-size: 9px; }
.selection-dock { padding: 8px 10px; border-top-color: #c8d8e4; box-shadow: 0 -5px 16px rgba(21,60,90,.1); }
.selection-summary { gap: 8px; }
.selection-summary span { font-size: 9px; }
.selection-summary strong { font-size: 15px; }
.summary-count, .summary-bets { display: flex; align-items: baseline; gap: 3px; }
.summary-count span, .summary-bets span { white-space: nowrap; }
.selection-summary .amount { margin-left: auto; }
.clear-selection { flex: 0 0 auto; align-self: center; min-height: 28px; padding: 0 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: #fff; font-size: 10px; }
.selection-controls { display: grid; grid-template-columns: minmax(0, 1fr) 84px auto; gap: 8px; margin-top: 7px; }
.pass-control { flex: 1 1 auto; }
.multiple-control { flex: 0 0 78px; }
.control-field.compact { width: auto; }
.control-field select { width: 100%; min-width: 0; max-width: none; min-height: 44px; border-radius: 6px; font-size: 12px; }
.stepper { min-height: 44px; grid-template-columns: 28px 1fr 28px; border-radius: 6px; }
.stepper button { height: 42px; font-size: 18px; }
.primary-action { min-height: 34px; border-radius: 7px; padding: 0 12px; font-size: 12px; }
.selection-controls .primary-action { min-height: 44px; margin-left: 0; }
.dock-note { min-height: 12px; margin-top: 4px; font-size: 9px; }
.empty-state { padding: 24px 14px; border-radius: 10px; font-size: 12px; }

@media (max-width: 430px) {
  .app-header { padding: 14px 14px 12px; }
  .brand-lockup strong { font-size: 16px; }
  .view { padding: 0 10px; }
  .selection-summary .amount strong { font-size: 14px; }
  .clear-selection { padding-inline: 5px; }
  .primary-action { padding-inline: 9px; }
  .order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-stat { padding: 10px 9px; }
}

/* Keep identifiers and teams readable without pushing cards outside the screen. */
.app-header > *, .brand-lockup, .header-actions, .order-top > *, .order-line > * { min-width: 0; }
.fixture-top { gap: 4px; }
.league-tag { flex-shrink: 0; }
.teams > span:first-child, .teams > span:last-child { white-space: normal; overflow-wrap: anywhere; line-height: 1.5; }
.option-button { min-width: 0; min-height: 48px; }
.option-button span { overflow-wrap: anywhere; font-size: 11px; }
.order-top { align-items: flex-start; gap: 8px; }
.order-meta { flex: 1; flex-direction: column; align-items: flex-start; gap: 4px; overflow-wrap: anywhere; }
.status-tag { flex: 0 0 auto; white-space: nowrap; }
.order-line { flex-wrap: wrap; align-items: baseline; }
.order-title { flex: 1 1 150px; overflow-wrap: anywhere; }
.order-amount { flex: 0 0 auto; white-space: nowrap; }
.order-details { overflow-wrap: anywhere; }
.order-actions { flex-wrap: wrap; }
.order-stat-amount { grid-column: span 2; }
.login-form input { font-size: 16px; text-transform: uppercase; }
.login-form .primary-action, .close-button, .icon-button { min-height: 44px; }
.close-button, .icon-button { width: 44px; flex-shrink: 0; }
.icon-button { border-radius: 8px; font-size: 12px; }
.dock-note:empty { display: none; }

@media (max-height: 450px) {
  .login-dialog { max-height: calc(100dvh - 16px); }
  .login-form { padding: 14px; gap: 8px; }
}
