/* ===== Design Tokens ===== */
:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(23, 33, 54, 0.9);
    --bg-input: rgba(15, 23, 42, 0.6);
    --border-color: rgba(99, 102, 241, 0.15);
    --border-hover: rgba(99, 102, 241, 0.35);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-blue: #6366f1;
    --accent-blue-light: #818cf8;
    --accent-cyan: #22d3ee;
    --accent-green: #34d399;
    --accent-amber: #fbbf24;
    --accent-red: #f87171;
    --accent-purple: #a78bfa;
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
    --gradient-accent: linear-gradient(135deg, #06b6d4, #3b82f6);
    --gradient-highlight: linear-gradient(135deg, #f59e0b, #ef4444);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Animated background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(139, 92, 246, 0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

.app {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ===== Header ===== */
.header {
    padding: 24px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-blue-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.25);
    border-radius: 100px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent-green);
}

.badge-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

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

/* ===== Card ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 28px;
    margin-bottom: 24px;
    backdrop-filter: blur(20px);
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-glow);
}

.card-header {
    margin-bottom: 24px;
}

.card-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.card-desc {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.label-hint {
    font-size: 0.72rem;
    color: var(--accent-blue-light);
    font-weight: 400;
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 100px;
}

.label-optional {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 400;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    width: 100%;
    padding: 10px 60px 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 500;
    transition: var(--transition);
    outline: none;
}

.input-wrapper input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-unit {
    position: absolute;
    right: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    pointer-events: none;
}

/* Slider */
.slider-wrapper {
    margin-top: 8px;
}

.slider-wrapper input[type="range"] {
    width: 100%;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, var(--accent-blue) 0%, var(--accent-blue) 50%, rgba(99, 102, 241, 0.2) 50%, rgba(99, 102, 241, 0.2) 100%);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-blue);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transition: transform 0.15s ease;
}

.slider-wrapper input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Category Buttons */
.category-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-family: inherit;
}

.category-btn:hover {
    border-color: var(--border-hover);
    background: rgba(99, 102, 241, 0.08);
    transform: translateY(-2px);
}

.category-btn.active {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.cat-icon {
    font-size: 1.4rem;
}

.cat-name {
    font-size: 0.78rem;
    font-weight: 600;
}

.cat-range {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.8;
}

/* Market Params */
.market-params {
    margin-top: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.params-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.params-header:hover {
    background: rgba(99, 102, 241, 0.05);
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--accent-blue-light);
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.toggle-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.toggle-btn svg {
    transition: transform 0.3s ease;
}

.toggle-btn.expanded svg {
    transform: rotate(180deg);
}

.params-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
    padding: 0 16px;
}

.params-body.open {
    max-height: 320px;
    padding: 0 16px 16px;
}

.param-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ===== Results ===== */
.results-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.result-card {
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.result-card.primary {
    border-color: rgba(99, 102, 241, 0.3);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
}

.result-card.accent {
    border-color: rgba(6, 182, 212, 0.3);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.08), rgba(59, 130, 246, 0.05));
}

.result-card.highlight {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08), rgba(239, 68, 68, 0.05));
}

