: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;
}

@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, 0.7), transparent 82%);
}

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

.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, 0.72);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
    flex-shrink: 0;
}
.back-link:hover,
.back-link:focus-visible {
    background: rgba(255, 252, 243, 0.92);
    outline: none;
}

.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;
}

.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;
}

/* form */
.form-row {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.field-group {
    flex: 1 1 200px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.field-label .req { color: #c0392b; margin-right: 2px; }

.field-input, .field-select {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    color: var(--ink);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease;
    font-family: inherit;
}

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

/* month picker */
.month-picker-wrap {
    position: relative;
}

.month-picker-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    width: 280px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(45, 54, 44, 0.16);
    padding: 14px;
}
.month-picker-popup.is-open { display: block; }

.mp-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.mp-year {
    font-weight: 700;
    font-size: 16px;
}
.mp-arrow {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
}
.mp-arrow:hover { background: rgba(22, 32, 26, 0.07); color: var(--ink); }

.mp-months {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}
.mp-month {
    height: 36px;
    border: none;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--ink);
    transition: background 140ms ease;
}
.mp-month:hover { background: rgba(22, 32, 26, 0.07); }
.mp-month.selected {
    background: var(--blue);
    color: #fff;
    font-weight: 700;
}

/* 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, 0.18);
    border-radius: 999px;
    background: rgba(22, 32, 26, 0.14);
    transition: background 0.2s ease, border-color 0.2s ease;
}
.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, 0.18);
    content: "";
    transition: transform 0.2s ease;
}
.display-toggle input:checked + i {
    border-color: rgba(36, 94, 168, 0.42);
    background: var(--blue);
}
.display-toggle input:checked + i::after {
    transform: translateX(18px);
}

/* type picker */
.type-picker-wrap {
    position: relative;
}

.type-picker-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    min-width: 240px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(45, 54, 44, 0.16);
    padding: 6px 0;
    overflow: hidden;
}
.type-picker-popup.is-open { display: block; }

.tp-option {
    display: block;
    width: 100%;
    padding: 10px 18px;
    border: none;
    background: none;
    text-align: left;
    font-size: 15px;
    font-family: inherit;
    color: var(--ink);
    cursor: pointer;
    line-height: 1.5;
}
.tp-option:hover { background: rgba(36, 94, 168, 0.07); }
.tp-option.selected { background: rgba(36, 94, 168, 0.1); font-weight: 600; }
.btn-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    align-self: flex-end;
    padding-bottom: 1px;
}

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

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

/* notice */
.notice-card {
    background: rgba(255, 248, 230, 0.85);
    border: 1px solid rgba(196, 122, 21, 0.22);
    font-size: 14px;
    line-height: 1.8;
    color: var(--muted);
}
.notice-card strong { color: var(--ink); }

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

.result-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}
@media (max-width: 600px) {
    .result-grid { grid-template-columns: 1fr; }
}

.result-item {
    padding: 18px 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.6);
    text-align: center;
}
.result-item-label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}
.result-item-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--blue);
    letter-spacing: -0.02em;
}
.result-item-sub {
    margin-top: 4px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

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

.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, 0.28);
    transition: transform 160ms ease, box-shadow 160ms ease;
    font-family: inherit;
}
.save-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(196, 122, 21, 0.36);
}
.save-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
