:root {
  --navy: #102a43;
  --ink: #183247;
  --muted: #718497;
  --line: #dce5ec;
  --soft: #f4f7f9;
  --blue: #1976d2;
  --blue-dark: #0f5fae;
  --green: #19a974;
  --amber: #e99b24;
  --red: #e05252;
  --shadow: 0 14px 40px rgba(30, 58, 79, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.reserved-slot-hidden { visibility: hidden; pointer-events: none; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 90% 3%, rgba(35, 141, 179, .10), transparent 25%), #eef3f6; font-family: "Noto Sans SC", sans-serif; font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(28px, calc((100vw - 1440px) / 2)); color: white; background: linear-gradient(100deg, #102e47 0%, #153e5a 70%, #126778 100%); box-shadow: 0 5px 18px rgba(10, 37, 56, .18); }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 37px; height: 37px; border: 1px solid rgba(255,255,255,.45); display: grid; place-items: center; transform: rotate(45deg); }
.brand-mark svg { width: 22px; transform: rotate(-45deg); fill: none; stroke: #61d5be; stroke-width: 2.3; }
.brand div { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; letter-spacing: 2px; }
.brand span { font: 500 8px/1.5 "Roboto Mono", monospace; color: #9db8c8; letter-spacing: 1.2px; }
.topbar-meta { font-size: 12px; color: #c2d6df; display: flex; align-items: center; gap: 8px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ee0a8; box-shadow: 0 0 0 5px rgba(78,224,168,.12); }
.status-dot.connecting { background: #f0bd55; box-shadow: 0 0 0 5px rgba(240,189,85,.14); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.connected { background: #4ee0a8; }
.status-dot.disconnected { background: #ff7070; box-shadow: 0 0 0 5px rgba(255,112,112,.14); }
.topbar-meta strong { font-weight: 500; }
.page-shell { width: min(920px, calc(50vw - 24px)); margin: 0 auto 60px; }
.breadcrumb { height: 52px; display: flex; align-items: center; gap: 10px; color: #7b8c9b; font-size: 12px; }
.breadcrumb span { color: #b5c1c9; }
.panel { background: rgba(255,255,255,.98); border: 1px solid rgba(213,224,232,.9); box-shadow: var(--shadow); }
.form-panel { border-top: 3px solid var(--green); }
.section-heading { padding: 24px 30px 20px; display: flex; align-items: flex-end; justify-content: space-between; border-bottom: 1px solid var(--line); }
.eyebrow { font: 600 10px "Roboto Mono", monospace; color: var(--green); letter-spacing: 1.8px; }
.section-heading h1, .result-topline h2 { margin: 4px 0 0; color: var(--navy); font-size: 22px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.form-section { padding: 22px 30px 25px; border-bottom: 1px solid #e8eef2; }
.form-section h2 { margin: 0 0 18px; font-size: 15px; color: var(--navy); display: flex; align-items: center; gap: 9px; }
.form-section h2 span { font: 600 10px "Roboto Mono", monospace; color: var(--green); padding: 3px 5px; border: 1px solid #8ad3bb; }
.form-grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4, .primary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-row { margin-top: 18px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field > span { color: #536a7d; font-size: 12px; font-weight: 500; }
.field i { font-style: normal; color: var(--red); margin-right: 4px; }
input, select { height: 40px; width: 100%; border: 1px solid #cbd8e1; border-radius: 3px; outline: none; color: var(--ink); background: #fff; padding: 0 12px; transition: border .2s, box-shadow .2s; }
input:focus, select:focus { border-color: #4b9bd8; box-shadow: 0 0 0 3px rgba(25,118,210,.09); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #718497 50%), linear-gradient(135deg, #718497 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.input-unit { display: flex; position: relative; }
.input-unit input { padding-right: 42px; }
.input-unit b { position: absolute; right: 12px; top: 11px; color: #8a9aaa; font-size: 12px; font-weight: 400; }
.age-control { display: flex; gap: 10px; }
.segmented { height: 40px; flex: 0 0 165px; display: flex; border: 1px solid #cbd8e1; border-radius: 3px; overflow: hidden; }
.segmented label { flex: 1; cursor: pointer; }
.segmented input { display: none; }
.segmented span { height: 100%; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.segmented input:checked + span { background: #e8f3fb; color: var(--blue-dark); font-weight: 600; box-shadow: inset 0 -2px var(--blue); }
.age-control .input-unit { flex: 1; }
.clinical-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 34px; }
.entry-column:first-child { padding-right: 34px; border-right: 1px dashed #ccd9e1; }
.column-title { display: flex; align-items: center; gap: 10px; margin-bottom: 13px; }
.column-title > div { display: flex; flex-direction: column; }
.column-title strong { font-size: 13px; }
.column-title small { color: #9aaab6; font: 500 9px "Roboto Mono"; text-transform: uppercase; letter-spacing: .8px; }
.column-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 3px; font-size: 12px; font-weight: 700; }
.diagnosis-icon { color: #1471bd; background: #e4f2fc; }
.surgery-icon { color: #138965; background: #e3f6f0; }
.entry-list { display: flex; flex-direction: column; gap: 10px; }
.entry-row { display: grid; grid-template-columns: 82px 1fr 76px; gap: 8px; align-items: center; }
.entry-row.primary-entry { grid-template-columns: 82px 1fr; }
.entry-row label { color: #64798a; font-size: 12px; text-align: right; padding-right: 5px; }
.entry-row label i { color: var(--red); font-style: normal; margin-right: 3px; }
.autocomplete { position: relative; min-width: 0; }
.autocomplete::after { content: ""; position: absolute; right: 14px; top: 15px; width: 7px; height: 7px; border-right: 1px solid #648197; border-bottom: 1px solid #648197; transform: rotate(45deg); pointer-events: none; }
.autocomplete input { width: 100%; padding-right: 34px; }
.autocomplete input[aria-expanded="true"] { border-color: #2b91c8; box-shadow: 0 0 0 2px rgba(43,145,200,.1); }
.candidate-dropdown { position: absolute; z-index: 30; top: calc(100% + 5px); left: 0; right: 0; max-height: 230px; overflow-y: auto; padding: 5px; border: 1px solid #b9ceda; border-radius: 4px; background: white; box-shadow: 0 12px 28px rgba(30,64,84,.18); }
.candidate-option { width: 100%; display: grid; grid-template-columns: minmax(88px, auto) 1fr; gap: 10px; padding: 9px 10px; border: 0; border-radius: 3px; color: #304d60; background: transparent; text-align: left; }
.candidate-option:hover, .candidate-option.active { background: #eaf5fb; }
.candidate-option strong { color: #0878b6; font: 600 11px "Roboto Mono", monospace; }
.candidate-option span { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.candidate-state { padding: 12px 10px; color: #8295a3; font-size: 11px; text-align: center; }
.icon-button { width: 40px; height: 40px; border: 1px solid #bcd0dc; color: var(--blue); background: #f8fbfd; border-radius: 3px; font-size: 20px; line-height: 1; }
.icon-button:hover, .text-button:hover { background: #eaf5fb; }
.entry-actions { display: grid; grid-template-columns: repeat(2, 36px); gap: 4px; }
.entry-actions .icon-button { width: 36px; height: 40px; font-size: 18px; }
.entry-actions .icon-button:disabled { color: #bdc8cf; background: #f5f7f8; border-color: #e0e6ea; cursor: not-allowed; }
.remove-entry { color: #9a6c6c; border-color: #decaca; }
.remove-entry:hover { color: #cf4747; background: #fff1f1; border-color: #e5aaaa; }
.form-actions { min-height: 78px; display: flex; justify-content: space-between; align-items: center; padding: 16px 30px; background: #fbfcfd; }
.privacy-note { color: #9aabb8; font-size: 11px; }
.privacy-note::before { content: "◇"; color: var(--green); margin-right: 6px; }
.form-actions > div { display: flex; gap: 10px; }
.button { height: 42px; padding: 0 25px; border-radius: 3px; font-weight: 600; border: 1px solid transparent; }
.button.secondary { background: white; color: #607487; border-color: #c8d4dc; }
.button.primary { min-width: 155px; color: white; background: linear-gradient(100deg, #1577cf, #0b91b4); box-shadow: 0 7px 14px rgba(21,119,207,.2); display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
.button.primary svg { width: 16px; fill: none; stroke: white; stroke-width: 2; }
.button.primary.loading span { opacity: .7; }
.button.primary.loading svg { animation: spin 1s linear infinite; }
.button:disabled { cursor: not-allowed; opacity: .72; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .45; } }
.result-panel { margin-top: 22px; overflow: hidden; transition: opacity .3s, transform .3s; }
.result-panel.refreshing { opacity: .55; transform: translateY(4px); }
.result-topline { padding: 20px 30px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.api-error { margin: 16px 30px 0; padding: 11px 14px; border-left: 3px solid var(--red); color: #a43a3a; background: #fff0f0; font-size: 12px; line-height: 1.6; }
.result-time { color: #93a2ae; font-size: 11px; }
.group-hero { display: grid; grid-template-columns: 145px 1fr 300px; align-items: center; min-height: 112px; padding: 20px 30px; background: linear-gradient(105deg, #f6fafc 0%, #eef8f7 100%); border-bottom: 1px solid #dbe7ea; }
.group-code { height: 68px; padding-right: 25px; border-right: 1px solid #cedde3; display: flex; flex-direction: column; justify-content: center; }
.group-code span { color: #718695; font-size: 11px; }
.group-code strong { color: var(--navy); font: 600 32px "Roboto Mono", monospace; letter-spacing: 2px; }
.group-info { padding: 0 28px; }
.group-info h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; color: #213d51; }
.tags { display: flex; gap: 8px; }
.tag { padding: 3px 9px; border-radius: 2px; font-size: 11px; font-weight: 500; }
.tag.blue { color: #146db0; background: #deeffb; }
.tag.amber { color: #a86408; background: #fff0d5; }
.tag.green { color: #13845e; background: #def4eb; }
.tag.red { color: #b83e3e; background: #fbe3e3; }
.match-rule { border-left: 3px solid #46b698; padding-left: 14px; }
.match-rule span { color: #8a9aa6; font-size: 10px; }
.match-rule p { margin: 5px 0 0; color: #496174; font-size: 12px; line-height: 1.65; }
.finance-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: 26px 30px; border: 1px solid var(--line); }
.finance-item { min-height: 105px; display: flex; flex-direction: column; justify-content: center; padding: 18px 28px; position: relative; }
.finance-item + .finance-item { border-left: 1px solid var(--line); }
.finance-item > span { color: #768a99; font-size: 12px; margin-bottom: 5px; }
.finance-item strong { color: var(--navy); font-weight: 400; }
.finance-item strong b { font: 600 25px "Roboto Mono", monospace; }
.finance-item strong small { font-size: 12px; margin-left: 5px; color: #6f8494; }
.finance-item strong em { font-style: normal; font: 500 22px "Roboto Mono"; }
.finance-item.profit { background: linear-gradient(100deg, #f2f9fd, #f0faf7); }
.finance-item.profit strong { color: #087db2; }
.finance-item.profit > i { position: absolute; right: 20px; top: 18px; font-style: normal; font-size: 10px; padding: 3px 8px; color: #15845f; background: #dff4ec; }
.finance-item.loss strong { color: #d44f4f; }
.finance-item.loss > i { color: #bb3c3c; background: #fbe4e4; }
.detail-block { margin: 0 30px 28px; }
.block-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.block-title h3 { font-size: 14px; margin: 0; color: var(--navy); }
.block-title span { color: #9aa9b5; font: 500 10px "Roboto Mono"; letter-spacing: .5px; }
.block-title span b { color: var(--blue); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.metric-group { min-width: 0; padding: 5px 16px; background: linear-gradient(145deg, #fff, #f7fafc); border: 1px solid #dbe5eb; border-top: 3px solid #4d9ac0; border-radius: 5px; box-shadow: 0 7px 20px rgba(36, 74, 98, .07); }
.metric-group:nth-child(2) { border-top-color: #38a987; }
.metric-group:nth-child(3) { border-top-color: #df9f3c; }
.metric-group:nth-child(4) { border-top-color: #2879b6; }
.metric { min-height: 67px; padding: 11px 2px; display: flex; flex-direction: column; justify-content: center; }
.metric + .metric { border-top: 1px dashed #d8e2e8; }
.metric span { color: #7d8f9c; font-size: 11px; }
.metric strong { color: #28475c; margin-top: 5px; font: 600 14px "Roboto Mono", monospace; }
.metric.highlight { margin: 0 -16px -5px; padding-left: 18px; padding-right: 18px; background: rgba(226, 241, 249, .58); }
.metric.highlight strong { color: #087db2; }
.chart-scale { padding: 68px 6px 75px; position: relative; margin: 0 8px; }
.ratio-bar { height: 14px; display: grid; grid-template-columns: 20% 30% 30% 20%; overflow: hidden; }
.ratio-bar span { border-right: 2px solid white; }
.ratio-bar .low { background: #efbd4c; }
.ratio-bar .normal-profit { background: #65badd; }
.ratio-bar .normal-loss { background: #237db7; }
.ratio-bar .high { background: #df6464; border: 0; }
.bar-labels { display: grid; grid-template-columns: 20% 30% 30% 20%; text-align: center; margin-top: 9px; }
.bar-labels span { display: flex; flex-direction: column; }
.bar-labels b { font-size: 10px; color: #5d7383; }
.bar-labels small { font-size: 9px; color: #a0adb6; }
.thresholds span { position: absolute; top: 62px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; white-space: nowrap; }
.thresholds i { width: 1px; height: 38px; background: #8395a3; }
.thresholds b { font-size: 10px; font-weight: 500; color: #6d7f8c; margin-top: 5px; }
.thresholds small { font: 500 10px "Roboto Mono"; color: #98a6af; }
.current-marker { position: absolute; top: 16px; left: 32.8%; height: 66px; width: 2px; background: var(--navy); z-index: 2; transition: left .5s ease; }
.current-marker::after { content: ""; position: absolute; bottom: -4px; left: -3px; width: 8px; height: 8px; background: var(--navy); transform: rotate(45deg); }
.current-marker div { position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%); background: var(--navy); color: white; padding: 6px 10px; text-align: center; white-space: nowrap; box-shadow: 0 5px 12px rgba(16,42,67,.2); }
.current-marker strong { font: 600 12px "Roboto Mono"; }
.current-marker span { display: block; color: #b9d0df; font-size: 9px; }
.toast { position: fixed; right: 28px; bottom: 28px; padding: 13px 18px; background: #153d52; color: white; box-shadow: 0 10px 30px rgba(15,42,60,.25); display: flex; gap: 11px; align-items: center; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .3s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #682f35; }
.toast.error > span { color: #682f35; background: #ffb7b7; }
.toast > span { width: 25px; height: 25px; display: grid; place-items: center; color: #153d52; background: #5ed2a9; border-radius: 50%; }
.toast div { display: flex; flex-direction: column; }
.toast strong { font-size: 12px; }
.toast small { color: #b7cad5; font-size: 10px; }

@media (min-width: 1201px) {
  .group-hero { grid-template-columns: 120px 1fr; }
  .group-info { padding-right: 0; }
  .match-rule { grid-column: 1 / -1; margin-top: 16px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1200px) {
  .page-shell { width: calc(100% - 32px); }
  .group-hero { grid-template-columns: 120px 1fr; }
  .match-rule { grid-column: 1 / -1; margin-top: 16px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .topbar { height: 60px; padding: 0 18px; }
  .topbar-meta { display: none; }
  .page-shell { width: calc(100% - 24px); }
  .section-heading { align-items: flex-start; padding: 20px; }
  .section-heading p, .privacy-note { display: none; }
  .form-section { padding: 20px; }
  .grid-3, .grid-4, .clinical-grid { grid-template-columns: 1fr; }
  .clinical-grid { gap: 24px; }
  .entry-column:first-child { padding: 0 0 24px; border-right: 0; border-bottom: 1px dashed #ccd9e1; }
  .form-actions { padding: 14px 20px; justify-content: flex-end; }
  .result-topline, .group-hero { padding-left: 20px; padding-right: 20px; }
  .group-hero { grid-template-columns: 1fr; }
  .group-code { border: 0; border-bottom: 1px solid #cedde3; height: auto; padding: 0 0 13px; }
  .group-code strong { font-size: 25px; }
  .group-info { padding: 15px 0 0; }
  .finance-summary { grid-template-columns: 1fr; margin: 20px; }
  .finance-item + .finance-item { border-left: 0; border-top: 1px solid var(--line); }
  .detail-block { margin-left: 20px; margin-right: 20px; }
  .metric-grid { grid-template-columns: 1fr; }
  .chart-scale { min-width: 620px; }
  .multiplier-block { overflow-x: auto; padding-bottom: 8px; }
}
@media (max-width: 440px) {
  .brand strong { font-size: 15px; }
  .section-heading h1 { font-size: 19px; }
  .entry-row { grid-template-columns: 68px 1fr 76px; }
  .age-control { flex-direction: column; }
  .segmented { flex-basis: 40px; }
  .button { padding: 0 18px; }
  .button.primary { min-width: 140px; }
  .metric-grid { grid-template-columns: 1fr; }
}
