/* ============================================
   MeatScanner Dark Theme - Design System
   ============================================ */

/* --- Google Fonts --- */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css');
@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;600;700&display=swap');

/* --- Design Tokens (Light Theme - Stitch) --- */
:root {
    /* Background */
    --bg-primary: #F7F9FB;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F2F4F6;

    /* Text */
    --text-primary: #191C1E;
    --text-secondary: #45464E;
    --text-muted: #75777F;

    /* Semantic */
    --success: #006A61;
    --danger: #BA1A1A;
    --warning: #B45309;
    --info: #1D4ED8;
    --gold: #B45309;

    /* Grade Colors */
    --grade-1pp: #B45309;
    --grade-1p: #006A61;
    --grade-1: #1D4ED8;
    --grade-2: #B45309;
    --grade-3: #75777F;

    /* Site Colors */
    --site-ekcm: #C0392B;
    --site-meatbox: #006A61;
    --site-nhlyvly: #1D4ED8;
    --site-minsok: #2D6A4F;
    --site-hanwooda: #C0392B;
    --site-ilpoomhanwoo: #5B21B6;

    /* Border & Shadow */
    --border-subtle: rgba(0, 0, 0, 0.06);
    --border-light: rgba(0, 0, 0, 0.10);
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);

    /* Fonts */
    --font-body: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Roboto Mono', monospace;

    /* Sizing */
    --header-height: 56px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 9999px;

    /* Extended Palette */
    --bg-deepest: #ECEEF0;
    --teal: #006A61;
    --purple: #5B21B6;

    /* Spacing (4px base scale) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Spacing aliases */
    --gap-sm: 8px;
    --gap-md: 12px;
    --gap-lg: 16px;
    --gap-xl: 24px;

    /* Grade Gradient Colors */
    --grade-1pp-gradient: linear-gradient(135deg, #FFD700, #FFA500);
    --grade-1p-gradient: linear-gradient(135deg, #A855F7, #7C3AED);
    --grade-1-gradient: linear-gradient(135deg, #3B82F6, #2563EB);
    --grade-2-gradient: linear-gradient(135deg, #22C55E, #16A34A);
    --grade-3-gradient: linear-gradient(135deg, #94A3B8, #64748B);

    /* Grade flat colors for text */
    --grade-1pp-color: #FFD700;
    --grade-1p-color: #A855F7;
    --grade-1-color: #3B82F6;
    --grade-2-color: #22C55E;
    --grade-3-color: #94A3B8;
}

/* --- Accessibility: Skip Link --- */
.ms-skip-link {
    position: absolute;
    top: -100px;
    left: 16px;
    background: var(--info);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    z-index: 9999;
    transition: top 0.2s;
}
.ms-skip-link:focus {
    top: 8px;
    color: #fff;
}

/* --- Accessibility: Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Reset & Base --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
}

a { color: var(--info); text-decoration: none; }
a:hover { color: #1E40AF; }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Sidebar Layout (Stitch) --- */
.ms-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 220px;
    background: #1B2A4A;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 1000;
    overflow-y: auto;
}

.ms-sidebar-logo { margin-bottom: 40px; }
.ms-sidebar-logo h1 { font-size: 20px; font-weight: 900; color: #fff; letter-spacing: -0.04em; }
.ms-sidebar-logo p { font-size: 11px; color: rgba(131,146,183,0.7); margin-top: 2px; }

.ms-sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.ms-sidebar-nav a,
.ms-sidebar-nav .ms-sidebar-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 4px;
    color: #94A3B8; font-size: 14px; font-weight: 500;
    text-decoration: none; cursor: pointer;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}
.ms-sidebar-nav a:hover,
.ms-sidebar-nav .ms-sidebar-item:hover { color: #fff; background: rgba(0,106,97,0.2); }
.ms-sidebar-nav a.active,
.ms-sidebar-nav .ms-sidebar-item.active { background: #006A61; color: #fff; font-weight: 700; }

.ms-sidebar-section {
    padding: 16px 12px 8px;
    font-size: 11px; font-weight: 700;
    color: #64748B; text-transform: uppercase; letter-spacing: 0.1em;
}
.ms-sidebar-footer {
    margin-top: auto; padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.ms-sidebar-icon { font-size: 20px; flex-shrink: 0; }

/* --- Main Content (with sidebar offset) --- */
.ms-main {
    flex: 1;
    margin-left: 220px;
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

/* Top app bar (page header) */
.ms-topbar {
    position: sticky; top: 0; z-index: 40;
    background: #F7F9FB;
    border-bottom: 1px solid var(--border-light);
    display: flex; justify-content: space-between; align-items: center;
    height: 64px; padding: 0 32px;
}
.ms-topbar-title { font-size: 18px; font-weight: 700; color: #1B2A4A; }
.ms-topbar-sub { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.ms-content {
    padding: 32px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
}

.ms-container {
    max-width: 1600px;
    margin: 0 auto;
}

/* Legacy header (hidden - replaced by sidebar) */
.ms-header { display: none; }

.ms-header-logo {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 32px;
    white-space: nowrap;
}

.ms-header-nav {
    display: flex;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    flex: 1;
}

.ms-header-nav a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 0.2s, background-color 0.2s;
    display: inline-flex;
    align-items: center;
    position: relative;
}

.ms-header-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.ms-header-nav a.active {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
    position: relative;
}

/* Active indicator bar */
.ms-header-nav > a.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--success);
    border-radius: 1px;
}

/* Navigation inline icons */
.ms-nav-icon {
    width: 16px;
    height: 16px;
    vertical-align: -2px;
    margin-right: 4px;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

/* Navigation Dropdown */
.ms-nav-dropdown {
    position: relative;
}

.ms-nav-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 0.2s, background 0.2s;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
}

.ms-nav-dropdown-trigger:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.ms-nav-dropdown-trigger.active {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.ms-nav-chevron {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}

.ms-nav-dropdown.open .ms-nav-chevron {
    transform: rotate(180deg);
}

.ms-nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    padding: 4px;
    z-index: 1100;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.ms-nav-dropdown.open .ms-nav-dropdown-menu {
    display: block;
}

.ms-nav-dropdown-menu a {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.ms-nav-dropdown-menu a:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.ms-nav-dropdown-menu a.active {
    color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.ms-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Hamburger menu (mobile) */
.ms-hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* --- Card --- */
.ms-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--card-shadow);
    margin-bottom: 24px;
}

.ms-card h2,
.ms-card h3 {
    color: var(--text-primary);
    margin-bottom: 16px;
}

.ms-card h2 { font-size: 18px; font-weight: 600; }
.ms-card h3 { font-size: 16px; font-weight: 600; }

/* --- KPI Card --- */
.ms-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.ms-kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.ms-kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.ms-kpi-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.ms-kpi-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* --- Section --- */
.ms-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.ms-section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* --- Navigation Buttons --- */
.ms-nav-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.ms-nav-btn {
    display: block;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    text-align: center;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: var(--card-shadow);
}

.ms-nav-btn:hover {
    border-color: var(--success);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
    color: var(--text-primary);
}

.ms-nav-btn small {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    margin-top: 6px;
}

/* --- Table --- */
.ms-table {
    width: 100%;
    border-collapse: collapse;
}

.ms-table thead {
    background: var(--bg-tertiary);
}

.ms-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-light);
}

.ms-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
    color: var(--text-secondary);
}

.ms-table tr:hover td {
    background: rgba(255, 255, 255, 0.04);
}

.ms-table tbody tr {
    transition: background 0.2s ease;
}

.ms-table .mono {
    font-family: var(--font-mono);
}

/* --- Badges --- */
.ms-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.ms-badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.ms-badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.ms-badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.ms-badge-info { background: rgba(59, 130, 246, 0.15); color: var(--info); }
.ms-badge-gold { background: rgba(255, 215, 0, 0.15); color: var(--gold); }

/* --- Buttons --- */
.ms-btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: var(--font-body);
}

.ms-btn-primary {
    background: var(--success);
    color: #fff;
}
.ms-btn-primary:hover {
    background: #16A34A;
    color: #fff;
}

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

.ms-btn-danger {
    background: var(--danger);
    color: #fff;
}
.ms-btn-danger:hover { background: #DC2626; }

.ms-btn-info {
    background: var(--info);
    color: #fff;
}
.ms-btn-info:hover { background: #2563EB; }

/* --- Forms --- */
.ms-select,
.ms-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-body);
    transition: border-color 0.2s;
}

.ms-select:focus,
.ms-input:focus {
    outline: none;
    border-color: var(--info);
}

.ms-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.ms-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* --- Sites Grid (Stitch: 4-col) --- */
.ms-sites-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.ms-site-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.ms-site-card:hover { transform: translateY(-3px); }

/* --- Card Collapsible Details (Phase 4) --- */
.ms-card-details-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    padding: 6px 0;
    margin-top: 4px;
    background: none;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-body);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.ms-card-details-toggle:hover {
    color: var(--text-secondary);
    border-color: var(--border-light);
    background: rgba(255,255,255,0.02);
}
.ms-card-details-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}
.ms-card-details-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}
.ms-card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.ms-card-details.open {
    max-height: 500px;
}

