/* ============================================================
   商户手机端「收款账本」
   视觉：墨蓝封面 × 米白账页 × 朱砂印 —— 新式中式账本
   ============================================================ */
:root {
    --ink: #1a2233;          /* 账本封面墨蓝 */
    --ink-2: #223050;
    --ink-line: rgba(255, 255, 255, .08);
    --paper: #f6f2e9;        /* 账页米白 */
    --paper-2: #fdfbf5;
    --line: #e6dfcd;         /* 账页格线 */
    --rule: rgba(60, 50, 30, .05);   /* 底纹横线 */
    --seal: #c2402a;         /* 朱砂红 */
    --seal-deep: #a5301c;
    --seal-soft: rgba(194, 64, 42, .08);
    --text: #2b2f3a;
    --muted: #938d7c;
    --amt-green: #1f7a4d;

    --serif: "Songti SC", "Noto Serif SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
    --num: "DIN Alternate", "Bahnschrift", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
    --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;

    --pad: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--text);
    background: var(--ink);
    min-height: 100dvh;
}

button, input { font-family: inherit; }

.mono { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }

/* ============ 登录页：账本封面 ============ */
.m-login-body {
    background:
        radial-gradient(140% 90% at 50% -20%, var(--ink-2) 0%, var(--ink) 62%),
        var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    padding-top: calc(24px + env(safe-area-inset-top));
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* 封面细纹：横向暗纹，像布面账本 */
.m-login-body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(0deg,
        var(--ink-line) 0 1px, transparent 1px 7px);
    opacity: .35;
    pointer-events: none;
}

.cover {
    position: relative;
    width: min(340px, 100%);
    text-align: center;
    animation: coverIn .55s cubic-bezier(.2, .7, .3, 1) backwards;
}

@keyframes coverIn {
    from { opacity: 0; transform: translateY(18px); }
}

/* 朱砂方印 */
.seal-mark {
    width: 66px;
    height: 66px;
    margin: 0 auto 18px;
    display: grid;
    place-items: center;
    background: var(--seal);
    color: #f8ece4;
    font-family: var(--serif);
    font-size: 34px;
    font-weight: 700;
    border-radius: 14px;
    box-shadow:
        inset 0 0 0 2px rgba(248, 236, 228, .35),
        inset 0 0 14px rgba(120, 20, 8, .55),
        0 10px 28px rgba(0, 0, 0, .45);
    transform: rotate(-4deg);
    animation: stamp .5s cubic-bezier(.2, 1.4, .4, 1) .15s backwards;
}

@keyframes stamp {
    from { opacity: 0; transform: rotate(-4deg) scale(1.7); }
}

.cover-title {
    margin: 0;
    font-family: var(--serif);
    font-size: 30px;
    letter-spacing: .35em;
    text-indent: .35em;   /* 让字间距视觉居中 */
    color: #f3efe4;
    font-weight: 700;
}

.cover-sub {
    margin: 10px 0 34px;
    font-size: 12px;
    letter-spacing: .5em;
    text-indent: .5em;
    color: rgba(243, 239, 228, .45);
}

.login-panel { text-align: left; }

.fld {
    display: block;
    margin-bottom: 20px;
}

.fld span {
    display: block;
    font-size: 12px;
    letter-spacing: .2em;
    color: rgba(243, 239, 228, .55);
    margin-bottom: 6px;
}

.fld input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(243, 239, 228, .28);
    border-radius: 0;
    color: #f3efe4;
    font-size: 17px;
    padding: 8px 2px 10px;
    outline: none;
    transition: border-color .2s;
    caret-color: var(--seal);
}

.fld input:focus { border-bottom-color: var(--seal); }

.cta {
    width: 100%;
    margin-top: 10px;
    padding: 15px;
    min-height: 50px;
    background: var(--seal);
    color: #faf1ea;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .3em;
    text-indent: .3em;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(165, 48, 28, .4);
    transition: transform .12s, background .2s;
}

.cta:active { transform: scale(.98); background: var(--seal-deep); }
.cta:disabled { opacity: .55; }

.login-err {
    min-height: 20px;
    margin-top: 14px;
    text-align: center;
    font-size: 13px;
    color: #ff9e8c;
}

.login-err.shake { animation: shake .4s; }

