/* ============================================
   gear.casa - Premium Storage Price Comparison
   ============================================ */

/* Custom Brand Colors & Design System */
:root {
    /* Brand Colors - Dark Mode */
    --bg-primary: #0a0e17;
    --bg-secondary: #141b2d;
    --bg-tertiary: #1e2740;
    --bg-hover: #2a3654;
    
    --text-primary: #e8edf5;
    --text-secondary: #a8b3cf;
    --text-tertiary: #6b7a99;
    
    --border-color: #2a3654;
    --border-hover: #3d4d6e;
    
    /* Brand Accent - Vibrant Blue/Purple Gradient */
    --accent-primary: #4a7cff;
    --accent-secondary: #7c3aed;
    --accent-gradient: linear-gradient(135deg, #4a7cff 0%, #7c3aed 100%);
    
    /* Status Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(74, 124, 255, 0.3);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* ---- Type scale (desktop-first per planning/ui-research.md) ----
       Roughly 1.2x ratio. Sizes are intentional anchors — every <p>,
       <h*>, <td>, .label etc. should pull from this scale and never
       a one-off pixel value. */
    --font-size-2xs:  11px;  /* uppercase chip labels, dense metadata        */
    --font-size-xs:   12px;  /* card meta, table chrome, secondary text      */
    --font-size-sm:   13px;  /* table body, dense rows, captions             */
    --font-size-base: 14px;  /* default UI text, form inputs, button label   */
    --font-size-md:   16px;  /* paragraph body in editorial surfaces         */
    --font-size-lg:   18px;  /* product names in cards, section titles       */
    --font-size-xl:   22px;  /* best-price values, top-of-detail price       */
    --font-size-2xl:  28px;  /* card hero, page title small                  */
    --font-size-3xl:  32px;  /* product hero title                           */
    --font-size-4xl:  48px;  /* landing-page hero — Linear scale             */
    --font-size-5xl:  64px;  /* reserved for the most marketing-y heroes     */

    --font-weight-regular: 400;
    --font-weight-medium:  500;
    --font-weight-semi:    600;
    --font-weight-bold:    700;

    --line-height-tight:  1.2;   /* large headlines                  */
    --line-height-normal: 1.4;   /* card titles, UI text             */
    --line-height-relaxed: 1.6;  /* paragraph body                   */

    --letter-spacing-tight:  -0.02em;  /* large headlines              */
    --letter-spacing-normal: 0;
    --letter-spacing-wide:   0.04em;   /* uppercase metadata labels    */

    /* ---- Spacing scale ---- 4px base unit. Use --space-N tokens for
       padding, margin, gap, etc. Stop inventing one-off values. */
    --space-0:   0;
    --space-1:   4px;   /* hairline gap, icon-to-text                 */
    --space-2:   8px;   /* tight gap                                  */
    --space-3:   12px;  /* dense cell padding                         */
    --space-4:   16px;  /* default card padding, default gap          */
    --space-5:   20px;  /* card padding (slightly roomier)            */
    --space-6:   24px;  /* section breathing                          */
    --space-8:   32px;  /* between major blocks                       */
    --space-10:  40px;  /* section separators                         */
    --space-12:  48px;  /* hero vertical                              */
    --space-16:  64px;  /* editorial-mode section gap                 */
    --space-20:  80px;  /* landing-page hero                          */

    /* ---- Density modes ----
       Two semantic spacing aliases that surfaces can switch between.
       Use these inside templates so the same components can render
       editorial-spacious OR dense-tabular without restyling. */
    --density-editorial-pad-x:  var(--space-6);
    --density-editorial-pad-y:  var(--space-8);
    --density-editorial-gap:    var(--space-6);

    --density-dense-pad-x:      var(--space-3);
    --density-dense-pad-y:      var(--space-2);
    --density-dense-gap:        var(--space-2);

    /* ---- Layout tokens ---- */
    --container-max:        1400px;
    --container-narrow-max: 900px;   /* editorial / reading width      */
    --content-gutter:       var(--space-4);

    /* ---- Z-index scale ---- single source of truth, no magic 999s. */
    --z-base:    1;
    --z-sticky:  100;
    --z-overlay: 500;
    --z-modal:   1000;
    --z-toast:   2000;
}

/* Light Mode Theme */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --shadow-glow: 0 0 20px rgba(74, 124, 255, 0.2);
}