/* --- Stat Items --- */
.ms-stat-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.ms-stat-item {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-md);
}

.ms-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
}

.ms-stat-value {
    font-family: var(--font-mono);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Grade Items --- */
.ms-grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.ms-grade-item {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--info);
}

/* --- Freshness Badge --- */
.ms-freshness {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.ms-freshness.good { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.ms-freshness.warn { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.ms-freshness.error { background: rgba(239, 68, 68, 0.15); color: var(--danger); }

/* --- Loading --- */
.ms-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 16px;
}

/* --- Period Buttons --- */
.ms-period-btns {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.ms-period-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-family: var(--font-body);
    transition: all 0.2s;
}

.ms-period-btn.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
    border-color: var(--info);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3), inset 0 0 12px rgba(59, 130, 246, 0.1);
}

.ms-period-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* --- Two Column Grid --- */
.ms-two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* --- Filter Grid --- */
.ms-filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* --- Rank --- */
.ms-rank { font-weight: 700; font-size: 18px; color: var(--text-muted); }
.ms-rank-1 { color: var(--gold) !important; }
.ms-rank-2 { color: #C0C0C0 !important; }
.ms-rank-3 { color: #CD7F32 !important; }

/* --- Weekend row --- */
.ms-weekend { background: rgba(239, 68, 68, 0.05); }
.ms-weekend td:first-child { color: var(--danger); }

/* --- Color utility --- */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info { color: var(--info) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-gold { color: var(--gold) !important; }

.font-mono { font-family: var(--font-mono) !important; }

/* --- Touch Optimization (Global) --- */
@media (pointer: coarse) {
    * { -webkit-tap-highlight-color: transparent; }
}

.ms-hamburger {
    min-width: 44px;
    min-height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
}

.ms-btn,
.ms-period-btn,
.ms-select,
.ms-input,
.filter-btn,
.reset-btn,
.tab-btn {
    min-height: 44px;
}

/* --- Table wrapper for horizontal scroll --- */
.ms-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- Responsive: 1440px (Large Desktop) --- */
@media (max-width: 1440px) {
    .ms-content {
        max-width: 1400px;
    }
    .ms-sites-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

/* --- Responsive: 1024px (Small Desktop / Landscape Tablet) --- */
@media (max-width: 1024px) {
    .ms-content {
        max-width: 100%;
        padding: calc(var(--header-height) + 16px) 16px 16px;
    }
    .ms-kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .ms-sites-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .ms-two-col-grid {
        gap: 16px;
    }
    .ms-hotdeal-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
}

/* --- Responsive: 768px (Tablet) --- */
@media (max-width: 768px) {
    .ms-content {
        padding: calc(var(--header-height) + 12px) 12px 12px;
    }

    .ms-header {
        padding: 0 12px;
    }

    .ms-header-nav {
        display: none;
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background: var(--bg-secondary);
        flex-direction: column;
        padding: 12px;
        border-bottom: 1px solid var(--border-subtle);
        gap: 2px;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .ms-header-nav.open {
        display: flex;
        max-height: 500px;
    }

    .ms-header-nav a {
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Mobile dropdown: inline instead of absolute */
    .ms-nav-dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: rgba(255,255,255,0.03);
        padding: 0 0 0 16px;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .ms-nav-dropdown-trigger {
        padding: 12px 14px;
        font-size: 14px;
        width: 100%;
        justify-content: flex-start;
    }

    .ms-hamburger {
        display: flex;
    }

    /* Card / Section padding reduction */
    .ms-card,
    .ms-section,
    .ms-site-card {
        padding: 16px;
        margin-bottom: 16px;
    }

    .ms-kpi-card {
        padding: 14px;
    }

    /* Grid overrides */
    .ms-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .ms-sites-grid {
        grid-template-columns: 1fr;
    }

    .ms-stat-row {
        grid-template-columns: 1fr;
    }

    .ms-grade-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .ms-filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .ms-hotdeal-grid {
        grid-template-columns: 1fr;
    }

    .ms-nav-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .ms-kpi-value {
        font-size: 22px;
    }

    /* Period buttons wrap */
    .ms-period-btns {
        flex-wrap: wrap;
    }

    /* Table cell padding reduction */
    .ms-table th,
    .ms-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    /* Chart container padding */
    .ms-chart-container {
        padding: 12px;
    }

    /* Image status grid */
    .ms-image-status-grid {
        grid-template-columns: 1fr !important;
    }

    /* Two column grid → 1 column */
    .ms-two-col-grid {
        grid-template-columns: 1fr !important;
    }

    /* Table scroll hint */
    .ms-table-wrapper {
        position: relative;
    }
    .ms-table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 24px;
        background: linear-gradient(to right, transparent, var(--bg-secondary));
        pointer-events: none;
        opacity: 0.8;
    }

    /* KPI compact on tablet */
    .ms-kpi-card {
        padding: 14px;
    }
    .ms-kpi-value {
        font-size: 22px;
    }
    .ms-kpi-sub {
        font-size: 11px;
    }
}

/* --- Responsive: 480px (Mobile) --- */
@media (max-width: 480px) {
    .ms-kpi-grid {
        grid-template-columns: 1fr;
    }

    .ms-grade-grid,
    .ms-filter-grid,
    .ms-nav-grid {
        grid-template-columns: 1fr;
    }

    .ms-card,
    .ms-section,
    .ms-site-card {
        padding: 12px;
        margin-bottom: 12px;
    }

    .ms-kpi-card {
        padding: 12px;
    }

    .ms-kpi-value {
        font-size: 18px;
    }

    .ms-stat-value {
        font-size: 16px;
    }

    .ms-kpi-label {
        font-size: 10px;
    }

    /* Period buttons stack */
    .ms-period-btns {
        flex-direction: column;
    }

    .ms-period-btn {
        flex: none;
    }

    .ms-nav-btn {
        padding: 14px;
        font-size: 14px;
    }

    /* Header */
    .ms-header-logo {
        font-size: 14px;
        margin-right: 8px;
    }

    .ms-header-logo img {
        height: 22px !important;
    }
}

/* ============================================
   Extended Design System
   ============================================ */

/* --- Glassmorphism --- */
.ms-card,
.ms-kpi-card,
.ms-section,
.ms-site-card {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* --- Card Hover Enhancement --- */
.ms-card:hover,
.ms-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.ms-site-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border-color: var(--border-light);
}

/* --- Focus Ring --- */
.ms-btn:focus-visible,
.ms-select:focus-visible,
.ms-input:focus-visible,
.ms-card-details-toggle:focus-visible,
.ms-period-btn:focus-visible,
.ms-nav-dropdown-trigger:focus-visible,
.ms-hamburger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--info);
}

a:focus-visible {
    outline: 2px solid var(--info);
    outline-offset: 2px;
    border-radius: 2px;
}

/* --- Skeleton Loading (Shimmer) --- */
@keyframes ms-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.ms-skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: ms-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

.ms-skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    width: 80%;
}

.ms-skeleton-value {
    height: 28px;
    width: 60%;
}

/* --- Real-time Flash --- */
@keyframes flash-new {
    0% { background-color: rgba(34, 197, 94, 0.3); }
    100% { background-color: transparent; }
}

.ms-flash-new {
    animation: flash-new 2s ease-out;
}

/* --- Pulse Dot --- */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

@keyframes pulse-dot-ring {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(2.2); opacity: 0; }
}

.ms-pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse-dot 2s ease-in-out infinite;
    margin-right: 6px;
    position: relative;
}

