:root {
    color-scheme: dark;
    --bg-main: #0B0E14; /* Extremely dark blue/black slate */
    --gold: #D4AF37;   /* Classic Gold */
    --gold-dim: rgba(212, 175, 55, 0.2);
    --gold-glow: #F3E5AB; 
    
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8f8f8;
    --text-secondary: #9BA3AD;
    --red-decline: #ef4444; 
    --green-grow: #22c55e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Soft mesh gradient background for premium feel */
    background-image: 
        radial-gradient(at 0% 0%, rgba(212, 175, 55, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(212, 175, 55, 0.05) 0px, transparent 50%);
    background-attachment: fixed;
}

.gold-text {
    color: var(--gold);
}

.opacity-50 {
    opacity: 0.5;
}

/* Glassmorphism Helpers */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header Config */
.top-header {
    margin-bottom: 2rem;
    padding-top: env(safe-area-inset-top, 1rem); /* PWA Safe Area */
}

.offline-vault-banner {
    margin: 0 0 1rem;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: #fcd34d;
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.35);
    border-radius: 10px;
    line-height: 1.35;
}

.offline-vault-banner.hidden {
    display: none !important;
}

.header-content {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "logo"
        "tools";
    gap: 0.85rem 0;
    align-items: center;
    margin-bottom: 2rem;
}

.logo {
    grid-area: logo;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

.header-tools-row {
    grid-area: tools;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.65rem 0.85rem;
    width: 100%;
}

.header-spot-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 0 1 auto;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

@media (min-width: 768px) {
    .header-content {
        grid-template-columns: auto minmax(160px, 1fr) auto;
        grid-template-areas: "logo spot actions";
        gap: 0.75rem 1rem;
    }

    .logo {
        justify-content: flex-start;
    }

    .header-tools-row {
        display: contents;
    }

    .header-spot-wrap {
        grid-area: spot;
        justify-self: center;
        max-width: 24rem;
        width: 100%;
    }

    .header-actions {
        grid-area: actions;
        justify-self: end;
    }
}

@media (max-width: 767px) {
    .logo-img {
        max-width: min(380px, 94vw);
        height: clamp(3.75rem, 18vw, 5.75rem);
        object-position: center;
    }

    .btn-add-header {
        min-width: 3rem;
        min-height: 3rem;
        padding: 0.85rem 1rem;
        border-radius: 50%;
        font-size: 1.15rem;
    }

    .btn-add-header i {
        font-size: 1.2rem;
    }
}

.header-spot {
    flex: 1;
    min-width: 0;
    display: flex;
    justify-content: center;
    max-width: 100%;
}

.btn-gold-chart {
    flex-shrink: 0;
    width: 2.35rem;
    height: 2.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: rgba(12, 14, 20, 0.94);
    color: var(--gold);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.btn-gold-chart:hover {
    border-color: rgba(212, 175, 55, 0.35);
    background: rgba(18, 22, 30, 0.98);
}

.btn-gold-chart:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}

.btn-gold-chart i {
    font-size: 1rem;
}

@media (max-width: 767px) {
    .btn-gold-chart {
        width: 2.85rem;
        height: 2.85rem;
        border-radius: 12px;
    }

    .btn-gold-chart i {
        font-size: 1.2rem;
    }
}

/* Live gold spot (header) */
.gold-spot-card {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    background: rgba(0, 0, 0, 0.22);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    width: 100%;
    max-width: 20rem;
}

.gold-spot-icon {
    color: var(--gold);
    font-size: 1.15rem;
    margin-top: 0.1rem;
    opacity: 0.9;
}

.gold-spot-body {
    flex: 1;
    min-width: 0;
}

.gold-spot-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 0.15rem;
}

.gold-spot-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.35rem 0.6rem;
}

.gold-spot-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.gold-spot-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.4rem;
    border-radius: 6px;
    border: 1px solid transparent;
}

.gold-spot-badge.is-live {
    color: var(--green-grow);
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
}

.gold-spot-badge.is-cached {
    color: var(--gold);
    background: var(--gold-dim);
    border-color: rgba(212, 175, 55, 0.35);
}

