/* ==========================================================================
   GTC 工作室记账 — 设计系统
   品牌三色直接承担账本语义：橙 < 支出 / 蓝 > 收入 / 绿 / 结余
   ========================================================================== */

:root {
    --out:   #D8552A;
    --out-bg:#FCEDE6;
    --in:    #1479B8;
    --in-bg: #E6F1F8;
    --net:   #5F9E2A;
    --net-bg:#EDF5E4;

    --paper: #EDF0E9;
    --card:  #FFFFFF;
    --ink:   #1A2229;
    --ink-2: #5C6870;
    --ink-3: #8C979D;
    --rule:  #E1E6DD;
    --dash:  #C9D2C4;
    --night: #16212B;

    /* 分类调色板：只用来「区分彼此」，不表达任何语义。
       和上面三色语义刻意拉开 —— 支出橙、收入蓝、结余绿永远是那三个含义，
       这里的颜色只是给账本、分类预算分段做标识，不可互换使用。 */
    --cat-1: #C77B3C;
    --cat-2: #6C7BA8;
    --cat-3: #8E6BA8;
    --cat-4: #B85C7A;
    --cat-5: #4E9080;
    --cat-6: #A8973F;
    --cat-7: #7A8B6C;
    --cat-8: #9A6B52;

    --font-body: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
    --font-num:  "Cascadia Mono", "JetBrains Mono", "SF Mono", Consolas, "Courier New", monospace;

    --r-sm: 6px;
    --r:    10px;
    --r-lg: 16px;
    --shadow: 0 1px 2px rgba(26,34,41,.05), 0 10px 26px rgba(26,34,41,.06);
    --rail-w: 232px;
    --tap: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p  { margin: 0 0 10px; }
a  { color: var(--in); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--in);
    outline-offset: 2px;
    border-radius: 4px;
}

