/* ═══════════════════════════════════════════════════════════
   PREMIUM FINANCIAL TRACKER — STYLE SYSTEM
   Elegant • Glassmorphism • Micro-Animations
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Light Theme */
    --bg-color: #f4f6fa;
    --bg-subtle: #edf0f7;
    --card-bg: #ffffff;
    --card-bg-glass: rgba(255, 255, 255, 0.72);
    --text-main: #1a1a2e;
    --text-muted: #6b7280;
    --border-color: rgba(0, 0, 0, 0.06);

    --primary: #6c5ce7;
    --primary-hover: #5a4bd1;
    --primary-glow: rgba(108, 92, 231, 0.12);
    --primary-soft: rgba(108, 92, 231, 0.06);

    --success: #00b894;
    --success-bg: rgba(0, 184, 148, 0.08);
    --success-glow: rgba(0, 184, 148, 0.18);
    --danger: #e17055;
    --danger-bg: rgba(225, 112, 85, 0.08);
    --danger-glow: rgba(225, 112, 85, 0.18);

    --gradient-primary: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --gradient-header: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #74b9ff 100%);
    --gradient-success: linear-gradient(135deg, #00b894, #55efc4);
    --gradient-danger: linear-gradient(135deg, #e17055, #fab1a0);

    --radius: 20px;
    --radius-sm: 12px;
    --radius-xs: 8px;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.04);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 30px var(--primary-glow);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);

    --nav-height: 72px;
}

[data-theme="dark"] {
    --bg-color: #0a0a14;
    --bg-subtle: #10101f;
    --card-bg: #161625;
    --card-bg-glass: rgba(22, 22, 37, 0.78);
    --text-main: #eaeaea;
    --text-muted: #7a7e9a;
    --border-color: rgba(255, 255, 255, 0.06);

    --primary: #a29bfe;
    --primary-hover: #b8b3ff;
    --primary-glow: rgba(162, 155, 254, 0.12);
    --primary-soft: rgba(162, 155, 254, 0.05);

    --success: #55efc4;
    --success-bg: rgba(85, 239, 196, 0.08);
    --success-glow: rgba(85, 239, 196, 0.15);
    --danger: #fab1a0;
    --danger-bg: rgba(250, 177, 160, 0.08);
    --danger-glow: rgba(250, 177, 160, 0.15);

    --gradient-primary: linear-gradient(135deg, #6c5ce7, #a29bfe);
    --gradient-header: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 50%, #74b9ff 100%);
    --gradient-success: linear-gradient(135deg, #00b894, #55efc4);
    --gradient-danger: linear-gradient(135deg, #e17055, #fab1a0);

    --shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
    --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.3);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* ===================== RESET & BASE ===================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

/* Hide number input spinner buttons */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-color);
    color: var(--text-main);
    transition: background-color 0.5s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding-bottom: calc(var(--nav-height) + 1.5rem);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle animated background */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 600px 400px at 20% 20%, rgba(108, 92, 231, 0.06), transparent),
        radial-gradient(ellipse 500px 300px at 80% 80%, rgba(0, 184, 148, 0.04), transparent);
    pointer-events: none;
    z-index: 0;
}

/* ===================== LAYOUT ===================== */
.app-container {
    width: 100%;
    max-width: 520px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    position: relative;
    z-index: 1;
}
@media (min-width: 768px) {
    .app-container {
        max-width: 640px;
        padding: 2rem;
        gap: 1.5rem;
    }
}

