/* ==========================================
   家計簿 - Daily Budget Manager
   Premium Dark UI with Glassmorphism
   ========================================== */

/* ---------- Reset & Variables ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #07070e;
    --bg-secondary: #0d0d1a;
    --bg-gradient: linear-gradient(135deg, #07070e 0%, #0d0d1a 50%, #0a0a18 100%);

    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-bg-hover: rgba(255, 255, 255, 0.07);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.14);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #475569;

    --accent-cyan: #22d3ee;
    --accent-indigo: #818cf8;
    --accent-gradient: linear-gradient(135deg, #22d3ee, #818cf8);

    --green: #4ade80;
    --green-dim: rgba(74, 222, 128, 0.15);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.15);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.15);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);

    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 120px;
    /* Ensure scroll space */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background animated orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

body::before {
    width: 500px;
    height: 500px;
    background: var(--accent-cyan);
    top: -150px;
    right: -150px;
    animation: float-orb 20s ease-in-out infinite alternate;
}

body::after {
    width: 400px;
    height: 400px;
    background: var(--accent-indigo);
    bottom: -100px;
    left: -100px;
    animation: float-orb 25s ease-in-out infinite alternate-reverse;
}

@keyframes float-orb {
    0% {
        transform: translate(0, 0) scale(1);
    }

    50% {
        transform: translate(40px, -30px) scale(1.1);
    }

    100% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

#app {
    position: relative;
    z-index: 1;
}

/* ---------- Glass Card ---------- */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    transition: border-color var(--transition), background var(--transition);
}

.glass-card:hover {
    border-color: var(--glass-border-hover);
}

/* ---------- Screens ---------- */
.screen {
    display: none;
    animation: fadeIn 0.4s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- Layout & Screens ---------- */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Loading Animation */
#loading-screen .logo-icon {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* News Ticker */
.news-ticker {
    background: rgba(0, 0, 0, 0.3);
    height: 36px;
    line-height: 36px;
    overflow: hidden;
    white-space: nowrap;
    position: relative;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.news-content {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 40s linear infinite;
}

.news-content:hover {
    animation-play-state: paused;
}

.news-item {
    margin-right: 48px;
    color: var(--text-primary);
    text-decoration: none;
}

.news-item:hover {
    text-decoration: underline;
    color: var(--accent-cyan);
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Market Widget */
.market-widget {
    margin-bottom: 24px;
}

/* Reminders */
.reminder-list {
    list-style: none;
    margin-top: 12px;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.reminder-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.active .reminder-item {
    animation: fadeIn 0.3s forwards;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
}

.delete-btn:hover {
    color: var(--accent-red);
}

.empty-msg {
    text-align: center;
    color: var(--text-secondary);
    padding: 12px;
    font-size: 0.85rem;
}

/* Urgent Task Bar */
.urgent-task-bar {
    background: rgba(255, 80, 80, 0.2);
    border-bottom: 1px solid rgba(255, 80, 80, 0.3);
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ffcccc;
    font-size: 0.9rem;
    animation: pulse-red 2s infinite;
}

.urgent-icon {
    font-size: 1.1rem;
}

.urgent-time {
    font-weight: bold;
    color: #fff;
    margin-left: auto;
}

@keyframes pulse-red {
    0% {
        background: rgba(255, 80, 80, 0.2);
    }

    50% {
        background: rgba(255, 80, 80, 0.35);
    }

    100% {
        background: rgba(255, 80, 80, 0.2);
    }
}

/* Calendar Widget */
.calendar-widget .widget-content {
    background: rgba(0, 0, 0, 0.2);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    padding: 8px 0;
    border-bottom: 1px solid var(--glass-border);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: var(--text-primary);
    position: relative;
    cursor: default;
}

.calendar-day.empty {
    background: transparent;
}

.calendar-day.today {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--accent-cyan);
    font-weight: bold;
}

.deadline-dot {
    width: 4px;
    height: 4px;
    background: var(--accent-red);
    border-radius: 50%;
    position: absolute;
    bottom: 6px;
}

/* Reminders Update */
.quick-input[type="datetime-local"] {
    color-scheme: dark;
}

.reminder-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 8px;
}

.reminder-meta.urgent {
    color: var(--accent-red);
    font-weight: bold;
}

/* ==========================================
   LOGIN SCREEN
   ========================================== */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 32px;
}

.logo-area {
    text-align: center;
    animation: slideDown 0.6s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 0 20px rgba(34, 211, 238, 0.3));
}

