:root {
    --bg: #f5f7f9;
    --surface: #fff;
    --text: #12213b;
    --muted: #708096;
    --border: #e0e7ed;
    --green: #087c60;
    --dark-green: #087358;
    --radius: 12px;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font:
        14px/1.65 -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "PingFang SC",
        "Microsoft YaHei",
        sans-serif;
}
button,
input,
select {
    font: inherit;
}
button,
a,
input,
select {
    -webkit-tap-highlight-color: transparent;
}
button {
    border: 1px solid transparent;
    border-radius: 7px;
    background: var(--green);
    color: white;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}
button:hover {
    background: #065f49;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
button.secondary {
    background: white;
    color: var(--text);
    border-color: #a8b4c3;
}
button.secondary:hover {
    background: #eef3f5;
}
button:focus-visible,
a:focus-visible {
    outline: 3px solid #5bb7a0;
    outline-offset: 3px;
}
header {
    max-width: 1280px;
    margin: auto;
    padding: 24px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 22px;
    font-weight: 750;
}
.brand-icon {
    background: var(--green);
    color: white;
    width: 38px;
    height: 40px;
    border-radius: 10px;
    display: grid;
    place-items: center;
}
svg {
    width: 24px;
    height: 24px;
}
main {
    max-width: 1280px;
    margin: auto;
    padding: 0 28px;
}
.intro {
    text-align: center;
    padding: 32px 0 30px;
}
h1 {
    font-size: 40px;
    letter-spacing: -1.5px;
    line-height: 1.3;
    margin: 0 0 12px;
    font-weight: 750;
}
.intro p {
    font-size: 18px;
    color: var(--muted);
    margin: 0;
}
.notice {
    border: 1px solid #d2e6df;
    background: #edf7f2;
    color: #386754;
    padding: 11px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}
.notice.error {
    background: #fff0ed;
    border-color: #f1c7bf;
    color: #a13e31;
}
.layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 22px;
    align-items: start;
}
.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}
.stats > div {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 23px 22px;
}
.stats span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}
.stats strong {
    font-size: 26px;
    letter-spacing: -0.7px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.green {
    color: var(--green);
}
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: white;
    padding: 24px;
    margin-bottom: 20px;
}
h2 {
    font-size: 20px;
    line-height: 1.4;
    margin: 0 0 18px;
    font-weight: 700;
}
.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}
.section-head h2 {
    margin: 0;
}
.section-head p {
    font-size: 12px;
    color: var(--muted);
    margin: 5px 0 0;
}
.section-head button {
    flex-shrink: 0;
}
.table-wrap {
    overflow-x: auto;
    border: 1px solid #edf0f4;
    border-radius: 8px;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
    font-size: 12px;
}
th {
    background: #f4f6f9;
    color: #637187;
    font-weight: 600;
    padding: 14px 10px;
}
td {
    padding: 16px 10px;
    border-top: 1px solid #edf0f4;
    font-variant-numeric: tabular-nums;
}
td small {
    display: block;
    white-space: normal;
    word-break: break-word;
    max-width: 140px;
    color: var(--muted);
    margin-top: 3px;
}
.row-action {
    background: transparent;
    color: var(--green);
    border: 0;
    padding: 3px;
    font-size: 12px;
}
.row-action:hover {
    background: #ecf5f1;
}
.row-action.delete {
    color: #a0504a;
}
.empty {
    text-align: center;
    padding: 42px 15px 49px;
    color: var(--muted);
}
.empty-icon {
    display: grid;
    place-items: center;
    margin: 0 auto 17px;
    border-radius: 50%;
    background: #f1f4f8;
    width: 64px;
    height: 64px;
    color: #a0adbd;
}
.empty-icon svg {
    width: 29px;
    height: 29px;
}
.empty h3 {
    font-size: 16px;
    margin: 0 0 7px;
    font-weight: 600;
}
.empty p {
    font-size: 12px;
    margin: 0;
}
.rules h2 {
    margin-bottom: 12px;
}
.rules p {
    color: #718096;
    margin: 6px 0;
    line-height: 1.9;
    font-size: 13px;
}
.forecast {
    background: var(--dark-green);
    border-radius: var(--radius);
    padding: 24px;
    color: white;
    margin-bottom: 20px;
}
.forecast h2 {
    margin-bottom: 20px;
}
.forecast label {
    color: #d6e9e2;
}
.date-row {
    display: flex;
    gap: 8px;
}
.date-row input {
    min-width: 0;
    margin: 0;
}
.date-row button {
    background: #ffffff18;
    border-color: #ffffff35;
    padding: 7px 10px;
    font-size: 12px;
}
.total-label {
    display: block;
    color: #d6e9e2;
    margin: 23px 0 3px;
}
.forecast output {
    display: block;
    font-size: 36px;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    font-variant-numeric: tabular-nums;
}
dl {
    margin: 14px 0 0;
    padding-top: 14px;
    border-top: 1px solid #ffffff35;
}
dl div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 5px 0;
}
dt {
    color: #d6e9e2;
}
dd {
    margin: 0;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.forecast-note {
    font-size: 11px;
    color: #c3dfd4;
    margin: 16px 0 0;
}
label {
    display: block;
    color: #647188;
    margin: 12px 0 6px;
    font-size: 13px;
}
input,
select {
    width: 100%;
    height: 40px;
    padding: 7px 11px;
    border: 1px solid #dce3ea;
    border-radius: 7px;
    background: white;
    color: #243046;
    outline: none;
    min-width: 0;
    font-size: 14px;
}
input:focus,
select:focus {
    border-color: #0c9471;
    box-shadow: 0 0 0 3px #109b7515;
}
select {
    font-size: 12px;
}
.settings h2 {
    margin-bottom: 16px;
}
.full {
    width: 100%;
    margin-top: 20px;
}
.hint {
    font-size: 12px;
    line-height: 1.8;
    color: var(--muted);
    margin: 16px 0 0;
}
footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 5px 0 30px;
    color: #8b96a5;
    font-size: 12px;
}
.dirty {
    color: #a06422;
}
dialog {
    width: min(440px, calc(100% - 32px));
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    color: var(--text);
    box-shadow: 0 24px 100px #12213b30;
}
dialog::backdrop {
    background: #14243c55;
    backdrop-filter: blur(3px);
}
.icon-button {
    font-size: 26px;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    padding: 2px 5px;
}
.icon-button:hover {
    background: #f0f3f7;
}
.optional {
    font-size: 11px;
    color: #97a2b1;
    margin-left: 5px;
}
.error {
    color: #a13e31;
    font-size: 13px;
}
.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
[hidden] {
    display: none !important;
}
@media (min-width: 1450px) {
    header,
    main {
        max-width: 1320px;
    }
    .layout {
        grid-template-columns: minmax(0, 1fr) 360px;
    }
    .stats strong {
        font-size: 30px;
    }
}
@media (max-width: 1050px) {
    .layout {
        grid-template-columns: minmax(0, 1fr) 310px;
        gap: 16px;
    }
    .stats > div {
        padding: 20px 13px;
    }
    .stats strong {
        font-size: 21px;
    }
    .panel {
        padding: 20px;
    }
    .forecast {
        padding: 22px;
    }
    .forecast output {
        font-size: 31px;
    }
}
@media (max-width: 800px) {
    header {
        padding: 18px 20px;
    }
    .brand {
        font-size: 19px;
    }
    main {
        padding: 0 20px;
    }
    .intro {
        padding: 24px 0;
    }
    h1 {
        font-size: 30px;
    }
    .intro p {
        font-size: 15px;
    }
    .layout {
        display: flex;
        flex-direction: column;
    }
    .ledger,
    aside {
        width: 100%;
    }
    aside {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
    .stats strong {
        font-size: 24px;
    }
    .stats > div {
        padding: 20px;
    }
    .forecast output {
        font-size: 30px;
    }
    footer {
        margin-top: 15px;
    }
}
@media (max-width: 560px) {
    header,
    main {
        padding-left: 16px;
        padding-right: 16px;
    }
    header button {
        padding: 8px 12px;
        font-size: 12px;
    }
    h1 {
        font-size: 27px;
        letter-spacing: -1px;
    }
    .intro p {
        font-size: 14px;
    }
    .notice {
        font-size: 12px;
    }
    .stats {
        gap: 8px;
    }
    .stats > div {
        padding: 15px 10px;
    }
    .stats span {
        font-size: 11px;
    }
    .stats strong {
        font-size: 17px;
        letter-spacing: -0.5px;
    }
    .panel {
        padding: 18px;
    }
    .section-head p {
        font-size: 11px;
    }
    .section-head button {
        padding: 8px 12px;
        font-size: 12px;
    }
    h2 {
        font-size: 18px;
    }
    aside {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    .forecast {
        order: -1;
    }
    .forecast output {
        font-size: 36px;
    }
    footer {
        display: block;
        font-size: 11px;
    }
    footer span {
        display: block;
    }
    table {
        min-width: 660px;
    }
    .empty p {
        font-size: 11px;
    }
    .empty {
        padding: 32px 8px;
    }
    .rules p {
        font-size: 12px;
    }
}
th {
    position: relative;
}
.date-row button {
    white-space: nowrap;
    flex-shrink: 0;
}
.records .table-wrap {
    max-height: 600px;
    overflow: auto;
}
.records thead {
    position: sticky;
    top: 0;
    z-index: 1;
}
.payment-status {
    font-size: 11px;
    display: inline-block;
    border-radius: 4px;
    padding: 1px 6px;
}
.payment-status.pending {
    background: #fff3df;
    color: #9a6a21;
}
.payment-status.recorded {
    background: #e8f5ed;
    color: #087358;
}
.payment-value {
    display: block;
    margin-top: 4px;
    font-weight: 600;
}
.pending-row td {
    color: #7b8798;
}
.pending-row td:first-child {
    color: #53657b;
}
.plan-overview dl {
    padding: 0;
    border: 0;
}
.plan-overview dt {
    color: var(--muted);
}
.plan-overview dd {
    color: var(--green);
}

.forecast-submit {
    background: #fff;
    color: var(--dark-green);
    border-color: white;
    margin-top: 16px;
}
.forecast-submit:hover {
    background: #e5f3ed;
}
.forecast form label:first-child {
    margin-top: 0;
}