.gold-spot-badge.is-offline {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--card-border);
}

@media (max-width: 767px) {
    .gold-spot-card {
        align-items: center;
        gap: 0.45rem;
        padding: 0.5rem 0.7rem;
        border-radius: 12px;
        max-width: none;
    }

    .gold-spot-icon {
        display: none;
    }

    .gold-spot-label {
        font-size: 0.62rem;
        letter-spacing: 0.05em;
        margin-bottom: 0.12rem;
        line-height: 1.25;
    }

    .gold-spot-row {
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.35rem 0.45rem;
    }

    .gold-spot-value {
        font-size: 1.2rem;
        line-height: 1.2;
    }

    .gold-spot-badge {
        font-size: 0.58rem;
        padding: 0.14rem 0.38rem;
        border-radius: 6px;
        letter-spacing: 0.03em;
        white-space: nowrap;
    }
}

.logo-img {
    height: clamp(3.25rem, 8vw, 4.25rem);
    width: auto;
    max-width: min(340px, 78vw);
    object-fit: contain;
    object-position: left center;
    display: block;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 12px rgba(212, 175, 55, 0.15));
}

.auth-logo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.auth-logo-img {
    width: min(420px, 92vw);
    height: auto;
    max-height: clamp(180px, 42vw, 240px);
    object-fit: contain;
    display: block;
}

.auth-logo-tagline {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 22rem;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card i {
    font-size: 1.5rem;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.stat-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Base Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, #B8860B 100%);
    color: #1a1a1a;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:active {
    transform: scale(0.97);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

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

/* Toolbar Config */
.toolbar {
    position: relative;
    z-index: 40;
    overflow: visible;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group, .sort-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    overflow: visible;
}

.btn-export-vault {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    flex-shrink: 0;
    padding: 0.55rem 1rem;
    border-radius: 30px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--gold);
    background: rgba(212, 175, 55, 0.08);
    color: var(--gold);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-export-vault.is-visible {
    display: inline-flex;
}

.btn-export-vault:hover {
    background: rgba(212, 175, 55, 0.18);
    border-color: var(--gold-glow);
}

.btn-export-vault:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--gold-dim);
}

.btn-export-vault i {
    font-size: 1rem;
}

.filter-group i {
    color: var(--gold);
}

.weight-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-glass {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.5rem 0.8rem;
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.input-glass:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold-dim);
}

/* Custom themed dropdowns (Flatpickr-matched panel); native <select> is visually hidden */
select.custom-select-native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.custom-select {
    position: relative;
    display: block;
    width: 100%;
}

.custom-select--full {
    min-width: 11.5rem;
}

.custom-select--unit {
    width: auto;
    flex-shrink: 0;
    align-self: stretch;
}

.custom-select-trigger {
    width: 100%;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
    padding: 0.5rem 2.35rem 0.5rem 0.85rem;
    margin: 0;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.35;
    text-align: left;
    color: var(--text-primary);
    cursor: pointer;
    background-color: rgba(12, 14, 20, 0.94);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-select-trigger::after {
    content: "";
    position: absolute;
    right: 0.6rem;
    top: 50%;
    width: 1.05rem;
    height: 1.05rem;
    margin-top: -0.525rem;
    background: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23D4AF37' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center / contain no-repeat;
    pointer-events: none;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.custom-select.is-open .custom-select-trigger::after {
    transform: rotate(180deg);
}

.custom-select-trigger:hover {
    border-color: rgba(212, 175, 55, 0.32);
    background-color: rgba(16, 20, 28, 0.98);
}

.custom-select-trigger:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 0 0 2px var(--gold-dim);
}

.custom-select-trigger:active {
    border-color: rgba(212, 175, 55, 0.45);
}

/* Panel: same surface + shadow as .flatpickr-calendar (opaque so it reads over glass/blur) */
.custom-select-panel {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 5000;
    padding: 0.35rem;
    background-color: #0b0e14;
    background-color: var(--bg-main);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    max-height: min(280px, 55vh);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.35) transparent;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
}

