* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background: linear-gradient(135deg, #eef2ff, #f8f4ff, #eefcf7);
    color: #252a41;
    min-height: 100vh;
}

/* HEADER */

header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    padding: 28px 7%;
    border-bottom: 1px solid rgba(100, 100, 150, 0.1);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}

.save-status {
    font-size: 13px;
    font-weight: 600;
    color: #68739a;
    white-space: nowrap;
}

.save-status-loading {
    color: #6651e8;
}

.save-status-saved {
    color: #19b96b;
}

.save-status-local {
    color: #c47b16;
}

.save-status-error {
    color: #d64545;
}

.sign-out-button {
    background: #f3f1ff;
    color: #6651e8;
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s ease;
}

.sign-out-button:hover {
    background: #e7e1ff;
}

.goal-notice {
    min-height: 20px;
    margin-bottom: 14px;
    color: #6651e8;
    font-size: 14px;
    font-weight: 600;
}

.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: #7c84a3;
}

.loading-spinner {
    width: 36px;
    height: 36px;
    margin: 0 auto 14px;
    border: 4px solid #e7e9f3;
    border-top-color: #6651e8;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.modal-subtitle {
    margin: -10px 0 20px;
    color: #68739a;
    line-height: 1.5;
}

.modal-message {
    min-height: 20px;
    margin: 0 0 14px;
    color: #d64545;
    font-size: 14px;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.secondary-button,
.danger-button {
    flex: 1;
    padding: 15px;
    border: none;
    border-radius: 13px;
    font-size: 16px;
    cursor: pointer;
}

.secondary-button {
    background: #f3f4fa;
    color: #3b4160;
}

.danger-button {
    background: #d64545;
    color: white;
}

.danger-button:hover {
    background: #c13737;
}

header h1 {
    font-size: 36px;
    margin-bottom: 6px;
    background: linear-gradient(90deg, #6c4cff, #9b5cff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: #68739a;
    font-size: 16px;
}

/* MAIN */

main {
    width: 88%;
    max-width: 1050px;
    margin: 45px auto;
}

/* SAVINGS CARD */

.summary {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #6651e8, #8d5cf6);
    color: white;
    padding: 35px;
    border-radius: 28px;
    margin-bottom: 35px;
    box-shadow: 0 18px 40px rgba(91, 71, 200, 0.25);
}

.summary::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    right: -70px;
    top: -90px;
}

.summary h2 {
    font-size: 20px;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
}

.total {
    font-size: 48px;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.summary p {
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 1;
}

/* GOALS */

.goals {
    background: rgba(255, 255, 255, 0.9);
    padding: 32px;
    border-radius: 28px;
    box-shadow: 0 12px 35px rgba(45, 45, 90, 0.08);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.section-header h2 {
    font-size: 27px;
}

#addGoalButton {
    background: linear-gradient(135deg, #6651e8, #8d5cf6);
    color: white;
    padding: 13px 20px;
    border-radius: 14px;
    font-size: 15px;
    box-shadow: 0 8px 18px rgba(102, 81, 232, 0.25);
    transition: 0.2s ease;
}

#addGoalButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 22px rgba(102, 81, 232, 0.3);
}

/* GOAL CARDS */

.goal-card {
    padding: 23px;
    border-radius: 20px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #ffffff, #f7f8ff);
    border: 1px solid #e6e7f5;
    box-shadow: 0 7px 20px rgba(40, 40, 80, 0.06);
    animation: goalAppear 0.35s ease;
    transition: 0.2s ease;
}

.goal-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(40, 40, 80, 0.1);
}

.goal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.goal-top h3 {
    font-size: 20px;
}

.goal-top span {
    background: #eeeaff;
    color: #6651e8;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: bold;
}

.goal-amount {
    font-size: 26px;
    font-weight: bold;
    margin-bottom: 15px;
}

.goal-amount span {
    color: #7c84a3;
    font-size: 15px;
    font-weight: normal;
}

/* PROGRESS BAR */

.progress-background {
    width: 100%;
    height: 14px;
    background: #e7e9f3;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #35d07f, #19b96b);
    border-radius: 999px;
    transition: width 0.8s ease;
}

/* EMPTY STATE */

.empty-state {
    text-align: center;
    padding: 55px 20px;
    color: #7c84a3;
}

.empty-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: float 2.5s ease-in-out infinite;
}

.empty-state h3 {
    color: #252a41;
    margin-bottom: 8px;
}

/* MODAL */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(35, 31, 65, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* !important keeps this helper winning over component
   display rules that are declared later in this file
   (such as .auth-screen and .loading-screen) */

.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 440px;
    padding: 32px;
    border-radius: 26px;
    position: relative;
    box-shadow: 0 25px 70px rgba(35, 31, 65, 0.25);
    animation: popIn 0.25s ease;
}

