:root{
  --bg:#f4f5f7; --card:#ffffff; --fg:#0f172a; --muted:#64748b; --muted2:#94a3b8;
  --border:#e6e8ec; --border2:#eef0f3;
  --primary:#1e63d6; --primary2:#1b52c9; --primary-fg:#ffffff;
  --blue-50:#eef4ff; --blue-100:#e0ebff; --blue-600:#1e63d6; --blue-700:#1b52c9;
  --orange:#f97316; --orange-bg:#fff2e6; --green:#16a34a; --green-bg:#e9f9ef;
  --red:#e11d48; --red-bg:#fdecef; --amber:#d97706; --amber-bg:#fff6e5; --purple:#7c3aed;
  --radius:14px; --radius-sm:10px;
  --shadow:0 1px 2px rgba(16,24,40,.04),0 1px 3px rgba(16,24,40,.06);
  --shadow-lg:0 10px 30px rgba(20,60,120,.10);
  --hero:linear-gradient(135deg,#1e63d6 0%,#2f6fe0 48%,#3b82f6 100%);
  --maxw:480px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;padding:0}
body{background:var(--bg);color:var(--fg);font-family:"Geist","PingFang HK","Microsoft JhengHei",-apple-system,system-ui,"Noto Sans TC",sans-serif;font-size:15px;line-height:1.55;-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
button{font-family:inherit}
.ico{width:24px;height:24px;display:inline-block;vertical-align:middle;flex:none}
img{max-width:100%}
[hidden]{display:none!important}

/* app frame — mobile centered */
#app{max-width:var(--maxw);margin:0 auto;min-height:100vh;background:var(--bg);position:relative;box-shadow:0 0 0 1px var(--border2)}
.page{padding:0 16px 96px;animation:fade .18s ease}
@keyframes fade{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
.muted{color:var(--muted)}
.small{font-size:12.5px}

/* top bar */
.topbar{position:sticky;top:0;z-index:30;display:flex;align-items:center;justify-content:space-between;padding:10px 16px;background:rgba(255,255,255,.86);backdrop-filter:blur(10px);border-bottom:1px solid var(--border2)}
.topbar .brand{display:flex;align-items:center;gap:8px;font-weight:800;color:var(--primary);font-size:16px}
.topbar .brand img{width:30px;height:30px;border-radius:7px}
.lang{display:flex;align-items:center;gap:5px;border:1px solid var(--border);border-radius:999px;padding:5px 12px;font-size:13px;color:#334155;background:#fff}
.backbar{position:sticky;top:0;z-index:30;display:flex;align-items:center;gap:8px;padding:12px 14px;background:rgba(255,255,255,.9);backdrop-filter:blur(10px);border-bottom:1px solid var(--border2);font-weight:700}
.backbar .bk{display:flex;align-items:center;justify-content:center;width:34px;height:34px;margin-left:-4px;border-radius:9px}
.backbar .bk:active{background:var(--blue-50)}

/* hero */
.hero{background:var(--hero);color:#fff;border-radius:20px;padding:18px 18px 16px;margin:14px 0 6px;box-shadow:var(--shadow-lg);position:relative;overflow:hidden}
.hero::after{content:"";position:absolute;right:-40px;top:-40px;width:170px;height:170px;background:rgba(255,255,255,.10);border-radius:50%}
.hero .greet{font-size:19px;font-weight:800;letter-spacing:.3px}
.hero .sub{display:flex;align-items:center;gap:8px;margin-top:7px}
.hero .chip{background:rgba(255,255,255,.20);border-radius:999px;padding:3px 11px;font-size:12.5px;font-weight:600}
.hero .avatar{position:absolute;right:18px;top:18px;width:52px;height:52px;border-radius:50%;border:2px solid rgba(255,255,255,.5);object-fit:cover;background:rgba(255,255,255,.25)}
.hero .stats{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin-top:16px}
.hero .stat{text-align:center}
.hero .stat b{display:block;font-size:22px;font-weight:800;line-height:1.1}
.hero .stat span{font-size:11.5px;opacity:.9}
.hero .stat+.stat{border-left:1px solid rgba(255,255,255,.22)}

/* section */
.sec-title{font-size:15px;font-weight:800;margin:20px 2px 10px;color:#1e293b}
.card{background:var(--card);border:1px solid var(--border2);border-radius:var(--radius);box-shadow:var(--shadow)}
.grid-card{background:var(--card);border:1px solid var(--border2);border-radius:18px;box-shadow:var(--shadow);padding:16px 8px}

/* icon grid */
.igrid{display:grid;grid-template-columns:repeat(4,1fr);gap:6px 4px}
.icell{display:flex;flex-direction:column;align-items:center;gap:7px;padding:8px 2px;border-radius:12px}
.icell:active{background:var(--blue-50)}
.itile{width:50px;height:50px;border-radius:15px;display:flex;align-items:center;justify-content:center;background:var(--blue-50);color:var(--primary)}
.itile .ico{width:24px;height:24px}
.icell span{font-size:12px;color:#334155;text-align:center;line-height:1.25}
.itile.orange{background:var(--orange-bg);color:var(--orange)}
.itile.green{background:var(--green-bg);color:var(--green)}
.itile.purple{background:#f2ecff;color:var(--purple)}

/* bottom nav */
.tabbar{position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:100%;max-width:var(--maxw);display:grid;grid-template-columns:repeat(5,1fr);background:rgba(255,255,255,.96);backdrop-filter:blur(12px);border-top:1px solid var(--border2);z-index:40;padding-bottom:env(safe-area-inset-bottom)}
.tab{display:flex;flex-direction:column;align-items:center;gap:3px;padding:9px 0 8px;color:var(--muted2);font-size:11px}
.tab .ico{width:23px;height:23px}
.tab.active{color:var(--primary)}
.tab .center{margin-top:-16px;width:46px;height:46px;border-radius:50%;background:var(--hero);color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 6px 16px rgba(30,99,214,.4)}
.tab.center-tab.active{color:var(--primary)}

/* lists */
.list{display:flex;flex-direction:column;gap:10px;margin-top:12px}
.row{background:var(--card);border:1px solid var(--border2);border-radius:var(--radius);box-shadow:var(--shadow);padding:13px 14px}
.row-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px}
.row .name{font-weight:700}
.row .meta{color:var(--muted);font-size:12.5px;margin-top:3px}
.badge{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;font-weight:600;padding:3px 9px;border-radius:999px;white-space:nowrap}
.b-blue{background:var(--blue-50);color:var(--primary)}
.b-green{background:var(--green-bg);color:var(--green)}
.b-amber{background:var(--amber-bg);color:var(--amber)}
.b-red{background:var(--red-bg);color:var(--red)}
.b-gray{background:#f1f5f9;color:#64748b}
.b-purple{background:#f2ecff;color:var(--purple)}

/* stat tiles row */
.tiles{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-top:12px}
.tiles.c3{grid-template-columns:repeat(3,1fr)}
.tiles.c4{grid-template-columns:repeat(4,1fr)}
.tile{background:var(--card);border:1px solid var(--border2);border-radius:var(--radius);box-shadow:var(--shadow);padding:13px}
.tile b{display:block;font-size:21px;font-weight:800}
.tile .lb{font-size:12px;color:var(--muted);margin-top:2px}
.tile.grad{background:var(--hero);color:#fff;border:none}
.tile.grad .lb{color:rgba(255,255,255,.85)}

/* segmented tabs */
.segs{display:flex;gap:6px;background:#eef1f5;border-radius:12px;padding:4px;margin:14px 0 4px;overflow-x:auto}
.seg{flex:1;text-align:center;padding:8px 12px;border-radius:9px;font-size:13.5px;font-weight:600;color:#64748b;white-space:nowrap}
.seg.active{background:#fff;color:var(--primary);box-shadow:var(--shadow)}

/* forms / buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;padding:13px;border-radius:12px;background:var(--hero);color:#fff;border:none;font-size:15px;font-weight:700;box-shadow:0 6px 16px rgba(30,99,214,.28)}
.btn:active{transform:translateY(1px)}
.btn.ghost{background:#fff;color:var(--primary);border:1px solid var(--border);box-shadow:none}
.btn.sm{width:auto;padding:8px 14px;font-size:13px;border-radius:10px}
.field{margin-top:14px}
.field label{font-size:12.5px;color:var(--muted);margin-bottom:6px;display:block}
.input{width:100%;border:1px solid var(--border);border-radius:11px;padding:12px 13px;font-size:15px;background:#fff;outline:none}
.input:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(30,99,214,.12)}

/* login */
.login-wrap{max-width:var(--maxw);margin:0 auto;min-height:100vh;background:#fff;display:flex;flex-direction:column}
.login-top{background:var(--hero);color:#fff;padding:46px 26px 40px;text-align:center;border-radius:0 0 26px 26px}
.login-top .logo{width:66px;height:66px;border-radius:18px;background:#fff;display:flex;align-items:center;justify-content:center;margin:0 auto 16px;box-shadow:var(--shadow-lg)}
.login-top .logo img{width:44px;height:44px}
.login-top h1{font-size:22px;font-weight:800;margin:0}
.login-top .en{font-size:12px;letter-spacing:3px;opacity:.8;margin-top:10px}
.login-body{padding:26px 24px;flex:1}
.login-body h2{font-size:24px;font-weight:800;margin:6px 0 4px}
.login-icon{width:52px;height:52px;border-radius:14px;background:#eef0ff;color:#4f46e5;display:flex;align-items:center;justify-content:center;margin-bottom:8px}
.err{color:var(--red);font-size:13px;margin-top:10px;min-height:16px}

/* misc */
.pill-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.kv{display:flex;justify-content:space-between;padding:11px 0;border-bottom:1px solid var(--border2);font-size:14px}
.kv:last-child{border-bottom:none}
.kv .k{color:var(--muted)}
.kv .v{font-weight:600;text-align:right}
.empty{text-align:center;color:var(--muted2);padding:48px 20px}
.empty .ico{width:40px;height:40px;opacity:.5;margin-bottom:10px}
.hero-card{background:var(--hero);color:#fff;border-radius:18px;padding:18px;box-shadow:var(--shadow-lg);margin-top:14px}
.progress{height:7px;border-radius:6px;background:#e8edf5;overflow:hidden;margin-top:8px}
.progress>i{display:block;height:100%;background:var(--hero);border-radius:6px}
.toast{position:fixed;left:50%;bottom:96px;transform:translateX(-50%);background:#0f172a;color:#fff;padding:10px 18px;border-radius:999px;font-size:13.5px;z-index:100;opacity:0;transition:opacity .2s;pointer-events:none;max-width:88%}
.toast.show{opacity:.96}
.spinner{width:26px;height:26px;border:3px solid var(--blue-100);border-top-color:var(--primary);border-radius:50%;animation:spin .7s linear infinite;margin:60px auto}
@keyframes spin{to{transform:rotate(360deg)}}
.section-lead{background:var(--card);border:1px solid var(--border2);border-radius:var(--radius);box-shadow:var(--shadow);padding:16px;margin-top:14px}
.coming{display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;padding:60px 24px;gap:14px}
.coming .big{width:78px;height:78px;border-radius:22px;background:var(--blue-50);color:var(--primary);display:flex;align-items:center;justify-content:center}
.coming .big .ico{width:38px;height:38px}

/* tool iframe wrapper */
.toolhdr{position:sticky;top:0;z-index:30;display:flex;align-items:center;justify-content:space-between;height:56px;padding:0 12px;background:var(--hero);color:#fff}
.toolhdr .bk{display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:9px}
.toolhdr .bk:active{background:rgba(255,255,255,.15)}
.toolhdr .tt{font-size:17px;font-weight:700}
.toolframe{position:relative;height:calc(100dvh - 56px - 64px);width:100%;background:#fff}
.toolframe iframe{display:block;width:100%;height:100%;border:0}

/* icon count badge (AI 小秘書) */
.itile{position:relative}
.itile .cnt{position:absolute;top:-6px;right:-6px;min-width:20px;height:20px;padding:0 5px;border-radius:999px;background:var(--red);color:#fff;font-size:11px;font-weight:700;display:flex;align-items:center;justify-content:center;box-shadow:0 1px 3px rgba(0,0,0,.2)}
.divider{height:1px;background:var(--border2)}

/* assistant chat bar */
.chatbar{position:fixed;left:50%;transform:translateX(-50%);bottom:64px;width:100%;max-width:var(--maxw);background:rgba(255,255,255,.97);backdrop-filter:blur(10px);border-top:1px solid var(--border2);padding:10px 12px;z-index:35}
.chatbar-in{display:flex;gap:8px;align-items:center}
.chatbar-in input{flex:1;border:1px solid var(--border);border-radius:11px;padding:11px 12px;font-size:15px;outline:none}
.chatbar-in input:focus{border-color:var(--primary)}
.qexp{width:38px;height:38px;flex:none;border:1px solid var(--border);border-radius:10px;background:#fff;color:#334155;display:flex;align-items:center;justify-content:center}
.quickq{display:flex;gap:8px;flex-wrap:wrap;padding-bottom:10px}
.chatlog .bubble{max-width:86%;padding:11px 14px;border-radius:14px;white-space:pre-wrap;line-height:1.6;font-size:14px}
.chatlog .bubble.me{align-self:flex-end;background:#e8eefc;color:#0f172a;border-bottom-right-radius:4px}
.chatlog .bubble.ai{align-self:flex-start;background:#fff;border:1px solid var(--border2);border-bottom-left-radius:4px}

/* team page */
.gencards{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin-top:12px}
.gencard{border-radius:12px;padding:11px 10px}
.gencard b{font-size:19px;font-weight:800;display:block;line-height:1.1;margin-top:2px}
.gc-blue{background:#eaf1fe;color:#1e63d6}
.gc-purple{background:#f1ecfe;color:#7c3aed}
.gc-teal{background:#e6f7f4;color:#0d9488}
.legend{display:flex;gap:16px;margin:14px 2px 6px;font-size:12.5px;color:#64748b}
.legend span{display:flex;align-items:center;gap:5px}
.lg{width:10px;height:10px;border-radius:3px;display:inline-block}
.lg-blue{background:#1e63d6}.lg-orange{background:#f97316}.lg-green{background:#16a34a}.lg-gray{background:#cbd5e1}
.orgtree{margin-top:6px}
.node{position:relative}
.children{margin-left:18px;padding-left:16px;border-left:2px solid #dbe4f2}
.node-card{background:#fff;border:1px solid var(--border2);border-radius:12px;box-shadow:var(--shadow);padding:11px 13px;margin-top:8px;display:flex;justify-content:space-between;align-items:center;gap:8px}
.node-card.me{background:var(--hero);color:#fff;border:none}
.node-card.inst{background:#fff7ed;border-color:#fed7aa}
.node-card.active{border-left:3px solid #16a34a}
.node-card.idle{border-left:3px solid #cbd5e1}
.node-card .nm{font-weight:700;font-size:14.5px}
.node-card.me .nm{color:#fff}
.node-card .rk{font-size:12px;color:#94a3b8;margin-top:2px}
.node-card.me .rk{color:rgba(255,255,255,.85)}
.node-card.inst .rk{color:#c2731c}
.nb{display:flex;align-items:center;gap:3px;font-size:12.5px;font-weight:700;color:#1e63d6;white-space:nowrap}
.node-card.me .nb{color:#fff}
.nbchev{width:16px;height:16px}
.nbx{color:#cbd5e1;display:flex}
.nbx .ico{width:18px;height:18px}

/* products page */
.psearch{display:flex;gap:8px;margin-top:12px}
.psearch input{flex:1;border:1px solid var(--border);border-radius:11px;padding:11px 12px;font-size:14px;outline:none}
.psearch input:focus{border-color:var(--primary)}
.pfilters{display:grid;grid-template-columns:1fr 1fr 1fr;gap:8px;margin-top:10px}
.pfilters select{border:1px solid var(--border);border-radius:10px;padding:9px 8px;font-size:13px;background:#fff;color:#334155}
.pchecks{display:flex;gap:14px;flex-wrap:wrap;margin-top:10px;font-size:13px;color:#475569}
.pchecks label{display:flex;align-items:center;gap:5px}
.plist{margin-top:10px;display:flex;flex-direction:column;gap:10px}
.prod{background:#fff;border:1px solid var(--border2);border-radius:12px;box-shadow:var(--shadow);padding:13px 14px}
.prod .pname{font-weight:700;font-size:14.5px}
.prod .pmeta{color:var(--muted);font-size:12.5px;margin-top:4px;display:flex;align-items:center;gap:4px;flex-wrap:wrap}
.pfi{width:14px;height:14px;vertical-align:-2px}
.pacts{display:flex;gap:8px;margin-top:11px}
.pact{flex:1;position:relative;display:flex;align-items:center;justify-content:center;gap:5px;border:1px solid var(--border);border-radius:9px;background:#fff;color:var(--primary);padding:8px 4px;font-size:12.5px;font-weight:600;cursor:pointer}
.pact:active{background:var(--blue-50)}
.pai{width:15px;height:15px}
.pab{position:absolute;top:-7px;right:-4px;min-width:17px;height:17px;padding:0 4px;border-radius:999px;background:var(--red);color:#fff;font-size:10px;font-weight:700;display:flex;align-items:center;justify-content:center}
.ppage{display:flex;justify-content:space-between;align-items:center;margin-top:16px}
.ppage button[disabled]{opacity:.4}

/* customers page */
.cacts{display:flex;gap:8px;margin-top:12px}
.cact{flex:1;position:relative;display:flex;align-items:center;justify-content:center;gap:5px;border:1px solid var(--border);border-radius:11px;background:#fff;color:#334155;padding:11px 4px;font-size:12.5px;font-weight:600;cursor:pointer}
.cact.hl{color:var(--orange);border-color:#fed7aa;background:#fff7ed}
.cstats{display:flex;gap:18px;margin-top:14px;font-size:13px;color:#64748b;padding:0 2px}
.cstats b{color:var(--fg);font-size:15px;margin-left:3px}
.clist{margin-top:12px;display:flex;flex-direction:column;gap:10px}
.cust{background:#fff;border:1px solid var(--border2);border-radius:12px;box-shadow:var(--shadow);padding:12px 14px;display:flex;align-items:center;gap:12px}
.cav{width:44px;height:44px;border-radius:12px;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:17px;flex:none}
.cust .cname{font-weight:700}
.cust .cmeta{color:var(--muted);font-size:12.5px;margin-top:3px}
.callbtn{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:10px;background:var(--blue-50);color:var(--primary);margin-top:8px}
.cbi{width:17px;height:17px}