.custom-select--unit .custom-select-panel {
    left: auto;
    right: 0;
    min-width: 100%;
}

.custom-select-option {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.75rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background-color: transparent;
    color: var(--text-primary);
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.35;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.custom-select-option:hover {
    background: var(--card-bg);
    border-color: var(--gold-dim);
}

.custom-select-option.is-selected {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg-main);
    font-weight: 600;
}

.custom-select-option.is-selected:hover {
    filter: brightness(1.06);
    border-color: var(--gold);
}

.combined-input .custom-select--unit .custom-select-trigger {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: none;
    min-width: 4.25rem;
    padding-left: 0.45rem;
    padding-right: 1.85rem;
    justify-content: center;
    text-align: center;
    font-weight: 600;
    color: var(--gold);
    background-color: rgba(14, 17, 24, 0.98);
}

.combined-input .custom-select--unit .custom-select-trigger::after {
    right: 0.45rem;
    width: 0.95rem;
    height: 0.95rem;
    margin-top: -0.475rem;
}

.combined-input .custom-select--unit .custom-select-trigger:hover {
    background-color: rgba(20, 24, 34, 0.98);
    border-color: rgba(212, 175, 55, 0.28);
}

/* iOS/Safari: native number styling can yield light bg + light text */
input[type="number"].input-glass {
    -webkit-appearance: none;
    appearance: none;
    background-color: rgba(12, 14, 20, 0.92);
    color: var(--text-primary);
    -webkit-text-fill-color: var(--text-primary);
}

.weight-filter input {
    width: 80px;
}

/* Gold List */
.feed-container {
    min-height: 50vh;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

.gold-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* List Item Styles */
.gold-card {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    border-radius: 12px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    transition: transform 0.2s, background 0.2s;
    animation: fadeIn 0.4s ease-out;
}

.gold-card.card-sold {
    opacity: 0.7;
    background: rgba(255, 255, 255, 0.01);
}

.sold-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: var(--red-decline);
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    z-index: 10;
    text-transform: uppercase;
}

.gold-card:active {
    background: rgba(255,255,255,0.06);
    transform: scale(0.99);
}

.gold-card-main {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    order: 1;
}

.card-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, rgba(212,175,55,0.2) 0%, rgba(212,175,55,0.05) 100%);
    border: 1px solid var(--gold-dim);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.5rem;
}

.card-main-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    line-height: 1.25;
    word-break: break-word;
}

.card-meta-desktop {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.35;
    margin: 0;
}

.mobile-only {
    display: none !important;
}

/* Weight | invested | rate — desktop: right-aligned column */
.card-metrics {
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    gap: 0.2rem;
    flex-shrink: 0;
}

.metric {
    display: flex;
    flex-direction: column;
    align-items: inherit;
    gap: 0.1rem;
    max-width: 100%;
}

.metric-label {
    display: none;
}

.metric-value {
    font-size: 0.95rem;
    line-height: 1.3;
    color: var(--text-primary);
}

.metric-weight {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--gold);
}

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

.metric-rate {
    font-size: 0.8rem;
    color: var(--gold);
    opacity: 0.9;
}

.metric-unit {
    font-size: 0.75em;
    opacity: 0.85;
    white-space: nowrap;
}

.card-profit {
    order: 3;
    flex-basis: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--card-border);
}

.card-profit-line {
    display: block;
    line-height: 1.35;
}

.btn-action {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: none;
    border-radius: 8px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: var(--red-decline);
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.2);
    color: var(--red-decline);
}

.btn-view {
    background: rgba(212, 175, 55, 0.1);
    color: var(--gold);
}

.btn-view:hover {
    background: rgba(212, 175, 55, 0.2);
    color: var(--gold);
}

.btn-sell {
    background: rgba(34, 197, 94, 0.1);
    color: var(--green-grow);
}

.btn-sell:hover {
    background: rgba(34, 197, 94, 0.2);
    color: var(--green-grow);
}

.green-text {
    color: var(--green-grow) !important;
}

