.metals-watch {
    background-color: #0a0e1a;
    color: #e8e9ed;
    min-height: 100vh;
    padding: 2rem;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

.header {
    margin-bottom: 2rem;
    max-width: 100%;
    overflow: hidden;
}

.header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.subtitle {
    color: #7c8ba1;
    margin-bottom: 0.75rem;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    max-width: 100%;
}

.currency-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: #141b2d;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    border: 2px solid #2a3547;
    max-width: 100%;
    box-sizing: border-box;
}

.currency-selector label {
    color: #7c8ba1;
    font-size: 0.9rem;
    font-weight: 600;
}

.currency-selector select {
    background-color: #0a0e1a;
    border: 2px solid #2a3547;
    border-radius: 4px;
    color: #ffffff;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s;
    min-width: 100px;
    flex-shrink: 0;
}

.currency-selector select:focus {
    outline: none;
    border-color: #0059b0;
}

.currency-selector select:hover {
    border-color: #0059b0;
}

.exchange-rate-info {
    color: #7c8ba1;
    font-size: 0.85rem;
    padding-left: 0.75rem;
    border-left: 2px solid #2a3547;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.rate-date {
    color: #5a6b7f;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.update-time {
    color: #7c8ba1;
    font-size: 0.9rem;
}

/* Market Prices styles remain the same */
.error-message {
    background-color: #dc0001;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.loading-message {
    background-color: #0059b0;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.market-pulse, .holdings, .valuation {
    background-color: #141b2d;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

.refresh-info, .section-info {
    color: #7c8ba1;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.prices-table {
    background-color: #1a2332;
    border-radius: 6px;
    overflow: hidden;
}

.prices-grid-header {
    display: grid;
    grid-template-columns: 200px 1fr 150px;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background-color: #0a0e1a;
    font-weight: 600;
    font-size: 0.875rem;
    color: #7c8ba1;
    border-bottom: 2px solid #2a3547;
}

.prices-grid-row {
    display: grid;
    grid-template-columns: 200px 1fr 150px;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2a3547;
    align-items: center;
    transition: background-color 0.2s;
}

.prices-grid-row:hover {
    background-color: #202939;
}

.prices-grid-row:last-child {
    border-bottom: none;
}

.metal-name-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.metal-icon {
    font-size: 1.5rem;
}

.price-cell {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
}

.change-cell {
    font-size: 1.125rem;
    font-weight: 600;
    text-align: right;
}

.change-cell.positive {
    color: #22c55e;
}

.change-cell.negative {
    color: #ef4444;
}

.no-data-message {
    padding: 2rem;
    text-align: center;
    color: #7c8ba1;
}

.no-data-message p {
    margin-bottom: 1rem;
}

.refresh-btn {
    background-color: #0059b0;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.refresh-btn:hover {
    background-color: #004a8f;
}

.ratio-info {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #1a2332;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ratio-label {
    color: #7c8ba1;
    font-size: 0.95rem;
}

.ratio-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #ffffff;
}

/* Master/Detail Styles */
.metal-master {
    margin-bottom: 1.5rem;
    background-color: #1a2332;
    border-radius: 8px;
    overflow: hidden;
}

.master-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #0a0e1a;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 2px solid #2a3547;
}

.master-header:hover {
    background-color: #0d1119;
}

.master-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.expand-icon {
    font-size: 0.875rem;
    color: #7c8ba1;
    width: 20px;
}

.metal-name {
    font-size: 1.25rem;
    color: #ffffff;
}

.master-summary {
    color: #7c8ba1;
    font-size: 0.9rem;
    font-weight: 400;
}

.master-actions {
    display: flex;
    gap: 0.5rem;
}

.add-detail-btn {
    background-color: #0059b0;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.add-detail-btn:hover {
    background-color: #004a8f;
}

.details-grid {
    padding: 0;
}

.detail-grid-header {
    display: grid;
    grid-template-columns: 200px 130px 110px 140px 130px 150px 50px;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background-color: #0a0e1a;
    font-weight: 600;
    font-size: 0.8rem;
    color: #7c8ba1;
    text-transform: uppercase;
}

.detail-grid-row {
    display: grid;
    grid-template-columns: 200px 130px 110px 140px 130px 150px 50px;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2a3547;
    align-items: center;
    transition: background-color 0.2s;
}

.detail-grid-row:hover {
    background-color: #1e2840;
}

.detail-grid-row.totals-row {
    background-color: #0a0e1a;
    border-top: 2px solid #ffd700;
    border-bottom: none;
    font-weight: 600;
}

.detail-cell {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
}

.detail-input {
    width: 100%;
    background-color: #0a0e1a;
    border: 2px solid #2a3547;
    border-radius: 4px;
    color: #ffffff;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.detail-input:focus {
    outline: none;
    border-color: #0059b0;
}