.ms-pulse-dot::before {
    content: '';
    position: absolute;
    top: -3px;
    left: -3px;
    width: 14px;
    height: 14px;
    background: rgba(34, 197, 94, 0.4);
    border-radius: 50%;
    animation: pulse-dot-ring 2s ease-out infinite;
}

/* --- Hot Deal Widget --- */
.ms-hotdeal-widget {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    border-left: 3px solid var(--danger);
    padding: 20px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
}

.ms-hotdeal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.ms-hotdeal-title {
    margin: 0;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.ms-hotdeal-time {
    font-size: 12px;
    color: var(--text-muted);
}

.ms-hotdeal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.ms-hotdeal-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.ms-hotdeal-card {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    transition: transform 0.2s;
}

.ms-hotdeal-card:hover {
    transform: translateY(-2px);
}

.ms-hotdeal-badge {
    font-size: 11px;
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.ms-hotdeal-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.4;
    max-height: 42px;
    overflow: hidden;
}

.ms-hotdeal-price-old {
    color: var(--text-muted);
    font-size: 12px;
    text-decoration: line-through;
}

.ms-hotdeal-price-new {
    color: var(--danger);
    font-size: 16px;
    font-weight: bold;
    font-family: var(--font-mono);
    margin-left: 8px;
}

/* --- Grade Badges --- */
.ms-grade-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.ms-grade-1pp {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #000;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.5);
}

.ms-grade-1p {
    background: linear-gradient(135deg, #A855F7, #7C3AED);
    color: #fff;
}

.ms-grade-1 {
    background: linear-gradient(135deg, #3B82F6, #2563EB);
    color: #fff;
}

.ms-grade-2 {
    background: linear-gradient(135deg, #22C55E, #16A34A);
    color: #fff;
}

.ms-grade-3 {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-muted);
}

/* --- Chart Container --- */
.ms-chart-container {
    background: var(--bg-tertiary);
    padding: 20px;
    border-radius: var(--radius-md);
}

.ms-chart-desc {
    color: var(--text-muted);
    margin-bottom: 16px;
    font-size: 14px;
}

/* --- Vendor Link Area --- */
.ms-vendor-link-area {
    text-align: center;
    padding: 40px 20px;
}

/* --- Pill Button Variant --- */
.ms-btn-pill {
    border-radius: var(--radius-pill);
    padding: 8px 20px;
}

/* --- Table Utilities --- */
.ms-th-rank { width: 60px; }
.ms-th-right { text-align: right; }
.ms-th-wide { width: 200px; }
.ms-td-right { text-align: right; }

.ms-table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}

/* --- Typography Scale --- */
.ms-text-xs { font-size: 11px; }
.ms-text-sm { font-size: 13px; }
.ms-text-base { font-size: 14px; }
.ms-text-lg { font-size: 16px; }
.ms-text-xl { font-size: 18px; }
.ms-text-2xl { font-size: 24px; }
.ms-text-3xl { font-size: 28px; }
