/* 牧歌 CRM（NUGE）深绿主题 · 依据 02-dashboard.png 设计系统 */
:root{
  --g:#16A34A; --g-dark:#15803D; --g-deep:#1D4E3F;
  --amber:#B45309; --amber2:#D97706;
  --ink:#1C2B27; --sub:#5B6E67; --faint:#8AA096;
  --line:#E4EAE6; --line2:#EDF2EF; --bg:#F5F6F4;
  --red:#DC2626; --cyan:#0E7490;
  --nav:#0C1F1A; --nav-t:#8FAF9F; --nav-on:#1B3D31;
}
*{margin:0;padding:0;box-sizing:border-box;font-family:"Microsoft YaHei","PingFang SC",sans-serif}
body{background:var(--bg);color:var(--ink);-webkit-font-smoothing:antialiased}
.px{display:flex;align-items:center}
.px-col{display:flex;flex-direction:column}
body.px{align-items:stretch}
.grow{flex:1}
/* 侧边导航 */
.nav{width:200px;background:var(--nav);flex-shrink:0;flex-direction:column;padding:16px 0 0}
.logo{display:flex;align-items:center;gap:10px;padding:0 18px 16px;border-bottom:1px solid rgba(255,255,255,.06)}
.lg{width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,#16A34A,#22C55E);color:#fff;font-weight:bold;font-size:17px;display:flex;align-items:center;justify-content:center}
.ln{color:#fff;font-size:15.5px;font-weight:bold;letter-spacing:.5px}
.ls{font-size:9.5px;color:#6E8C7E;margin-top:1px}
.ng{font-size:10.5px;color:#6E8C7E;padding:12px 20px 5px;letter-spacing:1px}
.mi{display:flex;align-items:center;gap:10px;margin:1px 10px;padding:9px 12px;font-size:13.5px;color:var(--nav-t);border-radius:8px}
.mi.on{background:var(--nav-on);color:#fff;font-weight:bold}
.mi .ic{width:16px;text-align:center;font-size:13px}
.bdg{margin-left:auto;background:var(--amber2);color:#fff;font-size:10px;min-width:16px;height:16px;border-radius:8px;display:flex;align-items:center;justify-content:center;padding:0 4px}
.navbot{margin-top:auto;border-top:1px solid rgba(255,255,255,.06);padding:12px 18px;display:flex;align-items:center;gap:10px}
.av{width:30px;height:30px;border-radius:50%;background:linear-gradient(135deg,#16A34A,#22C55E);color:#fff;font-size:12px;display:flex;align-items:center;justify-content:center;font-weight:bold;flex-shrink:0}
/* 顶栏 */
.main{flex:1;min-width:0;flex-direction:column}
.topbar{height:56px;background:#fff;border-bottom:1px solid var(--line);display:flex;align-items:center;padding:0 22px;gap:14px}
.tb-t{font-size:16px;font-weight:bold}
.tb-s{font-size:11px;color:var(--faint);margin-top:1px}
.srch{width:220px;height:32px;border:1px solid var(--line);border-radius:8px;display:flex;align-items:center;padding:0 10px;font-size:12px;color:var(--faint);background:#FAFBFA}
.segm{height:32px;border:1px solid var(--line);border-radius:8px;display:flex;align-items:center;padding:0 12px;font-size:12.5px;color:var(--sub);background:#fff;gap:6px}
.btn-g{height:32px;padding:0 14px;background:var(--g);color:#fff;border-radius:8px;display:flex;align-items:center;font-size:12.5px;font-weight:bold;gap:5px}
.btn-o{height:32px;padding:0 12px;border:1px solid var(--line);color:var(--sub);border-radius:8px;display:flex;align-items:center;font-size:12.5px;background:#fff;gap:5px}
/* 内容区 */
.content{flex:1;padding:14px 22px 16px;display:flex;flex-direction:column;gap:10px;overflow:hidden}
.card{background:#fff;border:1px solid var(--line);border-radius:10px}
.card-h{display:flex;align-items:center;justify-content:space-between;padding:11px 16px;border-bottom:1px solid var(--line2)}
.card-t{font-size:14px;font-weight:bold}
.card-sub{font-size:11px;color:var(--faint)}
.tag{display:inline-flex;align-items:center;font-size:11px;padding:2px 8px;border-radius:4px;line-height:1.5;white-space:nowrap}
.tag-g{background:#ECFDF5;color:#15803D}
.tag-a{background:#FFF7ED;color:#9A3412}
.tag-r{background:#FEF2F2;color:#DC2626}
.tag-b{background:#EFF6FF;color:#1D4ED8}
.tag-c{background:#ECFEFF;color:#0E7490}
.tag-gray{background:#F1F5F4;color:var(--sub)}
.dot{width:7px;height:7px;border-radius:50%;display:inline-block}
.kpi{flex:1;background:#fff;border:1px solid var(--line);border-radius:10px;padding:12px 16px}
.kpi .l{font-size:12px;color:var(--sub)}
.kpi .n{font-size:23px;font-weight:bold;letter-spacing:-.3px;margin-top:3px}
.kpi .d{font-size:11px;color:var(--faint);margin-top:3px}
.bar{height:6px;border-radius:3px;background:#E5EAE7;overflow:hidden}
.bar>i{display:block;height:100%;border-radius:3px}
.alert{flex:1;background:#fff;border:1px solid var(--line);border-radius:10px;padding:10px 14px;font-size:12px;line-height:1.6}
.alert .at{display:flex;align-items:center;gap:7px;font-weight:bold;font-size:12.5px;margin-bottom:4px}

/* ===== 由原型各页 style 抽取的公共组件（去 zoom，改自适应宽度） ===== */
body.px{min-height:100vh}
.nav{min-height:100vh}
.main{min-height:100vh}
.mi{overline:none}
.row{display:flex;align-items:center;padding:0 16px;flex:none;min-height:36px;border-bottom:1px solid var(--line2);font-size:12.5px;text-decoration:none;color:inherit}
.row:last-child{border-bottom:none}
.row.hd{min-height:0;padding:7px 16px;background:#F8FAF9;font-size:11px;color:var(--faint);font-weight:normal}
.row.fill{flex:1;min-height:32px}
.row.sel{background:#F0FDF4;box-shadow:inset 3px 0 0 var(--g)}
.row.miss{background:#FFF9F5}
.row.warn{background:#FFF9F5}
.row:hover{background:#FAFCFB}
.row.plain{cursor:default}
.row.plain:hover{background:transparent}
.rolechip{font-size:10.5px;font-weight:bold;padding:2px 8px;border-radius:5px;background:#F1F5F4;color:var(--sub);border:1px solid var(--line);white-space:nowrap}
.mono{font-family:Consolas,monospace;font-size:11px;color:var(--faint)}
.kh{display:inline-block;font-family:Consolas,monospace;font-size:11px;color:var(--faint);background:#F8FAF9;border:1px solid var(--line);border-radius:5px;padding:1px 7px}
.lvl{font-size:10.5px;font-weight:bold;width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;border-radius:5px;flex-shrink:0}
.lvl.a{background:#ECFDF5;color:#15803D;border:1px solid #A7F3D0}
.lvl.b{background:#F0F9FF;color:#0369A1;border:1px solid #BAE6FD}
.lvl.c{background:#F4F5F6;color:#6B7280;border:1px solid #E1E4E8}
.lvl.d{background:#FFF7ED;color:#C2410C;border:1px solid #FED7AA}
.stg{font-size:11px;padding:2px 8px;border-radius:4px;white-space:nowrap;display:inline-block}
.stg.s1{background:#F4F5F6;color:#6B7280}
.stg.s2{background:#F0FDF4;color:#4D7C0F}
.stg.s3{background:#FEFCE8;color:#A16207}
.stg.s4{background:#FFF7ED;color:#9A3412}
.stg.s5{background:#F0F9FF;color:#0369A1}
.stg.s6{background:#F1F5F4;color:var(--sub)}
.tm{font-size:11px;color:var(--sub);font-variant-numeric:tabular-nums}
.tm.late{color:var(--red);font-weight:bold}
.tl{position:relative;padding:2px 0 2px 26px}
.tl::before{content:"";position:absolute;left:9px;top:10px;bottom:10px;width:2px;background:var(--line2)}
.tn{position:relative;padding:0 0 11px 12px;font-size:12px;line-height:1.55}
.tn:last-child{padding-bottom:2px}
.tn::before{content:"";position:absolute;left:-21px;top:4px;width:8px;height:8px;border-radius:50%;background:#fff;border:2px solid var(--g)}
.tn.warn::before{border-color:var(--red)}
.tn.plan{color:var(--sub)}
.tn .tm{font-size:11px;color:var(--faint);margin-top:1px}
.evib{display:flex;align-items:center;gap:6px}
.evib .b{width:52px;height:5px;border-radius:3px;background:#E5EAE7;overflow:hidden}
.evib .b>i{display:block;height:100%;border-radius:3px}
.todo{padding:9px 14px;border-bottom:1px solid var(--line2)}
.todo:last-child{border-bottom:none}
.task{padding:10px 14px;border-bottom:1px solid var(--line2)}
.task:last-child{border-bottom:none}
.task .t{font-size:12.5px;font-weight:bold;display:flex;align-items:center;justify-content:space-between;gap:8px}
.task .d{font-size:11px;color:var(--faint);margin-top:4px;line-height:1.7}
.el{display:flex;gap:5px;flex-wrap:wrap;margin-top:5px}
.el .e{font-size:10px;padding:1px 6px;border-radius:4px;background:#F1F5F4;color:var(--sub)}
.el .e.ok{background:#ECFDF5;color:#15803D}
.el .e.miss{background:#FEF2F2;color:#DC2626}
.gapbox{padding:12px 14px;border-bottom:1px solid var(--line2)}
.gapbox:last-child{border-bottom:none}
.gapbox .t{font-size:12.5px;font-weight:bold;display:flex;align-items:center;justify-content:space-between;gap:8px}
.gapbox .d{font-size:11px;color:var(--faint);margin-top:5px;line-height:1.7}
.proc{flex:1;padding:0 10px}
.proc .pl{font-size:10.5px;color:var(--faint)}
.proc .pv{font-size:12px;font-weight:bold;margin-top:2px;display:flex;align-items:center;justify-content:space-between}
.week{display:flex;gap:5px;margin-top:8px}
.week .d1{flex:1;text-align:center;font-size:10px;color:var(--faint);padding:3px 0;border-radius:5px;background:#F1F5F4;line-height:1.5}
.week .d1.on{background:#ECFDF5;color:#15803D;font-weight:bold}
.week .d1.hit{background:#16A34A;color:#fff}
.frow{display:flex;gap:12px;padding:0 18px;margin-top:12px}
.fld2{flex:1;min-width:0}
.fld2 label{display:block;font-size:11.5px;color:var(--sub);margin-bottom:5px}
.fld2 label b{color:var(--red);margin-left:2px}
.fld2 input,.fld2 select,.fld2 textarea{width:100%;box-sizing:border-box;height:32px;border:1px solid var(--line);border-radius:7px;padding:0 10px;font-size:12.5px;color:var(--ink);background:#fff;outline:none}
.fld2 textarea{height:58px;padding:8px 10px;resize:vertical;line-height:1.6}
.fld2 input:focus,.fld2 select:focus,.fld2 textarea:focus{border-color:var(--g);box-shadow:0 0 0 2px rgba(22,163,74,.08)}
.fld2 .hint{font-size:10.5px;color:var(--faint);margin-top:4px}
.fld2 .hint.err{color:var(--red)}
.sect{display:flex;align-items:center;gap:8px;padding:14px 18px 0}
.sect .st{font-size:12.5px;font-weight:bold}
.sect .sl{font-size:10.5px;color:var(--faint)}
.opt{font-size:10.5px;color:var(--faint)}
.chiprow{display:flex;gap:6px;margin-top:8px;flex-wrap:wrap}
.indchip{font-size:11px;padding:3px 10px;border:1px solid var(--line);border-radius:6px;color:var(--sub);background:#FAFBFA;cursor:pointer}
.indchip.on{background:#ECFDF5;color:#15803D;border-color:#A7F3D0;font-weight:bold}
.uprow{display:flex;gap:12px;padding:0 18px;margin-top:10px}
.upbox{flex:1;height:62px;border:1px dashed var(--line);border-radius:8px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;font-size:11px;color:var(--faint);background:#FAFBFA}
.upbox b{font-size:12px;color:var(--sub)}
.btn-line{height:34px;border:1px solid var(--line);color:var(--sub);border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:12.5px;background:#fff;cursor:pointer}
.btn-main{flex:1;height:34px;background:var(--g);color:#fff;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:12.5px;font-weight:bold;border:none;cursor:pointer}
.formbar{display:flex;gap:8px;padding:12px 18px;border-top:1px solid var(--line2)}
.note{font-size:11px;color:var(--faint);line-height:1.7}
.warnline{font-size:11px;color:var(--red);background:#FEF2F2;border:1px solid #FECACA;border-radius:7px;padding:7px 10px;margin:0 18px}
.okline{font-size:11px;color:#15803D;background:#ECFDF5;border:1px solid #A7F3D0;border-radius:7px;padding:7px 10px;margin:0 18px}
.scroll{flex:1;min-height:0;overflow:auto}
/* ============================================================
   手机 / 小屏适配（v1.6 追加，≤900px）
   侧栏横向变顶部标签条；卡片纵向堆叠；表格可横向滑动
   ============================================================ */
@media (max-width: 900px){
  html,body{height:auto !important}
  body.px{display:block !important;align-items:initial !important}

  /* 侧栏 → 顶部横向滚动导航 */
  .nav{
    position:sticky;top:0;z-index:50;
    width:100% !important;min-height:0 !important;height:auto !important;
    flex-direction:row !important;flex-wrap:nowrap;
    align-items:center;overflow-x:auto;overflow-y:hidden;
    padding:0 6px;border-bottom:1px solid rgba(0,0,0,.08);
    -webkit-overflow-scrolling:touch;
  }
  .nav::-webkit-scrollbar{display:none}
  .logo,.ng,.navbot{display:none !important}
  .mi{margin:7px 3px;padding:7px 11px;white-space:nowrap;flex:0 0 auto;font-size:13px}
  .mi .ic{width:auto;margin-right:3px}

  /* 主区 */
  .main{min-height:0 !important;width:100%}
  .topbar{height:auto !important;min-height:50px;padding:8px 12px !important;gap:8px;flex-wrap:wrap}
  .tb-t{font-size:15px !important}
  .search,.srch{display:none !important}
  .content{padding:10px 10px 18px !important;gap:8px !important;overflow:visible !important}

  /* 卡片与行：允许换行、允许横向滚动看宽表 */
  .card{overflow-x:auto;-webkit-overflow-scrolling:touch}
  body .px{flex-wrap:wrap;align-items:stretch}
  body .px-col{min-width:0}

  /* KPI 两列 */
  .kpi{flex:1 1 46% !important;min-width:46% !important;padding:10px 12px}
  .kpi .n{font-size:19px !important}
  .alert{flex:1 1 100% !important;min-width:100% !important}

  /* 表格：字号收一点，允许横向滑动，不压列 */
  table{font-size:12px !important;min-width:520px}
  th,td{padding-left:8px !important;padding-right:8px !important}

  /* 表单：两列并排 → 单列 */
  .fld2{flex:1 1 100% !important;min-width:100% !important}
  input,select,textarea{font-size:15px !important}   /* 防 iOS 聚焦放大 */

  /* 按钮做大一点，方便手指点 */
  .btn-g,.btn-o,.segm{height:36px !important;font-size:13px !important}
  .btn-g{padding:0 16px !important}
}
`n
/* 极窄屏再收一档 */
@media (max-width: 420px){
  .content{padding:8px 8px 16px !important}
  .topbar{padding:7px 10px !important}
}

/* 第二轮修正：KPI 行换行 + 禁止整页横向滚动 */
@media (max-width: 900px){
  body{overflow-x:hidden !important}
  .kpis,.pg> .px,body .px{flex-wrap:wrap !important}
  .kpi{
    flex:1 1 calc(50% - 6px) !important;
    min-width:0 !important;
    max-width:calc(50% - 6px) !important;
  }
  .sect-t{flex-wrap:wrap;gap:6px}
  .card>div[style*="display:flex"]{flex-wrap:wrap;gap:6px}
}

/* 第三轮修正：取消内部滚动区，整页自然滚动 */
@media (max-width: 900px){
  html,body{height:auto !important;min-height:0 !important}
  .main{height:auto !important;min-height:0 !important}
  .content{
    overflow:visible !important;
    overflow-y:visible !important;
    overflow-x:visible !important;
    max-height:none !important;
    height:auto !important;
    flex:none !important;
  }
  .pg{min-height:0 !important}
  .nav{position:sticky;top:0}
}

/* 第四轮修正：手机上卡片不再被 flex 拉伸，消灭大片空白 */
@media (max-width: 900px){
  .content>*,.pg>*{flex:none !important}
  .card{flex:none !important;align-self:stretch}
  .two>.card{flex:none !important}
  .kpi{flex:0 0 calc(50% - 6px) !important}
  .alert{flex:0 0 100% !important}
  .card .card{flex:none !important}
}

/* 第五轮修正：满宽 + 不收缩，卡片不再按内容撑宽 */
@media (max-width: 900px){
  .content>*, .pg>*, .card{
    flex:0 0 auto !important;
    width:100% !important;
    max-width:100% !important;
    min-width:0 !important;
  }
  .card{overflow-x:auto !important}
  body .px{width:100% !important;max-width:100% !important}
  table{min-width:0 !important}
  th,td{white-space:nowrap}
}

/* 第六轮修正：左右并排的卡片改为竖向堆叠 */
@media (max-width: 900px){
  .two{flex-direction:column !important;width:100% !important;max-width:100% !important}
  .two>.card{width:100% !important;flex:0 0 auto !important}
  .two{display:flex !important}
  .scroll{box-sizing:border-box !important;max-width:100% !important}
  .sect-t{flex-wrap:wrap}
  .row{gap:6px !important}
}

/* 第七轮修正：列表行保持单行，容器内横向滑动，避免挤歪 */
@media (max-width: 900px){
  .row, .sect-t, .dec{flex-wrap:nowrap !important}
  .row{min-width:0}
  .scroll{overflow-x:auto !important;-webkit-overflow-scrolling:touch}
  .f1{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .bar{min-width:60px}
}

/* 第八轮修正：只让「内容区顶层行」换行，内层微排版一律不换行 */
@media (max-width: 900px){
  body .px{flex-wrap:nowrap !important}
  .content>.px, .content>.kpis, .card>.px{flex-wrap:wrap !important}
  .card>div[style*="display:flex"]{flex-wrap:nowrap !important}
}

/* 第九轮修正：行内标签不折行 */
@media (max-width: 900px){
  .px span, .row span, .rank span, .dec span{white-space:nowrap}
  .px .grow{flex:0 0 6px}
}

/* 第十轮修正：含表单字段的行允许换行（否则第二列被裁掉） */
@media (max-width: 900px){
  .px:has(.fld2), .px:has(input), .px:has(select), .px:has(textarea),
  .px:has(.fld1), .card:has(.fld2){flex-wrap:wrap !important}
  .fld2{flex:1 1 100% !important;min-width:100% !important;max-width:100% !important}
  .fld2 input,.fld2 select,.fld2 textarea{font-size:16px !important} /* 防 iOS 聚焦缩放 */
  .card-h{flex-wrap:wrap !important;gap:6px}
}

/* 第十一轮修正：.frow 表单行换行，每个字段占满一行 */
@media (max-width: 900px){
  .frow{flex-wrap:wrap !important}
  .frow>.fld2,.frow>.fld1{flex:1 1 100% !important;min-width:100% !important;max-width:100% !important}
  .sect{flex-wrap:wrap !important;gap:4px}
}

/* 第十二轮修正：多列布局（.px-col）在手机上竖排 */
@media (max-width: 900px){
  .px:has(> .px-col){flex-direction:column !important;align-items:stretch !important;height:auto !important}
  .px-col{width:100% !important;max-width:100% !important;flex:0 0 auto !important;height:auto !important}
  .px-col>*{flex:none !important}
}

/* 第十三轮修正：步骤条改为可横滑，单步固定宽度不再挤压 */
@media (max-width: 900px){
  .step{overflow-x:auto !important;flex-wrap:nowrap !important;-webkit-overflow-scrolling:touch}
  .step>.s{flex:0 0 118px !important;min-width:118px !important}
  .step .bar1{min-width:0}
}

/* ===== v1.7 追加：表格与栅格（Supabase 静态版） ===== */
.tbl{width:100%;border-collapse:collapse;font-size:12.5px}
.tbl th{font-size:11px;color:var(--faint);font-weight:normal;text-align:left;padding:7px 12px;background:#F8FAF9;border-bottom:1px solid var(--line2);white-space:nowrap}
.tbl td{padding:8px 12px;border-bottom:1px solid var(--line2);vertical-align:middle}
.tbl tr:last-child td{border-bottom:none}
.tbl tr.warn td{background:#FFF9F5}
.tbl tr:hover td{background:#FAFCFB}
.num{font-variant-numeric:tabular-nums}
.num.r{text-align:right}
.mut{color:var(--faint)}
.sm{font-size:11px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.card-body{padding:12px 16px}
@media (max-width:1100px){.grid4{grid-template-columns:1fr 1fr}.grid3{grid-template-columns:1fr 1fr}}
@media (max-width:720px){.grid2,.grid3{grid-template-columns:1fr}.grid4{grid-template-columns:1fr 1fr}.tbl{font-size:12px}.tbl th,.tbl td{padding:6px 8px}
  .tblwrap{overflow-x:auto;-webkit-overflow-scrolling:touch}
  .tblwrap>.tbl{margin:0}}

.tblwrap{width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}
.tblwrap>.tbl{min-width:0}

/* 第三轮修正（v1.7 全量版）：窄屏只在表格自己的滚动容器里横向滑动，卡片不再裁切 */
@media (max-width:900px){
  .card{overflow-x:visible !important}
  .tblwrap{overflow-x:auto !important;max-width:100%}
  .tblwrap>.tbl{width:max-content;min-width:100%}
  .kpi{min-width:0 !important}
}