.detail-cell.value-cell {
    justify-content: flex-end;
}

.value-amount {
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
}

.detail-cell.gain-loss-cell {
    justify-content: flex-end;
}

.detail-cell.gain-loss-cell > div {
    text-align: right;
}

.detail-cell.gain-loss-cell .positive {
    color: #22c55e;
}

.detail-cell.gain-loss-cell .negative {
    color: #ef4444;
}

.detail-cell.gain-loss-cell .positive div,
.detail-cell.gain-loss-cell .negative div {
    font-weight: 600;
    font-size: 0.95rem;
}

.detail-cell.gain-loss-cell .percent {
    font-size: 0.8rem;
    margin-top: 0.125rem;
}

.detail-cell.actions {
    justify-content: center;
}

.detail-cell.totals-label {
    color: #ffffff;
    font-size: 1rem;
}

.icon-delete-btn {
    background-color: transparent;
    color: #dc0001;
    border: 1px solid #dc0001;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.icon-delete-btn:hover {
    background-color: #dc0001;
    color: #ffffff;
    transform: scale(1.1);
}

.totals-gain-loss {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.totals-gain-loss .daily-change {
    font-size: 0.85rem;
    padding-top: 0.25rem;
    border-top: 1px solid #2a3547;
}

.totals-gain-loss .daily-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #7c8ba1;
    margin-right: 0.5rem;
}

