:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --text: #17201c;
  --muted: #65716b;
  --line: #d9dfdc;
  --green: #176b45;
  --green-soft: #e5f3eb;
  --blue: #245f9e;
  --blue-soft: #e6eff9;
  --orange: #a94f18;
  --orange-soft: #faebdf;
  --red: #aa2d2d;
  --red-soft: #fbe8e8;
  --shadow: 0 10px 26px rgba(24, 42, 34, .07);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { font-size: 18px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; line-height: 1.55; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.topbar { height: 68px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 max(24px, calc((100vw - 980px)/2)); position: sticky; top: 0; z-index: 20; }
.brand { font-size: 1.18rem; font-weight: 800; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 12px; cursor: pointer; }
.page { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1, .form-shell h1 { font-size: clamp(1.7rem, 4vw, 2.45rem); line-height: 1.18; margin: 5px 0 0; letter-spacing: -.04em; }
.date-line { margin: 0; color: var(--muted); font-size: .95rem; }
.small-link, .section-title-row a, .back-link { color: var(--green); font-weight: 700; }
.main-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.action-block { min-height: 190px; border-radius: 24px; padding: 28px; display: flex; flex-direction: column; justify-content: flex-end; box-shadow: var(--shadow); border: 2px solid transparent; }
.action-purchase { background: var(--blue-soft); color: #123d69; }
.action-sale { background: var(--green-soft); color: #104e33; }
.action-block:focus-visible { outline: 4px solid #111; outline-offset: 3px; }
.action-title { font-size: 1.7rem; font-weight: 900; }
.action-desc { margin-top: 8px; font-size: 1rem; }
.summary-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); margin: 20px 0; }
.summary-strip > div { background: var(--surface); padding: 22px 24px; display: flex; flex-direction: column; }
.summary-strip span, .plain-stats span, .section-block span, .inventory-extra span, .history-row span { color: var(--muted); font-size: .9rem; }
.summary-strip strong { font-size: 1.55rem; margin-top: 3px; }
.section-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-top: 20px; box-shadow: 0 4px 16px rgba(24,42,34,.035); }
.section-title-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-title-row h2 { margin: 0; font-size: 1.25rem; }
.plain-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.plain-stats.three { grid-template-columns: repeat(3, 1fr); margin: 18px 0; }
.plain-stats > div { background: #f7f9f8; border-radius: 14px; padding: 18px; display: flex; flex-direction: column; }
.plain-stats strong { font-size: 1.2rem; margin-top: 5px; }
.last-action { margin-top: 20px; background: var(--orange-soft); border: 1px solid #efc6aa; border-radius: var(--radius); padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.last-action > div { display: flex; flex-direction: column; }
.danger-link { color: var(--red); font-weight: 800; white-space: nowrap; }
.simple-row, .profit-row { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-top: 1px solid var(--line); }
.simple-row:first-of-type, .profit-row:first-of-type { border-top: 0; }
.simple-row > div, .profit-row > div { display: flex; flex-direction: column; }
.row-number, .profit-row > div:last-child { text-align: right; }
.bottom-nav { width: min(640px, calc(100% - 24px)); height: 68px; margin: 0 auto 28px; background: #fff; border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 8px 24px rgba(20,39,30,.08); display: grid; grid-template-columns: repeat(4, 1fr); overflow: hidden; }
.bottom-nav a { display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; }
.bottom-nav a.active { color: var(--green); background: var(--green-soft); }
.login-page { min-height: calc(100vh - 40px); display: grid; place-items: center; padding-bottom: 20px; }
.login-card { width: min(480px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 24px; padding: 36px; box-shadow: var(--shadow); text-align: center; }
.login-card h1 { font-size: 2rem; margin: 14px 0 6px; }
.login-card p { color: var(--muted); }
.simple-mark { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; background: var(--green); color: #fff; font-size: 1.6rem; font-weight: 900; }
.stack-form { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.stack-form label { font-weight: 800; margin-top: 8px; }
input, select { width: 100%; min-height: 58px; border: 2px solid #cbd3cf; border-radius: 14px; padding: 0 16px; background: #fff; color: var(--text); font-size: 1.08rem; }
input:focus, select:focus { outline: 4px solid rgba(23,107,69,.17); border-color: var(--green); }
.primary-button, .purchase-button, .sale-button, .secondary-button, .danger-button { border: 0; border-radius: 15px; min-height: 60px; padding: 14px 20px; font-weight: 900; cursor: pointer; text-align: center; }
.primary-button, .sale-button { background: var(--green); color: white; }
.purchase-button { background: var(--blue); color: white; }
.secondary-button { background: #fff; color: var(--text); border: 2px solid var(--line); }
.danger-button { background: var(--red); color: #fff; }
.huge { min-height: 66px; font-size: 1.15rem; margin-top: 12px; }
.block-link { display: flex; align-items: center; justify-content: center; }
.helper { font-size: .85rem; margin-bottom: 0; }
.form-shell { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: var(--shadow); }
.form-shell.narrow { width: min(660px, 100%); margin: 0 auto; }
.lead { color: var(--muted); margin-top: 8px; }
.back-link { display: inline-block; margin-bottom: 12px; }
.input-with-unit, .input-with-prefix { position: relative; }
.input-with-unit input { padding-right: 72px; }
.input-with-unit span { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; }
.input-with-prefix input { padding-left: 48px; }
.input-with-prefix span { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); font-weight: 800; }
.live-total { margin: 8px 0; background: #f2f5f3; border-radius: 14px; padding: 18px; display: flex; justify-content: space-between; align-items: center; }
.live-total strong { font-size: 1.45rem; }
.confirmation-shell { text-align: center; }
.confirm-list { margin: 24px 0; text-align: left; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.confirm-list > div { display: flex; justify-content: space-between; gap: 24px; padding: 17px 20px; border-top: 1px solid var(--line); }
.confirm-list > div:first-child { border-top: 0; }
.confirm-list span { color: var(--muted); }
.confirm-total { background: #f1f8f4; }
.confirm-total strong { font-size: 1.35rem; color: var(--green); }
.notice { border-radius: 14px; padding: 15px 18px; margin-bottom: 18px; font-weight: 700; }
.notice-success { background: var(--green-soft); color: #0c5636; border: 1px solid #acd3bd; }
.notice-error { background: var(--red-soft); color: #7c1f1f; border: 1px solid #e9b3b3; }
.inventory-list, .history-list { display: grid; gap: 14px; }
.inventory-row { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.inventory-main { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; }
.inventory-main h2 { margin: 0; font-size: 1.3rem; }
.inventory-main > strong { font-size: 1.7rem; color: var(--green); }
.inventory-extra { display: flex; gap: 20px; margin-top: 6px; }
.row-actions-wide { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.row-actions-wide a { min-height: 50px; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 12px; font-weight: 800; }
.profit-hero { background: var(--green); color: #fff; border-radius: 22px; padding: 34px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.profit-hero strong { font-size: clamp(2.2rem, 7vw, 4rem); line-height: 1.15; margin: 8px 0; }
.profit-hero small { opacity: .82; }
.month-filter { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.month-filter label { font-weight: 800; white-space: nowrap; }
.month-filter input { max-width: 230px; }
.month-filter button { min-height: 58px; border: 0; border-radius: 12px; padding: 0 24px; background: var(--text); color: #fff; font-weight: 800; }
.history-row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.history-date, .history-main, .history-total { display: flex; flex-direction: column; }
.history-total { text-align: right; }
.history-total strong { font-size: 1.12rem; }
.is-reversed { opacity: .48; filter: grayscale(1); }
.empty-state { color: var(--muted); padding: 28px; text-align: center; }
@media (max-width: 720px) {
  html { font-size: 17px; }
  .page { width: min(100% - 24px, 980px); padding-top: 20px; }
  .topbar { padding: 0 18px; height: 62px; }
  .main-actions { grid-template-columns: 1fr; gap: 14px; }
  .action-block { min-height: 150px; padding: 22px; }
  .action-title { font-size: 1.45rem; }
  .plain-stats { grid-template-columns: 1fr 1fr; }
  .plain-stats.three { grid-template-columns: 1fr; }
  .last-action { align-items: flex-start; flex-direction: column; }
  .inventory-extra { flex-direction: column; gap: 2px; }
  .history-row { grid-template-columns: 62px 1fr; }
  .history-total { grid-column: 2; text-align: left; flex-direction: row; gap: 12px; }
  .form-shell, .login-card { padding: 24px 20px; border-radius: 18px; }
  .month-filter { align-items: stretch; flex-wrap: wrap; }
  .month-filter input { max-width: none; flex: 1 1 60%; }
  .month-filter button { flex: 1; }
}
@media (max-width: 420px) {
  .summary-strip { grid-template-columns: 1fr; }
  .summary-strip.one-line { grid-template-columns: 1fr 1fr; }
  .plain-stats { grid-template-columns: 1fr 1fr; }
  .page-head { align-items: flex-start; }
  .row-actions-wide { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .action-block, .primary-button, .purchase-button, .sale-button { transition: transform .16s ease, box-shadow .16s ease; }
  .action-block:hover, .primary-button:hover, .purchase-button:hover, .sale-button:hover { transform: translateY(-2px); }
}

/* 月度 / 每日数据 */
.report-summary { margin: 18px 0 0; }
.month-overview { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.month-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 2px solid var(--line); border-radius: 16px; background: #fff; }
.month-card.selected { border-color: var(--green); background: var(--green-soft); }
.month-card.no-data:not(.selected) { background: #f8f9f8; }
.month-card-head, .month-card-money, .month-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.month-card-head strong { font-size: 1.2rem; }
.month-card-head span { color: var(--green); font-weight: 800; }
.month-card-money strong { font-size: 1.25rem; }
.month-card-bottom { color: var(--muted); font-size: .88rem; }
.daily-list { display: grid; gap: 10px; }
.daily-row { min-height: 86px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
a.daily-row { border-width: 2px; }
a.daily-row:hover { border-color: var(--green); }
.daily-row.no-data { background: #f8f9f8; color: var(--muted); }
.daily-date, .daily-money { display: flex; flex-direction: column; }
.daily-date strong { font-size: 1.18rem; }
.daily-date span, .daily-money span { color: var(--muted); font-size: .88rem; }
.daily-money { align-items: flex-end; text-align: right; }
.daily-money strong { color: var(--green); font-size: 1.14rem; }
.day-profit-hero { margin-top: 4px; }
.day-product-row { padding: 18px 0; border-top: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.day-product-row:first-of-type { border-top: 0; }
.day-product-row h3 { margin: 0; font-size: 1.1rem; }
.day-product-values { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.day-product-values span { color: var(--muted); }
.day-product-values strong { color: var(--green); }

@media (max-width: 720px) {
  .month-overview { grid-template-columns: 1fr; }
  .daily-row { align-items: flex-start; }
  .day-product-row { flex-direction: column; gap: 6px; }
  .day-product-values { align-items: flex-start; text-align: left; }
}

@media (max-width: 440px) {
  .daily-row { flex-direction: column; gap: 8px; }
  .daily-money { align-items: flex-start; text-align: left; }
  .month-card-bottom { flex-direction: column; align-items: flex-start; gap: 2px; }
}