.red-text {
    color: var(--red-decline) !important;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    position: relative;
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    overflow: visible;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-footer {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Vault PIN / menu / pick (above standard modals) */
.vault-flow-overlay {
    z-index: 1050;
}

.vault-flow-modal {
    max-width: 400px;
}

.vault-flow-hint {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.vault-pin-error {
    color: var(--red-decline);
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
}

.vault-pin-form .form-group.vault-pin-field {
    margin-bottom: 1rem;
}

.vault-pin-sr-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.vault-pin-field {
    position: relative;
}

.vault-pin-dots {
    display: flex;
    justify-content: center;
    gap: 0.65rem;
    min-height: 1.25rem;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.vault-pin-dot {
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    opacity: 0.55;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.vault-pin-dot.is-filled {
    background: var(--gold);
    border-color: var(--gold);
    opacity: 1;
}

.vault-pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.vault-pin-key {
    aspect-ratio: 1;
    max-height: 3.35rem;
    margin: 0 auto;
    width: 100%;
    max-width: 4.25rem;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

.vault-pin-key:hover {
    background: rgba(255, 255, 255, 0.12);
}

.vault-pin-key:active {
    transform: scale(0.94);
    background: rgba(255, 255, 255, 0.16);
}

.vault-pin-key-fn {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.vault-pin-key-submit {
    color: var(--green-grow, #22c55e);
    border-color: rgba(34, 197, 94, 0.35);
    background: rgba(34, 197, 94, 0.12);
}

.vault-pin-key-submit:hover {
    background: rgba(34, 197, 94, 0.22);
}

.vault-pin-continue {
    margin-top: 0.25rem;
}

.vault-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-vault-choice {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
}

.btn-vault-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red-decline);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-vault-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-vault-sell {
    background: rgba(34, 197, 94, 0.12);
    color: var(--green-grow);
    border: 1px solid rgba(34, 197, 94, 0.35);
}

.btn-vault-sell:hover {
    background: rgba(34, 197, 94, 0.2);
}

.btn-vault-lock {
    margin-top: 1rem;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 8px;
}

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

.vault-pick-subtitle {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.vault-pick-list {
    max-height: min(50vh, 320px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) transparent;
}

.vault-pick-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-primary);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.vault-pick-row:hover {
    border-color: rgba(212, 175, 55, 0.35);
    background: rgba(255, 255, 255, 0.04);
}

.vault-pick-ref {
    font-weight: 600;
    font-size: 1rem;
}

.vault-pick-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.vault-pick-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1.5rem 0.5rem;
}

/* Gold price chart modal */
.gold-chart-modal-panel {
    max-width: 560px;
    z-index: 1;
}

.chart-range-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.chart-range-tab {
    flex: 1 1 auto;
    min-width: 4.5rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.chart-range-tab:hover {
    border-color: rgba(212, 175, 55, 0.35);
    color: var(--text-primary);
}

.chart-range-tab.is-active {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}

.gold-chart-canvas-wrap {
    position: relative;
    min-height: 260px;
    margin-bottom: 0.75rem;
}

.gold-chart-canvas-wrap canvas {
    display: block;
    width: 100% !important;
    height: 260px !important;
}

.gold-chart-status {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 90%;
    z-index: 1;
}

.gold-chart-error {
    color: var(--red-decline);
}

.gold-chart-footnote {
    margin: 0;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--text-secondary);
    opacity: 0.85;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.row-group {
    display: flex;
    gap: 1rem;
}

.half {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
}

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
}

.input-wrapper:has(.input-icon) .input-glass {
    padding-left: 2.5rem;
}

.right-addon input {
    padding-right: 2.5rem;
}

.right-addon .addon {
    position: absolute;
    right: 1rem;
    color: var(--text-secondary);
}

.left-addon .input-glass {
    padding-left: 3.5rem;
}

.left-addon .addon {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
}

.w-full {
    width: 100%;
}

.mt-4 {
    margin-top: 2rem;
}


/* Animations */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .stats-cards {
        grid-template-columns: 1fr;
    }
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .weight-filter {
        flex: 1;
        justify-content: space-between;
    }
    .desktop-only {
        display: none;
    }
    .card-icon {
        display: none;
    }

    /* Vault cards: title + actions on one row; metrics as a clear 3-column strip */
    .gold-card {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 1rem 1rem 1.1rem;
        gap: 0.65rem 0.75rem;
    }

    .gold-card-main {
        flex: 1 1 0;
        min-width: 0;
        max-width: 100%;
        gap: 0;
        width: 100%;
    }

    /* Reference + bill in cols 1–2; date in col 3 (above Rate). Desktop uses .card-meta-desktop. */
    .mobile-only {
        display: block !important;
    }

    time.card-date.mobile-only {
        display: block !important;
    }

    .card-main-body {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.35rem 0.35rem;
        align-items: start;
        width: 100%;
    }

    .card-main-body .card-title {
        grid-column: 1 / 3;
        grid-row: 1;
        margin: 0;
    }

    .card-main-body .card-bill-line.mobile-only {
        grid-column: 1 / 3;
        grid-row: 2;
        margin: 0;
        font-size: 0.85rem;
        color: var(--text-secondary);
        line-height: 1.35;
    }

    .card-main-body .card-date.mobile-only {
        grid-column: 3;
        justify-self: center;
        text-align: center;
        font-size: 0.82rem;
        color: var(--text-secondary);
        line-height: 1.35;
        font-weight: 500;
        max-width: 100%;
        word-break: break-word;
    }

    .card-main-body:has(.card-bill-line) .card-date.mobile-only {
        grid-row: 1 / 3;
        align-self: start;
    }

    .card-main-body:not(:has(.card-bill-line)) .card-date.mobile-only {
        grid-row: 1;
        align-self: start;
    }

    .card-metrics {
        order: 2;
        flex-basis: 100%;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem 0.35rem;
        align-items: start;
        text-align: center;
        padding-top: 0.65rem;
        margin-top: 0.15rem;
        border-top: 1px solid var(--card-border);
    }

    .card-metrics .metric {
        align-items: center;
        text-align: center;
        min-width: 0;
    }

    .metric-label {
        display: block;
        font-size: 0.62rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--text-secondary);
        margin-bottom: 0.2rem;
        line-height: 1.2;
    }

    .metric-value {
        font-size: 0.82rem;
        justify-content: center;
        word-break: break-word;
        hyphens: auto;
    }

    .metric-weight {
        font-size: 0.95rem;
    }

    .metric-invested {
        font-size: 0.8rem;
    }

    .metric-rate {
        font-size: 0.78rem;
    }

    .card-profit {
        order: 3;
        flex-basis: 100%;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.35rem 0.75rem;
        margin-top: 0;
        align-items: baseline;
    }

    .card-profit .card-profit-line {
        display: inline;
    }

    .card-profit .card-profit-line:not(:last-child)::after {
        content: ' · ';
        color: var(--text-secondary);
        opacity: 0.6;
    }
}

/* Flatpickr Custom Theme */
.flatpickr-calendar {
    background: var(--bg-main) !important;
    border: 1px solid var(--card-border) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
    color: var(--text-primary) !important;
}
.flatpickr-months .flatpickr-month,
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--gold) !important;
    fill: var(--gold) !important;
}
.flatpickr-weekday, .flatpickr-day.flatpickr-disabled, .flatpickr-day.nextMonthDay, .flatpickr-day.prevMonthDay {
    color: var(--text-secondary) !important;
}
.flatpickr-day {
    color: var(--text-primary) !important;
}
.flatpickr-day.selected, .flatpickr-day.selected:focus, .flatpickr-day.selected:hover {
    background: var(--gold) !important;
    border-color: var(--gold) !important;
    color: var(--bg-main) !important;
}
.flatpickr-day:hover {
    background: var(--card-bg) !important;
    border-color: var(--gold-dim) !important;
}
.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after {
    border-bottom-color: var(--bg-main) !important;
}

.combined-input {
    display: flex;
    align-items: stretch;
}

.combined-input input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    flex: 1;
}

