/* ============ 设计变量 ============ */
:root{
  --bg:#F4F6FA;
  --surface:#FFFFFF;
  --surface-2:#F8F9FC;
  --border:#E8EBF2;
  --border-strong:#DAE0EC;
  --text:#1B2130;
  --text-2:#5A6478;
  --text-3:#8C95A8;
  --primary:#4C6EF5;
  --primary-dark:#3B57D6;
  --primary-soft:#EDF1FE;
  --success:#12B886;
  --success-soft:#E6F8F2;
  --warn:#F08C00;
  --warn-soft:#FFF4E2;
  --danger:#F05252;
  --danger-soft:#FFEDED;
  --purple:#7950F2;
  --purple-soft:#F1EDFE;
  --teal:#0CA5A5;
  --teal-soft:#E4F6F6;
  --r-lg:18px;
  --r-md:12px;
  --r-sm:9px;
  --sh-1:0 1px 2px rgba(17,24,39,.04);
  --sh-2:0 6px 18px -8px rgba(17,24,39,.14);
  --sh-3:0 18px 40px -18px rgba(17,24,39,.28);
  --side-w:246px;
  --ease:cubic-bezier(.22,.61,.36,1);
  --bottom-nav-h:62px;
  --topbar-h:64px;
  --scrollbar-thumb:#D6DCE8;
  --scrollbar-thumb-hover:#C2CAD9;
  --warn-row:#FFFBF4;
  --warn-row-hover:#FFF6E6;
  --primary-ghost:#fff;
  --shadow-strong:0 30px 70px -20px rgba(17,24,39,.4);
  --topbar-bg:rgba(244,246,250,.86);
  --topbar-bg-solid:rgba(244,246,250,.94);
  --mask:rgba(17,24,39,.35);
  --modal-mask:rgba(17,24,39,.4);
}

