@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap');

:root {
    /* Background Colors */
    --color-outside: #ccc;
    --color-background: #F7F7F7;
    --color-background-light: #FFFFFF;
    --color-background-dark: #E5E5E5;

    /* Text Colors */
    --color-text-primary: #000000;
    --color-text-secondary: #666666;
    --color-text-tertiary: rgba(0, 0, 0, 0.5);
    --color-text-light: #FFFFFF;

    /* Border Colors */
    --color-border: rgba(0, 0, 0, 0.12);

    /* Status Colors */
    --color-error: #FF3B30;

    /* Shadow Colors */
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-shadow-2: rgba(255, 255, 255, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Background Colors */
        --color-outside: #303030;
        --color-background: #131313;
        --color-background-light: #1F1F1F;
        --color-background-dark: rgba(255, 255, 255, 0.15);

        /* Text Colors */
        --color-text-primary: rgba(255, 255, 255, 0.87);
        --color-text-secondary: rgba(255, 255, 255, 0.5);
        --color-text-tertiary: rgba(255, 255, 255, 0.5);
        --color-text-light: #000;

        /* Border Colors */
        --color-border: rgba(255, 255, 255, 0.07);

        /* Shadow Colors */
        --color-shadow: rgba(255, 255, 255, 0.1);
        --color-shadow-2: rgba(0, 0, 0, 0.1);

        --color-chip-bg: rgba(255, 255, 255, 0.08);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    line-height: 1.4;
}

body,
html {
    width: 100%;
    height: 100%;
}

body {
    background-color: var(--color-outside);
    color: var(--color-text-primary);
}

.main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 0;
    height: 100%;
    max-height: 800px;
    background-color: var(--color-background-light);
    /* border: 1px solid var(--color-border); */
    display: flex;
    flex-direction: column;
    width: 100%;
    box-shadow: 4px 12px 40px rgba(0, 0, 0, 0.35);
}

.summary {
    display: flex;
    align-items: center;
    background-color: var(--color-background);
}

.summary-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--color-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 16px;
    color: var(--color-text-primary);
    cursor: pointer;
    user-select: none;
}

.summary-items {
    width: 100%;
    display: block;
    text-decoration: none;
}

.summary-item {
    gap: 4px;
    width: 100%;
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--color-text-tertiary);
    padding-right: 8px;
}

.summary-item .label {
    flex: 1;
}

.summary-item .material-icons {
    font-size: 20px;
}

/* Loading Spinner */
@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-shadow);
    border-top: 2px solid var(--color-text-primary);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
    margin-right: 24px;
}

.save-button .loading-spinner {
    width: 20px;
    height: 20px;
    border-color: var(--color-shadow-2);
    border-top-color: var(--color-text-light);
    vertical-align: middle;
    margin-right: 8px;
}

.amount-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--color-background-light);
    border-top: 1px solid var(--color-border);
    padding: 20px 0px;
    position: relative;
}

.amount-display {
    display: flex;
    align-items: center;
    gap: 4px;
}

.amount-display .amount {
    font-size: 48px;
    font-weight: bold;
    line-height: 1em;
}

.amount-display .currency {
    color: var(--color-text-tertiary);
}

/* Operation display above main number */
.operation-display {
    font-size: 14px;
    color: var(--color-text-tertiary);
    text-align: center;
    letter-spacing: 1px;
    position: absolute;
    top: calc(50%);
    opacity: 0;
    transform: translateY(-50%);
    transition: all 0.2s;
}

.operation-display.is-visible {
    opacity: 1;
    top: calc(50% - 40px);
}

/* Move note input to bottom, full width */

.note-wrapper {
    width: 100%;
    margin-bottom: 12px;
    padding: 0 12px;
}

.note-input {
    grid-column: span 3;
    padding: 12px 20px;
    border: none;
    border-top: 1px solid var(--color-border);
    width: 100%;
    color: var(--color-text-primary);
}

.note-input::placeholder {
    color: var(--color-text-tertiary);
}

.numpad .save-button {
    height: auto;
    grid-column: span 1;
    grid-row: span 1;
    background: var(--color-text-primary);
    color: var(--color-text-light);
    font-size: 24px;
    border: none;
    border-radius: 0px;
    padding: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.numpad .save-button .material-icons {
    font-size: 24px;
    transition: opacity 0.2s;
}

/* Loading state */
.numpad .save-button.loading .material-icons {
    opacity: 0;
}

.numpad .save-button.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-shadow-2);
    border-top: 2px solid var(--color-text-light);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
}

.numpad .save-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    max-width: 480px;
}

.login-form {
    margin-top: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.text-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 16px;
}

.error-message {
    color: var(--color-error);
    font-size: 14px;
    display: none;
}

.categories {
    margin-bottom: 12px;
    display: flex;
    overflow: auto;
    gap: 8px;
    background-color: var(--color-background-light);
    width: 100%;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.categories::-webkit-scrollbar {
    display: none;
}

.category {
    color: var(--color-text-primary);
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    background-color: var(--color-chip-bg);
    border-radius: 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.category.selected {
    background-color: var(--color-text-primary);
    color: var(--color-text-light);
}

.numpad {
    height: 50%;
    min-height: 320px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 0;
    margin-bottom: 0;
    background: var(--color-background-light);
}

.num {
    color: var(--color-text-primary);
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    transition: background 0.1s;
    border-right: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
}

.numpad .accent {
    background: var(--color-background);
}

.num:active,
.num.op:active {
    background: var(--color-background-dark);
}

.save-button,
.login-button {
    width: 100%;
    background-color: var(--color-text-primary);
    color: var(--color-text-light);
    border-radius: 100px;
    transition: all 0.2s;
    padding: 12px 16px;
    font-size: 16px;
}

.save-button:active {
    background-color: var(--color-text-secondary);
}

.save-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}