/* ===================== HEADER ===================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient-header);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: headerGradient 6s ease-in-out infinite;
}
@keyframes headerGradient {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}
@media (max-width: 600px) {
    .header-content h1 { font-size: 1.3rem; }
}

.header-content p {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.01em;
    margin-top: 0.1rem;
}

.theme-btn {
    background: var(--card-bg-glass);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition-bounce);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.theme-btn:hover {
    transform: rotate(20deg) scale(1.1);
    box-shadow: var(--shadow-glow);
    border-color: var(--primary);
}

/* ===================== TABS ===================== */
.tab-content {
    display: none;
    animation: fadeSlideIn 0.4s ease;
}
.tab-content.active {
    display: block;
}
@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== SUMMARY CARDS ===================== */
.summary-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
@media (min-width: 500px) {
    .summary-cards {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.85rem;
    }
    .summary-cards .balance-card {
        grid-column: 1 / -1;
    }
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* ─── Unified Summary Card ─── */
.unified-summary-card {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    padding: 0;
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    border-radius: var(--radius);
    border: none;
}

.unified-summary-card::after {
    display: none;
}

.summary-left {
    flex: 1;
    padding: 2.5rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.summary-left .card-title {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.summary-left .card-amount {
    color: white;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.summary-right.glass-panel {
    flex: 1.2;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.75rem;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem 1rem;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-item .item-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    gap: 4px;
}

.summary-item .item-value {
    font-size: 1.2rem;
    font-weight: 800;
}

.summary-item.item-income .item-value { color: #a2fbc3; }
.summary-item.item-expense .item-value { color: #ffb3b3; }
.summary-item.item-saving .item-value { color: #e6f0ff; }
.summary-item.item-debt .item-value { color: #ffd6b3; }

@media (max-width: 600px) {
    .unified-summary-card {
        flex-direction: column;
    }
    .summary-left {
        padding: 1.25rem 1rem 1rem;
        text-align: center;
        align-items: center;
    }
    .summary-left .card-amount {
        font-size: 2rem;
    }
    .summary-right.glass-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.2);
        padding: 1.25rem;
        gap: 1rem 0.75rem;
    }
}

/* ─── Income/Expense Cards ─── */
.card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-right: 0.85rem;
    flex-shrink: 0;
    transition: var(--transition);
}
.income-card .card-icon { background: var(--success-bg); color: var(--success); }
.expense-card .card-icon { background: var(--danger-bg); color: var(--danger); }
.saving-card .card-icon { background: var(--primary-soft); color: var(--primary); }
.debt-card .card-icon { background: var(--danger-bg); color: var(--danger); }
.income-card:hover .card-icon { background: var(--success-glow); box-shadow: 0 0 16px var(--success-glow); }
.expense-card:hover .card-icon { background: var(--danger-glow); box-shadow: 0 0 16px var(--danger-glow); }
.saving-card:hover .card-icon { background: var(--primary-glow); box-shadow: 0 0 16px var(--primary-glow); }
.debt-card:hover .card-icon { background: var(--danger-glow); box-shadow: 0 0 16px var(--danger-glow); }

.card-details .card-title {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.15rem;
}
.income-card .card-amount { color: var(--success); font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.expense-card .card-amount { color: var(--danger); font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.saving-card .card-amount { color: var(--primary); font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.debt-card .card-amount { color: var(--danger); font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }

/* ===================== SECTIONS ===================== */
section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
}
section h2 {
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    color: var(--text-main);
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ─── Month Countdown Card ─── */
.month-countdown-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.month-countdown-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.countdown-top {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.countdown-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.countdown-info:last-child {
    align-items: flex-end;
    text-align: right;
}

.countdown-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.countdown-label ion-icon {
    font-size: 0.85rem;
}

.countdown-days {
    display: flex;
    align-items: baseline;
    gap: 0.3rem;
}
.countdown-days span {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.02em;
    line-height: 1;
}
.countdown-days small {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.countdown-avg span {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--success);
    letter-spacing: -0.01em;
    line-height: 1;
}

.countdown-divider {
    width: 1px;
    height: 40px;
    background: var(--border-color);
    flex-shrink: 0;
}

.countdown-progress-wrap {
    margin-top: 0.85rem;
    height: 6px;
    background: var(--bg-subtle);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.countdown-progress-bar {
    height: 100%;
    border-radius: 10px;
    background: var(--gradient-primary);
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
    position: relative;
}
.countdown-progress-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
    animation: shimmer 2s ease-in-out infinite;
}
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.countdown-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 0.4rem;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-muted);
}

@media (max-width: 400px) {
    .countdown-days span { font-size: 1.65rem; }
    .countdown-avg span { font-size: 1.1rem; }
}

.add-transaction-section {
    margin-top: 0.85rem;
}

/* ─── Compact Home Tab (no-scroll) ─── */
#tab-home .unified-summary-card {
    margin-bottom: 0.5rem;
}
#tab-home .summary-left {
    padding: 1rem 0.85rem 0.75rem;
}
#tab-home .summary-left .card-title {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
}
#tab-home .summary-left .card-amount {
    font-size: 1.65rem;
}
#tab-home .summary-right.glass-panel {
    padding: 0.75rem;
    gap: 0.5rem 0.5rem;
}
#tab-home .summary-item .item-label {
    font-size: 0.68rem;
}
#tab-home .summary-item .item-value {
    font-size: 0.95rem;
}
#tab-home .add-transaction-section {
    margin-top: 0.4rem;
}
#tab-home section {
    padding: 0.85rem;
}
#tab-home section h2 {
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
}
#tab-home .type-selector {
    margin-bottom: 0.6rem;
    gap: 0.4rem;
}
#tab-home .type-btn {
    padding: 0.45rem;
    font-size: 0.8rem;
}
#tab-home .form-group {
    margin-bottom: 0.55rem;
}
#tab-home .form-group > label {
    font-size: 0.7rem;
    margin-bottom: 0.2rem;
}
#tab-home .owner-selector {
    gap: 0.35rem;
}
#tab-home .owner-btn {
    padding: 0.35rem 0.25rem;
    gap: 0.15rem;
}
#tab-home .owner-icon {
    width: 22px;
    height: 22px;
}
#tab-home .owner-name {
    font-size: 0.62rem;
}
#tab-home .form-row {
    gap: 0.5rem;
}
#tab-home input[type="text"],
#tab-home input[type="number"],
#tab-home select {
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
}
#tab-home .submit-btn {
    padding: 0.6rem;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* ─── Dashboard Charts ─── */
