/* 星刃财税系统 · 样式
 * 账本感：数字右对齐、等宽，细线分行，不堆卡片。
 * 品牌紫只用在主按钮和重点数字上；黄色表示要处理，红色表示出问题，并且总配文字。 */

:root {
  --paper: #fbfafe;
  --surface: #ffffff;
  --ink: #1c1830;
  --ink-2: #514c66;
  --ink-3: #807a94;
  --line: #e6e2f0;
  --line-2: #d6d0e5;
  --blade: #6b3fd9;
  --blade-ink: #5a30c4;
  --on-blade: #ffffff;
  --track: #ebe5fb;
  --wash: #f3effd;
  --warn: #fab219;
  --warn-ink: #7a5200;
  --warn-wash: #fff4d9;
  --crit: #d03b3b;
  --crit-ink: #b42828;
  --crit-wash: #fdecec;
  --good: #0ca30c;
  --good-ink: #006300;
  --good-wash: #e5f6e5;
  --focus: #6b3fd9;
  --shadow: 0 18px 48px rgba(28, 24, 48, 0.18), 0 2px 6px rgba(28, 24, 48, 0.08);

  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans CJK TC", system-ui, sans-serif;
  --num: "DIN Alternate", Bahnschrift, "DIN Pro", -apple-system, "Helvetica Neue", "Noto Sans CJK SC", sans-serif;

  --s-12: 12px;
  --s-13: 13px;
  --s-15: 15px;
  --s-18: 18px;
  --s-24: 24px;
  --s-36: 36px;

  --r-s: 6px;
  --r-m: 10px;
  --r-l: 16px;
  --wrap: 980px;
  --pad: clamp(16px, 4vw, 40px);
}

:root[data-theme="dark"] {
  color-scheme: dark;
    --paper: #14121c;
    --surface: #1d1a28;
    --ink: #eeebf7;
    --ink-2: #bdb8cf;
    --ink-3: #8f89a3;
    --line: #2c2840;
    --line-2: #3a3552;
    --blade: #9c7bff;
    --blade-ink: #b9a2ff;
    --on-blade: #14121c;
    --track: #2b2442;
    --wash: #241f36;
    --warn-ink: #fab219;
    --warn-wash: #3a2f12;
    --crit: #e35a5a;
    --crit-ink: #ff8f8f;
    --crit-wash: #3a1a1e;
    --good-ink: #3fcf3f;
    --good-wash: #15301a;
    --focus: #b9a2ff;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14121c;
    --surface: #1d1a28;
    --ink: #eeebf7;
    --ink-2: #bdb8cf;
    --ink-3: #8f89a3;
    --line: #2c2840;
    --line-2: #3a3552;
    --blade: #9c7bff;
    --blade-ink: #b9a2ff;
    --on-blade: #14121c;
    --track: #2b2442;
    --wash: #241f36;
    --warn-ink: #fab219;
    --warn-wash: #3a2f12;
    --crit: #e35a5a;
    --crit-ink: #ff8f8f;
    --crit-wash: #3a1a1e;
    --good-ink: #3fcf3f;
    --good-wash: #15301a;
    --focus: #b9a2ff;
    --shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--s-15)/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
body.sheet-open { overflow: hidden; }
a { color: var(--blade-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }

/* ---------- 顶栏 ---------- */

.banner {
  padding: 8px var(--pad);
  background: var(--warn-wash);
  color: var(--warn-ink);
  font-size: var(--s-13);
  text-align: center;
}

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  max-width: calc(var(--wrap) + 2 * var(--pad));
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) var(--pad) 14px;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; fill: var(--blade); }
.brand-mark-2 { opacity: 0.55; }
.brand-name { font-weight: 600; letter-spacing: 0.02em; }
.brand-sub { color: var(--ink-3); }

.tabs { display: flex; gap: 4px; flex: 1; }
.tabs a {
  position: relative;
  padding: 6px 12px;
  border-radius: var(--r-s);
  color: var(--ink-2);
  text-decoration: none;
}
.tabs a:hover { background: var(--wash); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tabs a[aria-current="page"]::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -2px;
  height: 2px; border-radius: 2px; background: var(--blade);
}

.view {
  max-width: calc(var(--wrap) + 2 * var(--pad));
  margin: 0 auto;
  padding: 20px var(--pad) 120px;
  outline: none;
}
.loading { color: var(--ink-3); padding: 40px 0; }