@keyframes shake {
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* ============ 主页：墨蓝头 + 账页 ============ */
.m-body {
    background: var(--ink);
    display: flex;
    flex-direction: column;
}

.ledger-head {
    padding: calc(14px + env(safe-area-inset-top)) var(--pad) 18px;
    color: #f3efe4;
    background:
        radial-gradient(120% 160% at 50% -40%, var(--ink-2) 0%, var(--ink) 70%);
}

.head-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.seal-dot {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    background: var(--seal);
    color: #f8ece4;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 700;
    border-radius: 8px;
    transform: rotate(-4deg);
    box-shadow: inset 0 0 0 1.5px rgba(248, 236, 228, .3), inset 0 0 8px rgba(120, 20, 8, .5);
}

.shop-name {
    flex: 1;
    margin: 0;
    font-family: var(--serif);
    font-size: 19px;
    font-weight: 700;
    letter-spacing: .06em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.exit {
    flex: none;
    font-size: 12px;
    color: rgba(243, 239, 228, .5);
    text-decoration: none;
    padding: 8px 0 8px 12px;
}

/* 钱包余额条 */
.wallet-strip {
    margin-top: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
}

.w-label {
    font-size: 12px;
    letter-spacing: .15em;
    color: rgba(243, 239, 228, .6);
}

.w-amt {
    font-size: 20px;
    font-weight: 700;
    color: #f3efe4;
}

.w-amt::before {
    content: "¥";
    font-size: 14px;
    margin-right: 3px;
    color: rgba(243, 239, 228, .55);
}

/* 日期切换 */
.date-nav {
    margin-top: 16px;
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.dn-btn {
    flex: none;
    width: 44px;
    min-height: 44px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    color: #f3efe4;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}

.dn-btn:active { background: rgba(255, 255, 255, .14); }
.dn-btn:disabled { opacity: .3; }

.dn-date {
    flex: 1;
    position: relative;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    min-height: 44px;
    cursor: pointer;
}

.dn-date input[type="date"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    -webkit-appearance: none;
}

.dn-main {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: .08em;
    pointer-events: none;
}

.dn-sub {
    font-size: 10px;
    color: rgba(243, 239, 228, .45);
    letter-spacing: .18em;
    pointer-events: none;
    margin-top: 1px;
}

/* ============ 账页 ============ */
.paper {
    flex: 1;
    position: relative;
    background:
        repeating-linear-gradient(0deg, var(--rule) 0 1px, transparent 1px 30px),
        linear-gradient(var(--paper-2), var(--paper) 140px);
    padding: 8px var(--pad) calc(30px + env(safe-area-inset-bottom));
    min-height: 60dvh;
}

/* 收据撕边：半圆锯齿透出墨蓝底 */
.paper::before {
    content: "";
    display: block;
    height: 12px;
    margin: -8px calc(var(--pad) * -1) 10px;
    background: radial-gradient(circle at 8px -4px, transparent 8px, var(--paper-2) 8.5px);
    background-size: 17px 12px;
    background-position: 4px 0;
}

/* 账本红线：左侧竖线 */
.paper::after {
    content: "";
    position: absolute;
    top: 6px;
    bottom: 0;
    left: 12px;
    width: 1.5px;
    background: rgba(194, 64, 42, .16);
    pointer-events: none;
}

/* 汇总区 */
.totals {
    padding: 16px 6px 18px;
    border-bottom: 1.5px solid var(--line);
    animation: rise .45s ease backwards;
}

.t-label {
    font-size: 12px;
    letter-spacing: .3em;
    color: var(--muted);
}

.t-amount-line {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: 6px;
}

.t-cny {
    font-family: var(--num);
    font-size: 22px;
    font-weight: 700;
    color: var(--seal);
}

.t-amount {
    font-family: var(--num);
    font-variant-numeric: tabular-nums;
    font-size: 44px;
    font-weight: 700;
    line-height: 1.05;
    color: var(--text);
    animation: stampIn .45s cubic-bezier(.2, 1.2, .4, 1) .1s backwards;
}

@keyframes stampIn {
    from { opacity: 0; transform: scale(1.12); }
}

.t-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--muted);
}

.t-meta .refund { color: var(--seal); }

.t-meta .sync-note {
    flex-basis: 100%;
    font-size: 11px;
    color: var(--muted);
    opacity: .75;
    letter-spacing: .02em;
}

.t-pays {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.pay-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 6px 10px;
    background: var(--seal-soft);
    border: 1px solid rgba(194, 64, 42, .18);
    border-radius: 8px;
    font-size: 12px;
    color: #7c4438;
}

.pay-chip b {
    font-family: var(--num);
    font-variant-numeric: tabular-nums;
    font-size: 13px;
    color: var(--seal-deep);
}

/* 流水列表 */
.rows { padding-top: 4px; }

.sec-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 6px 8px;
    font-size: 12px;
    letter-spacing: .25em;
    color: var(--muted);
}

.refresh-btn {
    border: none;
    background: none;
    color: var(--seal);
    font-size: 12px;
    letter-spacing: .1em;
    padding: 8px 0 8px 14px;
    cursor: pointer;
}

.row {
    border-bottom: 1px dashed var(--line);
    padding: 0 6px;
    animation: rise .4s ease backwards;
    cursor: pointer;
}

.row:nth-child(1) { animation-delay: .04s; }
.row:nth-child(2) { animation-delay: .08s; }
.row:nth-child(3) { animation-delay: .12s; }
.row:nth-child(4) { animation-delay: .16s; }
.row:nth-child(5) { animation-delay: .20s; }
.row:nth-child(6) { animation-delay: .24s; }
.row:nth-child(7) { animation-delay: .27s; }
.row:nth-child(8) { animation-delay: .30s; }

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
}