.num, .amount, .stat-value, .col-num {
    font-family: var(--font-num);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* 金额大小号：整数大、小数小 */
.mnum { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mfrac { font-size: .62em; vertical-align: .4em; opacity: .85; margin-left: 1px; }

/* 分类首字圆形徽章 */
.cat-badge {
    width: 34px; height: 34px; flex: none; border-radius: 50%;
    display: grid; place-items: center;
    background: #EFF2EC; color: var(--ink-2);
    font-weight: 700; font-size: 14px; line-height: 1;
}

.eyebrow {
    font-family: var(--font-num);
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0 0 6px;
}

.muted { color: var(--ink-2); }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.tiny  { font-size: 12px; }
.is-in { color: var(--in); }
.is-out{ color: var(--out); }
.is-net{ color: var(--net); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 内联 SVG 图标 */
.i {
    width: 18px; height: 18px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round;
}
.nav .i { width: 20px; height: 20px; opacity: .85; }
.nav a.on .i { opacity: 1; }
.op .i { width: 15px; height: 15px; }
.btn .i { width: 16px; height: 16px; }
.topbar .i { width: 20px; height: 20px; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--tap); padding: 0 18px;
    font: inherit; font-weight: 600; font-size: 14px;
    border: 1px solid transparent; border-radius: var(--r);
    background: var(--card); color: var(--ink);
    cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--night); color: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.btn-primary:hover { background: #223243; }
.btn-in   { background: var(--in); color: #fff; }
.btn-out  { background: var(--out); color: #fff; }
.btn-ghost{ background: transparent; border-color: var(--rule); color: var(--ink-2); }
.btn-ghost:hover { background: #fff; color: var(--ink); }
.btn-danger{ background: transparent; border: 1px solid #F0D5CB; color: var(--out); }
.btn-danger:hover { background: var(--out-bg); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field > label, .label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: var(--ink-2);
}
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=search], select, textarea {
    width: 100%; min-height: var(--tap); padding: 10px 12px;
    font: inherit; font-size: 16px; color: var(--ink);
    background: #fff; border: 1px solid var(--rule); border-radius: var(--r);
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--dash); }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--in);
    box-shadow: 0 0 0 3px rgba(20,121,184,.14);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
textarea { min-height: 88px; resize: vertical; }
select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    padding-right: 38px; cursor: pointer; line-height: 1.4;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235C6870' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 13px center; background-size: 14px 14px;
    transition: border-color .12s ease, box-shadow .12s ease, background-color .12s ease;
}
select:hover { border-color: var(--dash); background-color: #FCFDFB; }
select:focus { border-color: var(--in); background-color: #fff; }
select:active { border-color: var(--in); }
select:disabled { background-color: #F3F5F0; color: var(--ink-3); cursor: not-allowed; }
select option { color: var(--ink); background: #fff; }
select optgroup { color: var(--ink-2); font-style: normal; font-weight: 700; }
.hint { margin-top: 6px; font-size: 12px; color: var(--ink-3); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* 金额输入：¥ 前缀 */
.money-input { position: relative; }
.money-input::before {
    content: "¥"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    font-family: var(--font-num); font-size: 17px; color: var(--ink-3); pointer-events: none;
}
.money-input input { padding-left: 28px; font-family: var(--font-num); font-size: 18px; }

/* 收入/支出 切换 */
.kind-switch {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px;
    background: #E4E8E0; border-radius: var(--r);
}
.kind-switch input { position: absolute; opacity: 0; pointer-events: none; }
.kind-switch label {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; margin: 0; border-radius: var(--r-sm);
    font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.kind-switch input:checked + label { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(26,34,41,.14); }
.kind-switch input#kind-income:checked + label { color: var(--in); }
.kind-switch input#kind-expense:checked + label { color: var(--out); }
.kind-switch input:focus-visible + label { outline: 2px solid var(--in); outline-offset: 1px; }

/* ---------- 卡片 ---------- */
.card {
    min-width: 0;
    background: var(--card); border: 1px solid var(--rule);
    border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 8px 12px;
    flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--rule);
}
.card-head h2 { font-size: 16px; min-width: 0; }
.card-body { padding: 20px; }

/* ---------- 提示条 ---------- */
.flash-stack { display: grid; gap: 10px; margin-bottom: 16px; }
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: var(--r);
    background: #fff; border: 1px solid var(--rule);
    border-left-width: 3px; font-size: 14px;
}
.flash-success { border-left-color: var(--net); background: var(--net-bg); }
.flash-error   { border-left-color: var(--out); background: var(--out-bg); }
.flash-info    { border-left-color: var(--in); background: var(--in-bg); }

/* ---------- 徽标 ---------- */
.badge {
    display: inline-flex; align-items: center; padding: 2px 8px;
    font-size: 12px; font-weight: 600; border-radius: 999px;
    background: #EAEDE6; color: var(--ink-2);
}
.badge-in  { background: var(--in-bg);  color: var(--in); }
.badge-out { background: var(--out-bg); color: var(--out); }
.badge-off { background: #F0F0F0; color: #9A9A9A; }

/* ---------- 分类调色板取色 ----------
   .cN 只设一个 --c 变量，由消费它的组件决定画成背景还是描边。
   用途：账本色点、分类预算的分配环分段。不参与 支出/收入/结余 的语义表达。 */
.c1 { --c: var(--cat-1); }
.c2 { --c: var(--cat-2); }
.c3 { --c: var(--cat-3); }
.c4 { --c: var(--cat-4); }
.c5 { --c: var(--cat-5); }
.c6 { --c: var(--cat-6); }
.c7 { --c: var(--cat-7); }
.c8 { --c: var(--cat-8); }

/* 账本切换器（侧栏之外，页面头部 chip 行） */
.ledger-switch i.ldot {
    display: inline-block; width: 8px; height: 8px; border-radius: 2px;
    margin-right: 6px; vertical-align: baseline; background: var(--c, var(--ink-3));
}
.led-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; background: var(--c, var(--ink-3)); }

/* ==========================================================================
   应用外壳
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--rail-w) 1fr; min-height: 100vh; }

.rail {
    position: sticky; top: 0; align-self: start; height: 100vh;
    display: flex; flex-direction: column; gap: 18px;
    padding: 20px 16px; background: var(--night); color: #C8D3DC;
    overflow-y: auto;   /* 导航项增多（含账本、管理、成员），矮屏要能滚动 */
}
.rail-brand { display: flex; align-items: center; gap: 8px; min-width: 0; height: 56px; padding: 0 6px; border-bottom: 1px solid rgba(255,255,255,.09); }
.rail-brand img { height: 22px; width: auto; flex: none; background: transparent; }
.brand-sep { width: 1px; height: 20px; flex: none; background: rgba(255,255,255,.22); }
.brand-logo { display: contents; }
.brand-logo img { display: block; }
.brand-logo:hover { text-decoration: none; }
.brand-name { font-family: var(--font-num); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: #EAF0F4; white-space: nowrap; text-decoration: none; }
.brand-name:hover { color: #fff; text-decoration: none; }
.nav { display: grid; gap: 2px; }
.nav a {
    display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px;
    border-radius: var(--r-sm); color: #B4C2CD; font-size: 15.5px; font-weight: 500;
    transition: background .14s ease, color .14s ease;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.on { background: rgba(255,255,255,.1); color: #fff; box-shadow: inset 3px 0 0 var(--net); }
.nav .ic { width: 20px; text-align: center; font-size: 17px; opacity: .9; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; }
.who {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border-radius: var(--r-sm); background: rgba(255,255,255,.05);
}
.who .avatar {
    width: 30px; height: 30px; flex: none; border-radius: 8px;
    display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff;
    background: var(--in);
}
.who .name { font-size: 13px; color: #fff; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .role { font-family: var(--font-num); font-size: 10px; letter-spacing: .1em; color: #7F93A3; }
.rail-logout { font-size: 13px; color: #8FA1AF; text-align: right; }
.rail-logout:hover { color: #fff; }
.rail-dl { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 12px; border-radius: var(--r-sm); background: rgba(255,255,255,.07); color: #D6E0E8; font-size: 14px; font-weight: 600; text-decoration: none; transition: background .14s ease, color .14s ease; }
.rail-dl:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.rail-dl .i { width: 18px; height: 18px; }

.main { min-width: 0; padding: 26px 30px 60px; }
.wrap { max-width: 1000px; margin: 0 auto; }

.app-foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--rule); text-align: center; font-size: 12px; color: var(--ink-3); }
.app-foot a { color: inherit; text-decoration: none; }
.app-foot a:hover { color: var(--ink-2); text-decoration: underline; }

.topbar { display: none; }
.tabbar { display: none; }

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 14px;
    flex-wrap: wrap; margin-bottom: 20px;
}
.page-head .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==========================================================================
   概览：结余卡 + 流水条
   ========================================================================== */
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }

.balance {
    position: relative; overflow: hidden;
    padding: 24px; border-radius: var(--r-lg);
    background: var(--night); color: #fff; box-shadow: var(--shadow);
}
.balance::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(255,255,255,.045) 27px 28px);
}
.balance .eyebrow { color: #7F93A3; }
.stat-value { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat-value .cur { font-size: 18px; font-weight: 500; color: #8FA1AF; margin-right: 4px; }
.stat-line { display: flex; gap: 22px; margin-top: 14px; }
.stat-line > div { min-width: 0; }
.stat-line .k { font-size: 12px; color: #8FA1AF; }
.stat-line .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 17px; font-weight: 600; }

/* 流水条：收入/支出按比例的横向条，带等分刻度 */
.strip { margin-top: 18px; }
.strip-bar {
    position: relative; display: flex; height: 10px; border-radius: 999px;
    overflow: hidden; background: rgba(255,255,255,.12);
}
.strip-bar i { display: block; height: 100%; transition: width .5s cubic-bezier(.2,.7,.3,1); }
.strip-bar .s-in  { background: var(--in); }
.strip-bar .s-out { background: var(--out); }
.strip-ticks {
    height: 7px; margin-top: 5px;
    background: repeating-linear-gradient(to right, rgba(255,255,255,.28) 0 1px, transparent 1px 10%);
}
.strip-legend { display: flex; justify-content: space-between; margin-top: 6px; font-size: 12px; color: #8FA1AF; }
.strip-legend b { font-family: var(--font-num); color: #fff; font-weight: 600; }

.tile { padding: 18px 20px; }
.tile .k { font-size: 12px; color: var(--ink-2); }
.tile .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.tile .d { font-size: 12px; color: var(--ink-3); margin-top: 4px; }

/* ==========================================================================
   流水账页
   ========================================================================== */
.ledger { overflow: hidden; }
.day-group + .day-group { border-top: 1px dashed var(--dash); }
.day-head {
    display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
    padding: 10px 20px 8px; background: #F7F9F5;
    border-bottom: 1px solid var(--rule);
}
.day-head .d { font-family: var(--font-num); font-size: 12px; letter-spacing: .06em; color: var(--ink-2); }
.day-head .sum { font-family: var(--font-num); font-size: 12px; color: var(--ink-3); }

.entry {
    display: grid; grid-template-columns: 78px 1fr auto 96px; align-items: center; gap: 12px;
    min-height: 60px; padding: 10px 20px;
    border-bottom: 1px dashed var(--dash);
    transition: background .12s ease;
}
.entry:last-child { border-bottom: 0; }
.entry:hover { background: #FAFBF8; }
.entry .date { font-family: var(--font-num); font-size: 12px; color: var(--ink-3); }
.entry .main-col { min-width: 0; display: flex; align-items: center; gap: 10px; }
.entry .mc-txt { min-width: 0; }
.entry .title { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .meta { font-size: 12px; color: var(--ink-3); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 1px; }
.entry .cat {
    display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px;
    font-size: 12px; background: #EFF2EC; color: var(--ink-2);
}
.entry .amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 16px; font-weight: 700; text-align: right; }
.entry .amt .who-name { display: block; font-family: var(--font-body); font-size: 11px; font-weight: 400; color: var(--ink-3); }
/* 「全部账本」视图下每行的账本标记 */
.entry .meta .book-tag {
    display: inline-flex; align-items: center; padding: 0 7px; border-radius: 999px;
    background: var(--night); color: #EAF0F4; font-size: 11px; font-weight: 600;
}
/* 这笔收入已计入当月预算。蓝底上必须用纯白字，灰字压不住品牌蓝 */
.entry .meta .budget-tag {
    display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 999px;
    background: var(--in); color: #FFFFFF; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.entry .ops { display: flex; gap: 4px; opacity: 0; transition: opacity .12s ease; }
.entry:hover .ops, .entry:focus-within .ops { opacity: 1; }
.op {
    width: 30px; height: 30px; display: grid; place-items: center;
    border: 1px solid transparent; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-2); cursor: pointer; font-size: 14px; text-decoration: none;
}
.op:hover { background: #EFF2EC; border-color: var(--rule); text-decoration: none; }
.op.del:hover { background: var(--out-bg); color: var(--out); border-color: #F0D5CB; }

/* 分类排行榜（统计页） */
.rank { display: grid; gap: 14px; }
.rank-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; }
.rank-main { min-width: 0; }
.rank-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.rank-top .nm { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-top .nm em { font-style: normal; font-family: var(--font-num); font-size: 12px; color: var(--ink-3); font-weight: 500; margin-left: 6px; }
.rank-top .amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 700; white-space: nowrap; }
.rank-bar { height: 8px; border-radius: 999px; background: #EFF2EC; overflow: hidden; }
.rank-bar i { display: block; height: 100%; border-radius: 999px; background: var(--out); transition: width .5s cubic-bezier(.2,.7,.3,1); }
.rank-bar i.in { background: var(--in); }

/* 概览预算环形图 */
.ovring-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ovring { width: 132px; height: 132px; flex: none; }
.ovring .rb-bg { fill: none; stroke: var(--net); stroke-width: 12; }
.ovring .rb-fg { fill: none; stroke: var(--out); stroke-width: 12; stroke-linecap: round; transition: stroke-dashoffset .7s cubic-bezier(.2,.7,.3,1); }
.ovring .rb-fg.over { stroke: var(--out); }
.ovring .rb-num { font-family: var(--font-num); font-weight: 700; font-size: 22px; fill: var(--ink); text-anchor: middle; }
.ovring .rb-cap { font-size: 9px; fill: var(--ink-3); text-anchor: middle; letter-spacing: .05em; }
.ovring-rows { flex: 1; min-width: 180px; display: grid; gap: 10px; }
.ovring-rows .big { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px dashed var(--dash); }
.ovring-rows .big .k { font-size: 13px; color: var(--ink-2); }
.ovring-rows .big .v { font-size: 24px; font-weight: 700; }
.ovring-rows .row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13px; }
.ovring-rows .row .k { color: var(--ink-2); }
.ovring-rows .row .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; }
/* 概览预算卡：总进度环与分类预算分配环并排 */
.ovring-duo { display: flex; align-items: center; gap: 16px; flex: none; }
.ovring.ovring-sm { width: 104px; height: 104px; }
.ovring-sm .rb-num { font-size: 13px; }
.ovring-sm .rb-cap { font-size: 8px; }
/* 分配环的分段：一段一个分类（用 --cat-N 取色）+ 未分配 + 固定支出 */
.ovring .rb-seg {
    fill: none; stroke-width: 12; stroke: var(--c, var(--rule));
    animation: arcgrow .8s cubic-bezier(.2,.7,.3,1) both;
}
.ovring .rb-seg.unalloc { stroke: #DDE3D8; }
.ovring .rb-seg.fixed   { stroke: #B9C2B4; }

/* 分类预算图例（概览页的紧凑横排版，预算页用的是竖排 .alloc-legend） */
.cat-legend { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 14px; font-size: 12px; color: var(--ink-2); }
.cat-legend .it { display: inline-flex; align-items: center; gap: 6px; }
.cat-legend .it i { width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--rule)); flex: none; }
.cat-legend .it i.unalloc { background: #DDE3D8; }
.cat-legend .it i.fixed   { background: #B9C2B4; }
.cat-legend .it b { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

.ovring-mini { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--ink-2); }
.ovring-mini b { font-family: var(--font-num); color: var(--ink); font-weight: 600; }
@media (max-width: 560px) {
    .ovring-wrap { flex-direction: column; align-items: center; gap: 16px; }
    .ovring-rows { width: 100%; min-width: 0; }
}

/* 筛选条 */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; flex: 1 1 130px; min-width: 120px; }
.filters .field.grow { flex: 2 1 200px; }

/* 表格 */
table.grid-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid-table th {
    text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600;
    color: var(--ink-2); background: #F7F9F5; border-bottom: 1px solid var(--rule); white-space: nowrap;
}
.grid-table td { padding: 12px 14px; border-bottom: 1px dashed var(--dash); vertical-align: middle; }
.grid-table tr:last-child td { border-bottom: 0; }
.grid-table td.col-num { text-align: right; }

/* 分页 */
.pager { display: flex; gap: 6px; justify-content: center; align-items: center; padding: 18px 0 4px; flex-wrap: wrap; }
.pager a, .pager span {
    min-width: 36px; height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--rule); border-radius: var(--r-sm); background: #fff;
    font-family: var(--font-num); font-size: 13px; color: var(--ink-2);
}
.pager a:hover { border-color: var(--in); color: var(--in); text-decoration: none; }
.pager .cur { background: var(--night); border-color: var(--night); color: #fff; }
.pager .gap { border: 0; background: none; }

/* 空状态 */
.empty { padding: 46px 24px; text-align: center; }
.empty .mark { font-family: var(--font-num); font-size: 26px; letter-spacing: .1em; color: var(--dash); }
.empty h3 { margin: 8px 0 4px; }
.empty p { color: var(--ink-2); font-size: 14px; margin-bottom: 16px; }

/* 统计图 */
.bars { display: grid; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 132px; align-items: center; gap: 12px; font-size: 13px; }
.bar-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; border-radius: 999px; background: #EFF2EC; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--out); transition: width .5s cubic-bezier(.2,.7,.3,1); }
.bar-fill.in { background: var(--in); }
.bar-row .vl { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-2); white-space: nowrap; }

.trend { display: flex; align-items: flex-end; gap: 10px; height: 168px; padding-top: 10px; overflow-x: auto; }
.trend .col { flex: 1 0 34px; display: grid; justify-items: center; gap: 6px; min-width: 34px; }
.trend .pair { display: flex; align-items: flex-end; gap: 3px; height: 120px; width: 100%; justify-content: center; }
.trend .b { width: 11px; border-radius: 3px 3px 0 0; background: var(--rule); transition: height .5s cubic-bezier(.2,.7,.3,1); }
.trend .b.in  { background: var(--in); }
.trend .b.out { background: var(--out); }
.trend .lb { font-family: var(--font-num); font-size: 10px; color: var(--ink-3); white-space: nowrap; }

/* 快捷入口 */
.quick { display: flex; gap: 10px; flex-wrap: wrap; }
.quick a {
    display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px;
    border: 1px dashed var(--dash); border-radius: 999px; background: #fff;
    font-size: 14px; color: var(--ink-2);
}
.quick a:hover { border-style: solid; color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }

/* 分类管理 */
.cat-list { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cat-items { display: grid; gap: 6px; padding: 4px; }
.cat-chip {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 9px 12px; border-radius: var(--r-sm); background: #F7F9F5; font-size: 14px;
}
.cat-chip .sys { font-size: 11px; color: var(--ink-3); }

/* ==========================================================================
   宫格图标选择器（记一笔 / 分类预算共用）
   原先是 record_new.php 的页内样式，因为预算页也要用，上提到这里统一定义。
   ========================================================================== */
.picker { position: relative; }
.picker-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-height: var(--tap); padding: 0 12px; background: #fff; border: 1px solid var(--rule);
    border-radius: var(--r); font: inherit; font-size: 15px; color: var(--ink); cursor: pointer;
}
.picker-btn:hover { border-color: var(--dash); }
.picker-cur { display: flex; align-items: center; gap: 8px; min-width: 0; }
.picker-cur .i { width: 18px; height: 18px; color: var(--ink-2); flex: none; }
.picker-cur b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-cur .ph { color: var(--ink-3); font-weight: 500; }
.picker-btn .chev { width: 16px; height: 16px; color: var(--ink-3); flex: none; transition: transform .18s ease; }
.picker-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.picker-panel {
    margin-top: 8px; padding: 12px; border: 1px solid var(--rule);
    border-radius: var(--r); background: #F7F9F5; box-shadow: var(--shadow);
}
.cat-grid, .pay-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cat-tile, .pay-tile {
    display: grid; justify-items: center; gap: 6px; padding: 10px 4px;
    border: 1px solid var(--rule); border-radius: var(--r); background: #fff;
    font: inherit; font-size: 12px; color: var(--ink-2); cursor: pointer; text-decoration: none;
    transition: border-color .12s, box-shadow .12s, color .12s;
}
.cat-tile .i, .pay-tile .i { width: 22px; height: 22px; color: var(--ink-2); }
.cat-tile span, .pay-tile span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-tile:hover, .pay-tile:hover { border-color: var(--dash); color: var(--ink); text-decoration: none; }
.cat-tile.on, .pay-tile.on { border-color: var(--night); box-shadow: inset 0 0 0 1px var(--night); color: var(--night); }
.cat-tile.on .i, .pay-tile.on .i { color: var(--night); }
.cat-tile--set { border-style: dashed; color: var(--ink-3); }
.cat-tile--set .i { color: var(--ink-3); }

/* 账本单选（记一笔）：胶囊风格，与 .quick 同母题 */
.book-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.book-opt {
    position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px;
    border: 1px solid var(--rule); border-radius: 999px; background: #fff;
    font-size: 14px; color: var(--ink-2); cursor: pointer; text-decoration: none;
    transition: border-color .12s, box-shadow .12s, color .12s;
}
.book-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.book-opt:hover { border-color: var(--dash); color: var(--ink); text-decoration: none; }
.book-opt.on, .book-opt:has(input:checked) {
    border-color: var(--night); box-shadow: inset 0 0 0 1px var(--night); color: var(--night);
}
.book-opt--set { border-style: dashed; color: var(--ink-3); }
.book-opt .i { width: 15px; height: 15px; }

/* 勾选选项行（整行可点）：记一笔「计入本月预算」与预算页的长期设置共用。
   选中态只把描边和方框染成品牌蓝，勾用纯白、文字走近黑 —— 灰字压蓝底对比度不够 */
.opt-row {
    position: relative; display: flex; align-items: flex-start; gap: 11px; padding: 12px 14px;
    border: 1px solid var(--rule); border-radius: var(--r); background: #fff; cursor: pointer;
    transition: border-color .12s, box-shadow .12s;
}
.opt-row:hover { border-color: var(--dash); }
.opt-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt-box {
    position: relative; flex: none; width: 20px; height: 20px; margin-top: 1px;
    border: 1.5px solid var(--dash); border-radius: 6px; background: #fff;
    transition: border-color .12s, background .12s;
}
.opt-box::after {
    content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px;
    border: solid #FFFFFF; border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(.5); opacity: 0; transition: opacity .12s, transform .12s;
}
.opt-row:has(input:checked) { border-color: var(--in); box-shadow: inset 0 0 0 1px var(--in); }
.opt-row:has(input:checked) .opt-box { border-color: var(--in); background: var(--in); }
.opt-row:has(input:checked) .opt-box::after { opacity: 1; transform: rotate(45deg) scale(1); }
.opt-row:has(input:focus-visible) { outline: 2px solid var(--in); outline-offset: 2px; }
.opt-txt b { display: block; font-size: 14px; font-weight: 600; color: var(--ink); }
.opt-txt em { display: block; font-style: normal; font-size: 12px; color: var(--ink-2); margin-top: 3px; line-height: 1.5; }
.opt-row + .opt-row { margin-top: 8px; }

/* ==========================================================================
   分类预算：分配环 + 明细行（budget.php）
   ========================================================================== */
.alloc-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.alloc { width: 150px; height: 150px; flex: none; }
.alloc circle { fill: none; stroke-width: 14; }
.alloc .seg { stroke: var(--c, var(--rule)); animation: arcgrow .8s cubic-bezier(.2,.7,.3,1) both; }
.alloc .seg.unalloc { stroke: #DDE3D8; }
.alloc .seg.fixed   { stroke: #B9C2B4; }
.alloc .alloc-num { font-family: var(--font-num); font-weight: 700; font-size: 20px; fill: var(--ink); text-anchor: middle; }
.alloc .alloc-cap { font-size: 9px; fill: var(--ink-3); text-anchor: middle; letter-spacing: .05em; }
/* 从空弧长到目标弧长：只给 from，to 取元素自身的 stroke-dasharray */
@keyframes arcgrow { from { stroke-dasharray: 0 9999; } }

.alloc-legend { display: grid; gap: 8px; flex: 1; min-width: 176px; }
.alloc-legend .row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 13px; }
.alloc-legend .k { color: var(--ink-2); display: flex; align-items: center; gap: 7px; min-width: 0; }
.alloc-legend .k i { width: 9px; height: 9px; border-radius: 3px; flex: none; background: var(--c, var(--rule)); }
.alloc-legend .k i.unalloc { background: #DDE3D8; }
.alloc-legend .k i.fixed   { background: #B9C2B4; }
.alloc-legend .v { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-weight: 600; }

.alloc-sum {
    display: flex; gap: 20px; flex-wrap: wrap; align-items: baseline;
    padding: 11px 14px; border-radius: var(--r); background: #F7F9F5;
    font-size: 13px; color: var(--ink-2); margin-bottom: 14px;
}
.alloc-sum b { font-family: var(--font-num); font-size: 15px; color: var(--ink); }
.alloc-sum.over { background: var(--out-bg); color: var(--out); }
.alloc-sum.over b { color: var(--out); }

.bc-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px dashed var(--dash); }
.bc-row:last-of-type { border-bottom: 0; }
.bc-main { min-width: 0; }
.bc-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.bc-top .nm { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bc-top .amt { font-family: var(--font-num); font-variant-numeric: tabular-nums; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.bc-top .amt b { color: var(--ink); font-weight: 700; }
.bc-row.over .bc-top .amt b { color: var(--out); }
.bc-row .bar-track { display: block; }
/* 分类预算进度：没超支走结余绿，超支走支出橙（默认色） */
.bar-fill.ok { background: var(--net); }
.bc-note { font-size: 12px; color: var(--ink-3); }
.bc-add { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
.bc-add .picker { flex: 1 1 260px; min-width: 220px; }
.bc-add .money-input { flex: 0 1 160px; }
@media (max-width: 560px) {
    .alloc-wrap { flex-direction: column; align-items: center; gap: 16px; }
    .alloc-legend { width: 100%; min-width: 0; }
    .bc-row { grid-template-columns: 30px 1fr auto; gap: 10px; }
    .bc-add .picker, .bc-add .money-input { flex: 1 1 100%; }
}

/* ==========================================================================
   登录 / 注册
   ========================================================================== */
.auth {
    min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    background: var(--paper);
}
.auth-aside {
    position: relative; overflow: hidden; padding: 46px 44px;
    display: flex; flex-direction: column; justify-content: space-between;
    background: var(--night); color: #C8D3DC;
}
.auth-aside::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(to bottom, transparent 0 31px, rgba(255,255,255,.05) 31px 32px);
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-mark { display: flex; align-items: center; gap: 12px; }
.auth-mark img { height: 34px; background: #fff; border-radius: 7px; padding: 3px 7px; }
.auth-mark .intro { margin-left: auto; font-size: 13px; color: #9FB0BC; white-space: nowrap; }
.auth-mark .intro:hover { color: #fff; text-decoration: none; }
.auth-head { font-size: 30px; line-height: 1.28; color: #fff; max-width: 15em; }
.auth-mid { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 30px 0; }
.auth-head em { font-style: normal; font-family: var(--font-num); }
.auth-sub { color: #8FA1AF; font-size: 14px; max-width: 26em; margin-top: 12px; }
.auth-demo { margin-top: auto; }
.auth-demo .eyebrow { color: #7F93A3; }

.auth-panel { display: grid; place-items: center; padding: 34px 24px; }
.auth-box { width: 100%; max-width: 372px; }
.auth-box h1 { font-size: 24px; margin-bottom: 4px; }
.auth-box .lead { color: var(--ink-2); font-size: 14px; margin-bottom: 22px; }
.auth-box .card { box-shadow: var(--shadow); }
.auth-form { padding: 22px; }
/* 窄屏（手机）下三个链接放不下会换行：允许换行，但每个链接整体不拆开 ——
   否则「初始化数据库」会被断成「初始化数据 / 库」 */
.auth-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 14px; margin-top: 18px; font-size: 13px; color: var(--ink-2); }
.auth-foot a { white-space: nowrap; }
.auth-icp { margin: 14px 0 0; text-align: center; font-size: 12px; color: var(--ink-3); }
.auth-icp a { color: inherit; text-decoration: none; }
.auth-icp a:hover { color: var(--ink-2); text-decoration: underline; }
.auth-brand-mobile { display: none; }
.strokes { display: flex; gap: 5px; align-items: center; font-family: var(--font-num); font-weight: 700; font-size: 15px; }
.strokes span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 4px; color: #fff; }
.strokes .s1 { background: var(--out); }
.strokes .s2 { background: var(--net); }
.strokes .s3 { background: var(--in); }

.auth-sample { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 11px; max-width: 300px; }
.auth-sample li { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #9FB0BC; }
.auth-sample .strokes span { width: 19px; height: 19px; font-size: 13px; }
.auth-sample .nm { white-space: nowrap; }
.auth-sample .dots { flex: 1; border-bottom: 1px dotted rgba(255,255,255,.26); transform: translateY(-4px); }
.auth-sample .vv { font-family: var(--font-num); font-variant-numeric: tabular-nums; color: #fff; }
.auth-sample li.net { color: #C8D3DC; font-weight: 600; }
.auth-sample li.net .vv { color: #A9D67F; }

/* ---------- 初始化页 ---------- */
.page-install { display: grid; place-items: center; padding: 40px 20px; }
.install-card { width: 100%; max-width: 560px; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 28px; }
.install-card .brand-logo { height: 30px; display: block; margin-bottom: 14px; }
.install-card h1 { font-size: 20px; margin-bottom: 16px; }
.install-steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.install-steps li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm); background: #F7F9F5; font-size: 14px; }
.install-steps .step-detail { color: var(--ink-3); font-size: 12px; }
.install-steps .step-ok { box-shadow: inset 3px 0 0 var(--net); }
.install-steps .step-keep { box-shadow: inset 3px 0 0 var(--in); }
.install-cred { padding: 12px 14px; border-radius: var(--r); background: var(--net-bg); font-size: 14px; }
.install-cred b { font-family: var(--font-num); }
.install-fail { padding: 12px 14px; border-radius: var(--r); background: var(--out-bg); color: var(--out); }
.install-hint { font-size: 12px; color: var(--ink-3); }

/* ---------- 动效与自适应 ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .38s cubic-bezier(.2,.7,.3,1) both; }

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

@media (max-width: 1080px) {
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .span-2 { grid-column: span 2; }
}

@media (max-width: 960px) {
    .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
    .rail { display: none; }
    .main { padding: 18px 0 88px; }
    .wrap { max-width: none; padding: 0 14px; }

    .topbar {
        position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
        height: 56px; padding: 0 14px; background: var(--night); color: #fff;
    }
    .topbar img { height: 27px; width: auto; flex: none; background: transparent; }
    .topbar .brand-name { font-size: 15.5px; padding: 4px 0; }
    .topbar .t { font-size: 14px; font-weight: 600; }
    .topbar .spacer { flex: 1; min-width: 0; }
    .topbar .net { font-family: var(--font-num); font-size: 13px; color: #9FB0BC; white-space: nowrap; display: none; }
    .topbar a { color: #9FB0BC; flex: none; }
    @media (min-width: 430px) { .topbar .net { display: inline; } }

    .tabbar {
        position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: rgba(255,255,255,.97);
        border-top: 1px solid var(--rule);
        -webkit-backdrop-filter: blur(8px);   /* iOS Safari 18 以前只认带前缀的 */
        backdrop-filter: blur(8px);
    }
    .tabbar a {
        display: grid; justify-items: center; gap: 2px; padding: 6px 0; min-height: var(--tap);
        font-size: 11px; color: var(--ink-3); text-decoration: none;
    }
    .tabbar a .ic { width: 18px; height: 18px; }
    .tabbar a.on { color: var(--in); font-weight: 600; }
    .tabbar a.add { color: var(--net); }
    .tabbar a.add .ic {
        width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px;
        background: var(--net); color: #fff; font-size: 19px; margin-top: -12px; box-shadow: 0 4px 12px rgba(95,158,42,.35);
    }

    .grid-3, .grid-2, .cat-list { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .stat-value { font-size: 28px; }
    .balance { padding: 20px; }
    .strip-legend { flex-wrap: wrap; gap: 6px 16px; }

    .entry { grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; }
    .entry .date { display: none; }
    .entry .main-col { grid-column: 1; }
    .entry .amt { grid-column: 2; grid-row: 1; }
    .entry .ops { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; opacity: 1; }
    .row-2, .row-3 { grid-template-columns: 1fr; }

    .auth { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
    .auth-brand-mobile { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
    .auth-brand-mobile img { height: 28px; }
    .auth-panel { padding: 26px 16px 40px; }
}

@media (max-width: 520px) {
    .page-head { align-items: flex-start; }
    .head-actions { width: 100%; }
    .head-actions .btn { flex: 1; }
    .filters .field { flex: 1 1 100%; }
}

@media print {
    .rail, .tabbar, .topbar, .head-actions, .filters, .entry .ops, .app-foot { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #bbb; }
}