/* ---------- 按钮和输入框 ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--blade); border-color: var(--blade); color: var(--on-blade); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--blade-ink); }
.btn.quiet:hover { background: var(--wash); }
.btn.danger { border-color: transparent; background: transparent; color: var(--crit-ink); }
.btn.danger:hover { background: var(--crit-wash); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn.small { min-height: 30px; padding: 0 10px; font-size: var(--s-13); }

.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-s);
  background: var(--surface);
}
.textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: transparent; }
.input.is-bad, .select.is-bad { border-color: var(--crit); }
.select { appearance: none; -webkit-appearance: none; padding-right: 28px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat; }

.seg { display: inline-flex; padding: 2px; border: 1px solid var(--line-2); border-radius: var(--r-s); background: var(--surface); }
.seg button, .seg label {
  position: relative;
  padding: 4px 12px; border: 0; border-radius: 4px; background: transparent; color: var(--ink-2); cursor: pointer;
}
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg [aria-pressed="true"], .seg label:has(input:checked) { background: var(--ink); color: var(--paper); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 1px; }

/* ---------- 总览 ---------- */

.hero { padding: 28px 0 32px; }
.hero-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; font-weight: 400; }
.hero-lead { font-size: var(--s-24); color: var(--ink-2); }
.hero-num {
  font-size: clamp(44px, 8vw, 72px); line-height: 1; font-weight: 700;
  letter-spacing: -0.01em; color: var(--ink);
}
.hero-num.neg { color: var(--crit-ink); }
.hero-sub { margin-top: 12px; color: var(--ink-2); max-width: 46em; }
.hero-sub .num { color: var(--ink); font-weight: 700; }

.block { padding: 20px 0 8px; border-top: 1px solid var(--line); }
.block + .block { margin-top: 20px; }
.block-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; margin-bottom: 14px; }
.block-head h2 { font-size: var(--s-18); font-weight: 600; }
.hint { color: var(--ink-3); font-size: var(--s-13); }

.alloc { list-style: none; margin: 0; padding: 0; }
.alloc-row {
  display: grid;
  grid-template-columns: minmax(8em, 11em) 1fr minmax(12em, auto);
  align-items: center; gap: 4px 20px;
  padding: 12px 8px; margin: 0 -8px;
  border-radius: var(--r-s);
  color: inherit; text-decoration: none;
}
.alloc-row:hover { background: var(--wash); text-decoration: none; }
.alloc li + li .alloc-row { border-top: 1px solid var(--line); }
.alloc li + li .alloc-row:hover { border-top-color: transparent; }
.ar-name { font-weight: 600; }
.ar-name small { display: block; font-weight: 400; font-size: var(--s-12); color: var(--ink-3); line-height: 1.4; }
.ar-bar { display: flex; align-items: center; gap: 2px; height: 14px; }
.ar-track {
  position: relative; flex: 0 0 auto; width: var(--w); height: 14px; min-width: 2px;
  border-radius: 4px; background: var(--track); overflow: hidden;
}
.ar-fill { position: absolute; inset: 0 auto 0 0; width: var(--f); background: var(--blade); border-radius: 4px 0 0 4px; }
.ar-fill.full { border-radius: 4px; }
.ar-over { flex: 0 0 auto; width: var(--o); height: 14px; border-radius: 0 4px 4px 0; background: var(--crit); }
[data-status="warn"] .ar-fill { background: var(--warn); }
[data-status="over"] .ar-fill { background: var(--crit); }
.ar-nums { display: flex; align-items: baseline; justify-content: flex-end; gap: 12px; white-space: nowrap; }
.ar-left { font-size: var(--s-18); font-weight: 700; }
.ar-of { color: var(--ink-3); font-size: var(--s-13); }

.flag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: var(--s-12); font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.flag svg { width: 10px; height: 10px; fill: currentColor; }
.flag.warn { background: var(--warn-wash); color: var(--warn-ink); }
.flag.over, .flag.stop { background: var(--crit-wash); color: var(--crit-ink); }
.flag.up { background: var(--good-wash); color: var(--good-ink); }
.flag.watch { background: var(--wash); color: var(--ink-2); }
.flag.todo { background: transparent; color: var(--ink-3); border: 1px dashed var(--line-2); font-weight: 400; }
.flag.none { background: transparent; color: var(--ink-3); font-weight: 400; }

.note-line {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--r-s);
  background: var(--wash); color: var(--ink-2); font-size: var(--s-13);
}
.note-line.warn { background: var(--warn-wash); color: var(--warn-ink); }

.archived-head { margin: 18px 0 4px; color: var(--ink-3); font-size: var(--s-13); }
.alloc.is-archived .ar-name { color: var(--ink-3); }

/* ---------- 明细（账本） ---------- */