/* ============================================
   Base Styles
   ============================================ */

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

html {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    scroll-behavior: smooth;
}

/* ---- Accessibility primitives ----
   Universal focus-visible ring + skip link. The browser default focus
   ring is inconsistent across user agents and lots of older code in
   this codebase used `outline: none` to suppress it (bad for keyboard
   users). The :focus-visible selector only triggers on keyboard
   navigation, so mouse clicks don't show the ring. Coupled with the
   skip link below, every page is now keyboard-traversable. */

*:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Skip-to-main-content link — invisible until the keyboard reaches it,
   then jumps focus past the top nav. Add `<main id="main-content">`
   (or `id="content"`) on each page to receive the target. */
.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    background: var(--accent-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    font-weight: var(--font-weight-semi);
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
    z-index: var(--z-toast);
}
.skip-link:focus-visible {
    transform: translateY(0);
}

/* Visually-hidden helper — content readable by screen readers but not
   rendered. Use for icon-only buttons where the icon is meaningful. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-4);
}

/* ============================================
   Top Navigation Bar
   ============================================ */

.top-nav {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 20px;
    background: var(--bg-secondary);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

/* Theme Toggle Button */
.theme-toggle {
    padding: 12px 24px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semi);
    transition: all var(--transition-base);
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 255, 0.1);
}

.theme-toggle:active {
    transform: scale(0.98);
}

/* Top-nav search input — appears between logo and theme toggle */
.nav-search {
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: stretch;
    gap: 0;
    margin: 0 12px;
}
.nav-search input[type="search"] {
    flex: 1;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    padding: 10px 14px;
    font-size: var(--font-size-base);
    min-width: 0;
}
.nav-search input[type="search"]::placeholder {
    color: var(--text-tertiary);
}
.nav-search input[type="search"]:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 255, 0.1);
    position: relative;
    z-index: 1;
}
.nav-search button {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 0 14px;
    font-size: var(--font-size-base);
    color: var(--text-primary);
    cursor: pointer;
}
.nav-search button:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}
/* Mobile: keep the search bar visible but shrink it so the logo +
   theme toggle still fit. Hiding it entirely loses the most-used CTA. */
@media (max-width: 720px) {
    .nav-search { max-width: none; margin: 0 var(--space-2); }
    .nav-search input[type="search"] {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-sm);
    }
    /* Drop the "gear.casa" wordmark next to the logo on narrow screens;
       the logo image alone is enough brand recall and frees ~120px. */
    .site-title { display: none; }
    .top-nav { padding: var(--space-2); gap: var(--space-2); }
    .nav-admin-link,
    .theme-toggle {
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-size-xs);
    }
}

.nav-admin-link {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semi);
    white-space: nowrap;
}
.nav-admin-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   Hero Section - Premium Branding
   ============================================ */

.hero {
    text-align: center;
    padding: 32px 20px 24px;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background: var(--accent-gradient);
    opacity: 0.06;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.hero h1 {
    font-size: var(--font-size-4xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.5px;
    position: relative;
    animation: fadeInUp 0.6s ease-out;
    text-shadow: 0 2px 20px rgba(74, 124, 255, 0.3);
}

.hero p {
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
    position: relative;
    animation: fadeInUp 0.6s ease-out 0.1s backwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Header - Category Pages
   ============================================ */

header {
    margin-bottom: var(--space-5);
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

header:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-hover);
}

header h1 {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin-bottom: var(--space-1);
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
}

/* ============================================
   Category Grid - Premium Cards
   ============================================ */

.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-6);
}

.category-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    color: var(--text-primary);
    display: block;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.category-card:hover::before {
    opacity: 1;
}

.category-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: var(--accent-primary);
}

.category-card h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
    letter-spacing: -0.3px;
    transition: color var(--transition-base);
}

