:root {
    --bg-dark: #0f1115;
    --card-bg: rgba(255, 255, 255, 0.06);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-red-bg: rgba(239, 68, 68, 0.15);
    --accent-gas: #f59e0b;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    --glass-blur: blur(16px);
    --font-stack: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Branding */
.app-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.app-logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.app-title {
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #f8fafc, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

/* Header */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
}

.savings-container .label {
    font-size: 0.85rem;
    color: var(--accent-green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

#total-savings {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-main);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:active {
    transform: scale(0.98);
}

.label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 500;
}

h2 {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Specific Cards */
.monthly-card h2 {
    color: var(--text-main);
}

.daily-card {
    border-left: 4px solid var(--accent-blue);
}

.daily-card.overspent {
    border-left-color: var(--accent-red);
    background: var(--accent-red-bg);
}

.daily-card.overspent h2 {
    color: var(--accent-red);
}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-top: 16px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent-blue);
    width: 100%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.daily-card.overspent .progress-bar {
    background: var(--accent-red);
}

.today-expenses-toggle {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    text-align: center;
    transition: color 0.2s;
}
.today-expenses-toggle:hover {
    color: var(--text-main);
}
.today-expenses-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 150px;
    overflow-y: auto;
}
.today-expenses-list.hidden {
    display: none;
}
.today-expense-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}
.delete-btn {
    background: transparent;
    border: none;
    color: var(--accent-red);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
}

/* Gasoline Card */
.gasoline-card {
    border-top: 2px solid rgba(245, 158, 11, 0.3);
}

.gasoline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.gasoline-header h3 {
    color: var(--accent-gas);
}

.gauge-container {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Buttons */
.action-buttons {
    margin: 10px 0;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    background: var(--accent-blue);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
    transition: all 0.2s ease;
}

.primary-btn:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

.primary-btn:active {
    transform: translateY(1px);
}

.secondary-btn {
    padding: 14px;
    border-radius: 12px;
    background: transparent;
    color: var(--text-main);
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: var(--card-bg);
}

.small-btn {
    padding: 8px 12px;
    font-size: 0.9rem;
    border-radius: 8px;
}

/* Quick Adds */
.quick-adds h3 {
    font-size: 1.2rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.quick-add-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
}

.quick-add-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.quick-add-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.quick-add-btn .amount {
    color: var(--accent-green);
    font-size: 0.9rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: translateY(20px);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

input[type="number"],
input[type="text"] {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(0,0,0,0.2);
    color: white;
    font-size: 1rem;
    font-family: var(--font-stack);
    transition: border-color 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.radio-group {
    display: flex;
    gap: 16px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.modal-actions button {
    flex: 1;
}

.quick-add-templates {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.template-row {
    display: flex;
    gap: 8px;
}

.template-row input {
    padding: 10px;
}

.remove-template-btn {
    background: var(--accent-red-bg);
    color: var(--accent-red);
    border: none;
    border-radius: 8px;
    padding: 0 12px;
    cursor: pointer;
}

/* History */
.header-actions {
    display: flex;
    gap: 12px;
}

#history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.history-item-left strong {
    display: block;
    font-size: 1.05rem;
    margin-bottom: 4px;
}

.history-item-left .date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-item-left .source {
    text-transform: capitalize;
    color: var(--accent-gas);
}

.history-item-right.amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Calendar */
.calendar-wrapper {
    margin-bottom: 20px;
}
.calendar-header {
    text-align: center;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-muted);
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.cal-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    transition: all 0.2s ease;
}
.cal-cell:hover {
    transform: scale(1.1);
    z-index: 10;
}
.cal-cell.bg-green {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-green);
    color: var(--accent-green);
}
.cal-cell.bg-red {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--accent-red);
    color: var(--accent-red);
}
.cal-cell.bg-yellow {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--accent-gas);
    color: var(--accent-gas);
}
.cal-cell.bg-grey {
    color: var(--text-muted);
    opacity: 0.5;
}

/* Dynamic Calendar Icon */
.dynamic-cal-btn {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 6px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    text-decoration: none;
}
.cal-month {
    background: var(--accent-red);
    color: #fff;
    width: 100%;
    font-size: 0.55rem;
    font-weight: 700;
    text-align: center;
    padding: 2px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cal-day {
    color: #111;
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1.1;
    margin-top: 1px;
}

/* Stats Modal */
.stats-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-top: 10px;
}
.pie-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(#333 0% 100%);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: background 0.5s ease;
}
.stats-legend {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
}
.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
}
.legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
    margin-right: 8px;
}
.legend-name {
    flex: 1;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.legend-amount {
    font-weight: 700;
    margin-right: 8px;
}
.legend-percent {
    color: var(--text-muted);
    font-size: 0.8rem;
    width: 40px;
    text-align: right;
}