.dashboard-charts {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.15rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}
.chart-card:hover {
    box-shadow: var(--shadow-hover);
}

.chart-card-header {
    margin-bottom: 0.85rem;
}
.chart-card-header h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}
.chart-card-header h3 ion-icon {
    font-size: 1.1rem;
    color: var(--primary);
}

.chart-wrapper {
    position: relative;
    height: 240px;
}
.chart-wrapper-wide {
    height: 200px;
}

@media (max-width: 600px) {
    .chart-wrapper { height: 220px; }
    .chart-wrapper-wide { height: 180px; }
}

.chart-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 400;
}

/* ===================== FORM STYLES ===================== */
.form-group { margin-bottom: 1.15rem; }
.form-row { display: flex; gap: 0.75rem; }
@media (max-width: 400px) { .form-row { flex-direction: column; } }
.form-group.half { flex: 1; }

label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"], input[type="number"], input[type="date"], select {
    width: 100%;
    padding: 0.72rem 0.95rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-main);
    font-size: 0.92rem;
    font-weight: 500;
    transition: var(--transition);
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-glow);
    background: var(--card-bg);
}
input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
    font-weight: 400;
}

/* ─── Type Selector ─── */
.type-selector { display: flex; gap: 0.6rem; margin-bottom: 1.25rem; }
.type-selector input[type="radio"] { display: none; }
.type-btn {
    flex: 1;
    text-align: center;
    padding: 0.72rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: var(--transition);
    color: var(--text-muted);
    position: relative;
    overflow: hidden;
}
.type-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
}
.type-selector input[type="radio"]:checked + .income-btn {
    border-color: var(--success);
    color: var(--success);
    background: var(--success-bg);
    box-shadow: 0 0 0 3px var(--success-glow);
}
.type-selector input[type="radio"]:checked + .expense-btn {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-bg);
    box-shadow: 0 0 0 3px var(--danger-glow);
}
.type-selector input[type="radio"]:checked + .saving-btn {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ===================== OWNER SELECTOR ===================== */
.owner-selector {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.55rem;
}
@media (max-width: 400px) {
    .owner-selector {
        grid-template-columns: repeat(2, 1fr);
    }
}
.owner-selector input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}
.owner-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.7rem 0.4rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-bounce);
    background: var(--bg-subtle);
    text-align: center;
}
.owner-btn:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow), 0 0 20px var(--primary-glow);
}
.owner-icon {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
    transition: var(--transition);
}
.owner-selector input[type="radio"]:checked + .owner-btn .owner-icon {
    color: var(--primary);
    filter: drop-shadow(0 0 6px var(--primary-glow));
}
.owner-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.owner-selector input[type="radio"]:checked + .owner-btn {
    border-color: var(--primary);
    background: var(--primary-glow);
    box-shadow: 0 0 0 3px var(--primary-glow), 0 4px 20px var(--primary-glow);
}
.owner-selector input[type="radio"]:checked + .owner-btn .owner-name {
    color: var(--primary);
    font-weight: 700;
}

