/* 收支账簿 · 卡片风格（iOS 设置 / 记账 App 风格） */
:root{
  color-scheme: light;
  --bg:#F2F2F7; --card:#FFFFFF; --fill:#EFEFF4; --fill-2:#E5E5EA;
  --text:#1C1C1E; --text-2:#6C6C70; --text-3:#AEAEB2;
  --sep:rgba(60,60,67,.14);
  --accent:#007AFF; --accent-soft:rgba(0,122,255,.10);
  --green:#2FB350; --green-soft:rgba(52,199,89,.14);
  --orange:#F28C00; --orange-soft:rgba(255,149,0,.14);
  --red:#E5352B; --red-soft:rgba(255,59,48,.10);
  --cost:#AEAEB2;
  --switch-on:#34C759;
  --bar-h:62px;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    color-scheme: dark;
    --bg:#000000; --card:#1C1C1E; --fill:#2C2C2E; --fill-2:#3A3A3C;
    --text:#F2F2F7; --text-2:#98989F; --text-3:#636366;
    --sep:rgba(84,84,88,.55);
    --accent:#0A84FF; --accent-soft:rgba(10,132,255,.18);
    --green:#30D158; --green-soft:rgba(48,209,88,.18);
    --orange:#FF9F0A; --orange-soft:rgba(255,159,10,.18);
    --red:#FF453A; --red-soft:rgba(255,69,58,.16);
    --cost:#636366; --switch-on:#30D158;
  }
}
:root[data-theme="dark"]{
  color-scheme: dark;
  --bg:#000000; --card:#1C1C1E; --fill:#2C2C2E; --fill-2:#3A3A3C;
  --text:#F2F2F7; --text-2:#98989F; --text-3:#636366;
  --sep:rgba(84,84,88,.55);
  --accent:#0A84FF; --accent-soft:rgba(10,132,255,.18);
  --green:#30D158; --green-soft:rgba(48,209,88,.18);
  --orange:#FF9F0A; --orange-soft:rgba(255,159,10,.18);
  --red:#FF453A; --red-soft:rgba(255,69,58,.16);
  --cost:#636366; --switch-on:#30D158;
}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none!important}
body{margin:0;background:var(--bg);color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","PingFang SC","Hiragino Sans GB","Helvetica Neue","Microsoft YaHei",system-ui,sans-serif;
  font-size:16px;line-height:1.45;-webkit-font-smoothing:antialiased;-webkit-tap-highlight-color:transparent}
.num{font-variant-numeric:tabular-nums}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:6px}
code{font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:.9em;background:var(--fill);padding:1px 5px;border-radius:5px}
.neg{color:var(--red)}

.wrap{max-width:720px;margin:0 auto;padding:12px 16px calc(var(--bar-h) + 40px + env(safe-area-inset-bottom,0px))}

/* ---------- header ---------- */
header.top{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:8px 0 14px}
h1{font-size:32px;font-weight:700;letter-spacing:-.02em;margin:0;line-height:1.15}
.sync{font-size:13px;color:var(--text-2);margin-top:2px}
.period{display:inline-flex;background:var(--fill-2);border-radius:9px;padding:2px}
.period button{border:0;background:none;padding:5px 14px;border-radius:7px;font-size:13px;font-weight:500;color:var(--text)}
.period button[aria-pressed="true"]{background:var(--card);box-shadow:0 1px 3px rgba(0,0,0,.12),0 0 0 .5px rgba(0,0,0,.04);font-weight:600}

/* ---------- hero: where the money goes ---------- */
.hero{background:var(--card);border-radius:20px;padding:20px 18px 6px;margin-bottom:12px}
.hero-label{font-size:14px;color:var(--text-2);font-weight:500}
.big{font-family:ui-rounded,"SF Pro Rounded",-apple-system,"PingFang SC",system-ui,sans-serif;
  font-size:46px;font-weight:700;letter-spacing:-.02em;line-height:1.1;margin:2px 0 2px;font-variant-numeric:tabular-nums}
