:root{
  --navy:#020870; --text:#0B2540; --orange:#FF5722; --orange-text:#D84315;
  --bg:#F6F7F9; --surface:#FFFFFF; --line:#E4E7EC; --line2:#D5DAE1; --muted:#5B6676; --soft:#F1F3F6;
  --draft-bg:#FFF1E6; --draft-fg:#B3360F; --sent-bg:#E2F3EA; --sent-fg:#17663A; --sent-dot:#22A05A;
  --radius:14px;
  --font:-apple-system,BlinkMacSystemFont,"SF Pro Text","Helvetica Neue",Roboto,Arial,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font);-webkit-font-smoothing:antialiased}
body{min-height:100vh;padding-bottom:env(safe-area-inset-bottom)}
a{color:var(--text)}a:hover{color:var(--orange-text)}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
input[type=checkbox]{accent-color:var(--navy);width:18px;height:18px;margin:0;flex:none}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
.boot{min-height:100vh;display:flex;align-items:center;justify-content:center}
.boot img{width:160px;opacity:.9}

/* Buttons */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:10px;height:46px;padding:0 20px;border-radius:12px;border:1px solid var(--line2);background:#fff;color:var(--text);font-size:15px;font-weight:500;text-decoration:none;white-space:nowrap}
.btn:hover{color:var(--text);border-color:#B9C0CB}
.btn-primary{background:var(--navy);border-color:var(--navy);color:#fff}
.btn-primary:hover{color:#fff;background:#0A1590}
.btn-ghost{border:none;background:none;padding:0 6px;height:44px;text-decoration:underline;font-weight:400}
.btn-danger{color:var(--draft-fg)}
.btn[disabled]{opacity:.55;cursor:default}
.icon-btn{width:40px;height:40px;border-radius:10px;border:1px solid var(--line);background:#fff;display:inline-flex;align-items:center;justify-content:center;color:var(--text);text-decoration:none}
.icon-btn:hover{color:var(--text);border-color:#B9C0CB}

/* Layout */
.shell{display:flex;min-height:100vh}
.side{width:248px;flex:none;background:#fff;border-right:1px solid var(--line);padding:24px 18px;display:flex;flex-direction:column;gap:28px;position:sticky;top:0;height:100vh}
.brand{display:flex;align-items:center;gap:8px}
.brand img{width:104px;height:39px;object-fit:contain;object-position:left center;margin-left:-8px}
.badge{font-size:12px;font-weight:500;color:var(--muted);background:var(--soft);border-radius:6px;padding:3px 8px}
.nav{display:flex;flex-direction:column;gap:4px}
.nav a{display:flex;align-items:center;gap:12px;padding:11px 12px;border-radius:10px;text-decoration:none;font-size:15px}
.nav a.on{background:var(--navy);color:#fff;font-weight:500}
.me{margin-top:auto;display:flex;align-items:center;gap:10px;padding:10px;border-radius:12px;background:var(--bg)}
.avatar{width:36px;height:36px;border-radius:50%;background:var(--navy);color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;flex:none}
.avatar.soft{background:#E8ECF2;color:var(--text)}
.me small{display:block;color:var(--muted);font-size:12px}
.main{flex:1;min-width:0;padding:36px 44px 80px}
.page-head{display:flex;flex-wrap:wrap;align-items:flex-end;justify-content:space-between;gap:16px;margin-bottom:24px}
h1{margin:0;font-size:30px;letter-spacing:-.02em}
.sub{margin:6px 0 0;color:var(--muted);font-size:15px}
.tabbar{display:none}

/* Chips & status */
.chips{display:flex;flex-wrap:wrap;gap:8px}
.chip{height:36px;padding:0 14px;border-radius:999px;border:1px solid var(--line);background:#fff;font-size:14px}
.chip.on{background:var(--navy);border-color:var(--navy);color:#fff}
.st{display:inline-flex;align-items:center;gap:6px;font-size:13px;font-weight:500;padding:5px 10px;border-radius:999px;border:none;white-space:nowrap}
.st .dot{width:7px;height:7px;border-radius:50%}
.st.draft{background:var(--draft-bg);color:var(--draft-fg)}.st.draft .dot{background:var(--orange)}
.st.sent{background:var(--sent-bg);color:var(--sent-fg)}.st.sent .dot{background:var(--sent-dot)}
button.st.draft:hover{outline:2px solid #FFD2BD}

/* Toolbar */
.toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;margin-bottom:16px}
.search{flex:1 1 260px;max-width:420px;display:flex;align-items:center;gap:10px;height:44px;padding:0 14px;background:#fff;border:1px solid var(--line);border-radius:12px}
.search input{border:none;outline:none;flex:1;min-width:0;background:transparent;font-size:15px}

/* Table */
.card{background:#fff;border:1px solid var(--line);border-radius:16px}
.table-wrap{overflow-x:auto}
table.list{width:100%;min-width:860px;border-collapse:collapse;font-size:14px}
table.list th{text-align:left;color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.06em;font-weight:500;padding:14px 12px}
table.list th:first-child,table.list td:first-child{padding-left:20px}
table.list td{padding:16px 12px;border-top:1px solid #EEF0F3;vertical-align:middle}
table.list tr.row{cursor:pointer}
table.list tr.row:hover td{background:#FAFBFC}
.cell-main{display:flex;flex-direction:column;gap:3px}
.cell-main b{font-weight:500;font-size:15px}
.cell-main span,.muted{color:var(--muted);font-size:13px}
.lang{display:inline-block;min-width:26px;text-align:center;font-size:12px;font-weight:700;padding:4px 6px;border-radius:6px;background:var(--soft)}
.acts{display:flex;justify-content:flex-end;gap:6px}
.cards{display:none}
.empty{padding:48px 20px;text-align:center;color:var(--muted)}

/* Builder */
.bhead{background:#fff;border-bottom:1px solid var(--line);padding:14px 32px;display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:14px;position:sticky;top:0;z-index:5}
.bhead .left{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.bhead .title{display:flex;flex-direction:column;gap:4px}
.bhead .title b{font-size:19px}
.total{display:flex;flex-direction:column;align-items:flex-end}
.total small{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.total b{font-size:24px;color:var(--orange);letter-spacing:-.01em}
.bhead .right{display:flex;align-items:center;gap:16px;flex-wrap:wrap}
.bbody{padding:28px 32px 120px;display:flex;flex-wrap:wrap;gap:28px;align-items:flex-start}
.form{flex:1 1 520px;min-width:0;max-width:700px;display:flex;flex-direction:column;gap:18px}
.form fieldset{border:none;margin:0;padding:0;display:flex;flex-direction:column;gap:18px;min-width:0}
.sec{background:#fff;border:1px solid var(--line);border-radius:16px;padding:22px;display:flex;flex-direction:column;gap:16px}
.sec h2{margin:0;font-size:17px}
.sec h2 .n{color:var(--orange-text);margin-right:8px}
.sec-head{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap}
.row2{display:flex;flex-wrap:wrap;gap:12px}
.field{display:flex;flex-direction:column;gap:6px;font-size:13px;color:var(--muted)}
.row2>.field{flex:1 1 200px}
.field input,.field select,.field textarea{height:46px;border:1px solid var(--line2);border-radius:10px;padding:0 14px;font-size:15px;color:var(--text);background:#fff;width:100%}
.field textarea{height:auto;padding:12px 14px;resize:vertical;line-height:1.45}
.field input:focus,.field select:focus,.field textarea:focus,.search:focus-within{outline:2px solid #C7CBF5;border-color:var(--navy)}
.hint{font-size:13px;color:var(--muted);margin:0}
.seg{display:grid;gap:4px;background:var(--soft);padding:4px;border-radius:12px}
.seg.c2{grid-template-columns:repeat(2,minmax(0,1fr))}.seg.c3{grid-template-columns:repeat(3,minmax(0,1fr))}
.seg button{height:42px;border:none;border-radius:9px;background:transparent;font-size:15px}
.seg button.on{background:#fff;font-weight:700;box-shadow:0 1px 3px rgba(11,37,64,.12)}
.ptabs{display:flex;flex-wrap:wrap;gap:8px}
.ptab{min-height:52px;padding:8px 16px;border-radius:12px;border:1px solid var(--line2);background:#fff;text-align:left;display:flex;flex-direction:column;gap:2px}
.ptab b{font-size:14px}.ptab span{font-size:13px;opacity:.85}
.ptab.on{background:var(--navy);border-color:var(--navy);color:#fff}
.dashed{border:1px dashed #A9B2BF !important;background:#fff}
.item{border:1px solid var(--line);border-radius:16px;padding:18px;display:flex;flex-direction:column;gap:14px}
.item-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px}
.item-head b{font-size:16px}
.item-head .price{font-size:17px;font-weight:700;white-space:nowrap}
.steps{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.step{background:var(--bg);border-radius:14px;padding:12px 14px;display:flex;flex-direction:column;gap:8px}
.step .top{display:flex;flex-wrap:wrap;gap:2px 8px;justify-content:space-between;align-items:baseline;font-size:15px;font-weight:500}
.step .top small{font-size:13px;color:var(--muted);font-weight:400}
.step .ctl{display:flex;align-items:center;justify-content:space-between}
.step .ctl b{font-size:28px;min-width:48px;text-align:center}
.pm{width:44px;height:44px;border-radius:12px;border:1px solid var(--line2);background:#fff;font-size:22px;line-height:1}
.pm.plus{background:var(--navy);border-color:var(--navy);color:#fff}
.checks{display:flex;flex-direction:column}
.check{display:flex;align-items:center;gap:12px;min-height:42px;font-size:15px;cursor:pointer}
.check .r{margin-left:auto;font-size:14px;color:var(--muted)}
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:2px 16px}
.grid2 .check{font-size:14px;min-height:40px}
.picker{border:1px solid var(--navy);border-radius:16px;padding:16px;display:flex;flex-direction:column;gap:12px}
.picker .grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
.pick{min-height:56px;padding:10px 12px;border-radius:12px;border:1px solid var(--line);background:#fff;text-align:left;display:flex;flex-direction:column;gap:2px}
.pick b{font-size:14px;font-weight:500}.pick span{font-size:12px;color:var(--muted)}
.pick[disabled]{background:var(--bg);opacity:.6;cursor:default}
.formula{font-size:13px;color:var(--muted)}
.banner{border-radius:14px;padding:14px 16px;display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;font-size:14px}
.banner.sent{background:var(--sent-bg);color:var(--sent-fg)}
.banner.info{background:#EEF0F8;color:var(--navy)}

/* Preview */
.preview{flex:1 1 460px;min-width:0;display:flex;flex-direction:column;gap:10px;position:sticky;top:96px}
.preview-head{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;font-weight:500}
.sheet{background:#fff;border-radius:6px;box-shadow:0 1px 2px rgba(11,37,64,.06),0 12px 32px rgba(11,37,64,.08);padding:38px 44px 48px;max-width:640px;width:100%;font-family:Arial,Helvetica,sans-serif;font-size:12.5px;line-height:1.55;color:#1F2A37;display:flex;flex-direction:column;gap:16px;max-height:calc(100vh - 150px);overflow:auto}
.sheet .logo{display:flex;justify-content:flex-end}.sheet .logo img{width:96px;height:36px;object-fit:contain;object-position:right center;margin-right:-8px}
.sheet h3{margin:0;font-size:23px;color:var(--navy)}
.sheet h4{margin:0 0 4px;font-size:14px;color:var(--navy)}
.sheet ul{margin:0;padding-left:18px}
.sheet table{width:100%;border-collapse:collapse;font-size:11.5px;margin-top:4px}
.sheet th{background:var(--navy);color:#fff;text-align:left;padding:7px 8px}
.sheet td{padding:8px;border:1px solid var(--line);vertical-align:top}
.sheet .pkg{font-weight:700;font-size:13px;margin-top:6px}
.sheet .note b{display:block;margin-top:6px}
.sheet .addl-note{font-style:italic;font-size:11.5px;color:var(--muted);margin-top:6px}
.filepath{display:flex;align-items:center;gap:8px;font-size:13px;color:var(--muted)}
.mobile-bar,.preview-toggle{display:none}

/* Settings */
.stabs{display:flex;flex-wrap:wrap;gap:4px;border-bottom:1px solid var(--line);margin-bottom:22px}
.stabs button{height:46px;padding:0 16px;border:none;background:none;font-size:15px;border-bottom:3px solid transparent;margin-bottom:-1px}
.stabs button.on{font-weight:700;border-bottom-color:var(--orange)}
.price-cards{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:14px;margin-bottom:20px}
.price-cards .card{padding:20px;display:flex;flex-direction:column;gap:10px}
.money{display:flex;align-items:center;gap:8px;height:52px;border:1px solid var(--line2);border-radius:12px;padding:0 14px}
.money input{border:none;outline:none;font-size:24px;font-weight:700;width:100%;min-width:0}
.list-rows .lr{display:flex;align-items:center;gap:14px;padding:14px 20px;border-top:1px solid #EEF0F3;flex-wrap:wrap}
.list-rows .lr:first-child{border-top:none}
.lr .grow{flex:1 1 220px;min-width:0;display:flex;flex-direction:column;gap:3px}
.lr .grow b{font-weight:500;font-size:15px}
.pill{font-size:12px;font-weight:500;padding:4px 10px;border-radius:999px;background:var(--soft)}
.pill.warn{background:var(--draft-bg);color:var(--draft-fg)}
.pill.ok{background:var(--sent-bg);color:var(--sent-fg)}

/* Login */
.login{min-height:100vh;background:var(--navy);color:#fff;display:flex;align-items:center;justify-content:center;padding:32px 24px}
.login-in{width:100%;max-width:380px;display:flex;flex-direction:column;gap:56px}
.login img{width:190px;margin-left:-22px}
.login .tag{color:#B9C1F0;font-size:15px;margin-top:6px;letter-spacing:.04em}
.login h1{font-size:32px;line-height:1.15;color:#fff}
.login p{color:#D3D8F5;font-size:16px;line-height:1.5;margin:14px 0 0}
.login .gbtn{min-height:44px;display:flex;justify-content:center}
.login .note{color:#B9C1F0;font-size:13px;text-align:center;margin:12px 0 0}
.login .err{background:#fff;color:var(--draft-fg);border-radius:12px;padding:12px 14px;font-size:14px}

/* Modal & toast */
.overlay{position:fixed;inset:0;background:rgba(2,8,112,.35);display:flex;justify-content:center;align-items:flex-start;padding:12vh 16px 16px;z-index:50;overflow:auto}
.modal{width:100%;max-width:520px;background:#fff;border-radius:20px;padding:28px;display:flex;flex-direction:column;gap:18px;box-shadow:0 24px 64px rgba(2,8,112,.25)}
.modal h3{margin:0;font-size:20px}
.modal .done-head{display:flex;align-items:center;gap:14px}
.ok-circle{width:44px;height:44px;border-radius:50%;background:var(--orange);display:inline-flex;align-items:center;justify-content:center;flex:none}
.spinner{width:28px;height:28px;border-radius:50%;border:3px solid #FFE1D6;border-top-color:var(--orange);animation:spin .9s linear infinite;flex:none}
@keyframes spin{to{transform:rotate(360deg)}}
.stack{display:flex;flex-direction:column;gap:10px}
.sentbox{display:flex;align-items:center;gap:12px;padding:14px 16px;border-radius:12px;background:var(--bg);cursor:pointer}
#toast{position:fixed;left:50%;bottom:28px;transform:translateX(-50%);background:var(--text);color:#fff;padding:12px 18px;border-radius:12px;font-size:14px;opacity:0;pointer-events:none;transition:opacity .2s;z-index:60;max-width:90vw}
#toast.show{opacity:1}
#toast.err{background:var(--draft-fg)}

/* Mobile */
@media (max-width:860px){
  .side{display:none}
  .main{padding:calc(20px + env(safe-area-inset-top)) 18px 110px}
  .tabbar{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));position:fixed;left:0;right:0;bottom:0;background:#fff;border-top:1px solid var(--line);padding:6px 0 calc(8px + env(safe-area-inset-bottom));z-index:20}
  .tabbar a{display:flex;flex-direction:column;align-items:center;gap:3px;text-decoration:none;font-size:12px;color:var(--muted);padding:4px 0}
  .tabbar a.on{color:var(--navy);font-weight:700}
  .mtop{display:flex !important;justify-content:space-between;align-items:center;margin-bottom:14px}
  .mtop img{width:92px;height:34px;object-fit:contain;object-position:left center;margin-left:-10px}
  .page-head .btn-primary.new{display:none}
  .fab{display:flex !important}
  .table-wrap{display:none}
  .cards{display:flex;flex-direction:column;gap:10px}
  .card.lcard{padding:16px;display:flex;flex-direction:column;gap:10px;text-decoration:none}
  .lcard .r1,.lcard .r2{display:flex;justify-content:space-between;align-items:center;gap:10px}
  .lcard b{font-size:16px}
  .chips{flex-wrap:nowrap;overflow-x:auto}
  .chip{flex:none}
  .bhead{padding:calc(10px + env(safe-area-inset-top)) 16px 10px}
  .bhead .right{display:none}
  .bbody{padding:16px 14px 130px}
  .sec{padding:18px}
  .steps{gap:10px}
  .grid2,.picker .grid{grid-template-columns:1fr}
  .preview{display:none;position:static}
  .preview.open{display:flex}
  .sheet{padding:26px 22px;max-height:none}
  .preview-toggle{display:flex}
  .mobile-bar{display:flex;position:fixed;left:0;right:0;bottom:0;background:#fff;border-top:1px solid var(--line);padding:12px 16px calc(12px + env(safe-area-inset-bottom));align-items:center;justify-content:space-between;gap:12px;z-index:20}
  .mobile-bar .total b{font-size:20px}
  .mobile-bar .total{align-items:flex-start}
  .overlay{padding-top:8vh}
}
.mtop,.fab{display:none}
.fab{position:fixed;right:18px;bottom:calc(86px + env(safe-area-inset-bottom));width:60px;height:60px;border-radius:20px;background:var(--orange);align-items:center;justify-content:center;box-shadow:0 10px 24px rgba(255,87,34,.35);z-index:21}