.category-card:hover h2 {
    color: var(--accent-secondary);
}

.category-card p {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    margin-bottom: var(--space-3);
}

.category-stats {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.stat-label {
    color: var(--text-tertiary);
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-semi);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    color: var(--text-primary);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
}

/* ============================================
   Filters - Premium Dropdown Design
   ============================================ */

.filters {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-group label {
    font-weight: var(--font-weight-semi);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dropdown Filter Styles */
.filter-dropdown {
    position: relative;
}

.filter-dropdown-button {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
}

.filter-dropdown-button:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 255, 0.1);
}

.filter-dropdown-button .arrow {
    transition: transform var(--transition-base);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.filter-dropdown-button.open .arrow {
    transform: rotate(180deg);
    color: var(--accent-primary);
}

.filter-dropdown-button .selected-count {
    background: var(--accent-gradient);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    margin-left: var(--space-2);
    box-shadow: 0 2px 8px rgba(74, 124, 255, 0.3);
}

.checkbox-group {
    display: none;
    flex-direction: column;
    gap: 2px;
    max-height: 280px;
    overflow-y: auto;
    padding: var(--space-2);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
    margin-top: -1px;
}

.checkbox-group.open {
    display: flex;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.checkbox-item:hover {
    background: var(--bg-hover);
}

.checkbox-item input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--accent-primary);
}

.checkbox-item label {
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    flex: 1;
    user-select: none;
}

/* Number Input Styles */
.filter-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-medium);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.filter-group input[type="number"]:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 255, 0.1);
}

/* Button Styles */
.btn-primary,
.btn-secondary {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semi);
    cursor: pointer;
    transition: all var(--transition-base);
    letter-spacing: 0.3px;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(74, 124, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 124, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

/* ============================================
   Table - Premium Data Display
   ============================================ */

.loading {
    text-align: center;
    padding: 60px 20px;
    font-size: var(--font-size-md);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium);
}

.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1) 0%, rgba(239, 68, 68, 0.05) 100%);
    color: var(--error);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: var(--font-weight-medium);
}

.record-count {
    margin-bottom: var(--space-4);
    font-weight: var(--font-weight-semi);
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

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

thead {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

th {
    padding: 10px 12px;
    text-align: left;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
    position: relative;
    min-width: 100px;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background var(--transition-fast);
}

th.sortable:hover {
    background: var(--bg-hover);
}

th.resizing {
    user-select: none;
}

/* Column Resizer */
.column-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    z-index: 10;
    transition: background var(--transition-fast);
}

.column-resizer:hover,
.column-resizer.resizing {
    background: var(--accent-primary);
}

.sort-indicator {
    display: inline-block;
    margin-left: 6px;
    font-size: var(--font-size-2xs);
    color: var(--accent-primary);
}

th.sort-asc .sort-indicator::after {
    content: '▲';
}

th.sort-desc .sort-indicator::after {
    content: '▼';
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

td {
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-validated {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.1) 100%);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-unvalidated {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-incomplete {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.2) 0%, rgba(239, 68, 68, 0.1) 100%);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.condition-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.condition-new {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.1) 100%);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.condition-used {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.1) 100%);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.amazon-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: var(--font-weight-semi);
    transition: all var(--transition-fast);
    position: relative;
}

.amazon-link::after {
    content: '→';
    margin-left: var(--space-1);
    transition: transform var(--transition-fast);
    display: inline-block;
}

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

.amazon-link:hover::after {
    transform: translateX(4px);
}

/* Amazon Icon Link - First Column */
.amazon-cell {
    text-align: center;
    width: 45px;
    padding: 8px 6px !important;
}

.amazon-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    font-size: var(--font-size-lg);
    text-decoration: none;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
    cursor: pointer;
}

.amazon-icon-link:hover {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-glow);
}

.amazon-icon-link:active {
    transform: scale(0.95);
}

th[data-field="amazonUrl"] {
    width: 45px;
    min-width: 45px;
    text-align: center;
    padding: 8px 6px !important;
}

/* ============================================
   Sidebar Layout
   ============================================ */