.hero-sub{font-size:14px;color:var(--text-2)}
.bar{display:flex;height:10px;border-radius:5px;overflow:hidden;background:var(--fill);margin:16px 0 6px;gap:2px}
.bar .seg{display:block;height:100%;width:0;transition:width .4s ease}
.bar .seg:first-child{border-radius:5px 0 0 5px}
.bar .seg:last-child{border-radius:0 5px 5px 0}
.seg.cost{background:var(--cost)} .seg.alloc{background:var(--orange)} .seg.profit{background:var(--green)}
.legend{list-style:none;margin:0;padding:0}
.legend li{display:flex;align-items:center;gap:10px;padding:11px 0;font-size:15px;border-top:.5px solid var(--sep)}
.legend li:first-child{border-top:0}
.legend b{margin-left:auto;font-weight:500}
.dot{width:10px;height:10px;border-radius:50%;flex:none}
.dot.pay{background:none;border:2px solid var(--text-3)}
.dot.profit{background:var(--green)}
.dot.cost{background:var(--cost)} .dot.alloc{background:var(--orange)}

.counts{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--card);border-radius:14px;padding:12px 0;margin-bottom:22px}
.counts>div{display:flex;flex-direction:column;align-items:center;border-left:.5px solid var(--sep)}
.counts>div:first-child{border-left:0}
.counts .cv{font-family:ui-rounded,"SF Pro Rounded",-apple-system,system-ui,sans-serif;font-size:22px;font-weight:700;line-height:1.2}
.counts .cv.muted{color:var(--text-3)}
.counts .cl{font-size:12px;color:var(--text-2)}

/* ---------- bottom tab bar ---------- */
nav.tabs{position:fixed;left:0;right:0;bottom:0;z-index:15;display:flex;justify-content:center;
  background:var(--card);background:color-mix(in srgb,var(--card) 82%,transparent);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px);
  border-top:.5px solid var(--sep);padding:6px 4px calc(6px + env(safe-area-inset-bottom,0px))}
nav.tabs button{flex:1;max-width:110px;border:0;background:none;display:flex;flex-direction:column;align-items:center;gap:2px;padding:2px 0;color:var(--text-3);font-size:11px;font-weight:500}
nav.tabs svg{width:25px;height:25px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
nav.tabs button[aria-selected="true"]{color:var(--accent)}
nav.tabs button[aria-selected="true"] svg{stroke-width:2.1}

/* ---------- buttons ---------- */
.toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:14px}
.toolbar.flush{margin:0}
.btn{border:0;background:var(--fill);color:var(--accent);border-radius:10px;padding:9px 16px;font-size:15px;font-weight:600}
.btn.primary{background:var(--accent);color:#fff}
.btn.ghost{background:none;padding:8px 6px;font-weight:500}
.btn.danger{color:var(--red);background:var(--red-soft)}
.btn.mini{padding:5px 12px;font-size:13px;border-radius:14px;flex:none}
.btn:disabled{opacity:.4;cursor:not-allowed}
.link{border:0;background:none;padding:0;color:var(--accent);text-align:left}
.search{flex:1;min-width:150px;border:0;background:var(--fill-2);border-radius:10px;padding:9px 12px;font-size:15px}
.search::placeholder{color:var(--text-2)}

/* ---------- grouped list (customer groups, shared costs) ---------- */
.group{background:var(--card);border-radius:14px;margin-bottom:20px;overflow:hidden}
.g-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px 12px}
.g-left{min-width:0}
.g-name{border:0;background:none;padding:0;text-align:left;font-size:19px;font-weight:700;letter-spacing:-.01em}
.g-sub{font-size:13px;color:var(--text-2);margin-top:1px}
.g-sub b{font-weight:600;color:var(--text)}
.g-total{text-align:right;flex:none}
.g-total .v{font-size:19px;font-weight:700;font-family:ui-rounded,"SF Pro Rounded",-apple-system,system-ui,sans-serif}
.rows{list-style:none;margin:0;padding:0}
.row{display:grid;grid-template-columns:1fr auto;gap:4px 12px;align-items:center;padding:12px 16px;position:relative}
.row::before{content:"";position:absolute;top:0;left:16px;right:0;border-top:.5px solid var(--sep)}
.r-main{border:0;background:none;padding:0;text-align:left;min-width:0}
.r-name{font-size:16px;font-weight:500;overflow-wrap:anywhere}
.r-figs{display:flex;flex-wrap:wrap;gap:0 12px;font-size:13px;color:var(--text-2);margin-top:2px}
.r-right{display:flex;align-items:center;gap:12px}
.r-profit{font-size:16px;font-weight:600;text-align:right;min-width:76px}
.row.off .r-name{color:var(--text-3)}
.row.off .r-profit{color:var(--text-3);font-weight:400;text-decoration:line-through}
.g-foot{padding:4px 10px 8px;position:relative}
.g-foot::before{content:"";position:absolute;top:0;left:16px;right:0;border-top:.5px solid var(--sep)}
.tag{display:inline-block;font-size:12px;font-weight:600;padding:1px 7px;border-radius:6px;margin-left:6px;vertical-align:2px;background:var(--fill);color:var(--text-2)}
.tag.due{background:var(--orange-soft);color:var(--orange)}
.tag.over{background:var(--red-soft);color:var(--red)}

