@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@500;600;700&family=Noto+Sans+SC:wght@400;500;600;700;800&display=swap');

:root{
  --paper:#f4f7f5;
  --surface:#ffffff;
  --ink:#14221d;
  --muted:#63736c;
  --line:#d8e1dd;
  --green:#087a52;
  --green-deep:#075b40;
  --green-soft:#dff2e9;
  --coral:#d85d4b;
  --yellow:#f3bd35;
  --blue:#397d91;
  --shadow:0 12px 32px rgba(14,38,28,.16);
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
}

*{box-sizing:border-box}
html,body,#app{width:100%;height:100%;margin:0;overflow:hidden}
body{font-family:"Noto Sans SC",sans-serif;color:var(--ink);background:var(--paper);letter-spacing:0}
button,input,textarea,select{font:inherit;letter-spacing:0}
button{color:inherit}
#map{position:absolute;inset:0;background:#eaf0ed}
.maplibregl-ctrl-bottom-left,.maplibregl-ctrl-bottom-right,.maplibregl-ctrl-top-left,.maplibregl-ctrl-top-right{display:none!important}

.topbar{position:absolute;z-index:5;top:calc(10px + var(--safe-top));left:10px;right:10px;display:grid;grid-template-columns:1fr auto;gap:8px;pointer-events:none}
.brand-block,.top-actions,.search-box{pointer-events:auto}
.brand-block{display:flex;align-items:center;gap:9px;min-width:0;width:max-content;max-width:calc(100vw - 130px);height:48px;padding:6px 10px 6px 7px;background:rgba(255,255,255,.95);border:1px solid rgba(8,77,53,.12);box-shadow:0 5px 18px rgba(18,45,34,.12);border-radius:8px;backdrop-filter:blur(12px)}
.brand-mark{display:grid;place-items:center;width:34px;height:34px;flex:none;background:var(--green);color:white;border-radius:7px;font-size:18px;font-weight:800}
.brand-block h1{margin:0;font-size:15px;line-height:1.2;font-weight:800;white-space:nowrap}
.brand-block p{margin:1px 0 0;color:var(--muted);font-size:11px;line-height:1.2;white-space:nowrap}
.top-actions{display:flex;gap:6px}
.icon-button{display:grid;place-items:center;width:42px;height:42px;padding:0;border:1px solid var(--line);border-radius:7px;background:rgba(255,255,255,.96);box-shadow:0 5px 18px rgba(18,45,34,.10);cursor:pointer}
.icon-button svg{width:19px;height:19px;stroke-width:2.1}
.top-actions .icon-button{height:48px;width:40px}
.search-box{grid-column:1/-1;display:flex;align-items:center;gap:8px;height:42px;padding:0 8px 0 12px;border:1px solid rgba(8,77,53,.16);border-radius:8px;background:rgba(255,255,255,.96);box-shadow:0 5px 18px rgba(18,45,34,.10);backdrop-filter:blur(12px)}
.search-box>svg{width:18px;color:var(--green)}
.search-box input{min-width:0;flex:1;border:0;outline:0;background:transparent;color:var(--ink);font-size:14px}
.search-box input::placeholder{color:#87958f}
.search-box button{display:none;place-items:center;width:28px;height:28px;padding:0;border:0;background:transparent;color:var(--muted)}
.search-box button.visible{display:grid}
.search-box button svg{width:16px}

.map-key{position:absolute;z-index:8;top:calc(114px + var(--safe-top));right:10px;display:none;width:210px;padding:16px;background:rgba(255,255,255,.98);border:1px solid var(--line);border-radius:8px;box-shadow:var(--shadow)}
.map-key.open{display:block;animation:panel-in .18s ease-out}
.map-key h2{margin:0 0 12px;font-size:16px}
.map-key label{display:flex;align-items:center;gap:8px;min-height:34px;font-size:13px;cursor:pointer}
.map-key input{accent-color:var(--green)}
.map-key p{margin:9px 0 0;padding-top:9px;border-top:1px solid var(--line);font-size:11px;color:var(--muted)}
.key-close{position:absolute;right:7px;top:7px;display:grid;place-items:center;width:28px;height:28px;padding:0;border:0;background:transparent}
.key-close svg{width:16px}
.swatch{width:20px;height:12px;border-radius:2px;border:2px solid}
.swatch.opportunity{background:rgba(8,122,82,.22);border-color:var(--green)}
.swatch.trade{background:rgba(57,125,145,.08);border-color:var(--blue)}
.swatch.kaixin{width:12px;height:12px;border-radius:3px;background:var(--green);border-color:white;box-shadow:0 0 0 1px var(--green)}
.swatch.yifeng{width:12px;height:12px;border-radius:50%;background:var(--coral);border-color:white;box-shadow:0 0 0 1px var(--coral)}
.swatch.context{width:10px;height:10px;border-radius:50%;background:var(--yellow);border-color:white;box-shadow:0 0 0 1px var(--yellow)}

.sheet{position:absolute;z-index:6;left:0;right:0;bottom:0;height:41vh;min-height:286px;max-height:calc(100% - 116px - var(--safe-top));display:flex;flex-direction:column;background:var(--surface);border-top:1px solid var(--line);border-radius:8px 8px 0 0;box-shadow:0 -8px 28px rgba(14,38,28,.14);transition:height .24s ease;will-change:height}
.sheet[data-state="low"]{height:25vh;min-height:210px}
.sheet[data-state="high"]{height:calc(100% - 116px - var(--safe-top))}
.drag-zone{width:100%;height:25px;flex:none;display:grid;place-items:center;padding:0;border:0;background:transparent;touch-action:none;cursor:ns-resize}
.drag-zone span{display:block;width:42px;height:4px;background:#b6c1bc;border-radius:4px}
.sheet-overview{padding:0 14px 10px;flex:none}
.summary-line{display:flex;align-items:end;justify-content:space-between;gap:12px}
.summary-line h2{margin:2px 0 0;font-size:21px;line-height:1.2}
.summary-line h2 b{font-family:"IBM Plex Sans",sans-serif;font-size:27px;color:var(--green)}
.eyebrow{color:var(--green);font-size:11px;font-weight:700}
.summary-actions{display:flex;align-items:center;gap:6px;flex:none}
.method-pill{display:flex;align-items:center;height:29px;padding:0 8px;border-radius:6px;background:#fff4d8;color:#806015;font-size:11px;font-weight:700;white-space:nowrap}
.team-access{height:29px;display:flex;align-items:center;gap:5px;padding:0 8px;border:1px solid #b8d5c8;border-radius:6px;background:#f2f8f5;color:var(--green-deep);font-size:11px;font-weight:700;white-space:nowrap;cursor:pointer}
.team-access svg{width:14px}
.team-access.unlocked{border-color:var(--green);background:var(--green-soft)}
.filters{display:flex;gap:7px;margin-top:10px;overflow-x:auto;scrollbar-width:none;padding-bottom:1px}
.filters::-webkit-scrollbar{display:none}
.filter{display:flex;align-items:center;gap:4px;height:32px;flex:none;padding:0 11px;border:1px solid var(--line);border-radius:7px;background:white;color:#53635c;font-size:12px;font-weight:600;cursor:pointer}
.filter svg{width:14px}
.filter.active{border-color:var(--green);background:var(--green);color:white}
.candidate-list{flex:1;min-height:0;overflow:auto;overscroll-behavior:contain;border-top:1px solid #edf1ef;padding:3px 12px 14px}
.candidate-card{width:100%;display:grid;grid-template-columns:47px minmax(0,1fr) 24px;gap:10px;align-items:center;padding:13px 2px;border:0;border-bottom:1px solid #edf1ef;background:white;text-align:left;cursor:pointer}
.candidate-card:last-child{border-bottom:0}
.score-ring{display:grid;place-items:center;width:44px;height:44px;border-radius:50%;background:conic-gradient(var(--green) calc(var(--score)*1%),#e4ebe7 0);position:relative}
.score-ring:after{content:"";position:absolute;inset:4px;border-radius:50%;background:white}
.score-ring b{position:relative;z-index:1;font-family:"IBM Plex Sans",sans-serif;font-size:15px}
.candidate-copy{min-width:0}
.candidate-meta{display:flex;align-items:center;gap:6px;color:var(--muted);font-size:10px;font-weight:600}
.candidate-meta span{padding:2px 5px;border-radius:4px;background:var(--green-soft);color:var(--green-deep)}
.candidate-meta span.caution{background:#fff0ed;color:#a54134}
.candidate-copy h3{margin:3px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px;line-height:1.35}
.candidate-copy p{margin:3px 0 0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted);font-size:11px}
.candidate-card>svg{width:18px;color:#87958f}
.empty{display:grid;place-items:center;min-height:160px;color:var(--muted);font-size:13px;text-align:center}
.sheet-footer{flex:none;padding:8px 14px calc(8px + var(--safe-bottom));border-top:1px solid #edf1ef;color:#7b8983;background:#f8faf9;font-size:10px;text-align:center}

.detail{position:absolute;z-index:9;left:0;right:0;bottom:0;height:min(88vh,820px);display:flex;flex-direction:column;background:white;border-radius:8px 8px 0 0;box-shadow:0 -12px 36px rgba(14,38,28,.22);transform:translateY(105%);transition:transform .26s ease;visibility:hidden}
.detail.open{transform:translateY(0);visibility:visible}
.detail-head{height:54px;flex:none;display:grid;grid-template-columns:44px 1fr 44px;align-items:center;padding:5px 10px;border-bottom:1px solid var(--line)}
.detail-head .icon-button{width:38px;height:38px;box-shadow:none}
.detail-head>span{text-align:center;font-family:"IBM Plex Sans",sans-serif;font-size:12px;color:var(--muted);font-weight:700}
.detail-scroll{flex:1;overflow:auto;padding:20px 17px calc(24px + var(--safe-bottom))}
.detail-title-row{display:flex;align-items:start;justify-content:space-between;gap:14px}
.detail-title-row h2{margin:0;font-size:22px;line-height:1.3}
.hero-score{flex:none;text-align:center;color:var(--green)}
.hero-score b{display:block;font-family:"IBM Plex Sans",sans-serif;font-size:35px;line-height:1}
.hero-score span{font-size:10px;color:var(--muted)}
.detail-tags{display:flex;flex-wrap:wrap;gap:6px;margin-top:9px}
.detail-tag{padding:5px 7px;border-radius:5px;background:var(--green-soft);color:var(--green-deep);font-size:11px;font-weight:700}
.detail-tag.warn{background:#fff0ed;color:#a54134}
.detail-tag.neutral{background:#edf2f5;color:#446674}
.detail-section{margin-top:22px;padding-top:18px;border-top:1px solid var(--line)}
.detail-section h3{display:flex;align-items:center;gap:7px;margin:0 0 11px;font-size:15px}
.detail-section h3 svg{width:18px;color:var(--green)}
.evidence-list,.risk-list{display:grid;gap:8px}
.evidence-item,.risk-item{display:flex;gap:9px;align-items:flex-start;padding:10px 11px;border-radius:7px;background:#f1f7f4;font-size:13px;line-height:1.5}
.risk-item{background:#fff5f2}
.evidence-item svg,.risk-item svg{width:16px;flex:none;margin-top:2px;color:var(--green)}
.risk-item svg{color:var(--coral)}
.score-bars{display:grid;gap:10px}
.score-bar{display:grid;grid-template-columns:88px 1fr 38px;gap:8px;align-items:center;font-size:12px}
.bar-track{height:7px;border-radius:4px;background:#e5ece8;overflow:hidden}
.bar-track span{display:block;height:100%;background:var(--green);border-radius:4px}
.score-bar b{text-align:right;font-family:"IBM Plex Sans",sans-serif}
.metric-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:1px;background:var(--line);border:1px solid var(--line);border-radius:7px;overflow:hidden}
.metric{min-width:0;padding:10px 7px;background:white;text-align:center}
.metric b{display:block;font-family:"IBM Plex Sans",sans-serif;font-size:17px;color:var(--green-deep)}
.metric span{display:block;margin-top:2px;color:var(--muted);font-size:10px;white-space:nowrap}
.primary-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:18px}
.command{height:45px;display:flex;align-items:center;justify-content:center;gap:7px;border:1px solid var(--green);border-radius:7px;background:white;color:var(--green);font-weight:700;font-size:13px;text-decoration:none;cursor:pointer}
.command.primary{background:var(--green);color:white}
.command svg{width:18px}
.survey-status{padding:11px;border-radius:7px;background:#f4f7f5;color:var(--muted);font-size:12px}
.survey-status strong{color:var(--ink)}
.storage-note{margin:8px 0 0;color:#53635c;font-size:11px;line-height:1.55}
.survey-form{display:grid;gap:12px;margin-top:12px}
.survey-form label{display:grid;gap:5px;color:var(--muted);font-size:11px;font-weight:600}
.survey-form input,.survey-form textarea,.survey-form select{width:100%;min-height:40px;padding:9px 10px;border:1px solid #cbd6d1;border-radius:6px;background:white;color:var(--ink);outline:none;font-size:13px}
.survey-form textarea{min-height:82px;resize:vertical}
.survey-form input:focus,.survey-form textarea:focus,.survey-form select:focus{border-color:var(--green);box-shadow:0 0 0 3px rgba(8,122,82,.10)}
.form-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}
.fineprint{margin:12px 0 0;color:#7b8983;font-size:10px;line-height:1.6}

.toast{position:absolute;z-index:20;left:50%;bottom:calc(26px + var(--safe-bottom));max-width:calc(100vw - 32px);padding:10px 14px;border-radius:7px;background:#15352a;color:white;box-shadow:var(--shadow);font-size:12px;transform:translate(-50%,25px);opacity:0;visibility:hidden;transition:.2s}
.toast.show{transform:translate(-50%,0);opacity:1;visibility:visible}
.access-dialog{width:min(420px,calc(100vw - 28px));padding:0;border:1px solid var(--line);border-radius:8px;background:white;color:var(--ink);box-shadow:0 18px 54px rgba(14,38,28,.28)}
.access-dialog::backdrop{background:rgba(14,32,25,.42);backdrop-filter:blur(3px)}
.access-form{position:relative;display:grid;gap:12px;padding:24px}
.access-form h2{margin:0;text-align:center;font-size:20px}
.access-form>p{margin:0;color:var(--muted);font-size:13px;line-height:1.6;text-align:center}
.access-form label{display:grid;gap:6px;color:var(--muted);font-size:12px;font-weight:600}
.access-form input{width:100%;height:44px;padding:9px 11px;border:1px solid #cbd6d1;border-radius:6px;background:white;color:var(--ink);outline:none;font-size:14px}
.access-form input:focus{border-color:var(--green);box-shadow:0 0 0 3px rgba(8,122,82,.10)}
.access-icon{display:grid;place-items:center;width:44px;height:44px;margin:0 auto;border-radius:8px;background:var(--green-soft);color:var(--green)}
.access-icon svg{width:23px}
.access-close{position:absolute;top:8px;right:8px;display:grid;place-items:center;width:34px;height:34px;padding:0;border:0;background:transparent;color:var(--muted);cursor:pointer}
.access-close svg{width:18px}
.access-form .access-error{display:none;padding:8px 10px;border-radius:6px;background:#fff0ed;color:#a54134;text-align:left;font-size:12px}
.access-form .access-error.visible{display:block}
.loading{position:absolute;z-index:30;inset:0;display:grid;place-content:center;justify-items:center;gap:10px;background:var(--paper);transition:opacity .3s,visibility .3s}
.loading.hidden{opacity:0;visibility:hidden}
.loading span{width:34px;height:34px;border:3px solid #cbdcd4;border-top-color:var(--green);border-radius:50%;animation:spin .8s linear infinite}
.loading p{margin:0;color:var(--muted);font-size:13px}
.candidate-marker{display:grid;place-items:center;width:32px;height:32px;border:3px solid white;border-radius:50%;background:var(--green);color:white;box-shadow:0 4px 12px rgba(8,55,39,.34);font-family:"IBM Plex Sans",sans-serif;font-size:12px;font-weight:700;cursor:pointer;transition:transform .15s}
.candidate-marker.caution{background:var(--coral)}
.candidate-marker.active{transform:scale(1.2);box-shadow:0 0 0 5px rgba(8,122,82,.2),0 5px 14px rgba(8,55,39,.34)}
.yifeng-marker{display:grid;place-items:center;width:23px;height:23px;border:2px solid white;border-radius:50%;background:var(--coral);color:white;box-shadow:0 2px 7px rgba(90,35,29,.35);font-size:12px;font-weight:800}
.kaixin-marker{display:grid;place-items:center;width:24px;height:24px;border:2px solid white;border-radius:5px;background:var(--green-deep);color:white;box-shadow:0 2px 7px rgba(7,67,47,.35);font-size:11px;font-weight:800}

@keyframes spin{to{transform:rotate(360deg)}}
@keyframes panel-in{from{opacity:0;transform:translateY(-5px)}to{opacity:1;transform:none}}

@media (min-width:760px){
  .topbar{left:18px;right:auto;width:390px;top:18px}
  .brand-block{max-width:none}
  .sheet{left:18px;right:auto;bottom:18px;width:390px;height:calc(100% - 144px);max-height:none;min-height:0;border:1px solid var(--line);border-radius:8px;box-shadow:var(--shadow)}
  .sheet[data-state="low"],.sheet[data-state="middle"],.sheet[data-state="high"]{height:calc(100% - 144px);max-height:none}
  .drag-zone{display:none}
  .sheet-overview{padding-top:15px}
  .detail{left:auto;right:18px;bottom:18px;width:420px;height:calc(100% - 36px);border:1px solid var(--line);border-radius:8px;transform:translateX(110%)}
  .detail.open{transform:translateX(0)}
  .map-key{top:18px;right:18px}
}

@media (max-width:370px){
  .brand-block{max-width:calc(100vw - 118px)}
  .brand-block h1{font-size:14px}
  .top-actions{gap:4px}
  .top-actions .icon-button{width:36px}
  .method-pill{display:none}
  .candidate-card{grid-template-columns:44px minmax(0,1fr) 20px}
  .detail-scroll{padding-left:14px;padding-right:14px}
}

@media (prefers-reduced-motion:reduce){
  *,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;transition-duration:.01ms!important}
}