/* ============ 暗色主题（覆盖而非推翻） ============ */
:root[data-theme="dark"]{
  --bg:#0F1320;
  --surface:#181D2D;
  --surface-2:#1F2538;
  --border:#2A3148;
  --border-strong:#3A425E;
  --text:#E6E9F4;
  --text-2:#A6ADC4;
  --text-3:#7A829A;
  --primary:#7C9CFF;
  --primary-dark:#5C7CFA;
  --primary-soft:#20294A;
  --success:#3DDCB0;
  --success-soft:#1A3830;
  --warn:#FFB347;
  --warn-soft:#3A2E16;
  --danger:#FF6F6F;
  --danger-soft:#3A1F1F;
  --purple:#A78BFA;
  --purple-soft:#2A2244;
  --teal:#5EE3DE;
  --teal-soft:#1A3838;
  --sh-1:0 1px 2px rgba(0,0,0,.3);
  --sh-2:0 6px 18px -8px rgba(0,0,0,.5);
  --sh-3:0 18px 40px -18px rgba(0,0,0,.7);
  --scrollbar-thumb:#2A3148;
  --scrollbar-thumb-hover:#3A425E;
  --warn-row:#2E2516;
  --warn-row-hover:#3A2E18;
  --primary-ghost:#181D2D;
  --shadow-strong:0 30px 70px -20px rgba(0,0,0,.7);
  --topbar-bg:rgba(15,19,32,.82);
  --topbar-bg-solid:rgba(15,19,32,.95);
  --mask:rgba(0,0,0,.6);
  --modal-mask:rgba(0,0,0,.7);
}
/* 顶部 hero（首页）在暗色下保持主色渐变，仅压一压亮度 */
:root[data-theme="dark"] .hero{
  background:linear-gradient(120deg,#3B57D6 0%,#4C6EF5 48%,#6B5CD9 100%);
}
:root[data-theme="dark"] .topbar{background:var(--topbar-bg)}
:root[data-theme="dark"] .topbar.solid{background:var(--topbar-bg-solid)}

/* 响应式显隐基础类 */
.desktop-only{display:initial}
.mobile-only{display:none}
@media (max-width:860px){
  .desktop-only{display:none !important}
  .mobile-only{display:block}
}

/* ============ 基础 ============ */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Hiragino Sans GB","Microsoft YaHei",system-ui,sans-serif;
  font-size:14px;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
}
h1,h2,h3,h4,p{margin:0}
button{font-family:inherit;font-size:inherit;color:inherit;cursor:pointer;border:none;background:none}
input,select,textarea{font-family:inherit;font-size:inherit;color:inherit}
a{color:inherit;text-decoration:none}
::-webkit-scrollbar{width:9px;height:9px}
::-webkit-scrollbar-thumb{background:#D6DCE8;border-radius:9px;border:2px solid var(--bg)}
::-webkit-scrollbar-thumb:hover{background:#C2CAD9}
::-webkit-scrollbar-track{background:transparent}

/* ============ 布局 ============ */
.app{min-height:100vh}
.sidebar{
  position:fixed;top:0;left:0;bottom:0;width:var(--side-w);
  background:var(--surface);border-right:1px solid var(--border);
  display:flex;flex-direction:column;z-index:60;
}
.main{margin-left:var(--side-w);min-width:0;min-height:100vh;display:flex;flex-direction:column}
/* 内容区：随屏幕分档加宽并居中，避免宽屏上大片留白 */
.content{flex:1;padding:26px 30px 60px;width:100%;max-width:1240px;margin:0 auto}
/* 超宽屏：两列布局的卡片会很宽，把内容区限宽居中，避免元素被拉散 */
@media (min-width:1760px){
  .g2>.card.pad>.pomo,
  .g2>.card.pad>.calc-display,
  .g2>.card.pad>.calc-grid,
  .g2>.card.pad>.field,
  .g2>.card.pad>.field-row,
  .g2>.card.pad>.btn-block{max-width:540px;margin-left:auto;margin-right:auto}
}
@media (min-width:1500px){ .content{max-width:1400px} }
@media (min-width:1760px){
  .content{max-width:1620px}
  .g4{grid-template-columns:repeat(5,minmax(0,1fr))}
}
@media (min-width:2000px){ .content{max-width:1840px} }
@media (min-width:2400px){
  .content{max-width:2280px}
  .g4{grid-template-columns:repeat(6,minmax(0,1fr))}
  .auto{grid-template-columns:repeat(auto-fill,minmax(260px,1fr))}
  .auto-sm{grid-template-columns:repeat(auto-fill,minmax(226px,1fr))}
}
.mask{position:fixed;inset:0;background:var(--mask);opacity:0;pointer-events:none;transition:opacity .2s;z-index:55}
.mask.show{opacity:1;pointer-events:auto}

/* ============ 侧边栏 ============ */
.brand{display:flex;align-items:center;gap:11px;padding:22px 20px 18px}
.brand-mark{
  width:36px;height:36px;border-radius:11px;flex:none;
  background:linear-gradient(135deg,#5C7CFA,#4C6EF5);
  color:#fff;font-weight:700;font-size:16px;
  display:flex;align-items:center;justify-content:center;
  box-shadow:0 6px 14px -6px rgba(76,110,245,.7);
}
.brand-text{display:flex;flex-direction:column;min-width:0;flex:1}
.brand-text strong{font-size:15px;font-weight:600;letter-spacing:.3px}
.brand-text span{font-size:11px;color:var(--text-3);letter-spacing:.6px}
.nav{flex:1;overflow-y:auto;padding:4px 12px 10px}
.nav-label{font-size:11px;color:var(--text-3);padding:10px 10px 6px;letter-spacing:1px}
.nav-item{
  display:flex;align-items:center;gap:11px;width:100%;
  padding:9px 11px;margin-bottom:2px;border-radius:10px;
  color:var(--text-2);font-size:14px;text-align:left;
  transition:background .16s,color .16s,transform .16s;
}
.nav-item:hover{background:var(--surface-2);color:var(--text)}
.nav-item .ni-ico{flex:none;display:flex;opacity:.9}
.nav-item .ni-txt{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.nav-item .ni-badge{
  flex:none;font-size:11px;min-width:20px;height:19px;padding:0 6px;border-radius:20px;
  background:var(--surface-2);color:var(--text-3);display:flex;align-items:center;justify-content:center;
}
.nav-item.active{background:var(--primary-soft);color:var(--primary-dark);font-weight:600}
.nav-item.active .ni-ico{opacity:1}
.nav-item.active .ni-badge{background:#fff;color:var(--primary)}
.side-foot{padding:12px;border-top:1px solid var(--border);display:flex;flex-direction:column;gap:8px}
.side-user{display:flex;align-items:center;gap:9px;padding:6px 8px;border-radius:10px;cursor:pointer;transition:background .16s}
.side-user:hover{background:var(--surface-2)}
.avatar{width:28px;height:28px;border-radius:9px;background:var(--primary-soft);color:var(--primary-dark);display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;flex:none}
.side-user-name{font-size:13px;color:var(--text-2);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ============ 顶栏 ============ */
.topbar{
  position:sticky;top:0;z-index:40;
  display:flex;align-items:center;gap:14px;
  padding:16px 30px;
  background:var(--topbar-bg);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
  border-bottom:1px solid transparent;transition:border-color .2s,background .2s;
}
.topbar.solid{border-bottom-color:var(--border);background:var(--topbar-bg-solid)}
.tb-title{display:flex;align-items:baseline;gap:10px;min-width:0;flex:1}
.tb-title h1{font-size:20px;font-weight:700;letter-spacing:.2px;white-space:nowrap}
.tb-title span{font-size:13px;color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tb-right{display:flex;align-items:center;gap:8px}
.date-chip{
  font-size:12.5px;color:var(--text-2);background:var(--surface);
  border:1px solid var(--border);padding:5px 12px;border-radius:20px;box-shadow:var(--sh-1);
}

/* ============ 云端同步状态徽章 ============ */
.sync-chip{
  display:inline-flex;align-items:center;gap:6px;
  font-size:12.5px;color:var(--text-2);background:var(--surface);
  border:1px solid var(--border);padding:5px 11px;border-radius:20px;
  box-shadow:var(--sh-1);cursor:pointer;font-family:inherit;
  -webkit-tap-highlight-color:transparent;transition:border-color .2s,color .2s;
  white-space:nowrap;
}
.sync-chip:hover{border-color:var(--border-strong)}
.sync-chip .sync-dot{
  width:7px;height:7px;border-radius:50%;background:var(--success);flex:0 0 auto;
}
.sync-chip.s-run .sync-dot{background:var(--primary);animation:syncPulse 1s ease-in-out infinite}
.sync-chip.s-err .sync-dot{background:var(--danger)}
.sync-chip.s-off  .sync-dot{background:var(--text-3)}
.sync-chip.s-off  span{color:var(--text-3)}
.sync-chip.s-err  span{color:var(--danger)}
@keyframes syncPulse{0%,100%{opacity:1;transform:scale(1)}50%{opacity:.4;transform:scale(.75)}}

/* ============ 通用卡片 ============ */
.card{
  background:var(--surface);border:1px solid var(--border);
  border-radius:var(--r-lg);box-shadow:var(--sh-1);
  transition:box-shadow .2s var(--ease),border-color .2s,transform .2s var(--ease);
}
.card.pad{padding:20px}
.sec{margin-bottom:22px;animation:fadeUp .38s var(--ease) both}
.sec:nth-child(2){animation-delay:.04s}
.sec:nth-child(3){animation-delay:.08s}
.sec:nth-child(4){animation-delay:.12s}
.sec:nth-child(5){animation-delay:.16s}
@keyframes fadeUp{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:none}}
.sec-head{display:flex;align-items:center;gap:10px;margin-bottom:14px}
.sec-head h2{font-size:15px;font-weight:600;letter-spacing:.2px}
.sec-head .sh-sub{font-size:12.5px;color:var(--text-3)}
.sec-head .sh-right{margin-left:auto;display:flex;gap:8px;align-items:center}

.grid{display:grid;gap:14px}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.auto{grid-template-columns:repeat(auto-fill,minmax(232px,1fr))}
.auto-sm{grid-template-columns:repeat(auto-fill,minmax(208px,1fr))}

/* ============ 按钮 ============ */
.btn{
  display:inline-flex;align-items:center;justify-content:center;gap:7px;
  height:36px;padding:0 15px;border-radius:10px;
  font-size:13.5px;font-weight:500;white-space:nowrap;
  border:1px solid transparent;
  transition:background .16s,border-color .16s,transform .12s,box-shadow .16s,color .16s;
}
.btn:active{transform:scale(.975)}
.btn-ico{display:flex;flex:none}
.btn-primary{background:var(--primary);color:#fff;box-shadow:0 6px 14px -8px rgba(76,110,245,.9)}
.btn-primary:hover{background:var(--primary-dark);box-shadow:0 10px 20px -10px rgba(76,110,245,1)}
.btn-sale{background:var(--success);color:#fff;box-shadow:0 6px 14px -8px rgba(18,184,134,.9)}
.btn-sale:hover{background:#0A9F73;box-shadow:0 10px 20px -10px rgba(18,184,134,1)}
.btn-soft{background:var(--primary-soft);color:var(--primary-dark)}
.btn-soft:hover{background:#E1E8FD}
:root[data-theme="dark"] .btn-soft:hover{background:#2A3358}
.btn-outline{background:var(--surface);border-color:var(--border-strong);color:var(--text-2)}
.btn-outline:hover{border-color:var(--primary);color:var(--primary);background:var(--surface)}
.btn-ghost{background:transparent;color:var(--text-2)}
.btn-ghost:hover{background:var(--surface-2);color:var(--text)}
.btn-danger{background:var(--danger-soft);color:var(--danger)}
.btn-danger:hover{background:#FFDCDC}
:root[data-theme="dark"] .btn-danger:hover{background:#3A2222}
.sale-pay-action{font-weight:650;border-color:transparent;box-shadow:0 5px 12px -8px currentColor}
.sale-pay-unpaid{background:var(--danger-soft);color:var(--danger)}
.sale-pay-unpaid:hover{background:#FFDCDC;color:#C92A2A}
.sale-pay-partial{background:var(--purple-soft);color:var(--purple)}
.sale-pay-partial:hover{background:#E5DDFE;color:#6138D4}
.sale-pay-paid{background:var(--success-soft);color:#0A8C66}
.sale-pay-paid:hover{background:#CFF4E8;color:#087653}
:root[data-theme="dark"] .sale-pay-unpaid:hover{background:#3A2222;color:#FF8A8A}
:root[data-theme="dark"] .sale-pay-partial:hover{background:#2A2244;color:#C4B5FD}
:root[data-theme="dark"] .sale-pay-paid:hover{background:#1A3830;color:#3DDCB0}
.btn-sm{height:31px;padding:0 11px;font-size:12.5px;border-radius:9px}
.btn-block{width:100%}
.btn[disabled]{opacity:.5;pointer-events:none}
.icon-btn{
  width:34px;height:34px;border-radius:10px;display:flex;align-items:center;justify-content:center;
  color:var(--text-2);transition:background .16s,color .16s;flex:none;
}
.icon-btn:hover{background:var(--surface-2);color:var(--text)}
.icon-btn.danger:hover{background:var(--danger-soft);color:var(--danger)}
.icon-btn.sm{width:28px;height:28px;border-radius:8px}
.only-mobile{display:none}

/* ============ 表单控件 ============ */
.input,.select,.textarea{
  width:100%;height:38px;padding:0 12px;border-radius:10px;
  background:var(--surface);border:1px solid var(--border-strong);
  outline:none;transition:border-color .16s,box-shadow .16s;
}
.textarea{height:auto;min-height:88px;padding:10px 12px;resize:vertical;line-height:1.65}
.input:focus,.select:focus,.textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(76,110,245,.13)}
.input::placeholder,.textarea::placeholder{color:var(--text-3)}
.select{appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238C95A8' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center;padding-right:30px}
.search-wrap{position:relative;flex:1;min-width:0}
.search-wrap .input{padding-left:36px}
.search-wrap .sw-ico{position:absolute;left:11px;top:50%;transform:translateY(-50%);color:var(--text-3);display:flex;pointer-events:none}

/* ============ 徽章 / 标签 ============ */
.badge{
  display:inline-flex;align-items:center;gap:5px;height:22px;padding:0 9px;border-radius:20px;
  font-size:11.5px;font-weight:500;white-space:nowrap;
}
.badge.gray{background:var(--surface-2);color:var(--text-2);border:1px solid var(--border)}
.badge.blue{background:var(--primary-soft);color:var(--primary-dark)}
.badge.green{background:var(--success-soft);color:#0A8C66}
.badge.orange{background:var(--warn-soft);color:#B96C00}
.badge.red{background:var(--danger-soft);color:#D33B3B}
.badge.purple{background:var(--purple-soft);color:#5F3DC4}
.badge.teal{background:var(--teal-soft);color:#088}
.tag{display:inline-flex;align-items:center;height:21px;padding:0 8px;border-radius:6px;background:var(--surface-2);border:1px solid var(--border);font-size:11.5px;color:var(--text-2)}

/* ============ 统计卡 ============ */
.stat{display:flex;align-items:center;gap:13px;padding:16px 18px}
.stat-ico{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;flex:none}
.stat-body{min-width:0}
.stat-num{font-size:22px;font-weight:700;line-height:1.25;letter-spacing:.2px}
.stat-lbl{font-size:12.5px;color:var(--text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

/* ============ 列表项 ============ */
.list{display:flex;flex-direction:column}
.li{
  display:flex;align-items:center;gap:12px;padding:12px 16px;
  border-bottom:1px solid var(--border);transition:background .16s;
  animation:fadeUp .3s var(--ease) both;
}
.li:last-child{border-bottom:none}
.li:hover{background:var(--surface-2)}
.li-main{flex:1;min-width:0}
.li-title{font-size:14px;line-height:1.5;word-break:break-word}
.li-meta{font-size:12px;color:var(--text-3);margin-top:2px;display:flex;flex-wrap:wrap;gap:4px 12px;align-items:center}
.li-actions{display:flex;gap:2px;flex:none;align-items:center;opacity:.55;transition:opacity .16s}
.li:hover .li-actions{opacity:1}
.li.done .li-title{text-decoration:line-through;color:var(--text-3)}
.li.done .li-actions{opacity:.55}

/* 勾选框 */
.check{
  position:relative;
  width:20px;height:20px;border-radius:7px;flex:none;
  border:1.6px solid var(--border-strong);background:var(--surface);
  display:flex;align-items:center;justify-content:center;
  transition:background .16s,border-color .16s,transform .12s;
}
.check::after{content:"";position:absolute;inset:-10px;border-radius:14px}
.check:hover{border-color:var(--primary)}
.check:active{transform:scale(.9)}
.check svg{opacity:0;transform:scale(.5);transition:all .18s var(--ease);color:#fff}
.check.on{background:var(--primary);border-color:var(--primary)}
.check.on svg{opacity:1;transform:scale(1)}

/* 星标 */
.star{flex:none;display:flex;color:#D6DCE8;transition:color .16s,transform .12s}
.star:hover{transform:scale(1.12)}
.star.on{color:#F5A623}

/* ============ 空态 ============ */
.empty{
  padding:44px 20px;text-align:center;color:var(--text-3);
  display:flex;flex-direction:column;align-items:center;gap:6px;
}
.empty .e-ico{width:52px;height:52px;border-radius:16px;background:var(--surface-2);border:1px solid var(--border);display:flex;align-items:center;justify-content:center;margin-bottom:6px;color:var(--text-3)}
.empty .e-title{font-size:14px;color:var(--text-2);font-weight:500}
.empty .e-sub{font-size:12.5px}

/* ============ 表格 ============ */
.table-wrap{overflow:hidden;border-radius:var(--r-lg);border:1px solid var(--border);background:var(--surface);box-shadow:var(--sh-1)}
table.tbl{width:100%;border-collapse:collapse;font-size:13.5px}
table.tbl th{
  text-align:left;font-weight:500;font-size:12.5px;color:var(--text-3);
  padding:12px 14px;background:var(--surface-2);border-bottom:1px solid var(--border);white-space:nowrap;
}
table.tbl td{padding:12px 14px;border-bottom:1px solid var(--border);vertical-align:middle}
table.tbl tbody tr{transition:background .16s}
table.tbl tbody tr:hover{background:var(--surface-2)}
table.tbl tbody tr:last-child td{border-bottom:none}
table.tbl tr.warn-row{background:#FFFBF4}
table.tbl tr.warn-row:hover{background:#FFF6E6}
.cell-actions{display:flex;gap:2px;justify-content:flex-end}
.num{font-variant-numeric:tabular-nums;font-weight:600}
/* 表格内备注：桌面单行截断、悬停看全；占位横线弱化 */
.td-note{display:block;max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.td-dim{color:var(--text-3);opacity:.55}

/* ============ 首页 Hero ============ */
.hero{
  position:relative;overflow:hidden;padding:26px 28px;
  background:linear-gradient(120deg,#4C6EF5 0%,#5C7CFA 48%,#7C6DF2 100%);
  color:#fff;border:none;
}
.hero::after{
  content:"";position:absolute;right:-70px;top:-90px;width:280px;height:280px;border-radius:50%;
  background:rgba(255,255,255,.09);
}
.hero::before{
  content:"";position:absolute;right:60px;bottom:-120px;width:200px;height:200px;border-radius:50%;
  background:rgba(255,255,255,.07);
}
.hero-inner{position:relative;z-index:1;display:flex;align-items:center;gap:26px;flex-wrap:wrap}
.hero-date{font-size:15px;opacity:.9;letter-spacing:.5px}
.hero-hi{font-size:26px;font-weight:700;margin-top:4px;letter-spacing:.3px}
.hero-tip{font-size:13px;opacity:.85;margin-top:6px}
.hero-stats{display:grid;grid-template-columns:repeat(4,minmax(92px,1fr));gap:10px;margin-left:auto}
.hstat{
  background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.18);
  border-radius:14px;padding:11px 13px;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);
  transition:background .18s,transform .18s var(--ease);cursor:pointer;
}
.hstat:hover{background:rgba(255,255,255,.24);transform:translateY(-2px)}
.hstat-num{font-size:20px;font-weight:700;line-height:1.2;font-variant-numeric:tabular-nums}
.hstat-lbl{font-size:12px;opacity:.85;white-space:nowrap}

/* ============ 模块入口卡 ============ */
.mod-card{
  display:flex;gap:13px;padding:16px;cursor:pointer;text-align:left;
  background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);
  box-shadow:var(--sh-1);
  transition:transform .2s var(--ease),box-shadow .2s var(--ease),border-color .2s;
}
.mod-card:hover{transform:translateY(-3px);box-shadow:var(--sh-3);border-color:var(--border-strong)}
.mod-ico{width:42px;height:42px;border-radius:13px;display:flex;align-items:center;justify-content:center;flex:none}
.mod-body{min-width:0;flex:1}
.mod-name{font-size:14.5px;font-weight:600;display:flex;align-items:center;gap:8px}
.mod-desc{font-size:12.5px;color:var(--text-3);margin-top:3px;line-height:1.45;word-break:break-word}
.mod-count{font-size:11.5px;color:var(--text-3);margin-top:8px}

/* ============ 进度条 ============ */
.progress{height:6px;border-radius:6px;background:var(--surface-2);border:1px solid var(--border);overflow:hidden}
.progress i{display:block;height:100%;border-radius:6px;background:var(--primary);transition:width .45s var(--ease)}
.progress.green i{background:var(--success)}
.progress.orange i{background:var(--warn)}

/* ============ 项目卡 ============ */
.proj-card{padding:18px;display:flex;flex-direction:column;gap:12px}
.proj-top{display:flex;align-items:flex-start;gap:10px}
.proj-name{font-size:15px;font-weight:600;flex:1;min-width:0;word-break:break-word}
.proj-desc{font-size:12.5px;color:var(--text-2);line-height:1.65;min-height:20px;word-break:break-word}
.proj-foot{display:flex;align-items:center;gap:10px;font-size:12px;color:var(--text-3)}
.proj-foot .pf-right{margin-left:auto;display:flex;gap:2px}

/* ============ 网站 / 工具卡（两行式，避免按钮挤压文字） ============ */
.site-card{
  display:flex;flex-direction:column;gap:11px;padding:14px;cursor:pointer;
  border:1px solid var(--border);border-radius:var(--r-md);background:var(--surface);
  transition:transform .18s var(--ease),box-shadow .18s,border-color .18s;
}
.site-card:hover{transform:translateY(-2px);box-shadow:var(--sh-2);border-color:var(--border-strong)}
.site-card.dragging{opacity:.4}
.site-card.dragover{border-color:var(--primary);box-shadow:0 0 0 3px rgba(76,110,245,.12)}
.sc-top{display:flex;align-items:center;gap:11px;min-width:0}
.sc-foot{display:flex;align-items:center;gap:8px;min-height:24px}
.sc-ops{margin-left:auto;display:flex;gap:2px}
.site-ico{width:38px;height:38px;border-radius:11px;display:flex;align-items:center;justify-content:center;font-weight:600;font-size:15px;color:#fff;flex:none;overflow:hidden}
.site-ico img{width:100%;height:100%;object-fit:cover}
.site-body{min-width:0;flex:1}
/* 名称允许两行，长名字不至于被截掉大半；再长则省略号，悬停 title 可看全 */
.site-name{
  font-size:13.5px;font-weight:600;line-height:1.35;
  display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;
  overflow:hidden;overflow-wrap:anywhere;
}
.site-url{font-size:11.5px;color:var(--text-3);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.grip{cursor:grab;color:var(--text-3);display:flex;flex:none}

/* ============ 灵感卡片 ============ */
.note-card{padding:16px;display:flex;flex-direction:column;gap:10px;break-inside:avoid;margin-bottom:14px}
.note-text{font-size:13.5px;line-height:1.75;white-space:pre-wrap;word-break:break-word;color:var(--text)}
.note-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:11.5px;color:var(--text-3)}
.masonry{columns:3;column-gap:14px}
.masonry .note-card{display:flex;flex-direction:column;width:100%;break-inside:avoid;margin-bottom:14px}

/* ============ 学习图表 ============ */
.bars{display:flex;align-items:flex-end;gap:10px;height:132px;padding:0 2px}
.bar-col{flex:1;display:flex;flex-direction:column;align-items:center;gap:6px;height:100%;justify-content:flex-end}
.bar{
  width:100%;max-width:38px;border-radius:7px 7px 4px 4px;min-height:4px;
  background:var(--primary);opacity:.85;transition:height .5s var(--ease),opacity .18s;
}
.bar-col:hover .bar{opacity:1}
.bar-col.today .bar{background:var(--success)}
.bar-lbl{font-size:11px;color:var(--text-3)}
.bar-val{font-size:11px;color:var(--text-2);font-variant-numeric:tabular-nums}

/* ============ 筛选条 ============ */
.toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:16px}
.filters{display:flex;gap:6px;background:var(--surface);border:1px solid var(--border);padding:4px;border-radius:11px}
.filters button{
  padding:5px 13px;border-radius:8px;font-size:13px;color:var(--text-2);
  transition:background .16s,color .16s;white-space:nowrap;
}
.filters button:hover{background:var(--surface-2)}
.filters button.on{background:var(--primary-soft);color:var(--primary-dark);font-weight:600}
.chips{display:flex;gap:7px;flex-wrap:wrap}
.chip{
  padding:5px 12px;border-radius:20px;font-size:12.5px;color:var(--text-2);
  background:var(--surface);border:1px solid var(--border);transition:all .16s;
}
.chip:hover{border-color:var(--border-strong);background:var(--surface-2)}
.chip.on{background:var(--text);border-color:var(--text);color:#fff}
.toolbar .search-wrap{max-width:250px}

/* ============ 番茄钟 / 计算器 ============ */
.pomo{display:flex;flex-direction:column;align-items:center;gap:14px;padding:24px 18px}
.pomo-time{font-size:52px;font-weight:700;font-variant-numeric:tabular-nums;letter-spacing:1px;line-height:1}
.pomo-ring{width:150px;height:150px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:conic-gradient(var(--primary) 0deg,var(--surface-2) 0deg);transition:background .4s linear}
.pomo-ring span{width:120px;height:120px;border-radius:50%;background:var(--surface);display:flex;align-items:center;justify-content:center;font-size:34px;font-weight:700;font-variant-numeric:tabular-nums}
.pomo-modes{display:flex;gap:6px;background:var(--surface-2);border:1px solid var(--border);padding:4px;border-radius:11px}
.pomo-modes button{padding:5px 14px;border-radius:8px;font-size:13px;color:var(--text-2)}
.pomo-modes button.on{background:var(--surface);color:var(--primary-dark);font-weight:600;box-shadow:var(--sh-1)}
.calc-display{
  height:56px;border-radius:var(--r-md);background:var(--surface-2);border:1px solid var(--border);
  display:flex;align-items:center;justify-content:flex-end;padding:0 14px;
  font-size:24px;font-weight:600;font-variant-numeric:tabular-nums;overflow:hidden;white-space:nowrap;
}
.calc-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:8px;margin-top:12px}
.calc-grid button{
  height:44px;border-radius:10px;background:var(--surface-2);border:1px solid var(--border);
  font-size:15px;font-weight:500;transition:background .14s,transform .1s,color .14s;
}
.calc-grid button:hover{background:var(--primary-soft);border-color:#C9D5FC;color:var(--primary-dark)}
.calc-grid button:active{transform:scale(.95)}
.calc-grid button.op{background:var(--primary-soft);color:var(--primary-dark);border-color:#DCE4FD}
.calc-grid button.eq{background:var(--primary);color:#fff;border-color:var(--primary)}
.calc-grid button.eq:hover{background:var(--primary-dark);color:#fff}

/* ============ 快捷录入 ============ */
.quick{display:flex;gap:10px;align-items:center;padding:14px;margin-bottom:14px;background:var(--surface);border:1px solid var(--border);border-radius:var(--r-lg);box-shadow:var(--sh-1)}
.quick .input{flex:1;border-color:var(--border);background:var(--surface-2)}
.quick .input:focus{background:var(--surface)}

/* ============ 弹窗 ============ */
.modal-mask{
  position:fixed;inset:0;z-index:100;background:rgba(17,24,39,.4);
  display:flex;align-items:center;justify-content:center;padding:20px;
  animation:fadeIn .18s ease both;
}
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.modal{
  width:100%;max-width:460px;max-height:88vh;overflow-y:auto;
  background:var(--surface);border-radius:20px;box-shadow:0 30px 70px -20px rgba(17,24,39,.4);
  animation:popIn .24s var(--ease) both;
}
@keyframes popIn{from{opacity:0;transform:translateY(14px) scale(.97)}to{opacity:1;transform:none}}
.modal-head{display:flex;align-items:center;gap:10px;padding:20px 22px 12px}
.modal-head h3{font-size:16.5px;font-weight:600;flex:1}
.modal-body{padding:0 22px}
.modal-foot{display:flex;justify-content:flex-end;gap:9px;padding:18px 22px 20px}
.field{margin-bottom:14px}
.field label{display:block;font-size:12.5px;color:var(--text-2);margin-bottom:6px;font-weight:500}
.field .hint{font-size:11.5px;color:var(--text-3);margin-top:5px}
.field-row{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.modal-text{font-size:13.5px;color:var(--text-2);line-height:1.7}

/* ============ Toast ============ */
.toasts{position:fixed;bottom:26px;left:50%;transform:translateX(-50%);z-index:200;display:flex;flex-direction:column;gap:9px;align-items:center;pointer-events:none}
.toast{
  display:flex;align-items:center;gap:9px;
  background:var(--text);color:var(--bg);padding:10px 16px;border-radius:12px;font-size:13.5px;
  box-shadow:var(--shadow-strong);
  animation:toastIn .26s var(--ease) both;max-width:86vw;
}
.toast.out{animation:toastOut .22s var(--ease) both}
.toast.green{background:var(--success);color:#fff}
.toast.red{background:var(--danger);color:#fff}
:root[data-theme="dark"] .toast.green,
:root[data-theme="dark"] .toast.red{color:#0F1320}
@keyframes toastIn{from{opacity:0;transform:translateY(14px) scale(.96)}to{opacity:1;transform:none}}
@keyframes toastOut{to{opacity:0;transform:translateY(8px) scale(.97)}}

/* 触屏设备：常显操作按钮 + 放大点击目标，符合 Material/Apple HIG */
@media (hover:none){
  .li-actions,.li.done .li-actions{opacity:1;gap:4px}
  .check{width:26px;height:26px;border-width:1.8px}
  /* 图标按钮尺寸统一在下面的 max-width:860px 里定（40px），这里只放大图标本身。
     两条同优先级的规则一前一后写，后面的会把前面的顶掉（老坑），别再在这里写尺寸。 */
  .icon-btn.sm svg{width:18px;height:18px}
  .star.icon-btn.sm{width:40px;height:40px}
  .btn{min-height:40px}
  /* 列表项整体提高触摸反馈，避免行间错点 */
  .li{padding:14px 14px;gap:14px}
  .li-title{font-size:14.5px}
}
/* 小屏：按钮热区放大到 40px（此前 32px 手指常点不准；44px 那条被这里的规则顶掉过，已合并到这一处）。
   统计标签允许换行不截断。 */
@media (max-width:860px){
  .filters button,.chip,.pomo-modes button{min-height:36px}
  .icon-btn.sm{width:40px;height:40px;border-radius:10px}
  /* 操作按钮之间留出间距，避免误触相邻（尤其删除） */
  .cell-actions{gap:8px}
  .stat-lbl{white-space:normal;overflow:visible;text-overflow:clip;line-height:1.35}
  .stat{padding:14px 15px;gap:11px}
  .stat-ico{width:36px;height:36px;border-radius:11px}
}
@media (max-width:400px){
  .stat-num{font-size:20px}
  .stat-lbl{font-size:12px}
  .sec-head .sh-sub{white-space:normal}
}

/* ============ 数据页 ============ */
.kv{display:flex;justify-content:space-between;gap:12px;padding:9px 0;border-bottom:1px dashed var(--border);font-size:13.5px}
.kv:last-child{border-bottom:none}
.kv span{color:var(--text-2)}
.kv b{font-weight:600;font-variant-numeric:tabular-nums}

/* ============ 响应式 ============ */
@media (max-width:1180px){
  .masonry{columns:2}
}
@media (max-width:960px){
  .content{padding:20px 20px 60px;max-width:none}
  .topbar{padding:14px 20px}
  .hero-stats{grid-template-columns:repeat(4,minmax(80px,1fr));margin-left:0;width:100%}
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .g3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width:860px){
  /* 快速添加：输入框独占一行，按钮平分下一行，避免输入框被压窄 */
  .quick{flex-wrap:wrap;padding:12px}
  .quick>span{display:none}
  .quick .input{flex:1 1 100%}
  .quick .btn{flex:1;justify-content:center}
  .sidebar{transform:translateX(-100%);transition:transform .26s var(--ease);box-shadow:none}
  .sidebar.open{transform:none;box-shadow:0 0 40px rgba(0,0,0,.4)}
  .main{margin-left:0}
  .only-mobile{display:flex}
  .mask.show{display:block}
  .topbar{padding:12px 14px;gap:10px}
  .tb-title h1{font-size:18px}
  .date-chip{display:none}
  /* 窄屏只保留同步状态圆点，避免挤占标题 */
  .sync-chip{padding:6px 8px}
  .sync-chip span{display:none}
  .masonry{columns:1}
  .g2,.g3{grid-template-columns:1fr}
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .auto-sm{grid-template-columns:repeat(auto-fill,minmax(196px,1fr))}
  .toolbar .search-wrap{max-width:none;flex:1 1 100%}
  .hero{padding:22px}
  .hero-hi{font-size:22px}
  .hero-stats{grid-template-columns:repeat(2,1fr)}
  .field-row{grid-template-columns:1fr}
  /* 手机端表格 → 紧凑卡片 v2：字段名固定在左、内容左对齐紧跟，尽量不换行 */
  table.tbl thead{display:none}
  table.tbl,table.tbl tbody{display:block;width:100%}
  table.tbl tbody tr{display:grid;grid-template-columns:1fr 1fr;gap:0 12px;position:relative;
    padding:7px 10px;border:1px solid var(--border);border-radius:10px;margin-bottom:8px;background:var(--surface)}
  table.tbl tbody td{display:flex;justify-content:flex-start;align-items:baseline;gap:0;
    padding:1px 0;border:none;text-align:left;min-width:0;word-break:break-word;
    font-size:12.5px;line-height:1.45}
  table.tbl tbody td::before{content:attr(data-label);flex:none;flex-shrink:0;
    font-size:11.5px;color:var(--text-3);margin-right:7px}
  /* 长文本字段占满整行，尽量少换行 */
  table.tbl tbody td[data-label="备注"],table.tbl tbody td[data-label="说明"],
  table.tbl tbody td.td-note{grid-column:1/-1}
  /* 标题行：占满整行、左对齐；规格等 .sub 换行到标题下方 */
  table.tbl tbody tr>td:first-child{grid-column:1/-1;font-weight:600;font-size:13.5px}
  table.tbl tbody td.td-sel{position:absolute;top:8px;right:10px;padding:0}
  table.tbl tbody td.td-sel+td{grid-column:1/-1;padding-right:30px}
  table.tbl tbody td.td-main{flex-wrap:wrap}
  table.tbl tbody td.td-main .sub{flex-basis:100%;font-weight:400;font-size:11.5px;color:var(--text-3);text-align:left}
  /* 操作按钮行：占满整行、右对齐、上方虚线分隔 */
  table.tbl tbody td.td-actions{grid-column:1/-1;justify-content:flex-end;gap:4px;
    padding-top:5px;margin-top:3px;border-top:1px dashed var(--border)}
  table.tbl tbody td[colspan]{grid-column:1/-1;justify-content:center;text-align:center}
  /* 合计行强调 */
  table.tbl tbody tr.tr-total td{font-weight:600}
  table.tbl tbody tr.tr-total td::before{color:var(--text-2)}
  /* 手机端备注完整换行显示，不被单行截断 */
  .td-note{max-width:none;white-space:normal;text-align:left}
  /* 空值列直接折叠：桌面端保留「—」用于对齐列，手机上它只是白白占掉半张卡的高度。
     标记由 ui.js 的 tbl() 自动打（td-empty），全站表格统一生效。 */
  table.tbl tbody td.td-empty{display:none}
  .cell-actions{justify-content:flex-end}
  .li{padding:12px}
}
@media (max-width:520px){
  .tb-title span{display:none}
  .stat{padding:14px}
  .stat-num{font-size:19px}
  .sec-head{flex-wrap:wrap}
  .sec-head .sh-right{margin-left:0;width:100%}
}

/* ============ 底部 Tab Bar（仅手机端显示） ============ */
.bottom-nav {
  display: none;
}
@media (max-width:860px) {
  .bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 65;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--bottom-nav-h);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 24px -10px rgba(0,0,0,.18);
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    color: var(--text-3);
    font-size: 11px;
    border-radius: 10px;
    padding: 4px 0;
    min-height: 50px;
    transition: color .14s, background .14s;
  }
  .bn-item:active { background: var(--surface-2); }
  .bn-item.active { color: var(--primary); font-weight: 600; }
  .bn-item svg { display: block; }
  .bn-item .bn-dot {
    position: absolute; transform: translate(11px, -2px);
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--surface);
    display: none;
  }
  .bn-item { position: relative; }
  .bn-item.has-dot .bn-dot { display: block; }
  /* 留出底部空间给 tab bar，避免内容被遮 */
  .content { padding-bottom: calc(var(--bottom-nav-h) + 20px + env(safe-area-inset-bottom)); }
}

/* ============ 回到顶部按钮 ============ */
.back-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 28px -8px rgba(76,110,245,.55), var(--sh-2);
  opacity: 0; transform: translateY(20px); pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease), background .14s;
  z-index: 70;
}
.back-top.show {
  opacity: 1; transform: none; pointer-events: auto;
}
.back-top:hover { background: var(--primary-dark); }
.back-top:active { transform: translateY(2px); }
:root[data-theme="dark"] .back-top { box-shadow: 0 12px 28px -8px rgba(0,0,0,.7), var(--sh-2); }
/* 手机端：抬高并缩小，避免与底部 Tab 重叠（必须写在基础规则之后，否则被同优先级基础规则覆盖） */
@media (max-width:860px) {
  .back-top {
    right: 16px;
    bottom: calc(var(--bottom-nav-h) + 18px + env(safe-area-inset-bottom));
    width: 40px; height: 40px; border-radius: 12px;
  }
  .back-top svg { width: 18px; height: 18px; }
}

/* ============ 主题切换按钮组 ============ */
.theme-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 10px;
  gap: 2px;
}
.theme-switch button {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .14s, color .14s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button.on {
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: var(--sh-1);
}
:root[data-theme="dark"] .theme-switch button.on {
  background: var(--primary-soft);
  color: var(--primary);
}

/* ============ 库存移动端：极简单行列表 ============ */
/* 桌面端默认仍然是表格；≤860px 切到紧凑列表 */
@media (max-width:860px) {
  .inv-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-1);
  }
  .inv-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .14s;
  }
  .inv-row:last-child { border-bottom: none; }
  .inv-row:active { background: var(--surface-2); }
  .inv-row.out { background: var(--warn-row); }
  .inv-row.out:active { background: var(--warn-row-hover); }
  .inv-name {
    font-size: 14.5px; font-weight: 600;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .inv-name .inv-spec {
    font-size: 12.5px; font-weight: 400; color: var(--text-3);
    margin-left: 6px;
  }
  .inv-qty {
    display: inline-flex; align-items: center; gap: 6px;
    font-variant-numeric: tabular-nums; font-weight: 700;
    font-size: 16px; justify-self: end;
  }
  .inv-qty .inv-qty-btn {
    width: 32px; height: 32px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
  }
  .inv-qty .inv-qty-btn:hover { color: var(--primary); border-color: var(--primary); }
  .inv-qty .inv-qty-btn:active { transform: scale(.92); }
  .inv-meta {
    grid-column: 1 / -1;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-size: 12px; color: var(--text-3);
    min-width: 0;
  }
  .inv-meta .inv-note {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 60vw;
  }
  .inv-meta .inv-ops {
    margin-left: auto; display: flex; gap: 4px;
  }
  .inv-meta .inv-ops button {
    width: 36px; height: 36px;
    border-radius: 9px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
    display: flex; align-items: center; justify-content: center;
  }
  .inv-meta .inv-ops button.danger:hover { color: var(--danger); border-color: var(--danger); }
  .inv-meta .inv-ops button:hover { color: var(--primary); border-color: var(--primary); }
  .inv-list-empty {
    padding: 32px 20px;
    color: var(--text-3);
    text-align: center;
  }
}

@media (prefers-reduced-motion:reduce){
  *{animation-duration:.01ms !important;transition-duration:.01ms !important}
}