/* iOS switch */
.sw{position:relative;width:51px;height:31px;flex:none;border:0;padding:0;background:none}
.sw::before{content:"";position:absolute;inset:0;border-radius:999px;background:var(--fill-2);transition:background .2s}
.sw::after{content:"";position:absolute;top:2px;left:2px;width:27px;height:27px;border-radius:50%;background:#fff;box-shadow:0 3px 8px rgba(0,0,0,.15),0 1px 1px rgba(0,0,0,.16);transition:transform .2s}
.sw[aria-checked="true"]::before{background:var(--switch-on)}
.sw[aria-checked="true"]::after{transform:translateX(20px)}

/* due banner */
.alert{background:var(--card);border-radius:14px;padding:14px 16px 6px;margin-bottom:20px}
.alert>b{display:flex;align-items:center;gap:8px;font-size:15px;font-weight:600}
.alert>b::before{content:"";width:8px;height:8px;border-radius:50%;background:var(--orange)}
.alert.over>b::before{background:var(--red)}
.alert .due-list{list-style:none;margin:6px 0 0;padding:0}
.due-list li{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;font-size:14px;color:var(--text-2);border-top:.5px solid var(--sep)}
.due-list .link{color:var(--text);font-weight:500}
.due-list .btn.mini{background:var(--accent-soft);color:var(--accent)}

.empty{background:var(--card);border-radius:14px;padding:32px 20px;text-align:center;color:var(--text-2)}
.empty p{margin:0 0 14px}

/* panels (settings-style sections) */
.panel{background:var(--card);border-radius:14px;padding:16px;margin-bottom:20px}
.panel h2{font-size:17px;font-weight:600;margin:0 0 4px}
.panel p{margin:0 0 12px;color:var(--text-2);font-size:14px}
.radio{display:flex;flex-direction:column;border-radius:10px;overflow:hidden;background:var(--fill)}
.radio label{display:flex;gap:10px;align-items:center;padding:11px 12px;cursor:pointer;font-size:15px;border-top:.5px solid var(--sep)}
.radio label:first-child{border-top:0}
.radio input{accent-color:var(--accent);width:18px;height:18px;margin:0}
.hint{font-size:13px;color:var(--text-2);margin:-6px 0 12px}
.cols{display:grid;grid-template-columns:1fr 1fr;gap:0 12px}

/* tables */
.tbl-wrap{overflow-x:auto;margin:0 -16px;padding:0 16px}
table{width:100%;border-collapse:collapse;font-size:14px}
th,td{padding:10px 8px;text-align:right;white-space:nowrap;border-bottom:.5px solid var(--sep)}
th:first-child,td:first-child{text-align:left;padding-left:0}
th:last-child,td:last-child{padding-right:0}
th{font-weight:500;color:var(--text-2);font-size:13px}
tfoot td{font-weight:700;border-bottom:0}
#renewMonth{border:0;background:var(--fill-2);border-radius:10px;padding:9px 12px;font-size:15px}
.toolbar .meta{font-size:14px;color:var(--text-2)}

/* ---------- sheets ---------- */
dialog{border:0;padding:0;background:var(--bg);color:var(--text);border-radius:14px;width:min(480px,calc(100vw - 24px));
  max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);overflow-y:auto;box-shadow:0 20px 60px rgba(0,0,0,.25)}