/* Sidebar Toggle Button */
.sidebar-toggle {
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    padding: 12px 20px;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semi);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(74, 124, 255, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.sidebar-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 124, 255, 0.4);
}

.sidebar-toggle:active {
    transform: translateY(0);
}

.sidebar-toggle .hamburger {
    font-size: var(--font-size-lg);
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 380px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    position: sticky;
    top: 0;
    z-index: 10;
}

.sidebar-header h2 {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin: 0;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: var(--font-size-2xl);
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.sidebar-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-content {
    padding: 0;
}

.sidebar-section {
    border-bottom: 1px solid var(--border-color);
    padding: var(--space-6);
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.main-content {
    transition: margin-left var(--transition-base);
}

.main-content.sidebar-open {
    margin-left: 380px;
}

/* ============================================
   Column Manager (in Sidebar)
   ============================================ */

.column-manager-hint {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin: 0 0 16px 0;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.column-list {
    max-height: none;
    overflow-y: visible;
}

.column-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    cursor: move;
    transition: all var(--transition-fast);
    user-select: none;
}

.column-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.column-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.column-item.drag-over {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(74, 124, 255, 0.1);
}

.drag-handle {
    color: var(--text-tertiary);
    font-size: var(--font-size-lg);
    cursor: grab;
    flex-shrink: 0;
}

.drag-handle:active {
    cursor: grabbing;
}

.column-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent-primary);
    flex-shrink: 0;
}

.column-item label {
    flex: 1;
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.column-item.disabled {
    opacity: 0.5;
}

.column-item.disabled label {
    color: var(--text-tertiary);
}

.column-manager-actions {
    margin-top: var(--space-5);
    display: flex;
    justify-content: center;
}

.column-manager-actions .btn-secondary {
    width: 100%;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (min-width: 1200px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 100%;
        max-width: 380px;
    }
    
    .main-content.sidebar-open {
        margin-left: 0;
    }
}

@media (max-width: 767px) {
    .hero h1 {
        font-size: var(--font-size-4xl);
    }
    
    .hero p {
        font-size: var(--font-size-md);
    }
    
    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .top-nav {
        padding: 10px 12px;
        gap: var(--space-2);
    }
    
    .sidebar-toggle {
        padding: 10px 16px;
        font-size: var(--font-size-sm);
    }
    
    .sidebar-toggle .label {
        display: none;
    }
    
    .theme-toggle {
        padding: 10px 16px;
        font-size: var(--font-size-sm);
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: var(--font-size-sm);
        min-width: 600px;
    }

    th, td {
        padding: 12px 16px;
    }
    
    header h1 {
        font-size: var(--font-size-2xl);
    }
    
    .subtitle {
        font-size: var(--font-size-base);
    }
    
    .category-card {
        padding: var(--space-6);
    }
}

/* ============================================
   Scrollbar Styling
   ============================================ */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============================================
   UI component primitives — Phase 2c
   ============================================
   Every component below is namespaced .ui-* and pulls only from the
   design tokens defined in :root. New surfaces should use these
   classes instead of inventing new component CSS in EJS templates.

   Convention: base class + optional modifier (.ui-btn + .ui-btn-primary).
   Variants compose; they don't override colors with !important.

   See planning/design-system.md for when to use which component. */

/* ---- Card -------------------------------------------------------- */

.ui-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    color: var(--text-primary);
}
.ui-card-dense {
    padding: var(--space-3);
}
.ui-card-editorial {
    padding: var(--space-8);
}
.ui-card-clickable {
    transition: border-color var(--transition-fast), transform var(--transition-fast);
    cursor: pointer;
}
.ui-card-clickable:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}
.ui-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.ui-card-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semi);
    margin: 0;
    line-height: var(--line-height-normal);
}
.ui-card-meta {
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
    margin: var(--space-1) 0 0;
}

/* ---- Badge (colored brand pill, e.g. retailer labels) ------------ */

