:root {
    --bg: #f4efe6;
    --bg-deep: #113033;
    --surface: rgba(255, 252, 247, 0.92);
    --surface-strong: #fffdf9;
    --surface-soft: rgba(255, 255, 255, 0.72);
    --text: #142425;
    --muted: #5b6b6c;
    --line: rgba(20, 36, 37, 0.1);
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-soft: #d5f1ea;
    --warm: #f59e0b;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 24px 60px rgba(17, 48, 51, 0.14);
    --radius-xl: 28px;
    --radius-lg: 20px;
    --radius-md: 14px;
    --radius-sm: 12px;
}

@property --progress {
    syntax: "<number>";
    inherits: false;
    initial-value: 0;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28%),
        radial-gradient(circle at 85% 15%, rgba(245, 158, 11, 0.18), transparent 24%),
        linear-gradient(160deg, #f7f1e7 0%, #edf4f3 45%, #eaf0f7 100%);
}

button,
input,
select {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
}

a {
    color: inherit;
}

code {
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(17, 48, 51, 0.08);
    font-size: 0.92em;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 44px;
}

.auth-screen,
.dashboard-grid,
.content-grid {
    display: grid;
    gap: 22px;
}

.auth-screen {
    min-height: calc(100vh - 80px);
    grid-template-columns: minmax(320px, 460px) minmax(320px, 1fr);
    align-items: center;
}

.auth-card,
.info-card,
.panel {
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-xl);
    background: var(--surface);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.auth-card,
.info-card {
    padding: 34px;
}

.auth-card h1,
.topbar h1 {
    margin: 8px 0 10px;
    font-size: clamp(34px, 4vw, 48px);
    line-height: 1;
    letter-spacing: -0.04em;
}

.lead,
.lead-small,
.panel-subtitle {
    color: var(--muted);
    line-height: 1.65;
}

.lead {
    margin: 0 0 28px;
    font-size: 16px;
}

.lead-small {
    margin: 8px 0 0;
    font-size: 14px;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--accent);
}

.stack-form,
.form-grid {
    display: grid;
    gap: 16px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 8px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input:focus,
select:focus {
    border-color: rgba(15, 118, 110, 0.45);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

small {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.primary,
.ghost,
.tab,
.icon-button {
    min-height: 48px;
    border-radius: 999px;
    padding: 0 18px;
    font-weight: 800;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.primary:hover,
.ghost:hover,
.tab:hover,
.icon-button:hover {
    transform: translateY(-1px);
}

.primary {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 18px 36px rgba(15, 118, 110, 0.24);
}

.ghost,
.icon-button {
    color: var(--accent-strong);
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
}

.full-width,
.wide {
    width: 100%;
}

.auth-note {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(17, 48, 51, 0.05);
    color: var(--muted);
}

.feature-list {
    margin: 18px 0 0;
    padding-left: 18px;
    color: var(--muted);
    line-height: 1.7;
}

.app-shell {
    display: grid;
    gap: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    padding: 8px 2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.mini-role {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.user-badge,
.account-box,
.period-label,
.metric-card,
.list-row,
.tab,
.segmented,
.tabs,
.inline-form {
    border: 1px solid var(--line);
}

.user-badge,
.account-box {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.76);
}

.user-badge strong,
.account-box strong {
    display: block;
    font-size: 15px;
}

.user-badge span,
.account-box span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.6);
}

.tab {
    color: var(--muted);
    background: transparent;
}

.tab.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--bg-deep), #1c4d50);
}

.panel-stack,
.view-panel {
    display: grid;
    gap: 20px;
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
}

.content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
    padding: 26px;
}

.panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 8px 0 0;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.panel-subtitle {
    margin: 10px 0 0;
    font-size: 14px;
}

.compact-head {
    justify-content: flex-end;
    margin-bottom: 14px;
}

.segmented {
    display: inline-flex;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
}