.logo-title {
    font-size: 2.2rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.logo-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 28px;
    animation: slideUp 0.6s ease 0.1s both;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tab Switch */
.tab-switch {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* ---------- Form Elements ---------- */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.input-group input[type="text"],
.input-group input[type="password"],
.input-group input[type="number"],
.input-group input[type="date"] {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    transition: all var(--transition);
}

.input-group input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.1);
    background: rgba(255, 255, 255, 0.07);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input[type="date"] {
    color-scheme: dark;
}

.yen-input {
    position: relative;
    display: flex;
    align-items: center;
}

.yen-prefix {
    position: absolute;
    left: 14px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    pointer-events: none;
    z-index: 1;
}

.yen-input input {
    padding-left: 36px !important;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.balance-row {
    display: flex;
    gap: 8px;
}

.date-sm {
    width: 140px !important;
    font-size: 0.9rem !important;
    padding: 10px !important;
}

/* ---------- Buttons ---------- */
.primary-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: #000;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition);
}

.primary-btn:hover::before {
    opacity: 1;
}

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--glass-border-hover);
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: var(--glass-border-hover);
}

.edit-btn {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition);
}

.edit-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-loader {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-text {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
    min-height: 1.2em;
}

/* ==========================================
   MAIN SCREEN
   ========================================== */
#main-screen {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 16px 32px;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(180deg, var(--bg-primary) 60%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-icon {
    font-size: 1.3rem;
}

.wallet-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

/* ---------- Dashboard ---------- */
#dashboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* Balance Card */
.balance-card {
    padding: 24px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
}

.balance-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 8px;
}

.card-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.balance-amount {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.1;
}

/* Balance Breakdown */
.balance-breakdown {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.balance-breakdown span {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    padding: 18px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 6px;
    font-variant-numeric: tabular-nums;
}

/* Today Card */
.today-card {
    padding: 20px;
}

.today-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.today-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.today-stats {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 12px;
}

.today-spent {
    font-size: 1.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

.today-separator {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.today-budget {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

/* Progress Bar */
.today-progress {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    border-radius: 3px;
    background: var(--green);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.4s ease;
    min-width: 0;
}

.progress-bar.warning {
    background: var(--yellow);
}

.progress-bar.danger {
    background: var(--red);
}

.today-remaining {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-variant-numeric: tabular-nums;
}

.today-remaining.positive {
    color: var(--green);
}

.today-remaining.negative {
    color: var(--red);
}

/* Close Day */
.closing-area {
    display: flex;
    justify-content: center;
    padding-top: 4px;
}

.close-day-btn {
    padding: 10px 24px;
    background: rgba(129, 140, 248, 0.12);
    border: 1px solid rgba(129, 140, 248, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-indigo);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}

.close-day-btn:hover {
    background: rgba(129, 140, 248, 0.2);
    border-color: rgba(129, 140, 248, 0.4);
    transform: translateY(-1px);
}

.closed-badge {
    padding: 10px 24px;
    background: var(--green-dim);
    border: 1px solid rgba(74, 222, 128, 0.2);
    border-radius: var(--radius-sm);
    color: var(--green);
    font-size: 0.9rem;
    font-weight: 600;
}

/* ---------- Expense Section ---------- */
#expense-section {
    padding: 20px;
    margin-bottom: 16px;
}

.section-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.expense-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-row .input-group {
    margin-bottom: 0;
}

.add-btn {
    padding: 12px;
}

/* ---------- Settings ---------- */
#settings-section {
    margin-bottom: 16px;
}

.section-toggle {
    width: 100%;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
}

.toggle-arrow {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform var(--transition);
}

.section-toggle.open .toggle-arrow {
    transform: rotate(180deg);
}

.settings-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-content.open {
    max-height: 1000px;
}

.settings-inner {
    padding: 20px;
    margin-top: 8px;
}

/* ---------- History ---------- */
#history-section {
    margin-bottom: 24px;
}

.history-tabs {
    display: flex;
    gap: 4px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 12px;
}

.history-tab {
    flex: 1;
    padding: 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.history-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.history-tab:hover:not(.active) {
    color: var(--text-primary);
}

.history-content {
    display: none;
}

.history-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empty-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 24px 0;
}

/* Date Group */
.date-group {
    margin-bottom: 8px;
}

.date-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 4px 6px;
}