.modal-content h2 {
    margin-bottom: 25px;
    font-size: 25px;
}

.close-button {
    position: absolute;
    top: 14px;
    right: 18px;
    background: transparent;
    font-size: 30px;
    color: #7c84a3;
}

.close-button:hover {
    color: #252a41;
}

.modal-content label {
    display: block;
    margin-bottom: 7px;
    font-weight: bold;
    color: #3b4160;
}

.modal-content input {
    width: 100%;
    padding: 14px;
    border: 2px solid #e4e6f1;
    border-radius: 13px;
    margin-bottom: 18px;
    font-size: 16px;
    transition: 0.2s ease;
}

.modal-content input:focus {
    outline: none;
    border-color: #7657ed;
    box-shadow: 0 0 0 4px rgba(118, 87, 237, 0.12);
}

.create-button {
    width: 100%;
    padding: 15px;
    border-radius: 13px;
    background: linear-gradient(135deg, #6651e8, #8d5cf6);
    color: white;
    font-size: 16px;
    box-shadow: 0 8px 18px rgba(102, 81, 232, 0.22);
    transition: 0.2s ease;
}

.create-button:hover {
    transform: translateY(-2px);
}

/* ANIMATIONS */

@keyframes popIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes goalAppear {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-7px);
    }
}

/* MOBILE */

