:root {
    --accent: #f5c518;
    --bg: #f7f8fa;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --header-bg: #111111;
    --hover: #fafafa;
    --radius: 10px;
}

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

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

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: var(--header-bg);
    color: #fff;
    padding: 2.5rem 0 2rem;
    text-align: center;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: #9ca3af;
    font-weight: 400;
}

/* Loading */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Error */
.error {
    background: #fef2f2;
    color: #991b1b;
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin: 2rem 0;
    font-size: 0.875rem;
    border: 1px solid #fecaca;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    margin: 2rem 0 0;
    border-bottom: 2px solid var(--border);
}

.tab {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: transparent;
    transition: background 0.2s;
}

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

.tab.active {
    color: var(--text);
    font-weight: 600;
}

.tab.active::after {
    background: var(--accent);
}

/* Table */
.table-container {
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--border);
    border-top: none;
}

.products-table {
    width: 100%;
    border-collapse: collapse;
}

.products-table thead {
    border-bottom: 1px solid var(--border);
}

.products-table th {
    padding: 0.75rem 1.25rem;
    text-align: left;
    font-weight: 500;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.products-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 2rem;
}

.products-table th.sortable:hover {
    color: var(--text);
}

.products-table th.sort-asc::after {
    content: '\2191';
    position: absolute;
    right: 0.75rem;
    color: var(--accent);
    font-weight: 700;
}

.products-table th.sort-desc::after {
    content: '\2193';
    position: absolute;
    right: 0.75rem;
    color: var(--accent);
    font-weight: 700;
}

.products-table th.col-price,
.products-table td.col-price {
    text-align: right;
}

.products-table th.col-updated,
.products-table td.col-updated {
    text-align: right;
}

.products-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.products-table tbody tr:last-child {
    border-bottom: none;
}

.products-table tbody tr:hover {
    background: var(--hover);
}

.products-table td {
    padding: 0.875rem 1.25rem;
    font-size: 0.9rem;
}

/* Product name link */
.product-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

.product-link:hover {
    color: #b8960e;
}

/* Price */
.price {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.no-data {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.85rem;
}

/* Updated time */
.time-ago {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.footer a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Back link */
.back-link {
    display: inline-block;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s;
}

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

/* Product detail header */
.product-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-top: 1.5rem;
}

.product-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nikon-link {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 500;
    transition: color 0.15s;
}

.nikon-link:hover {
    color: var(--accent);
}

/* Current price display */
.product-meta {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-top: 0.75rem;
}

.current-price {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.price-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Stats row */
.stats-row {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.stat {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Period selector */
.period-selector {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.period-btn {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.period-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

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

/* Chart */
.chart-container {
    margin-top: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    height: 350px;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .header {
        padding: 1.75rem 0 1.5rem;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .tab {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
    }

    .products-table th,
    .products-table td {
        padding: 0.75rem 0.75rem;
    }

    .products-table td {
        font-size: 0.85rem;
    }

    .col-updated {
        display: none;
    }

    .product-header {
        flex-direction: column;
        gap: 0.25rem;
    }

    .product-header h2 {
        font-size: 1.25rem;
    }

    .current-price {
        font-size: 1.5rem;
    }

    .stats-row {
        gap: 0.5rem;
    }

    .stat {
        padding: 0.75rem 0.5rem;
    }

    .stat-value {
        font-size: 0.875rem;
    }

    .chart-container {
        padding: 1rem;
        height: 280px;
    }
}