.ui-badge {
    display: inline-block;
    padding: 3px var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semi);
    line-height: 1.4;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    white-space: nowrap;
}
.ui-badge-success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.4);
}
.ui-badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.4);
}
.ui-badge-error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--error);
    border-color: rgba(239, 68, 68, 0.4);
}
.ui-badge-accent {
    background: rgba(74, 124, 255, 0.15);
    color: var(--accent-primary);
    border-color: rgba(74, 124, 255, 0.4);
}

/* ---- Pill (small inline label) ----------------------------------- */

.ui-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border-radius: 999px;
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-semi);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* ---- Chip (active-filter chip with remove link) ------------------ */

.ui-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    text-decoration: none;
    transition: border-color var(--transition-fast);
}
.ui-chip:hover {
    border-color: var(--accent-primary);
}
.ui-chip-x {
    color: var(--text-tertiary);
    font-size: var(--font-size-base);
    line-height: 1;
}

/* ---- Stat (label + big value pair, e.g. price + per-unit) -------- */

.ui-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ui-stat-label {
    font-size: var(--font-size-2xs);
    font-weight: var(--font-weight-semi);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing-wide);
    color: var(--text-tertiary);
}
.ui-stat-value {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--text-primary);
    line-height: var(--line-height-tight);
}
.ui-stat-value-accent {
    color: var(--accent-primary);
}
.ui-stat-meta {
    font-size: var(--font-size-2xs);
    color: var(--text-tertiary);
    margin-top: 2px;
}
.ui-stat-hero .ui-stat-value {
    font-size: var(--font-size-3xl);
}
.ui-stat-mini .ui-stat-value {
    font-size: var(--font-size-lg);
}

/* ---- Empty state (zero-results / placeholder) -------------------- */

.ui-empty {
    text-align: center;
    padding: var(--space-12) var(--space-5);
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
}
.ui-empty-icon {
    font-size: var(--font-size-4xl);
    color: var(--text-tertiary);
    margin-bottom: var(--space-4);
}
.ui-empty-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semi);
    color: var(--text-primary);
    margin: 0 0 var(--space-2);
}
.ui-empty-message {
    font-size: var(--font-size-base);
    color: var(--text-secondary);
    margin: 0;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Button -------------------------------------------------------- */
/* Different from the legacy .theme-toggle; use .ui-btn for new code. */

.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semi);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast);
    white-space: nowrap;
}
.ui-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}
.ui-btn:disabled,
.ui-btn[aria-disabled="true"] {
    opacity: 0.55;
    cursor: not-allowed;
}
.ui-btn-primary {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}
.ui-btn-primary:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    opacity: 0.9;
}
.ui-btn-secondary {
    /* Default ui-btn styles already cover this. Kept for explicit usage. */
}
.ui-btn-ghost {
    background: transparent;
    border-color: transparent;
}
.ui-btn-ghost:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}
.ui-btn-sm {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
}
.ui-btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-md);
}

/* ---- Tooltip (CSS-only hover with native <title>-style positioning) */

.ui-tooltip {
    position: relative;
    display: inline-flex;
}
.ui-tooltip[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + var(--space-2));
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    z-index: var(--z-overlay);
}
.ui-tooltip:hover[data-tooltip]::after {
    opacity: 1;
}

/* ---- Loading skeleton (shimmer placeholder for async data) -------- */

.ui-skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0%,
        var(--bg-hover) 50%,
        var(--bg-tertiary) 100%
    );
    background-size: 200% 100%;
    animation: ui-skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
    color: transparent;
}
.ui-skeleton-text {
    height: 1em;
    width: 100%;
}
.ui-skeleton-block {
    height: 80px;
    width: 100%;
}
@keyframes ui-skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Section header (for detail page + category page sections) --- */

.ui-section-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semi);
    color: var(--text-primary);
    margin: 0 0 var(--space-4);
}
.ui-section-count {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: var(--font-size-xs);
    padding: 2px var(--space-2);
    border-radius: 999px;
    font-weight: var(--font-weight-regular);
}
.ui-section-note {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
    margin: 0 0 var(--space-3);
}

/* ---- Top-nav primitives (shared across every page) --------------- */

.logo-section {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    text-decoration: none;
    color: inherit;
}
.nav-logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
}
.site-title {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