/* ─── Submit Button ─── */
.submit-btn {
    width: 100%;
    padding: 0.82rem;
    background: var(--gradient-primary);
    background-size: 200% 200%;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 20px var(--primary-glow);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}
.submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px var(--primary-glow);
}
.submit-btn:hover::before { opacity: 1; }
.submit-btn:active { transform: translateY(0); box-shadow: 0 2px 10px var(--primary-glow); }

/* ===================== HISTORY SECTION ===================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}
.section-header h2 { margin-bottom: 0; }
.icon-btn {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition-bounce);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xs);
}
.icon-btn:hover {
    color: var(--primary);
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: rotate(90deg);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-height: calc(100vh - 300px);
    overflow-y: auto;
    padding-right: 0.5rem;
}
.history-list::-webkit-scrollbar { width: 3px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { background: var(--primary-glow); border-radius: 10px; }

.transaction-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    position: relative;
}
.transaction-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    border-radius: 0 2px 2px 0;
    transition: height 0.3s ease;
}
.transaction-item:hover::before {
    height: 60%;
}
.item-income::before { background: var(--success); }
.item-expense::before { background: var(--danger); }
.item-saving::before { background: var(--primary); }

.transaction-item:hover {
    transform: translateX(4px);
    border-color: transparent;
    box-shadow: var(--shadow);
}
@media (max-width: 500px) {
    .transaction-item { flex-direction: column; align-items: stretch; gap: 0.5rem; }
}

.trans-info { display: flex; align-items: center; gap: 0.75rem; }
.trans-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: var(--transition);
}
.item-income .trans-icon { background: var(--success-bg); color: var(--success); }
.item-expense .trans-icon { background: var(--danger-bg); color: var(--danger); }
.item-saving .trans-icon { background: var(--primary-soft); color: var(--primary); }

.trans-details .trans-desc {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.15rem;
    font-size: 0.88rem;
}
.trans-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.trans-details .trans-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}
.owner-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-glow);
    padding: 0.12rem 0.5rem;
    border-radius: 20px;
    line-height: 1.3;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.owner-badge svg {
    width: 10px;
    height: 10px;
}

.trans-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; }
@media (max-width: 500px) {
    .trans-right { flex-direction: row; justify-content: space-between; align-items: center; }
}
.trans-amount { font-weight: 800; font-size: 1rem; letter-spacing: -0.01em; }
.item-income .trans-amount { color: var(--success); }
.item-expense .trans-amount { color: var(--danger); }
.item-saving .trans-amount { color: var(--primary); }

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    opacity: 0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.transaction-item:hover .delete-btn { opacity: 0.6; }
.delete-btn:hover { opacity: 1 !important; color: var(--danger); background: var(--danger-bg); }

/* ─── Loading / Empty States ─── */
.loading-state, .empty-state {
    text-align: center;
    padding: 2.5rem;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 400;
}
.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 0.75rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== BOTTOM NAVIGATION ===================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--card-bg-glass);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
}
[data-theme="dark"] .bottom-nav {
    background: rgba(10, 10, 20, 0.85);
    border-top-color: rgba(255, 255, 255, 0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.62rem;
    font-weight: 600;
    gap: 0.2rem;
    flex: 1;
    padding-bottom: 8px;
    transition: var(--transition);
    position: relative;
    letter-spacing: 0.02em;
}
.nav-item ion-icon {
    font-size: 1.35rem;
    transition: var(--transition-bounce);
}
.nav-item.active {
    color: var(--primary);
}
.nav-item.active ion-icon {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 2px 8px var(--primary-glow));
}
.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    width: 20px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 4px 4px 0 0;
}

/* ===================== TOAST ===================== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: var(--card-bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 4px solid var(--success);
    color: var(--text-main);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    font-size: 0.88rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-left-color: var(--danger); }
#toast-icon { font-size: 1.2rem; color: var(--success); }
.toast.error #toast-icon { color: var(--danger); }

/* ===================== AI ASSISTANT ===================== */
.ai-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.65;
    margin-bottom: 1.25rem;
    font-weight: 400;
}