@media (max-width: 650px) {

    header {
        padding: 22px 6%;
    }

    .header-top {
        flex-direction: column;
    }

    header h1 {
        font-size: 30px;
    }

    main {
        width: 94%;
        margin: 25px auto;
    }

    .summary {
        padding: 27px;
        border-radius: 23px;
    }

    .total {
        font-size: 40px;
    }

    .goals {
        padding: 22px;
        border-radius: 23px;
    }

    .section-header {
        align-items: flex-start;
        gap: 15px;
    }

    .section-header h2 {
        font-size: 23px;
    }

    #addGoalButton {
        padding: 11px 14px;
    }
}
.money-buttons {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.money-buttons button {
    background: #eeeaff;
    color: #6651e8;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.2s ease;
}

.money-buttons button:hover {
    transform: translateY(-2px);
    background: #ddd6ff;
}

.money-buttons .custom-money {
    background: linear-gradient(135deg, #6651e8, #8d5cf6);
    color: white;
}

.money-buttons .custom-money:hover {
    background: linear-gradient(135deg, #5944d5, #7948df);
}
.remove-money {
    background: #ffe5e5;
    color: #d64545;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.2s ease;
}

.remove-money:hover {
    transform: translateY(-2px);
    background: #ffd2d2;
}
.edit-goal {
    background: #e8f0ff;
    color: #3972d6;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.2s ease;
}

.edit-goal:hover {
    transform: translateY(-2px);
    background: #d7e5ff;
}
.delete-goal {
    background: #ffe5e5;
    color: #d64545;
    padding: 9px 13px;
    border-radius: 10px;
    font-size: 14px;
    transition: 0.2s ease;
}

.delete-goal:hover {
    transform: translateY(-2px);
    background: #ffd2d2;
}
.deadline-info {
    margin-top: 14px;
    font-size: 14px;
    font-weight: 600;
    color: #6651e8;
}

.weekly-info {
    margin-top: 7px;
    font-size: 14px;
    color: #555;
    background: #f1edff;
    padding: 9px 12px;
    border-radius: 10px;
}
/* ============================= */
/* v0.8.9 ANIMATIONS */
/* ============================= */

/* Goal cards smoothly appear */
.goal-card {
    animation: goalAppear 0.45s ease-out;
}

@keyframes goalAppear {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Smooth progress bar */
.progress-bar {
    transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Buttons have a satisfying press */
.money-buttons button {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.money-buttons button:active {
    transform: scale(0.94);
}

/* Goal cards lift when hovered */
.goal-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.goal-card:hover {
    transform: translateY(-3px);
}
/* Floating money animation */

.goal-card {
    position: relative;
    overflow: hidden;
}

.money-float {
    position: absolute;
    right: 25px;
    top: 55px;
    font-size: 22px;
    font-weight: bold;
    color: #19b96b;
    pointer-events: none;
    animation: moneyFloat 0.9s ease-out forwards;
    z-index: 10;
}

@keyframes moneyFloat {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
    }

    25% {
        opacity: 1;
        transform: translateY(0) scale(1.1);
    }

    100% {
        opacity: 0;
        transform: translateY(-45px) scale(1);
    }
}
/* ============================= */
/* GOAL COMPLETE ANIMATION */
/* ============================= */

.goal-card {
    position: relative;
    overflow: hidden;
}

.goal-card.goal-complete {
    animation: goalComplete 0.7s ease;
}

.goal-celebration {
    position: absolute;
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%);
    font-size: 38px;
    font-weight: bold;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    animation: celebrationPop 1.2s ease-out forwards;
}

@keyframes goalComplete {
    0% {
        transform: scale(1);
    }

    35% {
        transform: scale(1.04);
    }

    65% {
        transform: scale(0.98);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes celebrationPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -30%) scale(0.5);
    }

    25% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    70% {
        opacity: 1;
        transform: translate(-50%, -70%) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -100%) scale(0.9);
    }
}
/* ============================= */
/* SAVEQUEST LOGIN */
/* ============================= */

.auth-screen {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.95);
    padding: 35px;
    border-radius: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.auth-card h1 {
    margin-bottom: 8px;
}

.auth-card > p {
    margin-bottom: 25px;
    color: #666;
}

.auth-card h2 {
    margin-bottom: 20px;
}

.auth-card label {
    display: block;
    text-align: left;
    margin: 12px 0 6px;
    font-weight: bold;
}

.auth-card input {
    width: 100%;
    box-sizing: border-box;
    padding: 13px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 16px;
}

.auth-card input:focus {
    outline: none;
    border-color: #7c4dff;
}

.auth-card .create-button {
    width: 100%;
    margin-top: 20px;
}

.auth-message {
    min-height: 20px;
    margin: 12px 0 !important;
}

.switch-auth {
    border: none;
    background: none;
    color: #6c3cff;
    cursor: pointer;
    font-size: 14px;
    margin-top: 8px;
}

.switch-auth:hover {
    text-decoration: underline;
}


/* ============================= */
/* COMPONENT THEME TOKENS */
/* ============================= */

:root {
    --sq-page: linear-gradient(135deg, #eef2ff, #f8f4ff, #eefcf7);
    --sq-surface: #ffffff;
    --sq-card: rgba(255, 255, 255, 0.95);
    --sq-surface-muted: #f3f1ff;
    --sq-surface-hover: #e7e1ff;
    --sq-border: #e4e6f1;
    --sq-text: #252a41;
    --sq-text-muted: #7c84a3;
    --sq-accent: #6651e8;
}

body {
    background: var(--sq-page);
}

body.theme-dark {
    --sq-page: linear-gradient(135deg, #0d0f1f, #141232, #0c1a1c);
    --sq-surface: #171a31;
    --sq-card: rgba(23, 26, 48, 0.97);
    --sq-surface-muted: #262a4d;
    --sq-surface-hover: #323764;
    --sq-border: #2c3159;
    --sq-text: #e8ebff;
    --sq-text-muted: #a3abcd;
    --sq-accent: #9b8cff;

    color: #e8ebff;
    color-scheme: dark;
    background: var(--sq-page);
}


/* ============================= */
/* APP LOADING SCREEN */
/* ============================= */

/* Sits on top of the whole app while Firebase starts up
   so the page never grows taller than the viewport. */

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--sq-page);
    animation: loadingScreenFallback 0.4s ease 8s forwards;
}

@keyframes loadingScreenFallback {
    to {
        opacity: 0;
        visibility: hidden;
    }
}


/* ============================= */
/* HEADER SETTINGS BUTTON */
/* ============================= */

.icon-button {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sq-surface-muted);
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    transition: 0.2s ease;
}

.icon-button:hover {
    background: var(--sq-surface-hover);
    transform: translateY(-2px);
}


/* ============================= */
/* LOGIN + MODAL SCROLL FIXES */
/* ============================= */

/* Keeps the login card centered while still letting the
   page scroll when the card is taller than the screen. */

.auth-screen {
    padding: 30px 20px;
}

.auth-card {
    margin: auto;
    background: var(--sq-card);
}

/* Tall modals (such as Settings) scroll instead of
   pushing their content off the top of the screen. */

.modal {
    overflow-y: auto;
}

.modal-content {
    margin: auto;
    background: var(--sq-surface);
    color: var(--sq-text);
}

.modal-content input,
.modal-content textarea {
    background: var(--sq-surface);
    color: var(--sq-text);
}


/* ============================= */
/* FORM CONTROLS */
/* ============================= */

button,
input,
select,
textarea {
    font-family: inherit;
}

button {
    background: none;
    border: none;
    cursor: pointer;
}


/* ============================= */
/* SETTINGS SCREEN */
/* ============================= */

.settings-content {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.settings-content .settings-group {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--sq-border);
}

.settings-content .settings-group:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.settings-content .settings-group h3 {
    margin-bottom: 16px;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sq-text-muted);
}

.settings-content .settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.settings-content .settings-row label {
    margin: 0;
}