.date-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-total {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Expense Item */
.expense-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    gap: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.expense-item-info {
    flex: 1;
    min-width: 0;
}

.expense-item-memo {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.expense-item-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.expense-item-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--red);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.expense-delete-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
    flex-shrink: 0;
}

.expense-delete-btn:hover {
    background: var(--red-dim);
    border-color: rgba(248, 113, 113, 0.2);
    color: var(--red);
}

/* Closing Item */
.closing-item {
    padding: 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    animation: slideIn 0.3s ease;
}

.closing-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.closing-item-date {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.closing-item-result {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
}

.closing-item-result.under {
    background: var(--green-dim);
    color: var(--green);
}

.closing-item-result.over {
    background: var(--red-dim);
    color: var(--red);
}

.closing-item-result.even {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.closing-item-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.closing-detail {
    font-size: 0.8rem;
}

.closing-detail-label {
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
}

.closing-detail-value {
    color: var(--text-secondary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ---------- Modals ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 380px;
    padding: 28px;
    z-index: 1;
    animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn {
    flex: 1;
}

.closing-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.closing-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--glass-border);
}

.closing-summary-row:last-child {
    border-bottom: none;
}

.closing-summary-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.closing-summary-value {
    font-size: 1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.closing-summary-value.positive {
    color: var(--green);
}

.closing-summary-value.negative {
    color: var(--red);
}

.closing-summary-value.neutral {
    color: var(--yellow);
}

/* ---------- Toast ---------- */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
    white-space: nowrap;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.success {
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid rgba(74, 222, 128, 0.3);
    color: var(--green);
}

.toast.error {
    background: rgba(248, 113, 113, 0.15);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--red);
}

.toast.info {
    background: rgba(34, 211, 238, 0.15);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: var(--accent-cyan);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* ---------- Footer ---------- */
.app-footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 400px) {
    .balance-amount {
        font-size: 2.2rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .today-spent {
        font-size: 1.5rem;
    }

    .input-row {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* Number input spinner remove */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ---------- Portal Screen ---------- */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    padding: 20px 0;
}

.portal-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    border: none;
    background: var(--glass-bg);
    color: var(--text-primary);
    font-family: inherit;
    transition: all var(--transition);
    min-height: 140px;
}

.portal-card:hover:not(.disabled) {
    transform: translateY(-4px);
    background: var(--glass-bg-hover);
    border-color: var(--glass-border-hover);
    box-shadow: var(--shadow-lg);
}

.portal-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.portal-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.portal-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.portal-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ---------- Persistent Settings (Dashboard) ---------- */
.settings-area {
    padding: 16px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.02);
    /* More subtle than glass-card default */
    border: 1px solid var(--glass-border);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

/* Compact Inputs for Settings */
.input-group.compact {
    margin-bottom: 0;
}

.input-group.compact label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.input-group.compact input {
    padding: 8px 12px;
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.2);
}

.sm-btn {
    padding: 10px;
    font-size: 0.85rem;
}

/* Responsive adjustments for settings grid */
@media (min-width: 480px) {
    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ---------- Portal Widgets ---------- */
.portal-widget {
    grid-column: span 1;
    background: var(--glass-bg);
    border-radius: var(--radius-md);
    padding: 16px;
    border: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 160px;
    transition: all var(--transition);
}

.portal-widget:hover {
    border-color: var(--glass-border-hover);
    background: var(--glass-bg-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.widget-icon {
    font-size: 1.2rem;
}

.widget-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
}

.widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Weather */
.weather-temp {
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
    background: linear-gradient(to bottom, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.weather-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.weather-loc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Transit */
.transit-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.transit-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: background 0.2s;
}

.transit-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Quick Add */
.quick-add-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.quick-input {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.quick-input:focus {
    border-color: var(--accent-cyan);
    background: rgba(0, 0, 0, 0.3);
}

.quick-btn {
    padding: 10px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.quick-btn:hover {
    opacity: 0.9;
}