dialog::backdrop{background:rgba(0,0,0,.35)}
.dlg{padding:18px 16px 16px}
.dlg h3{font-size:20px;font-weight:700;margin:0 0 14px;text-align:center}
.field{display:block;margin-bottom:12px}
.field.narrow{max-width:260px}
.field>span{display:block;font-size:13px;color:var(--text-2);margin:0 4px 5px}
.field input,.field select,.field textarea{width:100%;border:0;background:var(--card);border-radius:10px;padding:11px 12px;font-size:16px;min-height:44px}
.panel .field input,.panel .field select{background:var(--fill)}
.pair{display:grid;grid-template-columns:1fr 112px;gap:8px}
.check{display:flex;gap:10px;align-items:center;font-size:15px;margin:4px 0 12px}
.check input{accent-color:var(--switch-on);width:20px;height:20px;margin:0}
.dlg-actions{display:flex;justify-content:space-between;gap:8px;margin-top:10px;flex-wrap:wrap}
.dlg-actions .right{display:flex;gap:8px;margin-left:auto}
.err{color:var(--red);font-size:13px;min-height:1em;margin:0 4px 6px}
.renew-box{background:var(--card);border-radius:12px;padding:12px;margin:0 0 12px}
.renew-head{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:13px;color:var(--text-2);margin-bottom:6px}
.renew-box .hint{margin:4px 0 0}
.hist{list-style:none;margin:0 0 4px;padding:0;font-size:13px;max-height:180px;overflow-y:auto}
.hist li{display:flex;flex-wrap:wrap;gap:2px 12px;padding:8px 0;border-top:.5px solid var(--sep)}
.hist .hnote{color:var(--text-2)}
.renew-sum{margin:0 0 14px;line-height:1.8;background:var(--card);border-radius:12px;padding:12px 14px}

@media (max-width:600px){
  dialog{width:100%;max-width:100%;margin:auto 0 0;border-radius:14px 14px 0 0;max-height:92vh;max-height:92dvh}
  .dlg{padding-bottom:calc(16px + env(safe-area-inset-bottom,0px))}
  .cols{grid-template-columns:1fr}
  .big{font-size:42px}
}

