:root {
    --td-active-bg: #0f6e45;
    --td-range-bg: #0c5a38;
    --td-btn-hover-bg: #eef6f2;
    --td-font: "PingFang SC", "Microsoft YaHei", sans-serif;
    --brand: #0f6e45;
    --brand-dark: #0c5a38;
    --paper: #f5f7f6;
    --card: #ffffff;
    --ink: #1c211e;
    --muted: #6d756f;
    --line: #e6ebe8;
}

html, body {
    background: var(--paper);
    color: var(--ink);
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}

.container-narrow {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 16px;
}

.app-top {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(245, 247, 246, .94);
    backdrop-filter: blur(10px);
    padding: 12px 0 calc(12px + env(safe-area-inset-top));
    border-bottom: 1px solid var(--line);
}

.app-main {
    padding: 16px 0 110px;
}

.app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: #fff;
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}

.app-tabbar a {
    text-align: center;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.app-tabbar a i { font-size: 20px; }
.app-tabbar a.active { color: var(--brand); font-weight: 600; }
.app-tabbar .plus-btn {
    width: 38px;
    height: 38px;
    margin-top: -18px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
}
.app-tabbar .tab-plus { color: var(--brand); }

.btn-brand {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-brand:hover, .btn-brand:focus {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}
.btn-outline-brand {
    color: var(--brand);
    border-color: var(--brand);
}
.btn-outline-brand:hover {
    background: var(--brand);
    color: #fff;
}
.btn-text-danger {
    background: transparent;
    border: 0;
    color: #9a4038;
    font-weight: 600;
    padding: 8px 12px;
}
.btn-text-danger:hover, .btn-text-danger:focus {
    color: #b42318;
}
.text-brand { color: var(--brand) !important; }

.stat-card, .list-card, .item-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: none;
}
.stat-card { padding: 14px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.section-title { font-weight: 700; margin: 8px 0 8px; }
.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid #f0f3f1;
}
.list-row:last-child { border-bottom: 0; }
.item-card { padding: 14px; margin-bottom: 12px; }
.item-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.item-del {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 28px;
    padding: 0 10px;
    border: 1px solid #f3d2c6;
    border-radius: 999px;
    background: #fff6f2;
    color: #9a3412;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}
.item-del:hover { background: #fde8e2; color: #7c2d12; }
.item-del[hidden] { display: none !important; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 13px;
    color: var(--ink);
}
.period-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.period-tab {
    text-align: center;
    padding: 8px 0;
    border-radius: 999px;
    background: #fff;
    color: #5f675f;
    text-decoration: none;
    border: 1px solid var(--line);
    font-size: 14px;
}
.period-tab.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}
.settle-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px;
}
.settle-card:has(.settle-switch:checked) {
    background: #f7fbf8;
    border-color: #cfe4d6;
}
.settle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    cursor: pointer;
}
.settle-title { display: block; font-weight: 700; }
.settle-hint { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.settle-switch {
    appearance: none;
    -webkit-appearance: none;
    width: 48px;
    height: 28px;
    margin: 0;
    border: 0;
    border-radius: 999px;
    background: #d7ded9;
    position: relative;
    flex-shrink: 0;
    cursor: pointer;
    transition: background .15s ease;
}
.settle-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(36, 31, 26, .18);
    transition: transform .15s ease;
}
.settle-switch:checked { background: var(--brand); }
.settle-switch:checked::after { transform: translateX(20px); }
.settle-switch:focus-visible { outline: 0; box-shadow: 0 0 0 .2rem rgba(27, 107, 69, .18); }
.pay-methods {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e7f0ea;
}
.pay-methods[hidden] { display: none !important; }
.pay-methods-open { margin-top: 0; padding-top: 0; border-top: 0; }
.fold summary {
    list-style: none;
    cursor: pointer;
    color: var(--brand);
    font-size: 14px;
    font-weight: 600;
    padding: 4px 0 10px;
}
.fold summary::-webkit-details-marker { display: none; }
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--paper);
}
.auth-shell { width: 100%; max-width: 420px; margin: 0 auto; padding: 28px 16px; }
.auth-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 32px 22px 24px;
    box-shadow: none;
}
.auth-title { font-size: 26px; font-weight: 700; letter-spacing: .04em; margin: 0; }
.auth-sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.auth-field { position: relative; }
.auth-field i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 18px;
    pointer-events: none;
}
.auth-field .form-control { padding-left: 42px; }
.pay-method { margin: 0; cursor: pointer; }
.pay-method input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.pay-method span {
    display: block;
    text-align: center;
    padding: 8px 0;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 14px;
    font-weight: 600;
    color: #5f675f;
}
.pay-method input:checked + span {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.total-bar {
    position: sticky;
    bottom: calc(78px + env(safe-area-inset-bottom));
    z-index: 15;
    background: var(--brand);
    color: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    box-shadow: none;
}
.brand-logo {
    width: 76px;
    height: 76px;
    display: block;
    margin: 0 auto 4px;
}
.form-control, .form-select { border-radius: 10px; border-color: #e3e8e5; background: #fff; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(15, 110, 69, .12);
}
.btn { border-radius: 10px; }
.weigh-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eef6f1;
    color: var(--brand-dark);
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 13px;
}
.weigh-chip button {
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    line-height: 1;
}
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.photo-thumb {
    position: relative;
    display: block;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #eef2f0;
    border: 1px solid var(--line);
}
.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-thumb .photo-del {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: rgba(0,0,0,.55);
    color: #fff;
    line-height: 1;
    font-size: 14px;
}
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.debt { color: #b42318; }
.over { color: #17633e; }
.zero { color: var(--muted); font-weight: 600; font-size: 14px; }
.hero {
    background: var(--brand);
    color: #fff;
    border-radius: 16px;
    padding: 18px 16px 14px;
    box-shadow: none;
}
.hero-top, .hero-k { font-size: 12px; opacity: .78; }
.hero-top { display: flex; justify-content: space-between; }
.hero-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.hero-n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.method-cap { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.16); font-size: 12px; opacity: .78; }
.method-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 8px; }
a.owe-card {
    display: block;
    color: inherit;
    text-decoration: none;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px 13px;
}
.owe-go { color: var(--muted); font-size: 14px; }
.owe-n { margin: 2px 0 4px; font-size: 28px; font-weight: 700; line-height: 1.15; color: #b42318; font-variant-numeric: tabular-nums; }
.method-pill { background: rgba(255,255,255,.12); border-radius: 12px; padding: 8px 8px 7px; }
.method-pill span { display: block; font-size: 11px; opacity: .8; }
.method-pill b { font-size: 13px; font-variant-numeric: tabular-nums; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 8px 0; }
.section-head a { font-size: 13px; color: var(--brand); text-decoration: none; }
.tag { font-size: 11px; line-height: 1; border-radius: 999px; padding: 4px 7px; font-weight: 650; white-space: nowrap; }
.flow-note { margin: -2px 0 8px; font-size: 12px; color: var(--muted); line-height: 1.45; }
.flow-after { margin-top: 4px; font-size: 12px; color: #5f675f; }
.flow-amt-k { font-size: 11px; color: var(--muted); }
.flow-void .flow-money { color: var(--muted); text-decoration: line-through; }
.flow-btn {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 28px;
    margin-top: 8px;
    padding: 0 11px;
    border-radius: 999px;
    border: 1px solid transparent;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
}
.flow-btn-view {
    color: #17633e;
    background: #f3faf6;
    border-color: #cfe4d6;
}
.flow-btn-view:hover { color: #124832; background: #e7f5ec; }
.flow-btn-void {
    color: #9a3412;
    background: #fff6f2;
    border-color: #f3d2c6;
}
.flow-btn-void:hover { color: #7c2d12; background: #fde8e2; }
.tag-due { background: #fde8e2; color: #9a3412; }
.tag-ok { background: #e5f4eb; color: #17633e; }
.tag-void { background: #eef1ef; color: #5f675f; }
.order-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.settle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 30px;
    padding: 0 12px 0 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
}
.settle i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    display: block;
}
.settle-due { color: #9a3412; background: #fff6f2; box-shadow: inset 0 0 0 1px #f3d2c6; }
.settle-ok { color: #17633e; background: #f3faf6; box-shadow: inset 0 0 0 1px #cfe4d6; }
.settle-void { color: #6f675c; background: #f7f4ef; box-shadow: inset 0 0 0 1px #e4dcd0; }
.page-loading {
    position: fixed;
    inset: 0;
    z-index: 85;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 247, 246, .72);
}
.page-loading[hidden] { display: none !important; }
.page-loading-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 18px;
    font-weight: 650;
}
.page-loading-card i {
    width: 18px;
    height: 18px;
    border: 2px solid #d7e3dc;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.note {
    position: fixed;
    left: 16px;
    right: 16px;
    top: calc(62px + env(safe-area-inset-top));
    z-index: 80;
    max-width: 488px;
    margin: 0 auto;
    background: #241f1a;
    color: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    box-shadow: 0 10px 24px rgba(36, 31, 26, .22);
}
.ask {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
    background: rgba(36, 31, 26, .45);
}
.ask[hidden], .note[hidden] { display: none !important; }
.ask-card {
    width: min(420px, 100%);
    background: var(--card);
    border-radius: 22px;
    padding: 18px 16px 14px;
    box-shadow: 0 16px 40px rgba(36, 31, 26, .2);
}
.ask-text { white-space: pre-wrap; margin: 0 0 14px; line-height: 1.5; }
.ask-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.ask-open { overflow: hidden; }
.tempus-dominus-widget {
    border-radius: 16px;
    font-family: var(--td-font);
}
.formula { line-height: 1.45; }
.formula div + div { margin-top: 2px; }
.list-row.is-due { box-shadow: inset 3px 0 0 #e07a62; }
.empty {
    text-align: center;
    color: var(--muted);
    background: #fff;
    border: 1px dashed #d5ddd8;
    border-radius: 14px;
    padding: 22px 14px;
}
.nav-step {
    color: var(--brand-dark);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    min-width: 64px;
}
.nav-step.disabled { opacity: .35; pointer-events: none; }
.period-label { font-size: 13px; color: var(--ink); font-weight: 600; }
.name-hint {
    background: #fff6df;
    border: 1px solid #f0ddb0;
    border-radius: 14px;
    padding: 10px 12px;
    font-size: 13px;
}
.filter-card, .alert { border-radius: 16px; }
.alert { border: 0; }
.pager .pagination { justify-content: center; margin-bottom: 0; }
.pager .page-link { color: var(--brand-dark); }
.list-card { overflow: hidden; }
.app-top { border-bottom-color: var(--line); }
.stat-card, .list-card, .item-card, .settle-card, .auth-card { box-shadow: none; }
