:root {
    --brand: #F9C22B;
    --brand-dark: #E8B01A;
    --accent: #E3000B;
    --bg: #0D1117;
    --surface: #161B22;
    --surface-raised: #21262D;
    --border: #30363D;
    --text: #E6EDF3;
    --text-muted: #7D8590;
    --success: #3FB950;
    --danger: #F85149;
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --nav-height: 60px;
    --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── Layout ── */

.layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── Navbar ── */

.navbar {
    height: var(--nav-height);
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--brand);
    letter-spacing: -0.3px;
    flex-shrink: 0;
}

.navbar-brand::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    background-color: var(--accent);
    border-radius: 50%;
}

.navbar-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    flex: 1;
}

.navbar-menu a {
    display: block;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.15s, background-color 0.15s;
}

.navbar-menu a:hover {
    color: var(--text);
    background-color: var(--surface-raised);
    text-decoration: none;
}

.navbar-menu a.active {
    color: var(--brand);
    background-color: rgba(249, 194, 43, 0.1);
}

/* ── Footer ── */

.footer {
    border-top: 1px solid var(--border);
    padding: 16px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ── Page header ── */

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-muted);
    font-size: 13px;
}

/* ── Stats bar ── */

.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-chip {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-muted);
}

.stat-chip strong {
    color: var(--text);
    font-weight: 600;
}

/* ── Table ── */

.table-wrapper {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background-color: var(--surface);
}

.discounts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.discounts-table thead {
    background-color: var(--surface-raised);
    border-bottom: 1px solid var(--border);
}

.discounts-table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.discounts-table th.col-right,
.discounts-table td.col-right {
    text-align: right;
}

.discounts-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.discounts-table tbody tr:last-child td {
    border-bottom: none;
}

.discounts-table tbody tr:hover {
    background-color: var(--surface-raised);
}

.discounts-table tbody tr.at-lowest {
    background-color: rgba(63, 185, 80, 0.05);
}

.discounts-table tbody tr.at-lowest:hover {
    background-color: rgba(63, 185, 80, 0.1);
}

/* ── Table cells ── */

.cell-number {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.cell-name {
    font-weight: 500;
    color: var(--text);
    max-width: 280px;
}

.cell-retailer {
    white-space: nowrap;
}

.retailer-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
    background-color: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.cell-price {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text);
}

.cell-price.current {
    font-weight: 600;
    color: var(--brand);
}

.cell-discount {
    white-space: nowrap;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.discount-high {
    color: var(--success);
}

.discount-mid {
    color: var(--brand);
}

.discount-low {
    color: var(--text-muted);
}

.lowest-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    background-color: rgba(63, 185, 80, 0.15);
    color: var(--success);
    border: 1px solid rgba(63, 185, 80, 0.3);
    white-space: nowrap;
}

.cell-time {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* ── Loading state ── */

.app-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 16px;
    color: var(--text-muted);
}

.app-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    gap: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Empty / error states ── */

.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}

.error-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--danger);
}

/* ── Search form ── */

.search-form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.search-input {
    padding: 9px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    width: 220px;
    transition: border-color 0.15s;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    padding: 9px 20px;
    border-radius: var(--radius);
    border: none;
    background-color: var(--brand);
    color: #1A1A1A;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s;
    white-space: nowrap;
}

.btn-primary:hover {
    background-color: var(--brand-dark);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Set detail ── */

.set-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

.set-title span {
    color: var(--brand);
}

.section-heading {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* ── Chart ── */

.chart-wrapper {
    margin-top: 32px;
}

.chart-container {
    position: relative;
    height: 380px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 12px;
}

/* ── Blazor error UI ── */

#blazor-error-ui {
    background: var(--accent);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 12px 20px;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 14px;
    color: #fff;
    display: none;
}

#blazor-error-ui .reload {
    color: #fff;
    font-weight: 600;
    margin: 0 8px;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .main-content {
        padding: 20px 16px;
    }

    .cell-name {
        max-width: 160px;
    }

    .discounts-table th,
    .discounts-table td {
        padding: 8px 10px;
    }

    .stats-bar {
        gap: 10px;
    }
}
