:root{
  --bg:#f6f7f5; --card:#fff; --ink:#17231f; --muted:#6b7a75;
  --line:#e3e8e5; --brand:#0e5a4a; --brand-soft:#e6f2ee;
  --warn:#8a5a00; --warn-bg:#fff4dd; --danger:#a32a2a; --danger-bg:#fdecec;
  --ok:#1c7a4a; --ok-bg:#e7f6ee;
  --radius:16px;
}
@media (prefers-color-scheme: dark){
  :root{
    --bg:#101614; --card:#18211e; --ink:#e8f0ec; --muted:#93a49e;
    --line:#26332e; --brand:#5fd0ae; --brand-soft:#17332b;
    --warn:#ffd98a; --warn-bg:#33291a; --danger:#ff9c9c; --danger-bg:#331e1e;
    --ok:#7fe0ad; --ok-bg:#12301f;
  }
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{
  background:var(--bg); color:var(--ink);
  font:16px/1.55 -apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
  padding-bottom:calc(env(safe-area-inset-bottom) + 12px);
}

/* 顶栏 */
.topbar{
  position:sticky; top:0; z-index:20; display:flex; align-items:center; justify-content:space-between;
  gap:12px; padding:calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background:var(--brand); color:#fff;
}
.brand{display:flex; align-items:center; gap:10px; min-width:0}
.flag{font-size:22px; line-height:1}
.topbar h1{font-size:17px; margin:0; font-weight:650; letter-spacing:.2px}
.topbar .sub{margin:2px 0 0; font-size:12px; opacity:.82; white-space:nowrap; overflow:hidden; text-overflow:ellipsis}
.refresh{
  flex:0 0 auto; width:38px; height:38px; border-radius:50%; border:0;
  background:rgba(255,255,255,.16); color:#fff; font-size:19px; cursor:pointer;
}
.refresh:active{transform:scale(.94)}
.refresh.spin{animation:spin .8s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* Tab */
.tabs{
  position:sticky; top:calc(env(safe-area-inset-top) + 62px); z-index:19;
  display:flex; gap:6px; overflow-x:auto; padding:8px 12px;
  background:var(--bg); border-bottom:1px solid var(--line);
  scrollbar-width:none;
}
.tabs::-webkit-scrollbar{display:none}
.tab{
  flex:0 0 auto; padding:7px 14px; border-radius:999px; border:1px solid var(--line);
  background:var(--card); color:var(--muted); font-size:14px; cursor:pointer;
}
.tab.active{background:var(--brand); border-color:var(--brand); color:#fff; font-weight:600}

main{padding:12px 12px 24px; max-width:760px; margin:0 auto}
.panel{display:none}
.panel.active{display:block; animation:fade .18s ease}
@keyframes fade{from{opacity:0; transform:translateY(4px)}to{opacity:1; transform:none}}

/* 卡片 */
.card{
  background:var(--card); border:1px solid var(--line); border-radius:var(--radius);
  padding:14px; margin-bottom:12px;
}
.card h2{font-size:15px; margin:0 0 10px; display:flex; align-items:center; gap:8px}
.card h3{font-size:14px; margin:14px 0 8px}

/* 角标 */
.badge{display:inline-block; font-size:11px; padding:2px 8px; border-radius:999px; font-weight:600; white-space:nowrap}
.badge.demo{background:var(--warn-bg); color:var(--warn)}
.badge.live{background:var(--ok-bg); color:var(--ok)}
.badge.plain{background:var(--brand-soft); color:var(--brand)}

.meta{font-size:12px; color:var(--muted); margin:0 0 10px}
.meta a{color:var(--brand)}

/* 摘要格 */
.grid{display:grid; grid-template-columns:repeat(2,1fr); gap:10px}
.kpi{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:12px}
.kpi .n{font-size:22px; font-weight:700; color:var(--brand); line-height:1.2}
.kpi .l{font-size:12px; color:var(--muted); margin-top:2px}

/* 列表行 */
.row{display:flex; gap:10px; padding:10px 0; border-top:1px solid var(--line); align-items:flex-start}
.row:first-of-type{border-top:0}
.row .grow{flex:1; min-width:0}
.row .t{font-size:14.5px; font-weight:600; margin:0}
.row .d{font-size:12.5px; color:var(--muted); margin:3px 0 0}
.price{font-weight:700; color:var(--brand); white-space:nowrap}
.price small{font-weight:400; color:var(--muted); text-decoration:line-through; font-size:11px; margin-left:4px}
.tag{font-size:11px; color:var(--muted); border:1px solid var(--line); border-radius:6px; padding:1px 6px; margin-right:4px}
.expired{opacity:.45}
.expired .price{color:var(--muted)}

/* 治安条 */
.bars{display:flex; gap:3px; margin-top:6px}
.bars i{flex:1; height:5px; border-radius:3px; background:var(--line)}
.bars i.on{background:var(--brand)}
.bars i.on.low{background:var(--danger)}
.bars i.on.mid{background:#d9a441}

/* 罢工条目 */
.news{padding:11px 0; border-top:1px solid var(--line)}
.news:first-of-type{border-top:0}
.news a{color:var(--ink); text-decoration:none; font-weight:600; font-size:14.5px}
.news a:active{opacity:.7}
.news .when{font-size:12px; color:var(--muted); margin-top:4px; display:flex; gap:8px; flex-wrap:wrap}
.news .sum{font-size:13px; color:var(--muted); margin-top:6px}
.pill{font-size:11px; padding:1px 7px; border-radius:999px; background:var(--brand-soft); color:var(--brand)}
.pill.torino{background:var(--ok-bg); color:var(--ok)}
.pill.trasporti{background:var(--danger-bg); color:var(--danger)}

.empty{color:var(--muted); font-size:13px; padding:14px 0}
.srcline{font-size:12px; color:var(--muted); margin-top:10px}
.foot{padding:16px; text-align:center; color:var(--muted); font-size:12px}
.foot .hint{max-width:620px; margin:6px auto 0; line-height:1.6; opacity:.85}
.err{background:var(--danger-bg); color:var(--danger); border-radius:12px; padding:10px 12px; font-size:13px; margin-bottom:12px}

/* ==================== 图表 / 地图 / chips ==================== */
.chips{display:flex; gap:6px; overflow-x:auto; padding:2px 0 10px; scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{
  flex:0 0 auto; padding:6px 12px; border-radius:999px; border:1px solid var(--line);
  background:var(--bg); color:var(--muted); font-size:13px; cursor:pointer;
}
.chip.on{background:var(--brand-soft); border-color:var(--brand); color:var(--brand); font-weight:600}

.chartwrap{margin:6px 0 4px; background:var(--card)}
.chart{width:100%; height:auto; display:block}
.legend{display:flex; gap:14px; flex-wrap:wrap; font-size:12px; color:var(--muted); margin-top:6px}
.legend i{display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:5px; vertical-align:middle}

.mapbox{
  height:300px; border-radius:14px; overflow:hidden; border:1px solid var(--line);
  background:var(--brand-soft);
}
.mapbox.tall{height:420px}
.mapoff{padding:16px; font-size:13px; color:var(--muted); text-align:center}

/* Leaflet 深浅色适配 */
.leaflet-container{background:#e8eeea; font:inherit}
@media (prefers-color-scheme: dark){
  .leaflet-container{background:#1a2420}
  .leaflet-tile{filter:invert(1) hue-rotate(180deg) brightness(.85) contrast(.9)}
  .leaflet-bar a, .leaflet-popup-content-wrapper, .leaflet-popup-tip{background:var(--card); color:var(--ink); border-color:var(--line)}
}
.leaflet-popup-content-wrapper{border-radius:12px}
.leaflet-popup-content{font-size:13px; line-height:1.5; margin:10px 12px}

/* 地图上的自定义标记 */
.dlabel{
  position:absolute; transform:translate(-50%,-50%);
  font-size:11px; font-weight:700; color:#0b3b31; white-space:nowrap;
  text-shadow:0 0 3px #fff,0 0 3px #fff,0 0 3px #fff;
  pointer-events:none;
}
@media (prefers-color-scheme: dark){ .dlabel{color:#d6f5ea; text-shadow:0 0 3px #000,0 0 3px #000} }
.pin{
  width:24px; height:24px; border-radius:50% 50% 50% 0; transform:rotate(-45deg);
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 1px 4px rgba(0,0,0,.35); border:2px solid #fff;
}
.pin > *{transform:rotate(45deg); font-size:11px; line-height:1}

/* 地图上的价格 / 指数标签 */
.map-price{
  background: rgba(255,255,255,.94); border:0 !important; box-shadow:0 1px 5px rgba(0,0,0,.22);
  border-radius:9px; padding:3px 7px; font-size:11px; line-height:1.3; color:#0b3b31;
  text-align:center; font-weight:600; white-space:nowrap;
}
.map-price b{display:block; font-weight:700; font-size:10.5px; opacity:.85}
.map-price span{display:block; font-weight:800; font-size:12px; color:#b45309}
.leaflet-tooltip.map-price::before{display:none}
@media (prefers-color-scheme: dark){
  .map-price{background:rgba(24,33,30,.94); color:#d6f5ea}
  .map-price span{color:#ffd98a}
}
.maperr{
  position:absolute; left:10px; right:10px; bottom:10px; z-index:500;
  background:var(--warn-bg); color:var(--warn); border-radius:10px;
  padding:8px 10px; font-size:12px; text-align:center;
}
.mapbox{position:relative}

/* 地图尺寸与标签（第二轮调优：价格单行、更小、更大画布） */
.mapbox{height:340px}
.mapbox.tall{height:460px}
.map-price{
  background:rgba(255,255,255,.95); border:0 !important; box-shadow:0 1px 3px rgba(0,0,0,.25);
  border-radius:7px; padding:1px 5px; font-size:10px; line-height:1.5; color:#0b3b31;
  text-align:center; font-weight:800; white-space:nowrap; letter-spacing:.2px;
}
.leaflet-tooltip.map-price::before{display:none}
@media (prefers-color-scheme: dark){
  .map-price{background:rgba(20,28,25,.95); color:#d6f5ea}
}

/* 顶栏账号入口 */
.topbar-right{display:flex; align-items:center; gap:8px; flex:0 0 auto}
.account{
  padding:6px 12px; border-radius:999px; font-size:13px; text-decoration:none;
  background:rgba(255,255,255,.16); color:#fff; font-weight:600; white-space:nowrap;
  max-width:120px; overflow:hidden; text-overflow:ellipsis;
}
.account:active{transform:scale(.97)}

/* ==================== 双城 + 双语 ==================== */
.citybar{
  position:sticky; top:calc(env(safe-area-inset-top) + 62px); z-index:20;
  display:flex; gap:8px; padding:10px 12px 8px; background:var(--bg);
}
.citybtn{
  flex:1; display:flex; flex-direction:column; align-items:center; gap:1px;
  padding:8px 10px; border-radius:12px; border:1px solid var(--line);
  background:var(--card); color:var(--muted); font-family:inherit; font-size:14.5px; cursor:pointer;
}
.citybtn small{font-size:11px; opacity:.75; font-weight:400}
.citybtn.on{background:var(--brand); border-color:var(--brand); color:#fff; font-weight:700}
.citybtn.on small{opacity:.85}

.tabs{top:calc(env(safe-area-inset-top) + 118px)}
.tab small{font-size:10.5px; opacity:.7; font-weight:400}

h2 small, h3 small{font-size:11.5px; font-weight:400; color:var(--muted); margin-left:4px}

.hero{padding:4px 2px 14px}
.hero h2{margin:0 0 4px; font-size:20px}
.hero h2 small{font-size:13px; color:var(--muted); font-weight:500}
.hero p{margin:0; font-size:13px; color:var(--muted); line-height:1.55}

/* 语言切换按钮 */
.langbtn{
  min-width:38px; height:34px; padding:0 8px; border-radius:999px; border:0;
  background:rgba(255,255,255,.16); color:#fff; font-size:13px; font-weight:700;
  font-family:inherit; cursor:pointer;
}
.langbtn.on{background:#fff; color:var(--brand)}

/* ==================== 社区：评分 / 评价弹窗 ==================== */
.linkbtn{
  background:none; border:0; padding:0 0 0 8px; color:var(--brand);
  font:inherit; font-size:12.5px; cursor:pointer; text-decoration:underline;
}
.rating{color:var(--muted); font-size:12.5px}
.rating.has{color:var(--warn); font-weight:700}

.modal{
  position:fixed; inset:0; z-index:9999; background:rgba(0,0,0,.45);
  display:flex; align-items:flex-end; justify-content:center; padding:0;
}
.modal-card{
  background:var(--card); color:var(--ink); width:100%; max-width:520px;
  max-height:88vh; overflow:auto; border-radius:18px 18px 0 0;
  padding:18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -8px 30px rgba(0,0,0,.25);
}
.modal-card h2{font-size:17px; margin:0 0 10px}
.modal-card .field{margin-bottom:12px}
.modal-card textarea{
  width:100%; padding:10px 12px; font:inherit; font-size:15px; color:var(--ink);
  background:var(--bg); border:1px solid var(--line); border-radius:12px; resize:vertical;
}
.starpick{display:flex; gap:6px}
.starpick button{
  background:none; border:0; font-size:26px; line-height:1; cursor:pointer;
  color:#d9a441; padding:0 2px;
}
.rv{border-top:1px solid var(--line); padding:10px 0}
.rv:first-child{border-top:0}

/* 半月轮换徽标 */
.badge.new{background:var(--ok-bg); color:var(--ok)}
.badge.pick{background:var(--warn-bg); color:var(--warn)}

/* ==================== 租房安全 / 第三方群组 ==================== */
.warncard{border-color:color-mix(in srgb, var(--warn) 45%, var(--line)); background:var(--warn-bg)}
.redcard{border-color:color-mix(in srgb, var(--danger) 40%, var(--line)); background:var(--danger-bg)}
.linklist,.redlist,.tiplist,.checklist{margin:8px 0 0; padding-left:20px; font-size:13.5px; line-height:1.65}
.linklist li,.redlist li,.tiplist li,.checklist li{margin:3px 0}
.linklist li{list-style:none; padding-left:0}
.linklist li::before{content:"🔗 ";}
.redlist li::marker{color:var(--danger)}
.checklist li::marker{content:"✓ "; color:var(--ok); font-weight:700}
.tiplist li::marker{color:var(--warn)}
.redcard h2,.warncard h2{margin-bottom:8px}

/* ==================== 响应式重排：手机 / 平板 / 电脑 ==================== */
:root{ --wrap:1180px }

@media (min-width:820px){
  body{font-size:16.5px}
  .topbar{padding:14px 28px}
  .topbar h1{font-size:19px}
  .topbar .sub{font-size:12.5px}
  .tabs{padding:10px 28px; justify-content:center}
  .citybar{padding:12px 28px 8px; justify-content:center; max-width:var(--wrap); margin:0 auto}
  .citybtn{flex:0 1 280px}
  main{padding:18px 28px 44px; max-width:var(--wrap)}
  .card{padding:18px 20px}
  .foot{max-width:var(--wrap); margin:0 auto; padding:0 28px 28px}
  #tab-home .grid{grid-template-columns:repeat(4,minmax(0,1fr))}
}

/* 卡片网格：宽屏自动 2–3 栏 */
@media (min-width:980px){
  .panel.active{
    display:grid;
    grid-template-columns:repeat(auto-fill,minmax(340px,1fr));
    gap:16px;
    align-items:start;
  }
  .panel > .card{margin-bottom:0}
  /* 需要通栏的：地图、图表、表格、概览、警示 */
  .panel > .hero,
  .panel > .grid,
  .panel > .fullrow,
  .panel > .warncard,
  .panel > .redcard,
  .panel > .card:has(.mapbox),
  .panel > .card:has(svg.chart),
  .panel > .card:has(table){grid-column:1 / -1}
  .panel > .card:has(.mapbox){min-height:auto}
}
@media (hover:hover) and (min-width:980px){
  .card{transition:box-shadow .18s ease, transform .18s ease}
  .card:hover{box-shadow:0 10px 30px rgba(16,32,26,.10); transform:translateY(-2px)}
}

/* 超宽屏：正文可读性 */
@media (min-width:1400px){
  :root{--wrap:1280px}
}

/* ==================== 分页器 ==================== */
.pager{
  display:flex; flex-wrap:wrap; gap:8px; align-items:center; justify-content:center;
  padding:16px 6px 6px;
}
.pgbtn{
  padding:8px 13px; border-radius:10px; border:1px solid var(--line);
  background:var(--card); color:var(--ink); font:inherit; font-size:13.5px;
  cursor:pointer; line-height:1;
}
.pgbtn:hover:not([disabled]){border-color:var(--brand); color:var(--brand)}
.pgbtn[disabled]{opacity:.38; cursor:default}
.pgnums{display:flex; gap:5px; flex-wrap:wrap; justify-content:center}
.pgbtn.num{min-width:36px; text-align:center; padding:8px 0}
.pgbtn.num.on{background:var(--brand); border-color:var(--brand); color:#fff; font-weight:700}
.pgdots{color:var(--muted); padding:0 2px; align-self:center}
.pgcount{width:100%; text-align:center; font-size:12px; color:var(--muted); margin-top:2px}

/* 桌面：每个 Tab 的首张卡片（通常是导语/筛选）通栏 */
@media (min-width:980px){
  .panel > .card:first-of-type{grid-column:1 / -1}
  .panel > .hero + .grid{grid-column:1 / -1}
}
/* 页脚柔化 */
.foot{margin-top:26px; text-align:center}
.foot .hint{opacity:.75}

/* 首页卡片少，用两栏铺满，避免右侧留白 */
@media (min-width:980px){
  #tab-home{grid-template-columns:repeat(2,minmax(0,1fr))}
}


/* ==================== 对齐与呼吸感 ==================== */
/* 卡片内链接统一：品牌色 + 细下划线，不用浏览器默认蓝 */
.card a{color:var(--brand); text-decoration:none; border-bottom:1px solid color-mix(in srgb, var(--brand) 28%, transparent); transition:border-color .15s}
.card a:hover{border-bottom-color:var(--brand)}
.card a.btn,.card a.plink,.card a.rowlink{border-bottom:0}

/* 卡片内列表统一间距 */
.card ul{margin:8px 0 0; padding-left:18px; font-size:13.5px; line-height:1.7}
.card li{margin:3px 0}
.card li::marker{color:color-mix(in srgb, var(--brand) 60%, transparent)}
.card h2{flex-wrap:wrap; line-height:1.4}
.card h3{margin:16px 0 8px; font-size:13.5px; color:var(--muted); font-weight:700; letter-spacing:.2px}

/* 宽屏：同一行卡片等高，内部纵向排布 */
@media (min-width:980px){
  .panel.active{align-items:stretch}
  .panel > .card{display:flex; flex-direction:column; margin-bottom:0}
  .panel > .card > *:last-child{margin-bottom:0}
  .chips{flex-wrap:wrap; overflow:visible; padding-bottom:2px}
  .card + .card{margin-top:0}
}

/* 渠道磁贴：等宽等高的方块，替代参差的链接段落 */
.plgrid{display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:8px; margin-top:4px}
.plink{
  display:flex; flex-direction:column; gap:2px; padding:10px 11px;
  border:1px solid var(--line); border-radius:12px; background:var(--bg);
  color:var(--ink); text-decoration:none; border-bottom:1px solid var(--line) !important;
  transition:border-color .15s, transform .15s, background .15s;
}
.plink:hover{border-color:var(--brand); background:var(--brand-soft); transform:translateY(-1px)}
.plink b{font-size:13px; font-weight:650; line-height:1.35; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; word-break:normal; overflow-wrap:anywhere}
.plink small{font-size:11px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}

/* 一行一条的链接列表：左对齐、等间距 */
.rowlink{display:flex; align-items:center; gap:8px; padding:9px 2px; border-top:1px solid var(--line); color:var(--ink); text-decoration:none; border-bottom:0 !important}
.rowlink:first-of-type{border-top:0}
.rowlink .rk{flex:1; min-width:0; font-size:13.5px; font-weight:600}
.rowlink .rs{font-size:11.5px; color:var(--muted)}
.rowlink::after{content:"↗"; color:var(--muted); font-size:12px}
.rowlink:hover .rk{color:var(--brand)}

/* 折叠面板 */
details.acc{border:1px solid var(--line); border-radius:12px; padding:0 12px; background:var(--bg); margin-top:12px}
details.acc > summary{padding:11px 0; cursor:pointer; font-size:13.5px; font-weight:650; list-style:none; display:flex; align-items:center; gap:8px}
details.acc > summary::-webkit-details-marker{display:none}
details.acc > summary::before{content:"▸"; color:var(--muted); transition:transform .15s}
details.acc[open] > summary::before{transform:rotate(90deg)}
details.acc > div{padding-bottom:12px}

/* 三栏清单（红线/黄牌/签约前）：等宽，不参差 */
.safegrid{display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:18px 22px}
.safegrid h4{margin:0 0 6px; font-size:13.5px; font-weight:700}
.safegrid ul{margin:0; padding-left:17px; font-size:13px; line-height:1.65}
.safegrid .red h4{color:var(--danger)}
.safegrid .warn h4{color:var(--warn)}
.safegrid .ok h4{color:var(--ok)}

/* 警示卡保持醒目但收敛留白 */
.warncard{padding:16px 18px}
.warncard p{margin:0 0 8px; font-size:13px; line-height:1.6}
.warncard p:last-child{margin-bottom:0}

/* 桌面弹窗居中，手机保持底部抽屉 */
@media (min-width:760px){
  .modal{align-items:center; justify-content:center; padding:24px}
  .modal-card{border-radius:18px; max-height:86vh}
  .modal-card .row-btns{gap:10px}
}


/* 街区租金：等宽卡片网格，替代参差的长列表 */
.zonegrid{display:grid; grid-template-columns:repeat(auto-fill,minmax(168px,1fr)); gap:10px; margin-top:6px}
.zone{
  border:1px solid var(--line); border-radius:12px; padding:11px 12px; background:var(--bg);
  display:flex; flex-direction:column; gap:3px; min-height:104px;
}
.zone .zn{font-size:13.5px; font-weight:650; line-height:1.3; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.zone .zc{font-size:11px; color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.zone .zp{font-size:17px; font-weight:800; color:var(--brand); margin-top:auto; line-height:1.2}
.zone .zp small{font-size:11px; font-weight:500; color:var(--muted)}
.zone .zm{font-size:11.5px; color:var(--muted)}
.zone .zchg{font-size:11.5px; font-weight:650}
.zone .zchg.up{color:var(--danger)}
.zone .zchg.down{color:var(--ok)}

/* 地图弹窗 */
.leaflet-popup-content{font-size:13px; line-height:1.5; margin:10px 12px}
.leaflet-popup-content .mapmeta{color:var(--muted); font-size:11.5px}
.leaflet-popup-content .mapnav{
  display:inline-block; margin-top:8px; padding:6px 11px; border-radius:8px;
  background:var(--brand); color:#fff !important; font-size:12.5px; font-weight:600;
  text-decoration:none; border:0;
}
.leaflet-popup-content .mapnav:hover{filter:brightness(1.08)}
.map-price{background:rgba(255,255,255,.92); border:0; box-shadow:0 1px 4px rgba(0,0,0,.18); font-weight:700; color:#17231f}

/* 分享按钮 */
.sharebtn{
  margin:0 auto 12px; display:block; padding:10px 22px; border-radius:999px;
  border:1px solid var(--brand); background:var(--brand-soft); color:var(--brand);
  font:inherit; font-size:13.5px; font-weight:650; cursor:pointer;
}
.sharebtn:hover{background:var(--brand); color:#fff}