.segmented button {
    min-width: 54px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.segmented button.active {
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.period-controls {
    display: grid;
    grid-template-columns: 52px 1fr 52px;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.period-label {
    min-height: 52px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.76);
    font-weight: 800;
}

.hero-grid {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(240px, 1fr);
    gap: 20px;
    align-items: stretch;
}

.donut-card {
    display: grid;
    place-items: center;
    min-height: 340px;
    padding: 12px;
    border-radius: calc(var(--radius-xl) - 8px);
    background:
        radial-gradient(circle at top, rgba(245, 158, 11, 0.18), transparent 38%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(250, 250, 248, 0.72));
}

.budget-orbit {
    position: relative;
    width: min(360px, 100%);
    min-height: 280px;
    display: grid;
    place-items: center;
}

.donut {
    --progress: 0;
    --ring-hue: 145;
    --ring-start-hue: 162;
    width: min(280px, 70vw);
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at center, rgba(255, 253, 249, 0.98) 0 55%, transparent 56%),
        conic-gradient(
            from -90deg,
            hsl(var(--ring-start-hue) 72% 46%) 0%,
            hsl(var(--ring-hue) 78% 42%) calc(var(--progress) * 1%),
            rgba(17, 48, 51, 0.08) 0 100%
        );
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.8),
        0 24px 48px rgba(17, 48, 51, 0.15);
    transition:
        --progress 680ms cubic-bezier(0.2, 0.9, 0.2, 1),
        transform 260ms ease,
        box-shadow 260ms ease,
        filter 260ms ease;
}

.donut.over {
    background:
        radial-gradient(circle at center, rgba(255, 253, 249, 0.98) 0 55%, transparent 56%),
        conic-gradient(from -90deg, #fb923c 0 18%, #ef4444 58%, #dc2626 100%);
}

.donut-center {
    width: 52%;
    display: grid;
    gap: 6px;
    text-align: center;
}

.donut-toggle {
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.84);
    color: var(--text);
    cursor: pointer;
}

.donut-center strong {
    font-size: clamp(20px, 3vw, 26px);
    line-height: 1.2;
}

.donut-center span,
.donut-center small {
    color: var(--muted);
}

.donut-center span {
    font-weight: 700;
}

.donut-center small {
    font-size: 13px;
}

.orbit-label {
    position: absolute;
    z-index: 2;
    min-width: 96px;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border: 1px solid rgba(17, 48, 51, 0.08);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 16px 32px rgba(17, 48, 51, 0.12);
    transition: transform 280ms ease, opacity 280ms ease, box-shadow 280ms ease;
}

.orbit-label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.orbit-label strong {
    font-size: 20px;
    letter-spacing: -0.03em;
}

.orbit-label-spent {
    left: 4px;
    top: 42px;
    text-align: right;
    color: #0f766e;
    background: rgba(236, 253, 245, 0.94);
    border-color: rgba(15, 118, 110, 0.16);
}

.orbit-label-spent span {
    color: #0f766e;
}

.orbit-label-remaining {
    right: 4px;
    bottom: 54px;
    text-align: left;
    color: #2563eb;
    background: rgba(239, 246, 255, 0.94);
    border-color: rgba(37, 99, 235, 0.14);
}

.orbit-label-remaining span {
    color: #2563eb;
}

.orbit-label.danger {
    color: var(--danger);
    background: rgba(255, 245, 245, 0.94);
}

.orbit-label.danger span {
    color: #b91c1c;
}

.summary-stack {
    display: grid;
    gap: 14px;
}

.slim-summary {
    align-content: center;
    justify-items: stretch;
}

.hero-hint {
    margin: 0;
    padding: 16px 18px;
    border: 1px dashed rgba(15, 118, 110, 0.22);
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted);
    font-size: 14px;
    line-height: 1.6;
}

.metric-card {
    padding: 18px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.74);
}