.settings-content select,
.settings-content .settings-row input[type="text"] {
    padding: 11px 13px;
    border: 2px solid var(--sq-border);
    border-radius: 12px;
    background: var(--sq-surface);
    color: var(--sq-text);
    font-size: 15px;
    cursor: pointer;
}

.settings-content select {
    min-width: 132px;
}

.settings-content .settings-row input[type="text"] {
    width: 96px;
    margin-bottom: 0;
    text-align: center;
}

.settings-content select:focus,
.settings-content .settings-row input[type="text"]:focus {
    outline: none;
    border-color: var(--sq-accent);
    box-shadow: 0 0 0 4px rgba(118, 87, 237, 0.14);
}

.settings-content .settings-toggle {
    cursor: pointer;
}

.settings-content .settings-toggle span {
    color: var(--sq-text);
    font-weight: bold;
}

.settings-content .settings-toggle input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    accent-color: var(--sq-accent);
    cursor: pointer;
}

.settings-content .secondary-button {
    margin-top: 4px;
}

.modal-message-success {
    color: #19b96b;
}


/* ============================= */
/* DARK THEME OVERRIDES */
/* ============================= */

body.theme-dark header {
    background: rgba(20, 22, 44, 0.85);
    border-bottom-color: rgba(140, 150, 220, 0.16);
}

body.theme-dark header p,
body.theme-dark .loading-state,
body.theme-dark .empty-state,
body.theme-dark .modal-subtitle,
body.theme-dark .close-button,
body.theme-dark .goal-amount span {
    color: var(--sq-text-muted);
}

body.theme-dark .save-status {
    color: #a3abcd;
}

body.theme-dark .save-status-saved {
    color: #4ade8b;
}

body.theme-dark .save-status-local {
    color: #f0b357;
}

body.theme-dark .save-status-error {
    color: #ff8a8a;
}

body.theme-dark .save-status-loading {
    color: #a99bff;
}

body.theme-dark .goal-notice,
body.theme-dark .deadline-info {
    color: #a99bff;
}

body.theme-dark .sign-out-button,
body.theme-dark .icon-button {
    background: #262a4d;
    color: #b9aeff;
}

body.theme-dark .sign-out-button:hover,
body.theme-dark .icon-button:hover {
    background: #323764;
}

body.theme-dark .loading-spinner {
    border-color: #2a2f54;
    border-top-color: #8d7cff;
}

body.theme-dark .goals {
    background: rgba(23, 26, 48, 0.9);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.35);
}

body.theme-dark .goal-card {
    background: linear-gradient(135deg, #1c1f3b, #171a31);
    border-color: #2c3159;
    box-shadow: 0 7px 20px rgba(0, 0, 0, 0.35);
}

body.theme-dark .goal-top span {
    background: #2c2a5c;
    color: #b9aeff;
}

body.theme-dark .progress-background {
    background: #2a2f54;
}

body.theme-dark .empty-state h3 {
    color: #e8ebff;
}

body.theme-dark .weekly-info {
    background: #23264a;
    color: #c9cef5;
}

body.theme-dark .money-buttons button:not(.custom-money):not(.edit-goal):not(.remove-money):not(.delete-goal) {
    background: #2c2a5c;
    color: #b9aeff;
}

body.theme-dark .money-buttons button:not(.custom-money):not(.edit-goal):not(.remove-money):not(.delete-goal):hover {
    background: #3a3775;
}

body.theme-dark .edit-goal {
    background: #1d3252;
    color: #8fb8ff;
}

body.theme-dark .edit-goal:hover {
    background: #26406a;
}

body.theme-dark .remove-money,
body.theme-dark .delete-goal {
    background: #46202c;
    color: #ff9a9a;
}

body.theme-dark .remove-money:hover,
body.theme-dark .delete-goal:hover {
    background: #5b2836;
}

body.theme-dark .modal {
    background: rgba(8, 9, 20, 0.68);
}

body.theme-dark .modal-content {
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.55);
}

body.theme-dark .modal-content label {
    color: #c3c9ea;
}

body.theme-dark .modal-content input,
body.theme-dark .auth-card input {
    border-color: var(--sq-border);
}

body.theme-dark input::placeholder {
    color: #7b83ab;
}

body.theme-dark .secondary-button {
    background: #262a4d;
    color: #d6dbf5;
}

body.theme-dark .secondary-button:hover {
    background: #323764;
}

body.theme-dark .close-button:hover {
    color: #e8ebff;
}

body.theme-dark .auth-card > p {
    color: var(--sq-text-muted);
}

body.theme-dark .switch-auth {
    color: #b9aeff;
}

body.theme-dark .settings-content .settings-toggle span {
    color: var(--sq-text);
}

body.theme-dark .modal-message-success {
    color: #4ade8b;
}