/* toast */
.toast{position:fixed;left:50%;bottom:calc(var(--bar-h) + 16px + env(safe-area-inset-bottom,0px));transform:translateX(-50%) translateY(10px);
  background:rgba(30,30,32,.92);color:#fff;padding:10px 18px;border-radius:20px;font-size:14px;font-weight:500;opacity:0;pointer-events:none;transition:opacity .2s,transform .2s;z-index:30;max-width:calc(100vw - 32px)}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}

/* login */
.login{min-height:100vh;min-height:100dvh;display:grid;place-items:center;padding:24px 16px}
.login form{width:min(360px,100%);background:var(--card);border-radius:20px;padding:28px 20px 20px}
.login h1{text-align:center;margin-bottom:4px}
.login p.meta{margin:0 0 18px;text-align:center;color:var(--text-2);font-size:14px}
.login .field input{background:var(--fill)}
.login .btn{width:100%;padding:12px}

/* notify */
.times{display:flex;flex-wrap:wrap;gap:8px;align-items:center}
.time-chip{display:inline-flex;align-items:center;background:var(--fill);border-radius:10px;padding-left:10px}
.time-chip input{border:0;background:none;padding:8px 2px;width:auto;min-height:0}
.time-chip .btn{padding:6px 10px;color:var(--text-2)}
.logs{list-style:none;margin:0;padding:0;font-size:14px}
.logs li{display:grid;grid-template-columns:auto auto 1fr;gap:10px;padding:9px 0;border-top:.5px solid var(--sep)}
.logs li:first-child{border-top:0}
.logs .ok{color:var(--green);font-weight:600}
.logs .bad{color:var(--red);font-weight:600}
.logs .t{color:var(--text-2)}

@media (prefers-reduced-motion:reduce){*{transition:none!important}}

/* currency */
.pair3{display:grid;grid-template-columns:1fr 84px 96px;gap:8px}
.fx-warn{display:block;width:100%;text-align:left;border:0;background:var(--orange-soft);color:var(--orange);border-radius:10px;padding:9px 12px;margin:14px 0 0;font-size:13px;font-weight:500}
.fx-list{list-style:none;margin:0 0 14px;padding:0;border-radius:10px;background:var(--fill);overflow:hidden}
.fx-list li{display:grid;grid-template-columns:1fr auto 104px auto 40px;align-items:center;gap:8px;padding:8px 12px;border-top:.5px solid var(--sep);font-size:14px}
.fx-list li:first-child{border-top:0}
.fx-code{display:flex;flex-direction:column;line-height:1.25;min-width:0}
.fx-code small{font-size:12px;color:var(--text-2)}
.fx-list li.used .fx-code small{color:var(--accent)}
.fx-eq,.fx-b{color:var(--text-2);font-size:13px}
.fx-list input{width:100%;border:0;background:var(--card);border-radius:8px;padding:7px 8px;text-align:right;font-variant-numeric:tabular-nums}
.fx-tag{font-size:11px;color:var(--text-3);text-align:center}
.fx-tag.man{color:var(--accent);font-weight:600}
@media (max-width:420px){.pair3{grid-template-columns:1fr 78px 88px}.fx-list li{grid-template-columns:1fr 96px auto 36px}.fx-eq{display:none}}

/* security & custom currency */
.sub{font-size:15px;font-weight:600;margin:18px 0 8px}
.sub.flush,.hint.flush{margin:0}
.panel .sub:first-of-type{margin-top:12px}
.sec-row{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-top:20px;padding-top:16px;border-top:.5px solid var(--sep)}
.sec-row .hint{margin-top:2px}
.tfa-box{background:var(--fill);border-radius:12px;padding:14px;margin-top:12px}
.tfa-box p{color:var(--text)}
.qr{width:188px;height:188px;margin:4px auto 12px;background:#fff;border-radius:10px;padding:6px}
.qr svg{display:block;width:100%;height:100%}
.codes{list-style:none;margin:0 0 12px;padding:10px 12px;display:grid;grid-template-columns:1fr 1fr;gap:6px 16px;background:var(--card);border-radius:10px;font-family:ui-monospace,"SF Mono",Menlo,monospace;font-size:15px}
.sec-foot{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-top:20px;padding-top:16px;border-top:.5px solid var(--sep)}
.cur-add{display:grid;grid-template-columns:80px 80px 1fr auto;gap:8px}
.cur-add.two{grid-template-columns:1fr auto}
.cur-add input{border:0;background:var(--fill);border-radius:10px;padding:9px 10px;font-size:15px;min-width:0}
.tfa-box .cur-add input{background:var(--card)}
.fx-sym{font-weight:400;color:var(--text-2);font-size:12px}
.fx-del{font-size:12px}
@media (max-width:420px){.cur-add{grid-template-columns:1fr 1fr}.cur-add input:nth-child(3){grid-column:1/-1}}

/* custom order */
.sort-bar{display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--accent-soft);border-radius:14px;padding:10px 12px 10px 16px;margin-bottom:16px;font-size:14px}
.sort-bar .handle.demo{display:inline-block;width:20px;height:14px;vertical-align:-2px;background-position:0 1px,0 6px,0 11px}
.sort-groups{list-style:none;margin:0;padding:0}
.sort-head{gap:10px;justify-content:flex-start}
.g-name.as-text{font-size:17px}
.row.sort-row{display:flex;align-items:center;gap:10px;padding:8px 12px 8px 8px}
.sort-row .r-name{flex:1;min-width:0}
.handle{flex:none;width:36px;height:36px;touch-action:none;cursor:grab;border-radius:8px;
  background:linear-gradient(var(--text-3) 0 0) 8px 11px/20px 2px no-repeat,linear-gradient(var(--text-3) 0 0) 8px 17px/20px 2px no-repeat,linear-gradient(var(--text-3) 0 0) 8px 23px/20px 2px no-repeat}
.handle:hover{background-color:var(--fill)}
.sort-btns{margin-left:auto;display:flex;gap:6px;flex:none}
.sort-btns button{border:0;background:var(--fill);color:var(--accent);border-radius:8px;width:34px;height:32px;font-size:16px;font-weight:600}
.sortable.dragging{position:relative;z-index:6;box-shadow:0 10px 30px rgba(0,0,0,.2);background:var(--card);border-radius:12px}
body.is-dragging{user-select:none;-webkit-user-select:none;cursor:grabbing}
body.is-dragging .handle{cursor:grabbing}
.sort-bar .btn{white-space:nowrap;flex:none}
.sort-sub{display:block;font-size:13px;color:var(--text-2);font-weight:400}
.group > .rows:first-child > .row:first-child::before{display:none}