.ai-actions {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}
@media (max-width: 500px) {
    .ai-actions { flex-direction: column; }
}

/* Month Selector */
.ai-month-selector {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.85rem;
}
.ai-month-selector label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}
.ai-month-selector select {
    flex: 1;
    padding: 0.55rem 0.85rem;
    background: var(--bg-subtle);
    color: var(--text-main);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c5ce7' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}
.ai-month-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.ai-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-subtle);
    color: var(--text-main);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-bounce);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    position: relative;
    overflow: hidden;
}
.ai-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: inherit;
}
.ai-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px var(--primary-glow);
}
.ai-btn ion-icon { font-size: 1.05rem; position: relative; z-index: 1; }
.ai-btn span { position: relative; z-index: 1; }

.ai-result-container {
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    min-height: 80px;
}
.ai-result-container.hidden { display: none; }
.loading-state.hidden { display: none; }

/* ===================== MARKDOWN CONTENT (Premium) ===================== */
.markdown-content {
    color: var(--text-main);
    line-height: 1.8;
    font-size: 0.85rem;
    font-weight: 400;
    overflow-x: hidden;
}

/* ─── Headings ─── */
.markdown-content h1 {
    font-size: 1.15rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 1.75rem 0 0.75rem;
    letter-spacing: -0.02em;
}
.markdown-content h2 {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 1.5rem 0 0.65rem;
    padding: 0.6rem 0.85rem;
    background: var(--primary-soft);
    border-left: 3px solid var(--primary);
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    letter-spacing: -0.01em;
}
.markdown-content h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary);
    margin: 1.25rem 0 0.5rem;
}
.markdown-content h1:first-child,
.markdown-content h2:first-child,
.markdown-content h3:first-child {
    margin-top: 0;
}

/* ─── Paragraphs ─── */
.markdown-content p {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
    font-size: 0.84rem;
}

/* ─── Lists ─── */
.markdown-content ul, .markdown-content ol {
    margin-bottom: 0.85rem;
    padding-left: 0;
    list-style: none;
}
.markdown-content li {
    margin-bottom: 0.5rem;
    padding: 0.45rem 0.75rem 0.45rem 1.75rem;
    position: relative;
    background: var(--bg-subtle);
    border-radius: var(--radius-xs);
    font-size: 0.84rem;
    border: 1px solid var(--border-color);
}
.markdown-content ul li::before {
    content: '';
    position: absolute;
    left: 0.7rem;
    top: 0.72rem;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gradient-primary);
}
.markdown-content ol {
    counter-reset: md-counter;
}
.markdown-content ol li {
    counter-increment: md-counter;
}
.markdown-content ol li::before {
    content: counter(md-counter);
    position: absolute;
    left: 0.55rem;
    top: 0.42rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Inline Styles ─── */
.markdown-content strong {
    font-weight: 700;
    color: var(--text-main);
}
.markdown-content em {
    color: var(--primary);
    font-style: normal;
    font-weight: 600;
}

/* ─── Blockquote ─── */
.markdown-content blockquote {
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    padding: 0.85rem 1rem;
    margin: 1rem 0;
    border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
    color: var(--text-muted);
    font-size: 0.84rem;
    font-style: italic;
}

/* ─── Code ─── */
.markdown-content code {
    background: var(--primary-glow);
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.78em;
    color: var(--primary);
    font-weight: 600;
}
.markdown-content pre {
    background: #0d0d18;
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid rgba(255, 255, 255, 0.04);
}
.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: #cdd6f4;
    font-size: 0.8em;
}

/* ─── Horizontal Rule ─── */
.markdown-content hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 1.5rem 0;
}