.row-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 58px;
    padding: 9px 0;
}

.r-time {
    flex: none;
    width: 46px;
    font-family: var(--num);
    font-variant-numeric: tabular-nums;
    font-size: 14px;
    color: var(--muted);
}

.r-mid {
    flex: 1;
    min-width: 0;
}

.r-pay {
    font-size: 14.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.r-tags { margin-top: 3px; display: flex; gap: 6px; }

.r-tag {
    font-size: 10.5px;
    padding: 1.5px 6px;
    border-radius: 5px;
    background: rgba(60, 50, 30, .06);
    color: var(--muted);
    letter-spacing: .05em;
}

.r-tag.refund {
    background: var(--seal-soft);
    color: var(--seal-deep);
}

.r-amt {
    flex: none;
    font-family: var(--num);
    font-variant-numeric: tabular-nums;
    font-size: 18px;
    font-weight: 700;
    color: var(--amt-green);
}

.r-amt::before { content: "+"; font-size: 14px; margin-right: 1px; }

.r-amt.neg { color: var(--seal-deep); }
.r-amt.neg::before { content: ""; margin: 0; }

/* 展开明细 */
.row-detail {
    display: none;
    padding: 2px 0 14px 56px;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 2;
}

.row.open .row-detail { display: block; }
.row.open { background: rgba(60, 50, 30, .025); }

.row-detail b {
    color: var(--text);
    font-weight: 600;
    word-break: break-all;
}

/* 空态 / 加载态 / 错误 */
.empty {
    text-align: center;
    padding: 60px 0 30px;
    color: var(--muted);
}

.empty .e-seal {
    width: 58px;
    height: 58px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    border: 2px solid rgba(147, 141, 124, .35);
    border-radius: 12px;
    font-family: var(--serif);
    font-size: 24px;
    color: rgba(147, 141, 124, .5);
    transform: rotate(-6deg);
}

.empty .e-txt { font-size: 13px; letter-spacing: .2em; }

.skl {
    height: 58px;
    border-bottom: 1px dashed var(--line);
    position: relative;
    overflow: hidden;
}

.skl::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 6px;
    right: 6px;
    height: 16px;
    border-radius: 6px;
    background: linear-gradient(90deg, rgba(60,50,30,.05) 25%, rgba(60,50,30,.1) 50%, rgba(60,50,30,.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.load-err {
    margin: 30px 6px;
    padding: 14px;
    border: 1px solid rgba(194, 64, 42, .3);
    border-radius: 10px;
    background: var(--seal-soft);
    color: var(--seal-deep);
    font-size: 13px;
    text-align: center;
}

.paper-foot {
    text-align: center;
    padding-top: 26px;
    font-size: 11px;
    letter-spacing: .5em;
    text-indent: .5em;
    color: rgba(147, 141, 124, .55);
}

/* 大屏适配：账本居中，不至于拉太宽 */
@media (min-width: 640px) {
    .ledger-head { padding-left: calc(50vw - 302px); padding-right: calc(50vw - 302px); }
    .paper { padding-left: calc(50vw - 302px); padding-right: calc(50vw - 302px); }
    .paper::before { margin-left: calc(302px - 50vw); margin-right: calc(302px - 50vw); }
}