.page-head { padding: 24px 0 16px; }
.page-head h1 { font-size: var(--s-24); font-weight: 600; }
.page-head p { margin-top: 6px; color: var(--ink-2); max-width: 46em; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.filters .select, .filters .input { width: auto; min-width: 7.5em; }
.filters .search { flex: 1 1 12em; min-width: 10em; }
.filters .dates { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.filters .dates .input { min-width: 0; width: 10.5em; }

.list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 6px; }
.list-sum { flex: 1; color: var(--ink-2); }
.list-sum b { color: var(--ink); font-family: var(--num); font-size: var(--s-18); }

.day { margin-top: 18px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0 0 6px; border-bottom: 1px solid var(--line-2);
  font-size: var(--s-13); font-weight: 600; color: var(--ink-2);
}
.day-head .num { font-weight: 400; color: var(--ink-3); }
.ledger-list { list-style: none; margin: 0; padding: 0; }
.ledger-list li + li { border-top: 1px solid var(--line); }
.led-row {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 11px 8px; margin: 0;
  border: 0; border-radius: var(--r-s); background: transparent; text-align: left; cursor: pointer;
}
.led-row:hover { background: var(--wash); }
.led-main { flex: 1; min-width: 0; }
.led-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.led-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 2px; color: var(--ink-3); font-size: var(--s-13); }
.tag { padding: 0 7px; border-radius: 4px; background: var(--wash); color: var(--ink-2); font-size: var(--s-12); line-height: 1.7; }
.clip { display: inline-flex; align-items: center; gap: 2px; }
.clip svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.led-amt { font-size: var(--s-18); font-weight: 700; white-space: nowrap; }
.led-row.is-deleted .led-title, .led-row.is-deleted .led-amt { color: var(--ink-3); text-decoration: line-through; }
.trash-row { display: flex; align-items: center; gap: 8px; }
.trash-row .led-row { flex: 1; cursor: default; }
.trash-row .led-row:hover { background: transparent; }

.empty { padding: 36px 0; color: var(--ink-2); }
.empty b { color: var(--ink); }

/* ---------- 渠道 ---------- */

.week { margin-top: 26px; }
.week-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.week-head h2 { font-size: var(--s-18); font-weight: 600; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  padding: 6px 8px; border-bottom: 1px solid var(--line-2);
  text-align: left; font-size: var(--s-12); font-weight: 600; color: var(--ink-3);
}
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .r { text-align: right; }
.table td.num { font-size: var(--s-15); }
.table tfoot td { border-bottom: 0; border-top: 1px solid var(--line-2); font-weight: 600; }
.stat-input { width: 6.5em; min-height: 32px; padding: 4px 8px; text-align: right; font-family: var(--num); }
.saved-tick { margin-left: 6px; color: var(--good-ink); font-size: var(--s-12); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 预算 ---------- */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14em, 1fr)); gap: 14px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; border: 0; margin: 0; padding: 0; }
.field > span, .field > legend, .label { font-size: var(--s-13); color: var(--ink-2); padding: 0; }
.money-input { position: relative; }
.money-input::before { content: "¥"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.money-input .input { padding-left: 24px; font-family: var(--num); }
.budget-table td { padding: 6px 6px; }
.budget-table .input { min-height: 34px; }
.budget-table .col-name { width: 11em; }
.budget-table .col-budget { width: 9em; }
.budget-table .col-track { width: 5.5em; text-align: center; }
.budget-table .col-ops { width: 9.5em; white-space: nowrap; text-align: right; }
.budget-table tr.is-archived .input { color: var(--ink-3); }
.budget-table input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blade); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border: 0; border-radius: var(--r-s);
  background: transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--wash); }