.metric-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.metric-card.accent {
    background: linear-gradient(135deg, var(--bg-deep), #1d4f52);
    color: #fff;
    border-color: transparent;
}

.metric-card.accent span {
    color: rgba(255, 255, 255, 0.72);
}

.list-shell {
    display: grid;
    gap: 12px;
}

.inline-list-panel {
    display: grid;
    gap: 16px;
    min-height: 360px;
}

.inline-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.inline-list-head strong {
    font-size: 18px;
    letter-spacing: -0.02em;
}

.compact-ghost {
    min-height: 36px;
    padding: 0 14px;
    font-size: 13px;
}

.donut-card.is-loading .donut {
    filter: saturate(0.82);
    transform: scale(0.97);
}

.donut-card.is-loading .donut-center,
.donut-card.is-loading .orbit-label {
    opacity: 0.34;
    transform: translateY(8px) scale(0.96);
}

.donut-card.is-revealing .donut {
    animation: donut-entrance 620ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.donut-card.is-revealing .orbit-label-spent {
    animation: badge-fade-in-left 620ms 80ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.donut-card.is-revealing .orbit-label-remaining {
    animation: badge-fade-in-right 620ms 160ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.donut-card.is-revealing .donut-center {
    animation: center-fade-up 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes donut-entrance {
    0% {
        opacity: 0.32;
        transform: scale(0.9);
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

@keyframes badge-fade-in-left {
    0% {
        opacity: 0;
        transform: translate(-12px, 14px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes badge-fade-in-right {
    0% {
        opacity: 0;
        transform: translate(12px, 14px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes center-fade-up {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.74);
}

.list-row strong {
    display: block;
    font-size: 16px;
}

.list-row span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    line-height: 1.55;
}

.row-meta,
.day-values {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.row-meta time {
    color: var(--muted);
    font-size: 13px;
}

.day-values b,
.day-values span {
    margin: 0;
    font-size: 13px;
}

.link-danger {
    min-height: auto;
    padding: 0;
    background: transparent;
    color: var(--danger);
    font-weight: 800;
}

.danger-text {
    color: var(--danger);
}

.empty-state {
    padding: 28px 18px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
    color: var(--muted);
    text-align: center;
}

.span-2 {
    grid-column: span 2;
}

.action-row {
    align-items: end;
}

.inline-form {
    display: flex;
    gap: 10px;
    padding: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
}

.inline-form input {
    min-width: 120px;
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 999px;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    margin-right: 8px;
    font-size: 12px;
    font-weight: 800;
}

.pill.holiday {
    color: #9a3412;
    background: rgba(251, 146, 60, 0.18);
}

.pill.makeup_workday {
    color: #1d4ed8;
    background: rgba(96, 165, 250, 0.18);
}

.checkbox-row {
    grid-column: span 2;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.74);
}

.checkbox-row input {
    width: 18px;
    min-height: auto;
    height: 18px;
}

.amount-input {
    font-size: 28px;
    font-weight: 800;
}

.modal {
    width: min(540px, calc(100vw - 24px));
    border: 0;
    padding: 0;
    border-radius: var(--radius-xl);
    background: var(--surface-strong);
    box-shadow: 0 32px 72px rgba(0, 0, 0, 0.28);
}

.modal::backdrop {
    background: rgba(12, 22, 24, 0.46);
    backdrop-filter: blur(6px);
}

.dialog-close-row {
    display: flex;
    justify-content: flex-end;
    padding: 16px 16px 0;
}

.dialog-body {
    padding: 6px 28px 28px;
}

.dialog-body h2 {
    margin: 10px 0 18px;
    font-size: 30px;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(420px, calc(100vw - 28px));
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(16, 88, 82, 0.96);
    color: #fff;
    box-shadow: 0 22px 48px rgba(16, 88, 82, 0.28);
}

.toast.error {
    background: rgba(185, 28, 28, 0.96);
    box-shadow: 0 22px 48px rgba(185, 28, 28, 0.24);
}

@media (max-width: 980px) {
    .auth-screen,
    .dashboard-grid,
    .content-grid,
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    body {
        background:
            radial-gradient(circle at top, rgba(15, 118, 110, 0.14), transparent 34%),
            linear-gradient(180deg, #f6f0e7 0%, #eef4f3 100%);
    }

    .shell {
        width: 100%;
        padding: 16px 10px calc(102px + env(safe-area-inset-bottom, 0px));
    }

    .auth-card,
    .info-card,
    .panel {
        padding: 20px;
        border-radius: 22px;
    }

    .app-shell {
        gap: 14px;
    }

    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 4px 2px 0;
    }

    .topbar > div:first-child {
        min-width: 0;
    }

    .topbar h1 {
        margin: 0;
        font-size: 28px;
    }

    .topbar .eyebrow,
    .lead-small {
        display: none;
    }

    .topbar-actions {
        width: auto;
        flex-wrap: nowrap;
        justify-content: flex-end;
        align-items: center;
        gap: 6px;
    }

    .user-badge {
        display: none;
    }

    .mini-role {
        display: inline-flex;
        min-height: 30px;
        padding: 0 10px;
        font-size: 11px;
    }

    #logoutButton {
        min-height: 30px;
        padding: 0 10px;
        font-size: 11px;
        box-shadow: none;
    }

    .tabs {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom, 0px));
        z-index: 30;
        display: flex;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 8px;
        border-radius: 24px;
        background: rgba(255, 253, 249, 0.92);
        backdrop-filter: blur(18px);
        box-shadow: 0 18px 48px rgba(17, 48, 51, 0.18);
    }

    .tab {
        flex: 1;
        min-height: 56px;
        padding: 8px 4px;
        border-radius: 18px;
        font-size: 12px;
        line-height: 1.2;
        text-align: center;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2,
    .checkbox-row {
        grid-column: auto;
    }

    .period-controls {
        grid-template-columns: 44px 1fr 44px;
        gap: 10px;
    }

    .icon-button,
    .tab,
    .primary,
    .ghost {
        min-height: 44px;
    }

    .row-meta,
    .day-values,
    .list-row {
        align-items: flex-start;
    }

    .list-row {
        flex-direction: column;
    }

    .inline-form {
        width: 100%;
        flex-wrap: wrap;
        border-radius: 18px;
    }

    .panel-stack,
    .view-panel,
    .dashboard-grid,
    .content-grid,
    .hero-grid {
        gap: 12px;
    }

    .panel-head {
        margin-bottom: 14px;
    }

    .panel-head h2 {
        font-size: 24px;
    }

    .panel-subtitle,
    .lead {
        font-size: 14px;
    }

    .donut-card {
        min-height: 280px;
        padding: 10px;
    }

    .budget-orbit {
        width: 100%;
        min-height: 248px;
    }

    .compact-head {
        margin-bottom: 10px;
    }

    .metric-card {
        padding: 16px;
    }

    .metric-card strong {
        font-size: 24px;
    }

    .period-label {
        min-height: 44px;
        padding: 0 10px;
        font-size: 13px;
        text-align: center;
    }

    .dialog-body {
        padding: 6px 20px 22px;
    }

    .inline-list-panel {
        min-height: 300px;
    }

    .inline-list-head {
        align-items: flex-start;
    }

    .inline-list-head strong {
        font-size: 16px;
    }

    .compact-ghost {
        min-height: 30px;
        padding: 0 10px;
        font-size: 11px;
        box-shadow: none;
    }

    .hero-hint {
        padding: 14px 16px;
        font-size: 13px;
    }

    .orbit-label {
        min-width: 82px;
        padding: 10px 12px;
        border-radius: 16px;
    }

    .orbit-label strong {
        font-size: 17px;
    }

    .orbit-label span {
        font-size: 11px;
    }

    .orbit-label-spent {
        left: 0;
        top: 18px;
    }

    .orbit-label-remaining {
        right: 0;
        bottom: 22px;
    }
}
