/* ===== CSS Variables — Green/Nature theme ===== */
:root {
    --accent: #059669;
    --accent-light: #ecfdf5;
    --accent-dark: #047857;
    --bg: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f8fafc;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --green: #10b981;
    --red: #ef4444;
    --orange: #f59e0b;
    --blue: #0ea5e9;
    --sky: #38bdf8;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

/* ===== Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== Layout ===== */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: -webkit-fill-available;
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

.fixed-header {
    flex-shrink: 0;
    background: var(--bg);
    z-index: 10;
    padding-bottom: 2px;
}

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px 10px;
    -webkit-overflow-scrolling: touch;
}

/* ===== Header ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px 4px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-title {
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--sky));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}

/* ===== Date Nav ===== */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 6px 14px 8px;
}

.date-nav-arrow {
    background: var(--bg-card);
    border: 1px solid rgba(5,150,105,0.15);
    border-radius: 10px;
    padding: 6px;
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.date-nav-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 16px;
}

.date-nav-day {
    font-size: 24px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
}

.date-nav-monthyear {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Balance card ===== */
.balance-card-big {
    background: linear-gradient(135deg, #059669, #0ea5e9);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    color: white;
    box-shadow: 0 4px 20px rgba(5,150,105,0.3);
    margin-bottom: 8px;
    overflow: hidden;
}

.balance-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.balance-card-title {
    font-size: 12px;
    font-weight: 600;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.balance-amounts {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.balance-amount-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-amount-row.main {
    margin-bottom: 4px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.balance-currency-label {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.7;
}

.balance-amount {
    font-size: 15px;
    font-weight: 700;
}

.balance-amount-row.main .balance-amount {
    font-size: 22px;
    font-weight: 800;
}

/* ===== Finance summary row ===== */
.finance-summary-row {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.finance-summary-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.finance-summary-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.finance-summary-icon.expense {
    background: #fef2f2;
    color: var(--red);
}

.finance-summary-icon.income {
    background: #d1fae5;
    color: var(--accent);
}

.finance-summary-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.finance-summary-value {
    font-size: 16px;
    font-weight: 800;
}

/* ===== Currency display ===== */
.currency-display {
    text-align: center;
    padding: 2px 0 6px;
}

.currency-rate {
    font-size: 10px;
    color: var(--text-light);
    background: var(--bg-card);
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(5,150,105,0.1);
}

/* ===== Buttons ===== */
.finance-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.finance-actions button {
    flex: 1;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid rgba(0,0,0,0.1);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(239,68,68,0.25);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent), #10b981);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(5,150,105,0.25);
}

/* ===== Chart ===== */
.chart-container {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.chart-container canvas {
    display: block;
    width: 100%;
    height: 160px;
    max-height: 160px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    justify-content: center;
    padding-top: 8px;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.chart-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ===== Entries list ===== */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.entry-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    box-shadow: var(--shadow-sm);
    animation: fadeInUp 0.3s ease-out both;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.entry-type {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.entry-type-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* entry icon colors set via inline styles */

.entry-type-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.entry-date {
    font-size: 11px;
    color: var(--text-muted);
}

.entry-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.entry-amount {
    font-size: 15px;
    font-weight: 800;
}

.entry-amount.expense-amount { color: var(--red); }
.entry-amount.transfer-amount { color: var(--accent); }

.entry-equiv {
    font-size: 10px;
    color: var(--text-muted);
    text-align: right;
}

.entry-comment {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.entry-photo-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.08);
    margin-top: 4px;
}

.delete-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
}

/* ===== Bottom Tabs ===== */
.bottom-tabs {
    display: flex;
    flex-shrink: 0;
    background: var(--bg-card);
    border-top: 1px solid rgba(0,0,0,0.06);
    padding: 4px 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
}

.bottom-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
}

.bottom-tab.active {
    color: var(--accent);
}

.bottom-tab.active svg {
    filter: drop-shadow(0 1px 3px rgba(5,150,105,0.3));
}

/* ===== Tab content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 100;
    justify-content: center;
    align-items: flex-end;
    padding: 0;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 18px 8px;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 800;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

.modal-body {
    padding: 8px 18px 16px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 8px;
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(0,0,0,0.06);
    flex-shrink: 0;
}

.modal-footer button {
    flex: 1;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid rgba(0,0,0,0.1);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    -webkit-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(5,150,105,0.1);
}

.form-group textarea {
    resize: none;
    height: 60px;
}

.category-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.category-btn {
    padding: 8px 4px;
    border: 2px solid rgba(0,0,0,0.06);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.category-btn.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-dark);
}

.photo-upload-area {
    border: 2px dashed rgba(5,150,105,0.3);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 13px;
    transition: all 0.2s ease;
}

.photo-upload-area:active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.photo-upload-area img {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    object-fit: contain;
}

/* ===== Photo overlay ===== */
.photo-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.92);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.photo-overlay.active {
    display: flex;
}

.photo-overlay img {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.photo-overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 201;
}

/* ===== Stats ===== */
.stats-period-row {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.stats-period-btn {
    flex: 1;
    padding: 8px;
    border: 1.5px solid rgba(5,150,105,0.2);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.stats-period-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.stats-category-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.stats-cat-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.stats-cat-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
}

.stats-cat-amount {
    font-size: 14px;
    font-weight: 700;
}

.stats-cat-bar {
    height: 4px;
    border-radius: 2px;
    background: rgba(0,0,0,0.04);
    margin-top: 4px;
}

.stats-cat-bar-fill {
    height: 100%;
    border-radius: 2px;
}

.stats-total-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.stats-total-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    background: #1e293b;
    color: white;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    animation: toastIn 0.25s ease-out;
    box-shadow: var(--shadow-md);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.toast.error {
    background: #ef4444;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state svg {
    opacity: 0.3;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Animate in ===== */
.animate-in {
    animation: fadeInUp 0.35s ease-out both;
}

/* ===== Settings row ===== */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    cursor: pointer;
    border-radius: 8px;
}

.settings-row:active {
    background: var(--bg-hover);
}

.settings-row-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--accent-light);
}

.settings-row-text {
    flex: 1;
}

.settings-row-title {
    font-size: 14px;
    font-weight: 600;
}

.settings-row-subtitle {
    font-size: 11px;
    color: var(--text-muted);
}
