:root {
    --ink: #16201a;
    --muted: #647066;
    --paper: #f6f1e6;
    --panel: rgba(255, 252, 243, 0.88);
    --line: rgba(22, 32, 26, 0.14);
    --shadow: 0 30px 80px rgba(45, 54, 44, 0.16);
    --accent: #ffb84d;
    --accent-deep: #c47a15;
    --blue: #245ea8;
    --orange: #e5622a;
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-6px);
    }

    40% {
        transform: translateX(6px);
    }

    60% {
        transform: translateX(-4px);
    }

    80% {
        transform: translateX(4px);
    }
}

.shake {
    animation: shake 0.5s ease;
    border-color: #e05c5c !important;
    outline: none;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
    background:
        radial-gradient(circle at 12% 18%, rgba(255, 184, 77, 0.26), transparent 28%),
        radial-gradient(circle at 82% 12%, rgba(38, 122, 255, 0.17), transparent 30%),
        linear-gradient(135deg, #f8f0df 0%, #edf3e6 52%, #e7efe8 100%);
}

body::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    background-image:
        linear-gradient(rgba(22, 32, 26, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(22, 32, 26, 0.05) 1px, transparent 1px);
    background-size: 46px 46px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .7), transparent 82%);
}

.page-shell {
    width: min(1400px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 30px;
    position: relative;
}

/* top-bar */
.top-bar {
    display: flex;
    align-items: center;
    margin-bottom: 28px;
}

.back-link {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    color: #9a5c17;
    border: 1px solid #9a5c17;
    border-radius: 999px;
    background: rgba(255, 252, 243, .72);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}

.back-link:hover {
    background: rgba(255, 252, 243, .92);
}

.page-title {
    flex: 1;
    margin: 0;
    font-family: SimSun, "宋体", serif;
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 900;
    letter-spacing: -0.03em;
    text-align: center;
}

/* cloud toggle */
.cloud-toggle-wrap {
    flex-shrink: 0;
}

.display-toggle {
    position: relative;
    display: inline-flex;
    gap: 8px;
    align-items: center;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.display-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.display-toggle i {
    position: relative;
    width: 42px;
    height: 24px;
    border: 1px solid rgba(22, 32, 26, .18);
    border-radius: 999px;
    background: rgba(22, 32, 26, .14);
    transition: background .2s, border-color .2s;
}

.display-toggle i::after {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 3px 8px rgba(22, 32, 26, .18);
    content: "";
    transition: transform .2s;
}

.display-toggle input:checked + i {
    border-color: rgba(36, 94, 168, .42);
    background: var(--blue);
}

.display-toggle input:checked + i::after {
    transform: translateX(18px);
}

/* card */
.card {
    padding: 28px 32px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
    margin-bottom: 22px;
}

/* type tabs */
.type-section {
    margin-bottom: 20px;
}

.type-label {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
}

.type-label .req {
    color: #c0392b;
    margin-right: 2px;
}

.type-tabs {
    display: flex;
    gap: 10px;
}

.type-tab {
    height: 36px;
    padding: 0 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .6);
    color: var(--ink);
    transition: background 140ms, color 140ms, border-color 140ms;
}

.type-tab.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

/* section header (orange bar like in screenshot) */
.section-header {
    display: inline-block;
    background: var(--orange);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 14px 4px 10px;
    border-radius: 0 6px 6px 0;
    margin: -28px -32px 20px -32px;
    position: relative;
    clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 0 100%);
}

/* info grid — 4 columns: label | value | label | value */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.grid-cell {
    padding: 12px 14px;
    font-size: 14px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 4px;
}

.grid-cell:last-child {
    border-right: none;
}

.info-grid .grid-cell:nth-last-child(-n+4) {
    border-bottom: none;
}

.label-cell {
    background: rgba(244, 246, 244, 0.7);
    font-weight: 600;
    color: var(--ink);
    flex-wrap: wrap;
    line-height: 1.5;
}

.value-cell {
    background: rgba(255, 255, 255, .5);
}

.field-input,
.field-select {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .8);
    font-size: 14px;
    color: var(--ink);
    outline: none;
    font-family: inherit;
    transition: border-color 160ms, box-shadow 160ms;
}

.field-input:focus,
.field-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(36, 94, 168, .12);
}

/* radio */
.value-cell .radio-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    cursor: pointer;
    margin-right: 16px;
}

/* tip button */
.tip-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--muted);
    background: none;
    font-size: 11px;
    color: var(--muted);
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    font-family: inherit;
    line-height: 1;
}

.tip-btn:hover {
    background: rgba(22, 32, 26, .07);
}

/* forecast tip */
.forecast-tip {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--orange);
    font-weight: 600;
}

/* buttons */
.btn-row {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 22px;
}

.primary-button {
    height: 42px;
    padding: 0 36px;
    border: none;
    border-radius: 10px;
    background: var(--blue);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 160ms;
    font-family: inherit;
}

.primary-button:hover {
    opacity: .86;
}

.ghost-button {
    height: 42px;
    padding: 0 28px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, .6);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 140ms;
    font-family: inherit;
}

.ghost-button:hover {
    background: rgba(255, 255, 255, .9);
}

/* result */
.result-card {
    display: none;
}

.result-card.visible {
    display: block;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

@media (max-width: 600px) {
    .result-grid {
        grid-template-columns: 1fr;
    }
}

.result-item {
    padding: 18px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, .6);
    text-align: center;
}

.result-item-total {
    grid-column: 1 / -1;
    border-color: rgba(36, 94, 168, .3);
    background: rgba(36, 94, 168, .06);
}

.result-item-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}

.result-item-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.02em;
}

.result-item-total .result-item-value {
    font-size: 32px;
}

.result-item-sub {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

.result-note {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    margin-bottom: 12px;
    line-height: 1.6;
}

.save-row {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.save-button {
    height: 44px;
    padding: 0 40px;
    border: none;
    border-radius: 22px;
    background: linear-gradient(135deg, #ffb84d, #c47a15);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(196, 122, 21, .28);
    transition: transform 160ms, box-shadow 160ms;
    font-family: inherit;
}

.save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(196, 122, 21, .36);
}

.save-button:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* info grid half — only 2 data columns */
.info-grid-half {
    grid-template-columns: 1fr 1fr 1fr 1fr;
}

.info-grid-half .grid-cell:nth-last-child(-n+4) {
    border-bottom: none;
}

.tooltip-popup {
    position: fixed;
    z-index: 9999;
    max-width: 280px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(45, 54, 44, .16);
    font-size: 13px;
    line-height: 1.7;
    color: var(--ink);
}

.tooltip-popup[hidden] {
    display: none;
}