/* ─── Tables (fallback if AI still sends them) ─── */
.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.markdown-content th, .markdown-content td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
    white-space: nowrap;
}
.markdown-content th {
    background: var(--primary-glow);
    font-weight: 700;
    color: var(--primary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.markdown-content tbody tr:last-child td { border-bottom: none; }
.markdown-content tbody tr:nth-of-type(even) {
    background-color: var(--primary-soft);
}

/* ─── AI Chart Container (Premium) ─── */
.ai-chart-container {
    width: 100%;
    height: 300px;
    margin: 0.85rem 0;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 0.85rem;
    border: 1px solid var(--border-color);
    position: relative;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}
@media (min-width: 500px) {
    .ai-chart-container {
        height: 340px;
        padding: 1.25rem;
    }
}
[data-theme="dark"] .ai-chart-container {
    background: rgba(22, 22, 37, 0.8);
    border-color: rgba(255, 255, 255, 0.04);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.03);
}

/* ─── Remove Section Frames on Small Screens ─── */
@media (max-width: 600px) {
    .ai-section,
    .history-section {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0.5rem 0;
        border-radius: 0;
    }
}

/* ===================== CALENDAR ===================== */
.calendar-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

/* Calendar Header */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.cal-month-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    padding: 0.35rem 0.6rem;
    border-radius: var(--radius-xs);
    transition: var(--transition);
}
.cal-month-btn:hover {
    background: var(--primary-soft);
    color: var(--primary);
}
.cal-month-btn ion-icon {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.cal-nav-arrows {
    display: flex;
    gap: 0.35rem;
}

.cal-arrow-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: var(--transition);
}
.cal-arrow-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
    border-color: var(--primary);
}

/* Weekday Row */
.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    margin-bottom: 0.5rem;
}
.calendar-weekdays span {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 0.35rem 0;
}

/* Calendar Grid */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.cal-day {
    position: relative;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    transition: var(--transition);
    user-select: none;
}
.cal-day:hover {
    background: var(--primary-soft);
}
.cal-day.empty {
    cursor: default;
}
.cal-day.empty:hover {
    background: transparent;
}

.cal-day.today {
    background: var(--primary);
    color: white;
    font-weight: 700;
    box-shadow: 0 2px 12px var(--primary-glow);
}
.cal-day.today:hover {
    background: var(--primary-hover);
}

.cal-day.selected:not(.today) {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    box-shadow: inset 0 0 0 2px var(--primary);
}

.cal-day.other-month {
    color: var(--text-muted);
    opacity: 0.35;
}

/* Dots under calendar day numbers */
.cal-day-dots {
    display: flex;
    gap: 2px;
    position: absolute;
    bottom: 3px;
}
.cal-day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
}
.cal-day-dot.income {
    background: var(--success);
}
.cal-day-dot.expense {
    background: var(--danger);
}
.cal-day-dot.saving {
    background: var(--primary);
}
.cal-day.today .cal-day-dot {
    background: rgba(255, 255, 255, 0.85);
}

/* ─── Day Detail Section ─── */
.cal-day-detail {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-color);
    animation: fadeSlideIn 0.35s ease;
}

.cal-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.cal-detail-header h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
}
.cal-detail-header h2 ion-icon {
    color: var(--primary);
    font-size: 1.15rem;
}

.cal-detail-summary {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 1rem;
}
.cal-summary-chip {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
}
.cal-summary-chip ion-icon {
    font-size: 1rem;
}
.cal-summary-chip span {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
}
.cal-summary-chip strong {
    margin-left: auto;
    font-weight: 800;
    font-size: 0.85rem;
}
.cal-summary-chip.income {
    border-color: rgba(0, 184, 148, 0.2);
    background: var(--success-bg);
}
.cal-summary-chip.income ion-icon {
    color: var(--success);
}
.cal-summary-chip.income strong {
    color: var(--success);
}
.cal-summary-chip.expense {
    border-color: rgba(225, 112, 85, 0.2);
    background: var(--danger-bg);
}
.cal-summary-chip.expense ion-icon {
    color: var(--danger);
}
.cal-summary-chip.expense strong {
    color: var(--danger);
}

@media (max-width: 600px) {
    .calendar-card {
        border-radius: var(--radius-sm);
    }
    .cal-day-detail {
        background: transparent;
        border: none;
        box-shadow: none;
        padding: 0.75rem 0;
    }
    .cal-day {
        font-size: 0.8rem;
    }
    .cal-day-dots {
        bottom: 2px;
    }
    .cal-day-dot {
        width: 3px;
        height: 3px;
    }
}