.icon-btn[disabled] { opacity: 0.3; cursor: default; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sum-line { margin: 12px 0 0; font-size: var(--s-13); }
.sum-line.ok { color: var(--good-ink); }
.sum-line.warn { color: var(--warn-ink); }
.sum-line.over { color: var(--crit-ink); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.err-text { color: var(--crit-ink); font-size: var(--s-13); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: var(--s-13); color: var(--ink-2); }

/* ---------- 记一笔（抽屉） ---------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 16, 36, 0.38); animation: fade 0.16s ease-out; }
.sheet {
  position: fixed; z-index: 41; top: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  width: min(520px, 100vw);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease-out;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 8px; }
.sheet-head h2 { font-size: var(--s-18); font-weight: 600; }
.sheet-head .icon-btn svg { width: 18px; height: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .spacer { flex: 1; }

.amount-field { display: flex; align-items: baseline; gap: 6px; padding: 8px 0 6px; border-bottom: 2px solid var(--line-2); }
.amount-field:focus-within { border-bottom-color: var(--blade); }
.amount-field .cur { font-family: var(--num); font-size: var(--s-36); color: var(--ink-3); }
.amount-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-family: var(--num); font-size: 44px; font-weight: 700; line-height: 1.1; color: var(--ink);
}
.amount-field input::placeholder { color: var(--line-2); }
.field-err { display: block; color: var(--crit-ink); font-size: var(--s-13); }
.field-err:empty { display: none; }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5em, 1fr)); gap: 6px; }
.pick { position: relative; display: block; cursor: pointer; }
.pick input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick span {
  display: block; height: 100%; padding: 7px 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-s);
}
.pick b { display: block; font-weight: 600; font-size: var(--s-13); }
.pick small { display: block; font-size: var(--s-12); color: var(--ink-3); font-family: var(--num); }
.pick small.warn { color: var(--warn-ink); }
.pick small.over { color: var(--crit-ink); }
.pick input:checked + span { border-color: var(--blade); background: var(--wash); box-shadow: inset 0 0 0 1px var(--blade); }
.pick input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }
.cat-hint { font-size: var(--s-13); color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 4px 12px; border: 1px solid var(--line-2); border-radius: 999px; font-size: var(--s-13); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 1px; }

.field-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; align-items: end; }
.field-row .seg { display: flex; }
.field-row .seg label { flex: 1; text-align: center; padding: 6px 8px; }

.atts { display: flex; flex-wrap: wrap; gap: 8px; }
.att { position: relative; width: 72px; height: 72px; border-radius: var(--r-s); border: 1px solid var(--line-2); overflow: hidden; background: var(--wash); }
.att a { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--ink-2); font-size: var(--s-12); text-align: center; padding: 4px; word-break: break-all; }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att .att-x {
  position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(20, 16, 36, 0.7); color: #fff; cursor: pointer; line-height: 22px;
}
.att-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 72px; height: 72px; border: 1px dashed var(--line-2); border-radius: var(--r-s);
  color: var(--ink-2); font-size: var(--s-12); cursor: pointer;
}
.att-add:hover { background: var(--wash); }
.att-add svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.att.is-loading { display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: var(--s-12); }

.budget-warn { padding: 10px 12px; border-radius: var(--r-s); font-size: var(--s-13); }
.budget-warn:empty { display: none; }
.budget-warn.warn { background: var(--warn-wash); color: var(--warn-ink); }
.budget-warn.over { background: var(--crit-wash); color: var(--crit-ink); }
.budget-warn.info { background: var(--wash); color: var(--ink-2); }

.history { font-size: var(--s-13); color: var(--ink-2); }
.history summary { cursor: pointer; color: var(--blade-ink); }
.history ul { list-style: none; margin: 8px 0 0; padding: 0; }
.history li { padding: 6px 0; border-top: 1px solid var(--line); }
.history time { color: var(--ink-3); margin-right: 8px; font-family: var(--num); }

/* ---------- 对话框和提示 ---------- */

.dialog-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(20, 16, 36, 0.38); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade 0.12s ease-out; }
.dialog { width: min(420px, 100%); padding: 20px; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--shadow); }
.dialog h2 { font-size: var(--s-18); font-weight: 600; }
.dialog p { margin-top: 8px; color: var(--ink-2); }
.dialog .actions { justify-content: flex-end; margin-top: 20px; }

