/* Root variables for styling */

:root {
    --bg-color: #080b11;
    --card-bg: rgba(16, 22, 36, 0.65);
    --card-border: rgba(255, 255, 255, 0.05);
    --card-hover-border: rgba(99, 102, 241, 0.4);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --success: #10b981;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.5;
}


/* Background glows */

.glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(130px);
    z-index: -1;
    opacity: 0.25;
    pointer-events: none;
}

.glow-1 {
    width: 400px;
    height: 400px;
    background: #6366f1;
    top: -100px;
    left: -100px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: #8b5cf6;
    bottom: -150px;
    right: -100px;
}


/* Premium Card (Glassmorphism) */

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.1);
}


/* Typography */

h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    font-weight: 600;
}


/* Auth Container */

.auth-container {
    max-width: 420px;
    width: 90%;
    margin: 40px auto;
    padding: 32px 24px;
}

@media (min-width: 480px) {
    .auth-container {
        margin: 100px auto;
        padding: 40px 32px;
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 8px;
}

.logo-icon {
    font-size: 2rem;
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.logo-text {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a5b4fc 0%, #818cf8 50%, #c084fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@media (min-width: 480px) {
    .logo-text {
        font-size: 2rem;
    }
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-size: 1rem;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}


/* Inputs and Forms */

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

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 20px;
}

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

@media (min-width: 480px) {
    .form-row {
        flex-direction: row;
        gap: 16px;
    }
    .form-row .form-group {
        margin-bottom: 0;
    }
}

.flex-1 {
    flex: 1;
}

.flex-2 {
    flex: 2;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
    color-scheme: dark;
}

select option {
    background-color: #1a2035;
    color: #e2e8f0;
}

input:focus,
select:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-checkbox input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.form-checkbox label {
    margin-bottom: 0;
    user-select: none;
    cursor: pointer;
}


/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 8px;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
}

.btn-success {
    background: var(--success-gradient);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 6px;
}


/* Alerts */

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 16px;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}


/* Dashboard Screen Layout */

#dashboard-screen {
    max-width: 1200px;
    width: 95%;
    margin: 20px auto;
}

@media (min-width: 768px) {
    #dashboard-screen {
        margin: 40px auto;
    }
}


/* Navbar */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-bottom: 24px;
    gap: 12px;
}

@media (min-width: 768px) {
    .navbar {
        padding: 16px 28px;
        margin-bottom: 32px;
    }
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

@media (min-width: 480px) {
    .user-email {
        max-width: none;
    }
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}


/* User avatar wrap — avatar on mobile, email text on desktop */

.user-avatar-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
    transition: box-shadow 0.2s;
}

.user-avatar-wrap:hover .user-avatar {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}


/* Popover tooltip with full email — mobile only */

.email-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: rgba(16, 22, 36, 0.98);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 50;
    pointer-events: none;
}

.email-popover::before {
    content: '';
    position: absolute;
    top: -5px;
    right: 12px;
    width: 8px;
    height: 8px;
    background: rgba(16, 22, 36, 0.98);
    border-left: 1px solid rgba(99, 102, 241, 0.35);
    border-top: 1px solid rgba(99, 102, 241, 0.35);
    transform: rotate(45deg);
}


/* Desktop: show email text, hide avatar and popover */

@media (min-width: 640px) {
    .user-avatar {
        display: none;
    }
    .user-avatar-wrap {
        cursor: default;
    }
    .email-popover {
        display: none !important;
    }
}

.currency-switcher {
    position: relative;
}

.currency-switcher select {
    appearance: none;
    -webkit-appearance: none;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 28px 8px 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.2s;
    min-height: unset;
    width: auto;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.currency-switcher select:hover,
.currency-switcher select:focus {
    background-color: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}


/* Dashboard Grid */

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 380px 1fr;
        gap: 32px;
    }
}

.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

@media (min-width: 992px) {
    .dashboard-sidebar {
        gap: 32px;
    }
}

.analytics-card {
    padding: 24px;
}

.card-title {
    font-size: 1.15rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    border-left: 3px solid var(--primary);
    padding-left: 10px;
}


/* Forecast Card details */

.forecast-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.forecast-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.forecast-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.forecast-value {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}


/* Chart Styles */

.chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.chart-visual {
    position: relative;
    width: 160px;
    height: 160px;
}

.chart-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.center-total {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
}

.center-lbl {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.chart-legend {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    gap: 8px;
}

.legend-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-name {
    color: var(--text-secondary);
}

.legend-val {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
}


/* Subscriptions Section */

.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.main-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
}

