:root {
  --navy-950: #061326;
  --navy-900: #0a1b33;
  --navy-800: #102844;
  --blue: #087cf0;
  --cyan: #24b9e8;
  --teal: #12a99c;
  --amber: #f4a51c;
  --red: #da4b4b;
  --ink: #10233f;
  --muted: #667890;
  --line: #dce5ef;
  --surface: #f5f8fc;
  --card: #ffffff;
  --radius: 16px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--navy-950);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; background: var(--navy-950); }
body { margin: 0; min-height: 100vh; overflow-x: hidden; background: radial-gradient(circle at 77% 0%, #143d69 0, transparent 28rem), var(--navy-950); }
button, input, select, textarea { min-width: 0; font: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky; top: 0; z-index: 10; min-height: 72px; padding: 0 28px;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  color: white; background: rgba(6, 19, 38, .9); border-bottom: 1px solid rgba(101, 176, 242, .22);
  backdrop-filter: blur(18px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { color: #76c9ff; font-size: 25px; font-weight: 900; letter-spacing: .02em; }
.brand-name { font-size: 21px; font-weight: 800; }
.version-badge { padding: 5px 9px; border: 1px solid rgba(118, 201, 255, .3); border-radius: 999px; color: #9fd8ff; font-size: 12px; }
.main-nav { align-self: stretch; display: flex; gap: 12px; }
.nav-item { position: relative; padding: 0 20px; border: 0; background: none; color: #aabbd0; font-weight: 700; }
.nav-item::after { content: ""; position: absolute; left: 20px; right: 20px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; }
.nav-item:hover, .nav-item.active { color: white; }
.nav-item.active::after { background: #4ab6ff; }
.local-badge { justify-self: end; display: flex; align-items: center; gap: 8px; color: #adbed2; font-size: 13px; }
.local-badge b { font-weight: 600; }
.local-badge span { width: 8px; height: 8px; border-radius: 50%; background: #36d399; box-shadow: 0 0 0 5px rgba(54, 211, 153, .1); }
.local-badge.checking span { background: #f3b23c; box-shadow: 0 0 0 5px rgba(243, 178, 60, .1); }
.local-badge.offline span { background: #8394a8; box-shadow: 0 0 0 5px rgba(131, 148, 168, .1); }

.app-shell { max-width: 1720px; margin: 0 auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; }
.workspace-heading { display: flex; align-items: end; justify-content: space-between; margin: 4px 0 18px; color: white; }
.workspace-heading h1, .page-card h1 { margin: 3px 0 0; font-size: 26px; }
.eyebrow { margin: 0; color: #58baff; font-size: 11px; font-weight: 900; letter-spacing: .17em; }
.heading-note { max-width: 540px; margin: 0; color: #9fb1c8; font-size: 14px; text-align: right; }
.workspace-grid { display: grid; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr); gap: 16px; align-items: start; }
.workspace-grid > *, .form-grid > *, .odds-grid > * { min-width: 0; }

.input-panel, .result-panel { border-radius: 19px; box-shadow: 0 18px 55px rgba(0, 0, 0, .2); }
.input-panel { padding: 24px; background: #f8faff; }
.result-panel { min-width: 0; padding: 14px; background: rgba(15, 39, 68, .74); border: 1px solid rgba(109, 173, 230, .22); }
.result-empty { min-height: 560px; padding: 35px; display: grid; place-content: center; justify-items: center; border: 1px dashed rgba(137, 188, 230, .35); border-radius: 13px; color: #b3c5d7; text-align: center; }
.result-empty .empty-mark { display: grid; place-items: center; width: 58px; height: 58px; border: 1px solid rgba(104, 180, 240, .45); border-radius: 16px; color: #77c6ff; background: rgba(31, 99, 156, .2); font-size: 30px; }
.result-empty h2 { margin: 16px 0 7px; color: white; font-size: 22px; }
.result-empty p { max-width: 530px; margin: 0; color: #94aac0; font-size: 14px; line-height: 1.75; }
.form-section { padding-bottom: 21px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.section-title { display: flex; align-items: center; gap: 9px; margin-bottom: 15px; }
.section-title > span, .advanced summary b { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; color: white; background: var(--blue); font-size: 13px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title small { margin-left: auto; color: var(--muted); }
.form-grid { display: grid; gap: 13px; }
.form-grid.two { grid-template-columns: 1fr 1fr; }
label { display: grid; gap: 7px; color: #3d516c; font-size: 14px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cad8e8; border-radius: 9px; outline: none; color: #142b4a; background: white; transition: border-color .2s, box-shadow .2s; }
input, select { min-height: 43px; padding: 0 11px; }
textarea { padding: 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #3e9ef3; box-shadow: 0 0 0 3px rgba(8, 124, 240, .12); }
.odds-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid #cad8e8; border-radius: 10px; overflow: hidden; }
.odds-grid label { gap: 0; text-align: center; background: white; }
.odds-grid label + label { border-left: 1px solid #d8e1eb; }
.odds-grid span { padding: 8px 4px 3px; color: #62758c; font-size: 12px; }
.odds-grid input { border: 0; border-radius: 0; text-align: center; font-weight: 800; }
.advanced { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 11px; background: white; }
.advanced summary { min-height: 49px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; list-style: none; cursor: pointer; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary > span { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 800; }
.advanced summary small { color: #76889e; }
.advanced[open] summary { border-bottom: 1px solid var(--line); }
.advanced-body { padding: 14px; }
.field-help { margin: 10px 0 0; color: #8190a3; font-size: 12px; line-height: 1.5; }
.context-grid { display: grid; gap: 10px; }
.context-grid label { grid-template-columns: 1fr 130px; align-items: center; margin: 0; }
.context-grid select { min-height: 38px; }
.notes-label { margin-top: 5px; }
.form-actions { display: grid; grid-template-columns: 1fr 1.7fr; gap: 10px; margin-top: 18px; }
.form-actions.three { grid-template-columns: .8fr 1.15fr 1.55fr; }
.form-actions.three .button { padding-inline: 10px; font-size: 13px; white-space: nowrap; }
.button { min-height: 44px; padding: 0 16px; border: 0; border-radius: 9px; font-weight: 800; transition: transform .15s, filter .15s, background .15s; }
.button:hover { filter: brightness(1.04); }
.button:active { transform: translateY(1px); }
.button.primary { display: flex; align-items: center; justify-content: center; gap: 18px; color: white; background: linear-gradient(135deg, #087cf0, #1a90fa); box-shadow: 0 8px 18px rgba(8, 124, 240, .24); }
.button.primary i { font-size: 20px; font-style: normal; }
.button.secondary { color: #46617e; background: #e9eff7; }
.button.ghost { color: #61758d; background: transparent; border: 1px solid #d1ddea; }
.button.outline { color: #8ed2ff; background: rgba(17, 88, 145, .2); border: 1px solid #348fd3; }
.button.danger { color: #b73333; background: #ffe6e6; }

.match-banner { position: relative; min-height: 125px; padding: 24px 190px 24px 26px; display: grid; grid-template-columns: 1fr 150px 1fr; align-items: center; gap: 10px; overflow: hidden; border: 1px solid rgba(102, 179, 241, .34); border-radius: 13px; color: white; background: linear-gradient(135deg, rgba(25, 74, 120, .72), rgba(8, 27, 52, .36)); }
.match-banner::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(110deg, rgba(64, 156, 235, .08), transparent 32%); }
.match-banner > div { display: grid; gap: 6px; }
.match-banner small { color: #8ba6c4; font-size: 13px; }
.match-banner strong { overflow: hidden; font-size: clamp(18px, 2vw, 26px); text-overflow: ellipsis; white-space: nowrap; }
.match-banner .away { text-align: right; }
.versus { justify-items: center; padding: 0 16px; border-left: 1px solid rgba(155, 199, 236, .18); border-right: 1px solid rgba(155, 199, 236, .18); color: #a7b9cd; font-size: 13px; }
.versus b { color: #54b9ff; font-size: 23px; }
.versus span { color: #7f95ae; }
.match-banner .button { position: absolute; top: 18px; right: 18px; min-height: 39px; font-size: 13px; }

.metric-row { display: grid; gap: 10px; margin-top: 10px; }
.metric-row.three { grid-template-columns: 1fr 1.2fr 1fr; }
.metric-card { min-width: 0; padding: 18px; border: 1px solid #dbe5ef; border-radius: 12px; background: var(--card); box-shadow: 0 5px 15px rgba(0, 0, 0, .045); }
.card-heading { min-height: 26px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-heading h3 { margin: 0; font-size: 17px; }
.card-heading > span { color: #8090a3; font-size: 12px; }
.prob-list { display: grid; gap: 13px; margin-top: 20px; }
.prob-list > div { display: grid; grid-template-columns: 38px 1fr 54px; align-items: center; gap: 10px; font-size: 13px; }
.prob-list b { text-align: right; font-size: 15px; }
.track { height: 13px; overflow: hidden; border-radius: 999px; background: #e7edf4; }
.track i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #23a7ff); transition: width .55s ease; }
.prob-list > div:nth-child(2) .track i { background: #92a8bf; }
.prob-list > div:nth-child(3) .track i { background: var(--teal); }
.goal-chart { height: 137px; margin-top: 9px; padding-top: 9px; display: flex; align-items: end; justify-content: space-around; gap: 7px; border-bottom: 1px solid #d9e3ed; }
.goal-bar { position: relative; width: 15%; max-width: 43px; min-width: 26px; border-radius: 6px 6px 0 0; background: linear-gradient(#54cef1, #25aee3); transition: height .55s ease; }
.goal-bar b { position: absolute; left: 50%; top: -23px; transform: translateX(-50%); color: #31516f; font-size: 11px; }
.goal-bar span { position: absolute; left: 50%; bottom: -25px; transform: translateX(-50%); color: #63768d; font-size: 11px; white-space: nowrap; }
.donut-layout { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 15px; margin-top: 11px; }
.donut { width: 108px; height: 108px; display: grid; place-content: center; border-radius: 50%; text-align: center; background: conic-gradient(var(--blue) 0 45%, #dce4ed 45%); position: relative; }
.donut::after { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: white; }
.donut b, .donut span { position: relative; z-index: 1; }
.donut b { font-size: 21px; }
.donut span { color: #7a899b; font-size: 11px; }
.donut-layout dl { display: grid; gap: 7px; margin: 0; }
.donut-layout dl div { display: flex; justify-content: space-between; font-size: 12px; }
.donut-layout dt { color: #718197; }
.donut-layout dd { margin: 0; font-weight: 800; }

.decision-grid { grid-template-columns: 1.2fr 1fr 1fr; }
.market-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 14px 0 11px; padding: 4px; border-radius: 8px; background: #ecf1f7; }
.market-tabs span { padding: 8px 4px; border-radius: 6px; color: #60748b; font-size: 12px; text-align: center; }
.market-tabs span.active { color: white; background: var(--blue); box-shadow: 0 4px 8px rgba(8, 124, 240, .2); }
.selector-card p { margin: 0; color: #64768d; font-size: 13px; line-height: 1.6; }
.risk-line { display: grid; grid-template-columns: 66px 1fr; align-items: center; gap: 15px; margin-top: 16px; }
.risk-line > strong { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; color: #a35d00; background: #fff3d9; border: 6px solid #ffd886; font-size: 19px; }
.risk-line div { display: grid; gap: 4px; }
.risk-line b { font-size: 21px; }
.risk-line span { color: #6f8094; font-size: 12px; line-height: 1.45; }
.conclusion-card { display: flex; align-items: center; gap: 15px; background: linear-gradient(135deg, #f5fbff, #edf7ff); }
.conclusion-card .grade { display: grid; place-items: center; width: 66px; height: 66px; flex: 0 0 auto; border-radius: 14px; color: white; background: var(--blue); font-size: 31px; font-weight: 900; box-shadow: 0 8px 17px rgba(8, 124, 240, .23); }
.conclusion-card small { color: #708196; }
.conclusion-card h2 { margin: 3px 0; color: #0870d2; font-size: 25px; }
.conclusion-card p { margin: 0; color: #6d7d91; font-size: 12px; }
.bottom-grid { grid-template-columns: .9fr 1.5fr; }
.scores-card ol { padding: 0; margin: 14px 0 0; list-style: none; }
.scores-card li { display: grid; grid-template-columns: 24px 64px 1fr 43px; align-items: center; gap: 8px; min-height: 38px; }
.score-rank { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: white; background: #a6b6c8; font-size: 11px; }
.scores-card li:first-child .score-rank { background: var(--amber); }
.score-value { font-weight: 900; }
.score-track { height: 8px; overflow: hidden; border-radius: 9px; background: #e7edf4; }
.score-track i { display: block; height: 100%; background: var(--blue); }
.score-prob { color: #59708a; font-size: 12px; text-align: right; }
.insight-card ul { margin: 13px 0 10px; padding-left: 19px; color: #536980; font-size: 13px; line-height: 1.7; }
.insight-card li::marker { color: var(--blue); }
.protection { margin: 0; padding: 10px 12px; border-left: 3px solid var(--amber); border-radius: 4px; color: #825814; background: #fff7e7; font-size: 12px; }
.ai-card { margin-top: 10px; padding: 20px; border-color: #b9dcfa; background: linear-gradient(135deg, #f9fcff, #eef8ff); }
.ai-card .card-heading h3 { display: flex; align-items: center; gap: 9px; }
.ai-spark { display: inline-grid; place-items: center; width: 30px; height: 25px; border-radius: 7px; color: white; background: linear-gradient(135deg, #087cf0, #16b6cc); font-size: 12px; letter-spacing: .03em; }
.ai-empty { padding: 22px 2px 5px; color: #64778d; font-size: 14px; line-height: 1.65; }
.ai-loading { min-height: 100px; display: flex; align-items: center; justify-content: center; gap: 13px; color: #55708d; }
.ai-loading[hidden], .ai-result[hidden], .ai-error[hidden] { display: none; }
.ai-loading span { width: 22px; height: 22px; border: 3px solid #c9e4f9; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.ai-loading p { margin: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-result { margin-top: 16px; }
.ai-decision { display: grid; grid-template-columns: .65fr 1.35fr .7fr; overflow: hidden; border: 1px solid #cfe3f3; border-radius: 10px; background: white; }
.ai-decision > div { min-width: 0; padding: 14px 17px; display: grid; gap: 5px; }
.ai-decision > div + div { border-left: 1px solid #dce8f1; }
.ai-decision small { color: #71849a; font-size: 12px; }
.ai-decision b { color: white; width: fit-content; min-width: 34px; padding: 4px 9px; border-radius: 6px; background: var(--blue); font-size: 18px; text-align: center; }
.ai-decision strong { overflow: hidden; color: #0870d2; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.ai-summary { margin: 15px 0; color: #38536f; font-size: 14px; line-height: 1.75; }
.ai-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 12px 0 14px; }
.ai-columns h4 { margin: 0 0 7px; font-size: 13px; }
.ai-columns ul { margin: 0; padding-left: 18px; color: #5d7085; font-size: 13px; line-height: 1.65; }
.ai-columns li::marker { color: var(--blue); }
.ai-error { margin-top: 15px; padding: 13px 15px; border: 1px solid #f2c6c6; border-radius: 9px; color: #9b3030; background: #fff1f1; font-size: 13px; line-height: 1.6; }
.disclaimer { margin: 11px 4px 0; color: #8da3ba; font-size: 11px; text-align: center; }

.simple-view { max-width: 1180px; margin: 20px auto; }
.page-card { min-height: 520px; padding: 32px; border-radius: 18px; background: #f7faff; box-shadow: 0 20px 50px rgba(0, 0, 0, .22); }
.page-title-row { display: flex; justify-content: space-between; align-items: center; }
.page-intro { color: #63758a; line-height: 1.7; }
.history-content { margin-top: 25px; }
.history-empty { padding: 60px 20px; border: 1px dashed #c6d4e2; border-radius: 13px; color: #7a8ba0; text-align: center; }
.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td { padding: 13px 10px; border-bottom: 1px solid #e1e8f0; font-size: 13px; text-align: left; }
.history-table th { color: #718197; font-weight: 600; }
.history-table td { color: #1c3554; }
.record-grade { display: inline-grid; place-items: center; min-width: 31px; height: 27px; padding: 0 7px; border-radius: 7px; color: white; background: var(--blue); font-weight: 900; }
.model-page { max-width: 1000px; margin: auto; }
.model-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 28px 0; }
.model-grid article { padding: 21px; border: 1px solid #dae5ef; border-radius: 12px; background: white; }
.model-grid article span { color: #61baff; font-size: 12px; font-weight: 900; letter-spacing: .1em; }
.model-grid h2 { margin: 9px 0 6px; font-size: 17px; }
.model-grid p { margin: 0; color: #68798e; font-size: 13px; line-height: 1.6; }
.boundary-note { padding: 17px 20px; border-radius: 10px; color: #77531c; background: #fff5df; }
.boundary-note p { margin: 5px 0 0; line-height: 1.65; }
.toast { position: fixed; left: 50%; bottom: 26px; z-index: 30; padding: 12px 18px; border-radius: 9px; color: white; background: #102d4d; box-shadow: 0 10px 35px rgba(0, 0, 0, .24); opacity: 0; pointer-events: none; transform: translate(-50%, 12px); transition: .25s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1250px) {
  .topbar { grid-template-columns: 1fr auto; }
  .main-nav { order: 3; grid-column: 1 / -1; min-height: 46px; justify-content: center; }
  .topbar { padding-top: 12px; }
  .nav-item { min-height: 46px; }
  .workspace-grid { grid-template-columns: 350px minmax(0, 1fr); }
  .metric-row.three { grid-template-columns: 1fr 1fr; }
  .metric-row.three .metric-card:last-child { grid-column: 1 / -1; }
  .decision-grid { grid-template-columns: 1fr 1fr; }
  .decision-grid .conclusion-card { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .app-shell { padding: 15px; }
  .workspace-heading { align-items: start; gap: 8px; flex-direction: column; }
  .heading-note { text-align: left; }
  .workspace-grid { grid-template-columns: 1fr; }
  .input-panel { padding: 18px; }
  .match-banner { padding: 70px 15px 20px; grid-template-columns: 1fr 70px 1fr; }
  .match-banner .button { left: 15px; right: 15px; top: 14px; width: calc(100% - 30px); }
  .bottom-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { position: static; display: flex; flex-wrap: wrap; padding: 13px 15px 0; }
  .brand { width: 100%; }
  .version-badge, .local-badge { display: none; }
  .main-nav { width: 100%; overflow-x: auto; justify-content: flex-start; }
  .nav-item { padding: 0 14px; white-space: nowrap; }
  .workspace-heading h1 { font-size: 22px; }
  .workspace-heading, .heading-note { width: 100%; max-width: 100%; }
  .form-grid.two, .metric-row.three, .decision-grid, .model-grid { grid-template-columns: 1fr; }
  .form-actions.three { grid-template-columns: 1fr 1fr; }
  .form-actions.three .button.primary { grid-column: 1 / -1; grid-row: 1; }
  .metric-row.three .metric-card:last-child, .decision-grid .conclusion-card { grid-column: auto; }
  .match-banner { grid-template-columns: 1fr 55px 1fr; }
  .match-banner strong { font-size: 16px; }
  .match-banner time, .match-banner .versus span { display: none; }
  .metric-card { padding: 15px; }
  .odds-grid input { padding-inline: 4px; }
  .market-tabs { grid-template-columns: 1fr 1fr; }
  .ai-decision, .ai-columns { grid-template-columns: 1fr; }
  .ai-decision > div + div { border-left: 0; border-top: 1px solid #dce8f1; }
  .page-card { min-height: 400px; padding: 20px; }
  .history-content { overflow-x: auto; }
  .history-table { min-width: 650px; }
}