.result-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.result-value {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.result-card.primary .result-value { color: var(--accent-blue-light); }
.result-card.accent .result-value { color: var(--accent-cyan); }
.result-card.highlight .result-value { color: var(--accent-amber); }

.result-currency {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.7;
}

.result-unit {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
}

.result-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Impact Analysis */
.impact-section {
    margin-top: 24px;
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
}

.impact-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.impact-bar-wrapper {
    margin-bottom: 16px;
}

.impact-bar-wrapper:last-of-type {
    margin-bottom: 12px;
}

.impact-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.impact-value {
    font-weight: 600;
    color: var(--text-primary);
}

.impact-bar {
    width: 100%;
    height: 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 100px;
    overflow: hidden;
}

.impact-bar-fill {
    height: 100%;
    border-radius: 100px;
    background: var(--gradient-accent);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.impact-bar-fill.warning {
    background: var(--gradient-highlight);
}

.impact-advice {
    margin-top: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.6;
}

.impact-advice.safe {
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: var(--accent-green);
}

.impact-advice.warning {
    background: rgba(251, 191, 36, 0.08);
    border: 1px solid rgba(251, 191, 36, 0.2);
    color: var(--accent-amber);
}

.impact-advice.danger {
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: var(--accent-red);
}

/* ===== Info Section ===== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.info-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.info-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.info-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.info-item strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.info-item p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ===== Bilingual Labels ===== */
.title-en {
    font-size: 0.65em;
    font-weight: 400;
    color: var(--text-muted);
    opacity: 0.7;
    margin-left: 6px;
    letter-spacing: 0;
}

.subtitle-en,
.desc-en,
.label-en,
.section-en,
.badge-en {
    font-size: 0.78em;
    font-weight: 400;
    color: var(--text-muted);
    opacity: 0.65;
    margin-left: 4px;
}

.section-en {
    font-size: 0.6em;
    font-weight: 400;
    vertical-align: middle;
    margin-left: 8px;
}

.badge-en {
    font-size: 0.7em;
    display: block;
    margin-top: 1px;
    margin-left: 0;
}

/* ===== Footer ===== */

.footer {
    text-align: center;
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 16px;
}

.footer p {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-sub {
    margin-top: 4px;
    font-size: 0.72rem !important;
    opacity: 0.6;
}

.footer-privacy {
    margin-top: 8px;
    font-size: 0.72rem !important;
    opacity: 0.5;
}

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

/* Prevent iOS auto-zoom on input focus */
@supports (-webkit-touch-callout: none) {
    .input-wrapper input,
    .input-wrapper input:focus {
        font-size: 16px;
    }
}

/* Tablet */
@media (max-width: 768px) {
    .app {
        padding: 0 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .header {
        padding: 20px 0;
        margin-bottom: 20px;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .category-btn {
        padding: 12px 6px;
        min-height: 44px; /* Apple HIG touch target */
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .param-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .params-body.open {
        max-height: 400px; /* More space for stacked layout */
    }

    .results-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 20px;
        border-radius: var(--radius-lg);
        margin-bottom: 16px;
    }

    .card-header {
        margin-bottom: 16px;
    }

    .result-value {
        font-size: 1.4rem;
    }

    .result-card {
        padding: 16px;
    }

    /* Larger touch targets for inputs */
    .input-wrapper input {
        padding: 12px 60px 12px 14px;
        font-size: 16px; /* Prevent iOS zoom */
    }

    .slider-wrapper input[type="range"] {
        height: 6px;
    }

    .slider-wrapper input[type="range"]::-webkit-slider-thumb {
        width: 22px;
        height: 22px;
    }

    .impact-advice {
        font-size: 0.78rem;
        line-height: 1.7;
    }

    .footer {
        padding: 24px 0;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
    }
}

/* Mobile */
@media (max-width: 480px) {
    .app {
        padding: 0 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .header {
        padding: 16px 0;
        margin-bottom: 16px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .logo-icon {
        width: 40px;
        height: 40px;
    }

    .logo-icon svg {
        width: 22px;
        height: 22px;
    }

    .logo h1 {
        font-size: 1.15rem;
    }

    .subtitle {
        font-size: 0.72rem;
    }

    .header-badge {
        font-size: 0.72rem;
        padding: 5px 12px;
    }

    .category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .category-btn {
        padding: 10px 4px;
        border-radius: var(--radius-sm);
    }

    .cat-icon {
        font-size: 1.2rem;
    }

    .cat-name {
        font-size: 0.7rem;
    }

    .cat-range {
        font-size: 0.6rem;
    }

    .card {
        padding: 16px;
        border-radius: var(--radius-md);
        margin-bottom: 12px;
    }

    .card-header h2 {
        font-size: 1.05rem;
    }

    .result-value {
        font-size: 1.25rem;
        flex-wrap: wrap;
    }

    .result-label {
        font-size: 0.72rem;
    }

    .result-sub {
        font-size: 0.68rem;
        word-break: break-all;
    }

    .result-card {
        padding: 14px;
    }

    .impact-section {
        padding: 14px;
    }

    .impact-bar-label {
        font-size: 0.75rem;
    }

    .info-item {
        padding: 12px;
        gap: 10px;
    }

    .info-item strong {
        font-size: 0.82rem;
    }

    .info-item p {
        font-size: 0.72rem;
    }

    .form-group label {
        flex-wrap: wrap;
        font-size: 0.78rem;
    }

    .footer p {
        font-size: 0.72rem;
        padding: 0 8px;
    }

    .footer-sub {
        font-size: 0.65rem !important;
    }

    /* Disable hover effects on touch - they get sticky */
    .card:hover {
        border-color: var(--border-color);
        box-shadow: none;
    }

    .result-card:hover {
        transform: none;
        box-shadow: none;
    }

    .info-item:hover {
        border-color: var(--border-color);
        transform: none;
    }

    .category-btn:hover {
        transform: none;
    }
}

/* Very small screens (iPhone SE etc.) */
@media (max-width: 360px) {
    .category-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .result-value {
        font-size: 1.1rem;
    }

    .logo h1 {
        font-size: 1.05rem;
    }
}

/* ===== Year Selector ===== */
.year-selector {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.year-btn {
    padding: 6px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
}

.year-btn:hover {
    border-color: var(--border-hover);
    background: rgba(99, 102, 241, 0.08);
}

.year-btn.active {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue-light);
    font-weight: 600;
}

.phase-out-bar {
    position: relative;
    margin-top: 10px;
    height: 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 100px;
    overflow: visible;
}

.phase-out-fill {
    height: 100%;
    border-radius: 100px;
    background: linear-gradient(90deg, var(--accent-green), var(--accent-amber), var(--accent-red));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.phase-out-label {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== CN Code Product List ===== */
.cn-search-wrapper {
    position: relative;
}

.cn-search {
    width: 100%;
    padding: 10px 14px 10px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.cn-search:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.cn-search::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.cn-product-list {
    margin-top: 10px;
    max-height: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.cn-product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-family: inherit;
    text-align: left;
    width: 100%;
}

.cn-product-item:hover {
    background: rgba(99, 102, 241, 0.06);
    border-color: var(--border-color);
}

.cn-product-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.cn-product-main {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.cn-code {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-blue-light);
    font-family: 'SF Mono', 'Fira Code', monospace;
    white-space: nowrap;
    min-width: 90px;
}

.cn-name {
    font-size: 0.8rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cn-product-ef {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-shrink: 0;
}

.ef-value {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-cyan);
}

.ef-unit {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* ===== Emission Source Toggle ===== */
.toggle-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    display: flex;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 3px;
    cursor: pointer;
    font-family: inherit;
    overflow: hidden;
}

.toggle-option {
    padding: 6px 14px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    z-index: 1;
    transition: color 0.3s ease;
    user-select: none;
}

.toggle-option.active {
    color: var(--text-primary);
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.markup-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent-amber);
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.25);
    padding: 3px 8px;
    border-radius: 100px;
    white-space: nowrap;
}

/* ===== Data Status Indicator ===== */
.data-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 100px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background 0.3s ease;
}

.status-dot.loading {
    background: var(--accent-amber);
    animation: pulse-dot 1s ease-in-out infinite;
}

.status-dot.live {
    background: var(--accent-green);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.cached {
    background: var(--accent-blue-light);
}

.status-dot.offline {
    background: var(--text-muted);
}

.status-text {
    font-weight: 500;
}

/* ===== Live Indicator ===== */
.live-indicator {
    transition: var(--transition);
}

.live-indicator.live {
    background: rgba(34, 197, 94, 0.12);
    color: var(--accent-green);
}

/* ===== Domestic Carbon Hint ===== */
.domestic-carbon-hint {
    margin-top: 6px;
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* ===== Result Detail ===== */
.result-detail {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
    opacity: 0.7;
}

/* ===== CBAM Rate Badge ===== */
.cbam-rate-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--accent-cyan);
    background: rgba(34, 211, 238, 0.1);
    border: 1px solid rgba(34, 211, 238, 0.2);
    padding: 2px 7px;
    border-radius: 100px;
    margin-left: 6px;
    text-transform: none;
    letter-spacing: normal;
}

/* ===== Projection Chart ===== */
.projection-section {
    margin-top: 24px;
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
}

.projection-header {
    margin-bottom: 20px;
}

.projection-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.projection-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.projection-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
    padding-top: 16px;
}

.proj-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    height: 100%;
    cursor: pointer;
    transition: var(--transition);
}

.proj-bar:hover .proj-bar-fill {
    opacity: 0.9;
}

.proj-bar-value {
    font-size: 0.62rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    min-height: 16px;
    display: flex;
    align-items: flex-end;
}

.proj-bar.active .proj-bar-value {
    color: var(--accent-cyan);
}

.proj-bar-fill {
    width: 100%;
    border-radius: 4px 4px 0 0;
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.6), rgba(99, 102, 241, 0.25));
    transition: height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 2px;
}

.proj-bar.active .proj-bar-fill {
    background: linear-gradient(180deg, var(--accent-cyan), rgba(6, 182, 212, 0.4));
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.2);
}

.proj-bar-year {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 4px;
}

.proj-bar.active .proj-bar-year {
    color: var(--accent-cyan);
}

.proj-bar-rate {
    font-size: 0.58rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ===== Results Header ===== */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.results-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ===== Risk Badge ===== */
.risk-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
    white-space: nowrap;
}

.risk-badge.safe {
    color: var(--accent-green);
    background: rgba(34, 197, 94, 0.08);
    border-color: rgba(34, 197, 94, 0.25);
}

.risk-badge.warning {
    color: var(--accent-amber);
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.25);
}

.risk-badge.danger {
    color: var(--accent-red);
    background: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.25);
    animation: pulse-risk 2s ease-in-out infinite;
}

