:root{--ground:#F3F5F7;--surface:#FFFFFF;--ink:#10202B;--muted:#4A5A66;--line:#DCE2E7;--soft:#EEF1F4;
--accent:#0F5E73;--accent-ink:#FFFFFF;--fail:#A1262A;--flag:#A15C07;--good:#1D6B4F}
*{box-sizing:border-box}
body{margin:0;background:var(--ground);color:var(--ink);font:16px/1.45 "IBM Plex Sans",-apple-system,"PingFang HK","Noto Sans HK","Microsoft JhengHei",system-ui,sans-serif;
padding-bottom:calc(76px + env(safe-area-inset-bottom))}
main{max-width:760px;margin:0 auto;padding:0 16px 24px}
h1{font-size:28px;margin:8px 0 12px;letter-spacing:-.3px}
h2{font-size:15px;margin:20px 4px 8px;color:var(--muted);font-weight:600}
.card h2,.stack h2{margin:0;color:var(--ink);font-size:16px}
a{color:var(--accent)}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
.top{position:sticky;top:0;z-index:2;background:var(--ground);padding:calc(10px + env(safe-area-inset-top)) 16px 6px}
.search{max-width:760px;margin:0 auto}
.search input{width:100%;min-height:44px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--ink);
padding:0 14px;font:inherit}
.card{background:var(--surface);border:1px solid var(--line);border-radius:14px}
.pad{padding:14px 16px}
.stack{display:flex;flex-direction:column;gap:10px}
section.card{margin-top:12px}
.list{display:flex;flex-direction:column}
.row{display:flex;gap:10px;align-items:center;justify-content:space-between;min-height:56px;padding:10px 16px;
border-bottom:1px solid var(--soft);color:var(--ink);text-decoration:none}
.list .row:last-child{border-bottom:0}
.card .list .row{padding-left:0;padding-right:0}
.row-main{display:flex;flex-direction:column;gap:2px;min-width:0}
.row-title{font-size:15px;overflow-wrap:anywhere}
.row-meta,.muted{color:var(--muted)}
.row-meta,.small{font-size:13px}
.code{font-family:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;font-size:13px;color:var(--muted)}
.num{font-family:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;font-variant-numeric:tabular-nums}
.badge{flex:none;display:inline-flex;align-items:center;gap:4px;font-size:12px;font-weight:700;color:#fff;border-radius:6px;padding:3px 8px}
.badge svg{width:12px;height:12px;fill:none;stroke:#fff;stroke-width:3;stroke-linecap:round}
.badge.fail{background:#A1262A}.badge.flag{background:#A15C07}
.kv{display:flex;justify-content:space-between;gap:12px}
.bar{height:8px;background:var(--soft);border-radius:4px;overflow:hidden}
.bar span{display:block;height:8px;background:#1F5F99;border-radius:4px}
.tabs{position:fixed;left:0;right:0;bottom:0;display:flex;justify-content:space-around;background:var(--surface);
border-top:1px solid var(--line);padding:6px 8px calc(8px + env(safe-area-inset-bottom))}
.tabs a{display:flex;flex-direction:column;align-items:center;gap:2px;min-width:72px;min-height:48px;justify-content:center;
font-size:12px;color:var(--muted);text-decoration:none}
.tabs a[aria-current]{color:var(--accent);font-weight:700}
.tabs svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.chips{display:flex;flex-wrap:wrap;gap:8px;margin:4px 0 8px}
.chip{font:inherit;font-size:14px;min-height:40px;padding:0 14px;border-radius:999px;border:1px solid var(--line);background:var(--surface);color:var(--ink)}
.chip.on{background:var(--accent);border-color:var(--accent);color:var(--accent-ink);font-weight:600}
.grid{display:grid;grid-template-columns:minmax(0,1fr) 64px 48px 56px;gap:8px;align-items:center;min-height:56px;padding:8px 16px;
border-bottom:1px solid var(--soft);color:var(--ink);text-decoration:none}
.grid .num{text-align:right}
.grid.head{min-height:36px;font-size:12px;color:var(--muted);font-weight:600}
.grid.head span:not(:first-child){text-align:right}
.name{display:flex;flex-direction:column;min-width:0}
.name b{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.head-row{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;flex-wrap:wrap}
.head-row h1{margin-bottom:2px}
.head-row p{margin:0 0 4px}
.btn{font:inherit;font-weight:600;min-height:44px;padding:0 18px;border-radius:12px;border:1px solid var(--accent);
background:var(--accent);color:var(--accent-ink)}
.btn.ghost{background:transparent;color:var(--accent)}
.link{font-weight:600;text-decoration:none}
.years{display:flex;flex-wrap:wrap;gap:8px}
.year{display:flex;flex-direction:column;align-items:center;min-width:64px;padding:6px 8px;border-radius:10px;background:var(--soft);font-size:13px}
.hero{background:#10202B;color:#fff;border-radius:16px;padding:18px;margin-bottom:12px}
.hero .big{font-family:"IBM Plex Mono",ui-monospace,"SF Mono",Menlo,monospace;font-size:44px;letter-spacing:-1px}
.form{display:grid;grid-template-columns:repeat(auto-fit,minmax(140px,1fr));gap:12px;margin-top:12px}
.form label{display:flex;flex-direction:column;gap:4px;font-size:14px;color:var(--muted)}
.form input{min-height:44px;border-radius:10px;border:1px solid var(--line);background:var(--surface);color:var(--ink);padding:0 12px;font:inherit}
.form .btn,.form p{grid-column:1/-1}
.error{color:var(--fail);font-weight:600}
.login{max-width:360px;padding-top:calc(18vh + env(safe-area-inset-top))}
.login form{display:flex;flex-direction:column;gap:10px}
.login input{min-height:44px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--ink);padding:0 14px;font:inherit}
.login button{min-height:44px;border:0;border-radius:12px;background:var(--accent);color:var(--accent-ink);font:inherit;font-weight:600}
.login .error{color:var(--fail);margin:0}

/* mockup-aligned pieces */
.title-row{display:flex;justify-content:space-between;align-items:flex-end;gap:12px;margin:8px 0 12px}
.title-row h1{margin:0}
.date{font-size:13px;color:var(--muted)}
.pill{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--muted);background:var(--surface);
border:1px solid var(--line);border-radius:999px;padding:6px 10px;white-space:nowrap}
.pill svg{width:14px;height:14px;fill:none;stroke:var(--ink);stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.alerts{display:flex;flex-direction:column;gap:12px}
.alert{display:flex;flex-direction:column;gap:6px;background:var(--surface);border:1px solid var(--line);border-radius:14px;
padding:14px 16px;color:var(--ink);text-decoration:none}
.alert-top{display:flex;justify-content:space-between;align-items:center;gap:10px}
.alert-name{font-weight:600;font-size:16px;color:var(--ink);text-decoration:none;min-height:32px;display:inline-flex;align-items:center;gap:6px}
.alert-body{font-size:14px;line-height:1.4;overflow-wrap:anywhere}
.alert-meta{font-size:13px;color:var(--muted)}
.badge.info{background:#E3F1EA;color:#1D6B4F}
.tiles{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.tile{background:var(--surface);border:1px solid var(--line);border-radius:12px;padding:10px 12px}
.tile .k{font-size:12px;color:var(--muted)}
.tile .v{font-family:"IBM Plex Mono",ui-monospace,monospace;font-size:18px}
.tile .v.wait{font-family:inherit;font-size:14px;color:var(--muted)}
.warn{color:#A15C07;font-weight:600}
/* explanations and summaries */
.why{display:flex;flex-direction:column;gap:8px;font-size:14px}
.facts{display:flex;flex-wrap:wrap;gap:6px}
.fact{background:var(--soft);border-radius:6px;padding:3px 8px;font-size:13px}
.summary{background:#F7F9FA;border:1px solid var(--soft);border-radius:10px;padding:8px 12px}
.summary-head{font-size:13px;font-weight:600}
.summary ul{margin:4px 0 0;padding-left:18px}
.summary li{margin:2px 0}
.why details summary,.check summary{cursor:pointer;min-height:32px;display:flex;align-items:center;gap:8px}
.why details summary{color:var(--accent);font-weight:600;font-size:13px}
.why details p{margin:4px 0 0;line-height:1.5}
/* Webb verdicts and checklist */
.verdict{flex:none;font-size:13px;font-weight:700;border-radius:6px;padding:3px 10px;border:1.5px solid}
.verdict.ok{color:#1D6B4F;border-color:#1D6B4F}
.verdict.watch{color:#A15C07;border-color:#A15C07}
.verdict.avoid{color:#fff;background:#A1262A;border-color:#A1262A}
.metrics{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:13px;color:var(--muted)}
.metrics b{color:var(--ink);font-family:"IBM Plex Mono",ui-monospace,monospace;font-weight:500}
.check-group h3{font-size:14px;margin:10px 0 4px}
.check{border-top:1px solid var(--soft);padding:4px 0}
.check p{margin:2px 0 6px}
.check-title{font-size:15px}
.st{flex:none;font-size:12px;font-weight:700;border-radius:5px;padding:2px 7px;min-width:44px;text-align:center}
.st.pass{background:#E3F1EA;color:#1D6B4F}.st.flag{background:#A15C07;color:#fff}
.st.fail{background:#A1262A;color:#fff}.st.pending{background:var(--soft);color:var(--muted)}
.evidence{margin:6px 0 10px;padding-left:10px;border-left:3px solid var(--soft);display:flex;flex-direction:column;gap:6px;font-size:14px}
.wait{color:var(--muted);font-family:inherit;font-size:14px}
.tile .v .wait{font-size:14px}
/* screen filters */
.filters fieldset{border:0;padding:0;margin:0 0 12px}
.filters legend{font-weight:600;font-size:14px;margin-bottom:6px}
.grid2{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.grid2 label{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--muted)}
.grid2 input{min-height:44px;border-radius:10px;border:1px solid var(--line);background:var(--surface);color:var(--ink);padding:0 12px;font:inherit}
.seg{display:flex;flex-wrap:wrap;gap:8px}
.seg-item{display:flex;align-items:center;gap:6px;min-height:40px;padding:0 12px;border:1px solid var(--line);border-radius:999px;font-size:14px}
.form-actions{display:flex;align-items:center;gap:16px}
a.chip{display:inline-flex;align-items:center;text-decoration:none}
.filters-box summary{cursor:pointer;min-height:48px;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.filters-box form{padding-top:0}
/* chat */
.head-actions{display:flex;gap:8px;align-items:center}
a.btn{display:inline-flex;align-items:center;text-decoration:none}
.chat-log{display:flex;flex-direction:column;gap:10px;margin:8px 0 12px}
.bubble{max-width:88%;padding:10px 14px;border-radius:14px;white-space:pre-wrap;overflow-wrap:anywhere;line-height:1.5;font-size:15px}
.bubble.user{align-self:flex-end;background:var(--accent);color:var(--accent-ink);border-bottom-right-radius:4px}
.bubble.assistant{align-self:flex-start;background:var(--surface);border:1px solid var(--line);border-bottom-left-radius:4px}
.bubble.pending{color:var(--muted)}
.ask{position:sticky;bottom:calc(72px + env(safe-area-inset-bottom));display:flex;gap:8px;align-items:flex-end;
background:var(--ground);padding:8px 0}
.ask textarea{flex:1;min-height:48px;max-height:160px;border-radius:12px;border:1px solid var(--line);background:var(--surface);
color:var(--ink);padding:10px 12px;font:inherit;resize:vertical}
.tabs a{min-width:64px}

/* desktop: menu at the top, wider page, two columns where it helps */
@media (min-width: 960px){
  body{padding-bottom:0;padding-top:0}
  .top{display:flex;align-items:center;gap:24px;max-width:1240px;margin:0 auto;padding:14px 24px 10px}
  .search{flex:1;max-width:420px;margin:0}
  .tabs{position:sticky;top:0;bottom:auto;z-index:3;justify-content:center;gap:8px;border-top:0;border-bottom:1px solid var(--line);padding:4px 24px}
  .tabs a{flex-direction:row;gap:8px;min-height:44px;padding:0 16px;font-size:15px;border-radius:10px}
  .tabs a[aria-current]{background:var(--soft)}
  main{max-width:1240px;padding:0 24px 40px}
  .tiles{grid-template-columns:repeat(4,minmax(0,1fr))}
  .tiles.two{grid-template-columns:repeat(2,minmax(0,1fr))}
  .alerts{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
  .wide-2{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:16px;align-items:start}
  .wide-2>section.card{margin-top:12px}
  .filters .grid2{grid-template-columns:repeat(4,minmax(0,1fr))}
  .chat-log,.ask,#starters{max-width:860px}
  .ask{bottom:0}
  .bubble{max-width:75%}
  .form{grid-template-columns:repeat(3,minmax(0,1fr))}
}
/* spreadsheet tables */
.sheet-wrap{overflow-x:auto;background:var(--surface);border:1px solid var(--line);border-radius:14px}
.sheet{border-collapse:collapse;width:100%;font-size:14px;font-variant-numeric:tabular-nums}
.sheet th,.sheet td{padding:8px 12px;border-bottom:1px solid var(--soft);white-space:nowrap}
.sheet td{text-align:right;font-family:"IBM Plex Mono",ui-monospace,monospace}
.sheet thead th{position:sticky;top:0;background:#EEF2F5;font-size:12px;color:var(--muted);text-align:right;font-weight:600}
.sheet thead th:first-child,.sheet tbody th{text-align:left;position:sticky;left:0;background:var(--surface);z-index:1;font-weight:500}
.sheet thead th:first-child{background:#EEF2F5;z-index:2}
.sheet tr.total th,.sheet tr.total td{font-weight:700;border-top:1.5px solid var(--ink)}
.sheet tr.factor td{color:var(--muted)}
.sheet tr.picked th,.sheet tr.picked td{background:#EAF3F6}
.sheet td.strong{font-weight:700}
.sheet .neg{color:#A1262A}
.sheet .zero{color:var(--muted)}
/* stock sub-tabs, DCF formula column */
.subtabs{display:flex;gap:4px;overflow-x:auto;margin:12px 0 0;border-bottom:1px solid var(--line)}
.subtabs a{flex:none;padding:10px 14px;min-height:44px;display:flex;align-items:center;color:var(--muted);text-decoration:none;font-weight:600;border-bottom:3px solid transparent}
.subtabs a[aria-current]{color:var(--ink);border-bottom-color:var(--accent)}
.row-link{display:block;padding:6px 0;color:var(--ink);text-decoration:none;font-size:14px;border-bottom:1px solid var(--soft)}
.basis{margin:0;padding-left:20px;line-height:1.6}
.sheet td.formula,.sheet th.formula{text-align:left;font-family:inherit;color:var(--muted);white-space:normal;min-width:220px;max-width:320px;font-size:13px}
.sheet td.tot,.sheet th.tot{background:#F3F6F8;font-weight:600;border-right:1.5px solid var(--line)}
.sheet.compact td,.sheet.compact th{padding:6px 10px}
/* floating kefi panel: a full-height sheet on phones, a right-hand panel on desktop */
.kefi-fab{position:fixed;right:16px;bottom:calc(84px + env(safe-area-inset-bottom));z-index:5;display:flex;align-items:center;gap:6px;
min-height:48px;padding:0 18px;border-radius:999px;border:0;background:var(--accent);color:var(--accent-ink);font:inherit;font-weight:700;
box-shadow:0 4px 14px rgba(16,32,43,.25);cursor:pointer}
.kefi-fab svg,.icon-btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.kefi{border:0;padding:0;margin:auto 0 0;width:100vw;max-width:100vw;height:88dvh;max-height:88dvh;background:var(--ground);color:var(--ink);
border-radius:18px 18px 0 0;box-shadow:0 -6px 30px rgba(16,32,43,.25);overflow:hidden}
.kefi[open]{display:flex;flex-direction:column}
.kefi::backdrop{background:rgba(16,32,43,.35)}
.kefi-head{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:calc(12px + env(safe-area-inset-top)) 16px 10px;
border-bottom:1px solid var(--line);background:var(--surface)}
.kefi-head-actions{display:flex;align-items:center;gap:12px}
.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;border:0;background:transparent;color:var(--ink);cursor:pointer}
.kefi-log{flex:1;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:12px 16px}
.kefi-starters{padding:0 16px}
.kefi-ask{display:flex;gap:8px;align-items:flex-end;padding:8px 16px calc(12px + env(safe-area-inset-bottom));border-top:1px solid var(--line);background:var(--surface)}
.kefi-ask textarea{flex:1;min-height:48px;max-height:140px;border-radius:12px;border:1px solid var(--line);background:var(--surface);color:var(--ink);padding:10px 12px;font:inherit;resize:none}
@media (min-width: 960px){
  .kefi-fab{bottom:24px;right:24px}
  .kefi{position:fixed;inset:auto 24px 88px auto;margin:0;width:420px;height:min(640px,calc(100vh - 120px));max-height:none;
    border:1px solid var(--line);border-radius:16px;box-shadow:0 12px 40px rgba(16,32,43,.28);z-index:6}
}
/* sortable screen table */
.sheet.screen th[scope=row] a{font-weight:600;color:var(--ink);text-decoration:none}
.sheet.screen th[scope=row]{min-width:150px;white-space:normal}
.sheet a.sort{color:inherit;text-decoration:none;display:inline-flex;min-height:32px;align-items:center}
.sheet a.sort.on{color:var(--ink)}
.sheet td.empty{text-align:left;font-family:inherit;color:var(--muted);white-space:normal}
.tone{flex:none;font-size:12px;font-weight:700;border-radius:6px;padding:2px 8px;background:var(--soft);color:var(--muted)}
.tone.pos{background:#E3F1EA;color:#1D6B4F}.tone.neg{background:#A1262A;color:#fff}