.totals-gain-loss .percent {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.delete-btn {
    background-color: #dc0001;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.delete-btn:hover {
    background-color: #b00001;
}

/* Portfolio Summary styles */
.empty-details {
    padding: 2rem;
    text-align: center;
    color: #7c8ba1;
    background-color: #1a2332;
}

/* Valuation Summary */
.valuation-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.metal-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.summary-card {
    background-color: #1a2332;
    border-radius: 8px;
    padding: 2rem 1.75rem;
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card.total {
    background-color: #1a2332;
    border: 2px solid #00FF00;
}

.summary-card.total .summary-label {
    font-size: 1.4rem;
}

.summary-card.total .summary-value {
    color: #00FF00;
}

.summary-card.gold {
    border: 2px solid #ffd700;
}

.summary-card.silver {
    border: 2px solid #c0c0c0;
}

.summary-card.invested {
    border: 2px solid #2a8215;
}

.summary-label {
    color: #7c8ba1;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.summary-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.75rem;
    line-height: 1.1;
}

.summary-card.total .summary-value,
.summary-card.gold .summary-value,
.summary-card.silver .summary-value,
.summary-card.invested .summary-value {
    color: #2a8215;
}

.summary-value.positive {
    color: #22c55e;
}

.summary-value.negative {
    color: #ef4444;
}

.summary-gain {
    font-size: 1.125rem;
    font-weight: 600;
}

.summary-gain.positive {
    color: #22c55e;
}

.summary-gain.negative {
    color: #ef4444;
}

.summary-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #2a3547;
}

.detail-line {
    color: #7c8ba1;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-line:last-child {
    margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 1600px) {
    .detail-grid-header,
    .detail-grid-row {
        grid-template-columns: 180px 120px 100px 130px 120px 140px 40px;
        gap: 0.5rem;
        font-size: 0.85rem;
    }
    
    .valuation-summary {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 1400px) {
    .detail-grid-header,
    .detail-grid-row {
        grid-template-columns: 160px 110px 90px 120px 110px 130px 35px;
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    
    .detail-input {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }
    
    .icon-delete-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem;
    }
}

@media (max-width: 1200px) {
    .metals-watch {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .prices-grid-header,
    .prices-grid-row {
        grid-template-columns: 180px 1fr 130px;
        gap: 0.75rem;
    }
    
    .valuation-summary {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .summary-card {
        padding: 1.5rem;
    }
    
    .summary-value {
        font-size: 2rem;
    }
    
    /* Stack detail grid on smaller screens */
    .detail-grid-header {
        display: none;
    }
    
    .detail-grid-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 1rem;
        border: 1px solid #2a3547;
        border-radius: 6px;
        margin-bottom: 0.75rem;
    }
    
    .detail-cell {
        justify-content: flex-start !important;
    }
    
    .detail-cell::before {
        content: attr(data-label);
        font-weight: 600;
        color: #7c8ba1;
        margin-right: 0.5rem;
        min-width: 150px;
    }
    
    .detail-cell.gain-loss-cell > div {
        text-align: left;
    }
    
    .detail-cell.actions {
        justify-content: flex-start !important;
    }
}

@media (max-width: 768px) {
    .metals-watch {
        padding: 0.75rem;
    }
    
    .header {
        margin-bottom: 1.5rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .header-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .currency-selector {
        width: 100%;
        flex-wrap: wrap;
        overflow: visible;
    }
    
    .currency-selector select {
        flex: 1;
        min-width: 120px;
        max-width: 100%;
    }
    
    .exchange-rate-info {
        flex-basis: 100%;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #2a3547;
        padding-top: 0.5rem;
        margin-top: 0.5rem;
        white-space: normal;
        max-width: 100%;
    }
    
    .update-time {
        font-size: 0.85rem;
    }
    
    /* Portfolio Summary on Mobile */
    .valuation {
        padding: 1rem;
    }
    
    .valuation-summary {
        gap: 0.75rem;
    }
    
    .summary-card {
        padding: 1.25rem 1rem;
    }
    
    .summary-label {
        font-size: 0.8rem;
    }
    
    .summary-value {
        font-size: 1.75rem;
        margin-bottom: 0.5rem;
    }
    
    .summary-gain {
        font-size: 1rem;
    }
    
    /* Market Prices on Mobile */
    .market-pulse, .holdings {
        padding: 1rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    .refresh-info, .section-info {
        font-size: 0.8rem;
    }
    
    .prices-grid-header {
        display: none;
    }
    
    .prices-grid-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
    }
    
    .metal-name-cell {
        grid-column: 1;
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .price-cell {
        font-size: 1.25rem;
    }
    
    .change-cell {
        font-size: 1rem;
        text-align: left;
    }
    
    .ratio-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.75rem;
    }
    
    .ratio-value {
        font-size: 1.1rem;
    }
    
    /* Holdings on Mobile */
    .master-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
        padding: 0.75rem 1rem;
    }
    
    .master-title {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .metal-name {
        font-size: 1.1rem;
    }
    
    .master-summary {
        flex-basis: 100%;
        font-size: 0.85rem;
    }
    
    .master-actions {
        width: 100%;
    }
    
    .add-detail-btn {
        width: 100%;
        padding: 0.75rem;
    }
    
    .detail-grid-row {
        padding: 0.75rem;
        gap: 0.5rem;
    }
    
    .detail-input {
        font-size: 0.9rem;
        padding: 0.5rem;
    }
    
    .icon-delete-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1rem;
    }
    
    .empty-details {
        padding: 1.5rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .metals-watch {
        padding: 0.5rem;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .subtitle {
        font-size: 0.8rem;
    }
    
    .currency-selector {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        gap: 0.5rem;
    }
    
    .currency-selector label {
        font-size: 0.85rem;
    }
    
    .currency-selector select {
        font-size: 0.85rem;
        padding: 0.4rem 1.5rem 0.4rem 0.5rem;
        max-width: 100%;
    }
    
    .exchange-rate-info {
        font-size: 0.75rem;
        word-wrap: break-word;
    }
    
    .rate-date {
        display: block;
        margin-left: 0;
        margin-top: 0.25rem;
    }
    
    .market-pulse, .holdings, .valuation {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }
    
    h2 {
        font-size: 1rem;
        margin-bottom: 0.4rem;
    }
    
    .summary-card {
        padding: 1rem 0.75rem;
    }
    
    .summary-value {
        font-size: 1.5rem;
    }
    
    .summary-gain {
        font-size: 0.9rem;
    }
    
    .prices-grid-row {
        padding: 0.75rem;
    }
    
    .metal-name-cell {
        font-size: 0.95rem;
    }
    
    .metal-icon {
        font-size: 1.25rem;
    }
    
    .price-cell {
        font-size: 1.1rem;
    }
    
    .change-cell {
        font-size: 0.9rem;
    }
    
    .ratio-info {
        padding: 0.5rem 0.75rem;
    }
    
    .ratio-label, .ratio-value {
        font-size: 0.9rem;
    }
    
    .master-header {
        padding: 0.5rem 0.75rem;
    }
    
    .metal-name {
        font-size: 1rem;
    }
    
    .master-summary {
        font-size: 0.8rem;
    }
    
    .add-detail-btn {
        font-size: 0.85rem;
        padding: 0.6rem;
    }
    
    .detail-grid-row {
        padding: 0.5rem;
    }
    
    .detail-input {
        font-size: 0.85rem;
        padding: 0.45rem;
    }
    
    .value-amount {
        font-size: 0.9rem;
    }
    
    .totals-gain-loss {
        font-size: 0.85rem;
    }
    
    .totals-gain-loss .daily-change {
        font-size: 0.8rem;
    }
    
    .totals-gain-loss .daily-label {
        font-size: 0.7rem;
    }
}

@media (max-width: 360px) {
    .header h1 {
        font-size: 1.1rem;
    }
    
    .summary-value {
        font-size: 1.35rem;
    }
    
    .price-cell {
        font-size: 1rem;
    }
    
    .metal-name-cell {
        font-size: 0.9rem;
    }
}