@keyframes pulse-risk {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.risk-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.risk-dot.safe { background: var(--accent-green); }
.risk-dot.warning { background: var(--accent-amber); }
.risk-dot.danger { background: var(--accent-red); animation: pulse-dot 1s ease-in-out infinite; }

/* ===== Action Button (Print) ===== */
.action-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-sm);
    color: var(--accent-blue-light);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.action-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: var(--accent-blue);
}

/* ===== Indirect Emission Notice ===== */
.indirect-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin-bottom: 16px;
    background: rgba(251, 191, 36, 0.06);
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--accent-amber);
}

.indirect-icon {
    flex-shrink: 0;
}

/* ===== Stress Test ===== */
.stress-test-section {
    margin-top: 24px;
    padding: 20px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--border-color);
}

.stress-header {
    margin-bottom: 14px;
}

.stress-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.stress-desc {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.stress-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.stress-btn {
    padding: 7px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.stress-btn:hover {
    border-color: var(--border-hover);
    background: rgba(99, 102, 241, 0.08);
}

.stress-btn.active {
    border-color: var(--accent-blue);
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-blue-light);
    font-weight: 600;
}

.stress-comparison {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.stress-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    flex: 1;
    min-width: 120px;
}

.stress-item.stressed {
    border-color: rgba(248, 113, 113, 0.3);
    background: rgba(248, 113, 113, 0.05);
}

.stress-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.stress-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stress-item.stressed .stress-value {
    color: var(--accent-red);
}

.stress-arrow {
    color: var(--text-muted);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stress-delta {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--accent-red);
    padding: 6px 12px;
    background: rgba(248, 113, 113, 0.08);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* ===== Print Styles ===== */
@media print {
    body {
        background: white;
        color: #1a1a1a;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body::before { display: none; }

    .app { max-width: 100%; padding: 0 20px; }

    .header { border-bottom-color: #ddd; }
    .header-badge, .data-status { display: none !important; }

    .card {
        background: white;
        border-color: #ddd;
        backdrop-filter: none;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .input-section { display: none; }

    .result-card {
        border-color: #ddd;
        background: #f8f8f8 !important;
    }

    .result-value { color: #1a1a1a !important; }
    .result-card.primary .result-value { color: #4f46e5 !important; }
    .result-card.accent .result-value { color: #0891b2 !important; }
    .result-card.highlight .result-value { color: #d97706 !important; }

    .stress-test-section,
    .projection-section { page-break-inside: avoid; }

    .action-btn { display: none !important; }

    .footer-privacy { display: block; }

    .info-section { display: none; }
}

/* ===== Readonly Input ===== */
input[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
}

input[readonly]:focus {
    border-color: var(--border-color);
    box-shadow: none;
}

/* ===== Animation ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.5s ease forwards;
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }

/* Number transition */
.result-value span {
    transition: all 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* ===== Responsive - New Components ===== */
@media (max-width: 768px) {
    .year-selector {
        gap: 3px;
    }

    .year-btn {
        padding: 5px 8px;
        font-size: 0.72rem;
    }

    .cn-product-list {
        max-height: 180px;
    }

    .projection-chart {
        height: 140px;
        gap: 4px;
    }

    .proj-bar-value {
        font-size: 0.55rem;
    }

    .proj-bar-year {
        font-size: 0.6rem;
    }

    .proj-bar-rate {
        display: none;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
    }

    .data-status {
        font-size: 0.68rem;
    }

    .toggle-switch-wrapper {
        flex-wrap: wrap;
    }

    .params-body.open {
        max-height: 500px;
    }
}

@media (max-width: 480px) {
    .year-selector {
        gap: 2px;
    }

    .year-btn {
        padding: 4px 6px;
        font-size: 0.68rem;
    }

    .cn-code {
        min-width: 70px;
        font-size: 0.68rem;
    }

    .cn-name {
        font-size: 0.72rem;
    }

    .cn-product-item {
        padding: 8px 10px;
    }

    .projection-chart {
        height: 120px;
        gap: 3px;
    }

    .projection-header h3 {
        font-size: 0.85rem;
    }

    .data-status {
        display: none;
    }
}