@media (min-width: 576px) {
    .main-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.section-title {
    font-size: 1.5rem;
}

.subs-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* Subscription Row Card */

.sub-row {
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.sub-row.inactive {
    opacity: 0.65;
}

.sub-info-block {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.sub-avatar {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    border: 1px solid rgba(99, 102, 241, 0.2);
    flex-shrink: 0;
}

.sub-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.sub-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.sub-category-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.sub-date-badge {
    display: flex;
    align-items: center;
    gap: 4px;
}


/* Status markers and badges */

.badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-overdue {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
    animation: pulse-danger 2s infinite;
}

.badge-soon {
    background: rgba(245, 158, 11, 0.15);
    color: #fde047;
    border: 1px solid rgba(245, 158, 11, 0.25);
}

@keyframes pulse-danger {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.sub-actions-container {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 14px;
}

.sub-pricing {
    text-align: left;
    margin-right: 0;
    word-break: break-word;
    min-width: 0;
}

.sub-cost {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    word-break: break-all;
}

.sub-freq {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.sub-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

@media (min-width: 640px) {
    .sub-row {
        padding: 20px 24px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
    }
    .sub-info-block {
        flex: 1 1 auto;
        min-width: 0;
    }
    .sub-actions-container {
        flex: 0 0 auto;
        width: auto;
        justify-content: flex-end;
        border-top: none;
        padding-top: 0;
        white-space: nowrap;
    }
    .sub-pricing {
        text-align: right;
        margin-right: 24px;
        white-space: nowrap;
    }
    .sub-actions {
        flex-wrap: nowrap;
    }
}


/* Modal Styling */

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 6, 10, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s;
}

.modal {
    width: 92%;
    max-width: 520px;
    padding: 24px 20px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (min-width: 480px) {
    .modal {
        padding: 32px;
    }
}

@keyframes modal-enter {
    from {
        transform: translateY(20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

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

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.8rem;
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}


/* Category select custom input */

.category-select-wrapper {
    display: flex;
    gap: 10px;
}

.custom-category-input-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    width: 100%;
}

@media (min-width: 400px) {
    .custom-category-input-row {
        flex-direction: row;
    }
    .custom-category-input-row input {
        flex: 2;
    }
}


/* Toast System */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    left: 24px;
    text-align: center;
    padding: 16px 24px;
    background: rgba(16, 22, 36, 0.95);
    border-radius: 8px;
    border: 1px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: translateY(100px);
    opacity: 0;
}

@media (min-width: 576px) {
    .toast {
        left: auto;
        max-width: 350px;
        text-align: left;
    }
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}


/* Utils helper classes */

.hidden {
    display: none !important;
}


/* Action icons inside tables/rows */

.action-icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.action-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.1);
}

.action-icon-btn.btn-pay {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--success);
    font-weight: bold;
    padding: 0 12px;
    width: auto;
    white-space: nowrap;
    flex-shrink: 0;
}


/* Edit button – blue background on hover */

.action-icon-btn.btn-edit {
    background: rgba(59, 130, 246, 0.15);
    /* blue */
    border-color: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    padding: 0 12px;
    width: auto;
}

.action-icon-btn.btn-edit:hover {
    background: var(--primary);
    color: white;
}

.action-icon-btn.btn-pay:hover {
    background: var(--success);
    color: white;
}


/* Delete button – red background on hover */

.action-icon-btn.btn-delete {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    padding: 0 12px;
    width: auto;
}

.action-icon-btn.btn-delete:hover {
    background: var(--danger);
    color: white;
}


/* Icon size within action buttons */

.action-icon-btn .icon {
    width: 1rem;
    height: 1rem;
    vertical-align: middle;
}


/* ============================================================
   MOBILE-FIRST IMPROVEMENTS (≤ 640px)
   ============================================================ */


/* Prevent font size zoom on input focus (iOS) */

@supports (-webkit-touch-callout: none) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select {
        font-size: 16px;
    }
}


/* Touch-friendly tap targets */

@media (max-width: 640px) {
    .btn {
        min-height: 48px;
        padding: 12px 20px;
    }
    .btn-sm {
        min-height: 40px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    select {
        min-height: 48px;
        padding: 12px 14px;
    }
    .action-icon-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
    .tab-btn {
        min-height: 48px;
        font-size: 1rem;
    }
    /* Auth screen — full width on very small screens */
    .auth-container {
        width: 100%;
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 32px 20px;
        border: none;
    }
    /* Navbar — two rows on mobile */
    .navbar {
        padding: 12px 14px;
        margin-bottom: 16px;
        border-radius: 12px;
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
        gap: 6px 8px;
        align-items: center;
    }
    .nav-brand {
        grid-column: 1;
        grid-row: 1 / 3;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        align-self: stretch;
    }
    .nav-brand .logo-text {
        font-size: 1.3rem;
    }
    .nav-brand .logo-icon {
        width: 34px;
        height: 34px;
    }
    /* Row 1: avatar + logout pushed right */
    .nav-actions {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
    }
    .user-email {
        display: none;
    }
    /* Row 2: selectors pushed right */
    .nav-controls {
        grid-column: 2;
        grid-row: 2;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
        width: auto;
    }
    /* Currency switcher compact */
    .currency-switcher select {
        font-size: 0.8rem;
        padding: 7px 24px 7px 10px;
    }
    /* Dashboard grid — single column, subscriptions first */
    .dashboard-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    .dashboard-main {
        order: 1;
    }
    .dashboard-sidebar {
        order: 2;
        display: flex;
        flex-direction: column;
        gap: 16px;
        width: 100%;
    }
    .analytics-card {
        width: 100%;
        padding: 18px;
    }
    .forecast-grid {
        gap: 10px;
    }
    .forecast-item {
        padding: 10px 14px;
    }
    /* Dashboard screen — proper padding */
    #dashboard-screen {
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 12px 16px 40px;
        box-sizing: border-box;
    }
    .main-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .section-title {
        font-size: 1.2rem;
    }
    .btn-with-icon {
        padding: 10px 14px;
        font-size: 0.9rem;
        min-height: 44px;
    }
    /* Subscription rows — compact on mobile */
    .sub-row {
        padding: 14px;
        gap: 12px;
    }
    .sub-avatar {
        width: 42px;
        height: 42px;
        font-size: 1.15rem;
        border-radius: 10px;
    }
    .sub-name {
        font-size: 0.95rem;
    }
    .sub-meta {
        font-size: 0.75rem;
        gap: 6px;
    }
    .sub-cost {
        font-size: 1.1rem;
    }
    .sub-actions {
        gap: 8px;
    }
    /* Modal — slide-up sheet on mobile */
    .modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }
    .modal {
        width: 100%;
        max-width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        padding: 20px 18px 32px;
        animation: modal-slide-up 0.35s cubic-bezier(0.34, 1.2, 0.64, 1);
    }
    @keyframes modal-slide-up {
        from {
            transform: translateY(100%);
            opacity: 0.5;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    /* Drag handle indicator for bottom sheet feel */
    .modal::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: 2px;
        margin: 0 auto 18px;
    }
    .modal-header {
        margin-bottom: 18px;
    }
    .modal-header h3 {
        font-size: 1.1rem;
    }
    .modal-actions {
        flex-direction: column-reverse;
        gap: 10px;
        margin-top: 20px;
    }
    .modal-actions .btn {
        width: 100%;
    }
    /* Form rows stay stacked on small screens */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    .form-group {
        margin-bottom: 16px;
    }
    /* Category select wrapper */
    .category-select-wrapper {
        flex-direction: row;
        gap: 8px;
    }
    .category-select-wrapper select {
        flex: 1;
    }
    /* Custom category input */
    .custom-category-input-row {
        flex-direction: column;
        gap: 8px;
    }
    /* Toast — full width at bottom with safe area */
    .toast {
        bottom: 16px;
        left: 12px;
        right: 12px;
        font-size: 0.9rem;
        padding: 14px 18px;
    }
    /* Chart on mobile — side by side */
    .chart-container {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 16px;
        align-items: center;
    }
    .chart-visual {
        width: 120px;
        height: 120px;
        flex-shrink: 0;
    }
    .center-total {
        font-size: 1.1rem;
    }
    .chart-legend {
        flex: 1;
        min-width: 120px;
        gap: 8px;
    }
    .legend-item {
        font-size: 0.78rem;
    }
}


/* ============================================================
   SMALL TABLETS (641px – 991px) — sidebar above, horizontal
   ============================================================ */

@media (min-width: 641px) and (max-width: 991px) {
    #dashboard-screen {
        width: 96%;
        margin: 24px auto;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .dashboard-sidebar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    .analytics-card {
        padding: 20px;
    }
    .modal {
        width: 88%;
        max-width: 520px;
        padding: 28px 24px;
        border-radius: 16px;
        animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
}


/* ============================================================
   SAFE AREA — notch / home bar support (iOS)
   ============================================================ */

@supports (padding: max(0px)) {
    .toast {
        bottom: max(16px, env(safe-area-inset-bottom));
    }
    .auth-container {
        padding-bottom: max(32px, env(safe-area-inset-bottom));
    }
    @media (max-width: 640px) {
        .modal {
            padding-bottom: max(32px, env(safe-area-inset-bottom));
        }
        #dashboard-screen {
            padding-bottom: max(80px, calc(env(safe-area-inset-bottom) + 60px));
        }
    }
}
/* ── Verification / Reset screens ── */
.auth-hint {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-hint strong {
    color: var(--text-primary);
}

.mt-8 {
    margin-top: 8px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

.btn-link:hover {
    color: var(--text-primary);
}