.toasts { position: fixed; left: 50%; bottom: 24px; z-index: 70; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 12px 10px 16px; border-radius: var(--r-m);
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow);
  font-size: var(--s-13); pointer-events: auto; animation: rise 0.18s ease-out;
}
.toast.error { background: var(--crit-ink); color: #fff; }
.toast button { border: 0; background: transparent; color: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; padding: 2px 4px; }

.fab { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

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

/* ---------- 手机 ---------- */

@media (max-width: 720px) {
  .topbar { gap: 12px; padding-top: 10px; padding-bottom: 10px; }
  .add-top { display: none; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    justify-content: space-around; gap: 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabs a { flex: 1; text-align: center; padding: 8px 0; }
  .tabs a[aria-current="page"]::after { left: 30%; right: 30%; bottom: 2px; }
  .fab {
    position: fixed; right: 16px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 31;
    display: inline-flex; align-items: center; gap: 6px;
    padding: 0 18px; height: 48px; border: 0; border-radius: 999px;
    background: var(--blade); color: var(--on-blade); font-weight: 600; box-shadow: var(--shadow); cursor: pointer;
  }
  .fab svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
  .view { padding-bottom: 150px; }
  .toasts { bottom: calc(128px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }

  .alloc-row { grid-template-columns: 1fr auto; gap: 8px 12px; }
  .ar-bar { grid-column: 1 / -1; grid-row: 2; }
  .ar-nums { flex-direction: column; align-items: flex-end; gap: 0; }

  .sheet { top: auto; left: 0; width: 100%; max-height: 94vh; border-radius: var(--r-l) var(--r-l) 0 0; animation-name: rise; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row .field:first-child { grid-column: 1 / -1; }
  .filters .select { flex: 1 1 40%; }
  .budget-table .col-desc { display: none; }
}

/* =====================================================================
 * 第一步（记账）新增
 * ===================================================================== */

.pos { color: var(--good-ink); }
.neg { color: var(--crit-ink); }
.strong { font-weight: 700; }
.small { font-size: var(--s-13); }
.struck { text-decoration: line-through; color: var(--ink-3) !important; }
.warn-text { color: var(--warn-ink); font-weight: 600; }
.crit-text { color: var(--crit-ink); font-weight: 600; }
.dot { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: var(--line-2); margin: 0 2px; vertical-align: middle; }

/* 顶栏右边的人 */
.who { margin-left: auto; }
.who-link { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; color: var(--ink); text-decoration: none; }
.who-link:hover { text-decoration: none; }
.who-link small { color: var(--ink-3); font-size: var(--s-12); }
.add-top { margin-left: 8px; }
.topbar { gap: 20px; }

/* 登录 */
body.auth .tabs, body.auth .who, body.auth .add-top, body.auth .fab { display: none !important; }
.auth-card { max-width: 380px; margin: 6vh auto 0; padding: 28px 24px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); }
.auth-card h1 { font-size: var(--s-24); font-weight: 600; margin: 4px 0 12px; }
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: var(--s-13); }
.auth-brand .brand-mark { width: 20px; height: 20px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.block-btn { width: 100%; min-height: 42px; }
.demo-logins { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.demo-logins .chips { margin-top: 8px; }
body.auth .topbar .brand { visibility: hidden; }

/* 页头 */
.page-head.with-actions { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head p b { font-family: var(--num); color: var(--ink); }
.back-link { display: inline-flex; align-items: center; gap: 2px; margin-top: 16px; color: var(--ink-2); font-size: var(--s-13); }
.back-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.back-link + .page-head, .back-link + .hero { padding-top: 8px; }

/* 统计条 */
.stat-row { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.stat { flex: 1 1 8em; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 10px 0; min-width: 0; }
.stat + .stat { padding-left: 14px; border-left: 1px solid var(--line); }
.stat span { font-size: var(--s-12); color: var(--ink-3); }
.stat b { font-size: var(--s-18); font-weight: 700; white-space: nowrap; }
.stat small { font-size: var(--s-12); color: var(--ink-3); }

.hero-lead small { font-size: var(--s-13); color: var(--ink-3); }
.small-hero { padding: 18px 0 14px; }
.small-hero .hero-num { font-size: clamp(40px, 9vw, 60px); }
.small-hero .hero-lead { font-size: var(--s-18); }
.hero-num.muted { color: var(--ink-3); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 8px; }

.todo { list-style: none; margin: 0; padding: 0; }
.todo li { position: relative; padding: 9px 0 9px 16px; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; }
.todo li::before { content: ""; position: absolute; left: 2px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.todo li.warn::before { background: var(--warn); }
.todo li.over::before { background: var(--crit); }
.todo li.watch::before { background: var(--blade); }
.todo a, .link-btn { color: var(--ink); }
.link-btn { padding: 0; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; }
.link-btn:hover { text-decoration: underline; }
.block-head a { font-size: var(--s-13); }

/* 列表行 */
.led-row { text-decoration: none; color: inherit; }
a.led-row:hover { text-decoration: none; }
.led-row.static { cursor: default; }
.led-row.static:hover { background: transparent; }
.ord-no { flex: 0 0 auto; min-width: 2.6em; color: var(--ink-3); font-size: var(--s-13); }
.led-side { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.led-amts { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.led-amts small { font-size: var(--s-12); }
.ledger-list.compact .led-row { padding-top: 8px; padding-bottom: 8px; }
.led-row.is-deleted .led-amt, .led-row.is-deleted .led-title { color: var(--ink-3); text-decoration: line-through; }

/* 订单状态 */
.flag.st-open { background: var(--wash); color: var(--blade-ink); }
.flag.st-stored { background: var(--warn-wash); color: var(--warn-ink); }
.flag.st-expired { background: var(--crit-wash); color: var(--crit-ink); }
.flag.st-done { background: var(--good-wash); color: var(--good-ink); }
.flag.st-forced { background: transparent; color: var(--ink-2); border: 1px solid var(--line-2); }
.flag.st-refunded { background: transparent; color: var(--ink-3); border: 1px solid var(--line-2); }
.flag.st-void { background: transparent; color: var(--ink-3); text-decoration: line-through; }
.as-btn { border: 0; cursor: pointer; font: inherit; text-align: left; }
.flag.as-btn { font-size: var(--s-12); }
.note-line.as-btn { display: block; width: 100%; }

/* 筛选 */
.filters .seg button { white-space: nowrap; }
.month-nav { display: inline-flex; align-items: center; gap: 4px; }
.month-nav b { min-width: 6.5em; text-align: center; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--s-13); color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--blade); }
.select.narrow { width: auto; min-width: 8em; }

/* 抽屉 */
.sheet.wide { width: min(720px, 100vw); }
.sheet-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-pad { padding: 4px 20px 28px; }
.sheet-form { display: flex; flex-direction: column; gap: 16px; padding: 4px 20px 0; min-height: 100%; }
.sheet-form .sheet-foot { position: sticky; bottom: 0; margin: auto -20px 0; background: var(--surface); }
.price-hint { font-size: var(--s-13); }
.wide-seg { display: flex; }
.wide-seg label { flex: 1; text-align: center; padding: 7px 6px; }
.wide-seg small { font-size: var(--s-12); opacity: 0.75; }
.pick-tier { display: flex; flex-direction: column; gap: 6px; }
.pick-tier + .pick-tier { margin-top: 10px; }
.pick-tier .label { font-size: var(--s-12); color: var(--ink-3); }
.pick em.mini { font-style: normal; font-weight: 400; font-size: var(--s-12); color: var(--warn-ink); }
.custom-box { padding: 12px; border-radius: var(--r-m); background: var(--wash); }
.boss-check { display: flex; flex-wrap: wrap; gap: 6px; }
.boss-check:empty { display: none; }
fieldset.field { min-width: 0; }
fieldset.field legend { margin-bottom: 6px; }

.detail-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 10px; }
.detail-head h3 { font-size: var(--s-24); font-weight: 600; }
.kvs { margin: 0; }
.kv-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-row dt { color: var(--ink-2); flex: 0 0 auto; }
.kv-row dd { margin: 0; text-align: right; min-width: 0; }
.kv-row.strong dt { color: var(--ink); font-weight: 600; }
.sub-h { margin: 20px 0 6px; font-size: var(--s-15); font-weight: 600; }
.seg-list { list-style: none; margin: 0; padding: 0; }
.seg-list li { display: grid; grid-template-columns: 4em 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.seg-no { color: var(--ink-3); font-size: var(--s-13); }
.seg-state { font-size: var(--s-13); color: var(--ink-2); text-align: right; }
.mini-table td { padding: 7px 4px; }
.mini-table tfoot td { font-weight: 600; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 6px; padding-top: 14px; border-top: 1px solid var(--line); }
.att.big { width: 110px; height: 140px; }

/* 对话框 */
.dialog { max-height: calc(100vh - 40px); overflow-y: auto; }
.dlg-body { margin-top: 8px; color: var(--ink-2); line-height: 1.7; }
.dlg-fields { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.dlg-fields:empty { display: none; }
.dialog .field > span small { font-weight: 400; }
.btn.danger-fill { background: var(--crit); border-color: var(--crit); color: #fff; font-weight: 600; }

/* 日结表 */
.day-table td.who { font-weight: 600; white-space: nowrap; }
.day-table td.ops, .table td.ops { white-space: nowrap; text-align: right; }
.day-table td small { display: block; font-size: var(--s-12); }
.day-table .sub-row td { padding-top: 0; border-bottom: 1px solid var(--line-2); }
.day-table tbody tr:not(.sub-row) td { border-bottom: 0; }
.day-table details summary { cursor: pointer; color: var(--ink-3); font-size: var(--s-12); }
.entry-lines { list-style: none; margin: 4px 0 0; padding: 0; }
.entry-lines li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--s-13); }
.entry-lines li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.entry-lines small { font-size: var(--s-12); }
.entry-lines .struck-row { color: var(--ink-3); text-decoration: line-through; }
.dispute { margin: 8px 0 4px; padding: 8px 10px; border-radius: var(--r-s); background: var(--crit-wash); color: var(--crit-ink); font-size: var(--s-13); }
.dispute.done { background: var(--wash); color: var(--ink-2); }

/* 更多 */
.menu-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.menu-list li { border-bottom: 1px solid var(--line); }
.menu-list a, .menu-list button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 4px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: inherit; }
.menu-list a:hover, .menu-list button:hover { background: var(--wash); text-decoration: none; }
.menu-list span { display: flex; flex-direction: column; }
.menu-list small { color: var(--ink-3); font-size: var(--s-13); }
.menu-list svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: var(--ink-3); stroke-width: 2; }
.month-nav svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.audit-list { list-style: none; margin: 8px 0 0; padding: 0; }
.audit-list li { display: grid; grid-template-columns: 7.5em 5em 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: var(--s-13); }
.audit-list time { color: var(--ink-3); }
.audit-list .who { font-weight: 600; margin: 0; }

/* 设置 */
.set-table td { padding: 5px 4px; }
.set-table .w-s { width: 8.5em; }
.set-table .input, .set-table .select { min-height: 34px; }
.set-table .input:disabled, .set-table .select:disabled, .settings .input:disabled { background: transparent; border-color: var(--line); color: var(--ink); opacity: 1; }
.pct { position: relative; }
.pct::after { content: "%"; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.pct .input { padding-right: 26px; }
.save-bar { position: sticky; bottom: 0; display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 12px 0; background: var(--paper); border-top: 1px solid var(--line); margin-top: 20px; }
.save-bar .field-err { flex: 1; }
.settings .block-head .hint { font-size: var(--s-12); }

/* 手机 */
@media (max-width: 720px) {
  .desk-only { display: none; }
  .who-link small { display: none; }
  .who-link span { font-size: var(--s-13); color: var(--ink-2); }
  .stat { flex: 1 1 40%; padding: 8px 10px 8px 0; }
  .stat + .stat { padding-left: 10px; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat b { font-size: var(--s-15); }
  .ord-no { min-width: 2.2em; }
  .led-side { flex-direction: column-reverse; align-items: flex-end; gap: 2px; }
  .led-row { gap: 10px; }
  .page-head.with-actions .head-actions { width: 100%; }
  .page-head.with-actions .head-actions .btn { flex: 1; }
  .filters .seg { max-width: 100%; overflow-x: auto; }
  .audit-list li { grid-template-columns: 1fr; gap: 0; }
  .save-bar { bottom: calc(56px + env(safe-area-inset-bottom)); }
  .sheet { max-height: 92vh; }
  .wide-seg label { padding: 7px 2px; font-size: var(--s-13); }
  /* 日结表在手机上变成一张张 */
  .day-table thead { display: none; }
  .day-table, .day-table tbody, .day-table tr, .day-table td { display: block; width: 100%; }
  .day-table tbody tr:not(.sub-row) { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 10px; padding: 12px 0 4px; border-top: 1px solid var(--line-2); }
  .day-table tbody tr:not(.sub-row) td { padding: 0; text-align: left; }
  .day-table td.who { grid-column: 1 / 3; font-size: var(--s-15); }
  .day-table td.r::before { display: block; font-family: var(--font); font-size: var(--s-12); color: var(--ink-3); font-weight: 400; }
  .day-table td:nth-child(2)::before { content: "分成"; }
  .day-table td:nth-child(3)::before { content: "调整"; }
  .day-table td:nth-child(4)::before { content: "罚款"; }
  .day-table td:nth-child(5)::before { content: "上日结余"; }
  .day-table td:nth-child(6)::before { content: "应发"; }
  .day-table td:nth-child(7)::before { content: "留个税"; }
  .day-table td:nth-child(8)::before { content: "先发"; }
  .day-table td:nth-child(9) { grid-column: 3; grid-row: 1; text-align: right; }
  .day-table td.ops { grid-column: 1 / -1; text-align: left; padding-top: 6px; }
  .day-table td.ops:empty { display: none; }
  .day-table .sub-row td { border-bottom: 0; padding: 0 0 8px; }
}
@media (max-width: 720px) {
  /* 顶栏的毛玻璃会让底部导航跟着顶栏走，手机上去掉 */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
}
.entry-lines + .hint, .scroll-x + .hint, .kvs + .hint, .actions + .hint { margin-top: 14px; }

/* ---------- 税务 ---------- */
.good-text { color: var(--good-ink); font-weight: 600; }
.tax-pair { margin-top: -10px; }
.tax-pair .stat b { font-size: var(--s-24); }
.tax-pair .stat b.good-text { font-size: var(--s-18); line-height: 1.6; }
.tax-pair .stat small { color: var(--ink-3); font-size: var(--s-12); line-height: 1.5; }
.th-item { padding: 16px 0; border-top: 1px solid var(--line); }
.th-item:first-child { border-top: 0; padding-top: 2px; }
.th-item h3 { font-size: var(--s-15); font-weight: 600; margin: 0 0 8px; }
.th-item h3 small { margin-left: 6px; font-weight: 400; font-size: var(--s-12); color: var(--ink-3); }
.th-item p { margin: 4px 0; color: var(--ink-2); }
.th-item b.num { color: var(--ink); }
.th-item b.num.crit-text { color: var(--crit-ink); }
.meter { margin: 6px 0 8px; padding: 4px 0; }
.meter-track { position: relative; height: 14px; border-radius: 4px; background: var(--track); }
.meter-fill { position: absolute; inset: 0 auto 0 0; min-width: 2px; border-radius: 4px; background: var(--blade); }
.meter-fore { position: absolute; top: 0; bottom: 0; border: 2px dashed var(--blade); border-left: 0; border-radius: 0 4px 4px 0; box-sizing: border-box; }
.meter-line { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); }
[data-status="warn"] .meter-fill { background: var(--warn); }
[data-status="warn"] .meter-fore { border-color: var(--warn); }
[data-status="over"] .meter-fill { background: var(--crit); }
.meter-nums { font-size: var(--s-15); }
.th-tag { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 4px; background: var(--wash); color: var(--ink-2); font-size: var(--s-12); line-height: 1.7; font-weight: 400; }
.th-item p.th-note { font-size: var(--s-13); color: var(--ink-3); }
.th-people { list-style: none; margin: 0; padding: 0; }
.th-people li { display: grid; grid-template-columns: minmax(4.5em, 1fr) minmax(6em, auto) minmax(0, 2.4fr) minmax(7em, auto); gap: 2px 14px; align-items: baseline; padding: 7px 0; border-top: 1px solid var(--line); }
.th-people li:first-child { border-top: 0; }
.th-people .p-name { font-weight: 600; }
.th-people .p-gross, .th-people .p-tax { text-align: right; white-space: nowrap; }
.th-people .p-st { color: var(--ink-2); font-size: var(--s-13); }
.th-people .p-st .good-text { font-weight: 400; }
.tax-warns { margin: 12px 0 4px; }
.block-small { display: block; font-size: var(--s-12); line-height: 1.5; }
.due-table + .due-table, .scroll-x + .scroll-x { margin-top: 10px; }
.tax-table th, .tax-table td { white-space: nowrap; }
.tax-table tr.cur td { background: var(--wash); }
.how { margin: 16px 0 8px; }
.how summary { cursor: pointer; color: var(--blade-ink); font-weight: 600; }
.how .sub-h { margin-top: 14px; }
.steps { margin: 4px 0 8px; padding-left: 1.4em; color: var(--ink-2); font-size: var(--s-13); line-height: 1.7; }
.policy-list { list-style: none; margin: 0; padding: 0; }
.policy-list li { padding: 12px 0; border-top: 1px solid var(--line); }
.policy-list li:first-child { border-top: 0; padding-top: 0; }
.policy-list p { margin: 4px 0 0; }
.pol-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.flag.ok { background: var(--good-wash); color: var(--good-ink); }
.kv-row.warn-row dd { color: var(--warn-ink); font-weight: 600; }
#tax-settings .kv-row dd { max-width: 70%; }
@media (max-width: 720px) {
  .th-people li { grid-template-columns: 1fr auto; }
  .th-people .p-st { grid-column: 1; }
  .th-people .p-tax { grid-column: 2; }
  .tax-pair .stat b { font-size: var(--s-18); }
}
@media (max-width: 720px) {
  .tax-table th, .tax-table td { padding: 8px 5px; font-size: var(--s-13); }
  .tax-table td.num { font-size: var(--s-13); }
}

/* ---------- 星刃电竞 logo ---------- */
.brand-logo { width: 30px; height: 30px; border-radius: 7px; background: #fff; object-fit: cover; box-shadow: 0 0 0 1px var(--line); flex: none; }
.auth-logo-wrap { display: flex; justify-content: center; margin: -4px 0 10px; }
.auth-logo { width: 132px; height: 132px; border-radius: 22px; background: #fff; object-fit: cover; box-shadow: 0 0 0 1px var(--line); }
.auth-brand-center { justify-content: center; }
.auth-card h1 { text-align: center; }

/* 我的账号：邮箱和手机号（api 7） */
.contact-cell { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; justify-content: flex-end; }
.contact-btns { display: inline-flex; gap: 6px; }