/* ===================== FLATPICKR OVERRIDES ===================== */
.flatpickr-input {
    cursor: pointer !important;
}
.flatpickr-calendar {
    border-radius: var(--radius-sm) !important;
    box-shadow: var(--shadow-hover) !important;
    border: 1px solid var(--border-color) !important;
    font-family: 'Inter', sans-serif !important;
}
[data-theme="dark"] .flatpickr-calendar {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}
[data-theme="dark"] .flatpickr-day {
    color: var(--text-main) !important;
}
[data-theme="dark"] .flatpickr-day:hover {
    background: var(--primary-glow) !important;
    border-color: var(--primary) !important;
}
[data-theme="dark"] .flatpickr-day.selected {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}
[data-theme="dark"] .flatpickr-monthDropdown-months,
[data-theme="dark"] .flatpickr-current-month input.cur-year {
    color: var(--text-main) !important;
    background: transparent !important;
}
[data-theme="dark"] .flatpickr-months .flatpickr-prev-month,
[data-theme="dark"] .flatpickr-months .flatpickr-next-month {
    fill: var(--text-main) !important;
    color: var(--text-main) !important;
}
[data-theme="dark"] span.flatpickr-weekday {
    color: var(--text-muted) !important;
}
.flatpickr-day.selected {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}
.flatpickr-day.today {
    border-color: var(--primary) !important;
}

/* ===================== LOGIN SCREEN ===================== */
.login-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    background-image: 
        radial-gradient(ellipse at 20% 50%, rgba(108,92,231,0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(232,67,147,0.08) 0%, transparent 50%);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.login-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.login-container {
    width: 100%;
    max-width: 380px;
    padding: 2.5rem 1.75rem;
    margin: 0 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-hover);
    text-align: center;
}
[data-theme="dark"] .login-container {
    background: rgba(22, 22, 37, 0.9);
    border-color: rgba(255,255,255,0.05);
    box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}

.login-logo {
    margin-bottom: 1.25rem;
}
.login-logo-img {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.login-title {
    font-size: 1.35rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.35rem;
}
.login-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 1.75rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.login-field {
    position: relative;
    display: flex;
    align-items: center;
    overflow: hidden;
    border-radius: var(--radius-sm);
}
.login-field ion-icon {
    position: absolute;
    left: 0.85rem;
    font-size: 1.1rem;
    color: var(--text-muted);
    z-index: 1;
}
.login-field input {
    width: 100%;
    padding: 0.75rem 0.85rem 0.75rem 2.65rem;
    background: var(--bg-subtle);
    color: var(--text-main);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
}
.login-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.login-field input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}
.login-field input[type="password"],
.login-field input[type="text"] + .toggle-pw-btn ~ input,
.login-field:has(.toggle-pw-btn) input {
    padding-right: 2.8rem;
}

.toggle-pw-btn {
    position: absolute;
    right: 3px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: color 0.2s ease;
}
.toggle-pw-btn:hover {
    color: var(--primary);
}

.login-error {
    font-size: 0.8rem;
    color: var(--error);
    text-align: left;
    min-height: 0;
    transition: var(--transition);
}
.login-error:not(:empty) {
    min-height: 1.2rem;
    padding: 0.4rem 0.65rem;
    background: rgba(230, 57, 70, 0.08);
    border-radius: var(--radius-xs);
}

.login-submit-btn {
    padding: 0.8rem;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    transition: var(--transition-bounce);
    margin-top: 0.35rem;
}
.login-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px var(--primary-glow);
}
.login-submit-btn:active {
    transform: translateY(0);
}
.login-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.login-submit-btn ion-icon {
    font-size: 1.15rem;
}

/* ─── Header Actions (Logout + Theme) ─── */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.logout-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(230, 57, 70, 0.1);
    border: none;
    color: var(--error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
}
.logout-btn:hover {
    background: rgba(230, 57, 70, 0.2);
    transform: scale(1.1);
}

/* Install PWA Button */
.install-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 184, 148, 0.15);
    border: none;
    color: var(--success);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: var(--transition);
    animation: pulse-install 2s ease-in-out infinite;
}
.install-btn:hover {
    background: rgba(0, 184, 148, 0.3);
    transform: scale(1.1);
}
@keyframes pulse-install {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.3); }
    50% { box-shadow: 0 0 0 6px rgba(0, 184, 148, 0); }
}
