/**
 * LedgerIQ Upload Page - Editorial Merged Styles
 * Merges original inline styles (base layout) + redesign overrides
 * with editorial tokens from iq-suite-editorial.css
 *
 * Color mapping:
 *   Green #16a34a → sage teal --liq-primary #4a9080
 *   Gray #f8fafc  → cream --cream #faf8f5
 *   Gray #1e293b  → ink --ink #1a1a1a
 *   Inter         → DM Sans body, Fraunces headers, JetBrains Mono data
 */

/* ============================================
   CSS CUSTOM PROPERTIES (editorial overrides)
   ============================================ */
:root {
    /* Map old green tokens to sage teal */
    --liq-green-50: var(--liq-light);
    --liq-green-100: #d0ebe4;
    --liq-green-200: #b3ddd2;
    --liq-green-300: #8ec9ba;
    --liq-green-400: #6aac9b;
    --liq-green-500: var(--liq-primary);
    --liq-green-600: var(--liq-primary);
    --liq-green-700: var(--liq-deep);
    --liq-green-800: #2d5c4f;
    --liq-green-900: #1f4639;

    /* Map old gray tokens to warm cream */
    --liq-gray-50: var(--cream);
    --liq-gray-100: var(--ivory);
    --liq-gray-200: var(--rule);
    --liq-gray-300: #c4c0b8;
    --liq-gray-400: var(--ink-subtle);
    --liq-gray-500: var(--ink-muted);
    --liq-gray-600: var(--ink-light);
    --liq-gray-700: var(--ink-light);
    --liq-gray-800: var(--ink);
    --liq-gray-900: var(--ink);

    /* Status */
    --liq-success: var(--ed-success);
    --liq-success-light: var(--ed-success-light);
    --liq-warning: var(--ed-warning);
    --liq-warning-light: var(--ed-warning-light);
    --liq-error: var(--ed-error);
    --liq-error-light: var(--ed-error-light);

    /* Typography - editorial */
    --liq-font-sans: var(--ed-font-sans);
    --liq-font-mono: var(--ed-font-mono);

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

    /* Shadows - lighter */
    --liq-shadow-sm: var(--ed-shadow-sm);
    --liq-shadow-md: var(--ed-shadow-md);
    --liq-shadow-lg: var(--ed-shadow-lg);
    --liq-shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.08);

    /* Border Radius - tight editorial */
    --liq-radius-sm: 4px;
    --liq-radius-md: 4px;
    --liq-radius-lg: 4px;
    --liq-radius-xl: 4px;
}


/* ==============================================
   ██████   █████  ███████ ███████
   ██   ██ ██   ██ ██      ██
   ██████  ███████ ███████ █████
   ██   ██ ██   ██      ██ ██
   ██████  ██   ██ ███████ ███████
   Base layout from original inline styles
   ============================================== */

body {
    margin: 0;
    font-family: var(--ed-font-sans);
    display: flex;
    min-height: 100vh;
    color: var(--ink);
    line-height: 1.5;
    padding-top: 56px;
    box-sizing: border-box;
    background: var(--cream);
}

/* ============================================
   TOP BAR - EDITORIAL MASTHEAD
   ============================================ */
header.top-bar {
    height: 56px;
    background: #fff;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 24px;
    border-bottom: 1px solid var(--rule);
    box-shadow: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 10000;
    overflow: hidden;
}

header.top-bar::before {
    display: none;
}

header.top-bar .brand {
    font-family: var(--ed-font-serif);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    white-space: nowrap;
    margin-right: 1rem;
    color: var(--ink);
}

header.top-bar .brand a {
    color: var(--ink);
    text-decoration: none;
}

header.top-bar nav.top-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
    padding-left: 0;
}

header.top-bar nav.top-nav .nav-links {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

header.top-bar nav.top-nav a {
    font-family: var(--ed-font-sans);
    color: var(--ink-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--ed-radius);
    transition: all 0.15s ease;
    white-space: nowrap;
}

header.top-bar nav.top-nav a:hover {
    background: var(--ivory);
    color: var(--ink);
}

header.top-bar nav.top-nav a:active {
    transform: scale(0.95);
}

/* Buy Credits / Upgrade Buttons */
header.top-bar nav.top-nav a#buyCredits,
header.top-bar nav.top-nav a#upgradeButton {
    background: var(--ivory);
    border: 1px solid var(--rule);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--ed-radius);
    box-shadow: none;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
    position: relative;
    overflow: hidden;
}

header.top-bar nav.top-nav a#buyCredits:hover,
header.top-bar nav.top-nav a#upgradeButton:hover {
    background: var(--paper);
    border-color: var(--ink-subtle);
    color: var(--ink);
    transform: none;
    box-shadow: none;
}

header.top-bar nav.top-nav a#buyCredits:active,
header.top-bar nav.top-nav a#upgradeButton:active {
    transform: scale(0.98);
}

/* Kill the shimmer animation on CTA buttons */
#buyCredits span,
#upgradeButton span {
    display: none;
}

header.top-bar nav.top-nav .nav-right-items {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--ink-muted);
    cursor: pointer;
    padding: 0.5rem;
    margin-left: 1rem;
}

.mobile-menu-toggle i {
    width: 28px;
    height: 28px;
}

/* ============================================
   MERCHANT PARSER BUTTON
   ============================================ */
.merchant-parser-container {
    position: relative;
    margin-bottom: 1rem;
}

.merchant-parser-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--liq-deep);
    color: #fff;
    border: 1px solid var(--rule);
    padding: 0.65rem 1rem;
    border-radius: var(--ed-radius-pill);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: var(--ed-shadow-sm);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.merchant-parser-btn:hover {
    background: var(--liq-primary);
    box-shadow: var(--ed-shadow-md);
}

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

.merchant-parser-btn i {
    width: 14px;
    height: 14px;
}

/* ============================================
   SIDEBAR - CREAM EDITORIAL
   ============================================ */
.sidebar {
    width: 200px;
    background: var(--cream);
    padding: 20px;
    border-right: 1px solid var(--rule);
    flex-shrink: 0;
    box-sizing: border-box;
    transition: width 0.3s ease-in-out;
    position: fixed;
    left: -280px;
    top: 56px;
    height: calc(100vh - 56px);
    z-index: 9998;
    box-shadow: var(--ed-shadow-lg);
}

.sidebar.active {
    left: 0;
}

.sidebar-toggle {
    display: flex;
    position: fixed;
    top: 68px;
    left: var(--liq-space-4);
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius-lg);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10001;
    box-shadow: var(--ed-shadow-md);
    transition: all 0.15s ease;
}

.sidebar-toggle:hover {
    background: var(--ivory);
    border-color: var(--liq-primary);
    box-shadow: var(--ed-shadow-lg);
}

.sidebar-toggle i {
    width: 20px;
    height: 20px;
    display: block;
    color: var(--ink-muted);
}

.logo-section {
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--rule);
}

.logo-title {
    font-family: var(--ed-font-serif);
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.2px;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    margin-bottom: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--ink-muted);
    text-decoration: none;
    border-radius: var(--ed-radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
}

.nav-link:hover {
    background: var(--ivory);
    color: var(--ink);
}

.support-link {
    background: var(--liq-primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: var(--ed-radius);
    margin-top: 1rem;
    text-align: center;
    font-weight: 500;
    transition: all 0.2s ease;
    box-shadow: var(--ed-shadow-sm);
    display: block;
    text-decoration: none;
}

.support-link:hover {
    background: var(--liq-deep);
    color: white;
}

.nav-list .nav-item:last-of-type {
    margin-top: 1rem;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    padding: 32px;
    padding-left: calc(32px + 56px);
    background: var(--cream);
    margin-left: 0;
    box-sizing: border-box;
    min-width: 0;
    min-height: calc(100vh - 56px);
}

.tool-container {
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
}

.container {
    padding: 0;
    margin: 0;
    max-width: none;
}

/* ============================================
   HEADER SECTION
   ============================================ */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 32px;
    padding: 0;
}

.header p {
    color: var(--ink-muted);
    font-size: 1.25rem;
    opacity: 0.9;
}

.header-image {
    margin-bottom: 16px;
    max-width: 320px;
    width: 80%;
}

.tier-display {
    margin: 16px auto;
}

.header-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.header-title {
    font-family: var(--ed-font-serif);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--liq-deep);
    margin: 0;
    padding: 0;
    text-align: center;
    letter-spacing: -0.3px;
}

.header-description {
    font-size: 1rem;
    color: var(--ink-muted);
    margin: 0;
    line-height: 1.5;
}

.guide-button {
    background: #fff;
    color: var(--liq-deep);
    border: 1px solid var(--rule);
    padding: 0.625rem 1.25rem;
    border-radius: var(--ed-radius);
    font-family: var(--ed-font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-top: 16px;
}

.guide-button:hover {
    background: var(--ivory);
    border-color: var(--liq-primary);
    color: var(--liq-deep);
    transform: translateY(-1px);
    box-shadow: var(--ed-shadow-sm);
}

.guide-section {
    background: #fff;
    border-radius: var(--ed-radius);
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid var(--rule);
}

/* ============================================
   INPUT SECTION
   ============================================ */
.input-section {
    display: grid;
    gap: 2rem;
    background: #fff;
    padding: 32px;
    border-radius: var(--ed-radius);
    border: 1px solid var(--rule);
    position: relative;
    padding-top: 3rem;
    box-shadow: var(--ed-shadow-sm);
}

.input-section:hover {
    transform: none;
    box-shadow: var(--ed-shadow-md);
}

/* View History Tab */
.view-history-tab {
    display: inline-flex;
    align-items: center;
    position: absolute;
    top: -1px;
    left: 24px;
    background: var(--ivory);
    color: var(--ink-muted);
    padding: 8px 16px;
    border: 1px solid var(--rule);
    border-bottom: 1px solid #fff;
    border-radius: var(--ed-radius) var(--ed-radius) 0 0;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
    z-index: 5;
    text-decoration: none;
    box-shadow: none;
}

.view-history-tab:hover {
    background: var(--liq-light);
    color: var(--liq-deep);
    transform: translateY(-2px);
    box-shadow: var(--ed-shadow-sm);
}

.view-history-tab:active {
    transform: translateY(-1px);
}

.view-history-tab i {
    margin-right: 0.4em;
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.15em;
}

/* ============================================
   CREDIT STATUS
   ============================================ */
.credit-status {
    background: var(--ivory);
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
    padding: 20px;
    margin-bottom: 24px;
    transition: all 0.2s ease;
}

.credit-counts {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 24px;
}

.credit-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
}

.credit-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.credit-value {
    display: block;
    font-family: var(--ed-font-mono);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink);
}

.credit-value.low-credits {
    color: var(--ed-error);
    animation: pulse 2s infinite;
}

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

#monthlyCredits,
#creditsUsed,
#bonusCredits {
    font-family: var(--ed-font-mono);
    font-weight: 700;
    color: var(--liq-deep);
}

/* Credit Upsell */
.credit-upsell {
    margin-top: 0.75rem;
    text-align: center;
}

.credit-upsell-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--liq-deep);
    background: var(--liq-light);
    border: 1px solid rgba(74, 144, 128, 0.3);
    border-radius: var(--ed-radius-pill);
    text-decoration: none;
    transition: all 0.2s ease;
}

.credit-upsell-link:hover {
    background: rgba(74, 144, 128, 0.15);
    border-color: var(--liq-primary);
    transform: translateY(-1px);
    box-shadow: var(--ed-shadow-sm);
}

.credit-upsell-link .upsell-text {
    color: var(--liq-deep);
}

.credit-upsell-link i {
    color: var(--liq-primary);
}

/* Credits Progress Bar */
.credits-progress-container {
    margin-bottom: 1rem;
    background: var(--rule);
    height: 8px;
    border-radius: var(--ed-radius-pill);
    overflow: hidden;
    position: relative;
}

.credits-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--liq-primary), var(--liq-deep));
    border-radius: var(--ed-radius-pill);
    transition: width 0.5s ease-out;
}

.credits-progress-info {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

#creditsProgressText {
    font-family: var(--ed-font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ink-muted);
    background: #fff;
    padding: 2px 8px;
    border-radius: var(--ed-radius);
    border: 1px solid var(--rule);
}

.premium-notification {
    color: var(--ed-warning);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
    text-align: center;
    background-color: var(--ed-warning-light);
    padding: 0.5rem;
    border-radius: var(--ed-radius);
    border: 1px solid rgba(217, 119, 6, 0.3);
}

/* ============================================
   FILE UPLOAD SECTION
   ============================================ */
.file-upload-section {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    margin-bottom: 24px;
}

.file-upload-section:hover {
    transform: none;
    box-shadow: none;
}

.file-upload-section::before {
    display: none;
}

.file-input-container {
    margin-bottom: 1.5rem;
}

.file-label {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: #fff;
    border: 2px dashed var(--rule);
    border-radius: var(--ed-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-label:hover {
    border-color: var(--liq-primary);
    background: var(--liq-light);
    transform: none;
    box-shadow: none;
}

.file-label.drag-over {
    border-color: var(--liq-primary);
    background: var(--liq-light);
    transform: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 128, 0.15);
}

.file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ivory);
    border-radius: var(--ed-radius);
    margin-right: 16px;
    color: var(--ink-muted);
    flex-shrink: 0;
}

.file-icon i {
    width: 20px;
    height: 20px;
}

.file-text {
    flex: 1;
    font-size: 0.875rem;
    color: var(--ink-muted);
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-button {
    padding: 8px 16px;
    background: var(--liq-primary);
    color: white;
    border-radius: var(--ed-radius);
    font-size: 0.8125rem;
    font-weight: 600;
    transition: background 0.15s ease;
    margin-left: 1rem;
}

.file-label:hover .file-button {
    background: var(--liq-deep);
}

.file-input-hidden {
    display: none;
}

.file-name {
    display: block;
    margin-top: 8px;
    font-family: var(--ed-font-mono);
    font-size: 0.8125rem;
    color: var(--ink-muted);
    padding-left: calc(40px + 16px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   ANALYZE BUTTON
   ============================================ */
.analyze-button {
    width: 100%;
    padding: 16px;
    background: var(--liq-primary);
    color: white;
    border: none;
    border-radius: var(--ed-radius);
    font-family: var(--ed-font-sans);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--ed-shadow-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

.analyze-button:hover {
    background: var(--liq-deep);
    box-shadow: var(--ed-shadow-md);
}

.analyze-button i {
    width: 18px;
    height: 18px;
}

/* ============================================
   TAB NAVIGATION - EDITORIAL PILLS
   ============================================ */
.tab-nav-container {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 1rem;
}

.tab-nav {
    display: inline-flex;
    background: var(--ivory);
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius-pill);
    overflow: hidden;
    padding: 4px;
    gap: 4px;
    box-shadow: none;
    backdrop-filter: none;
}

.tab-nav button {
    background: transparent;
    border: none;
    padding: 0.6rem 1.25rem;
    font-family: var(--ed-font-sans);
    font-weight: 500;
    font-size: 13px;
    color: var(--ink-muted);
    transition: all 0.2s ease;
    border-radius: var(--ed-radius-pill);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

/* Hover effects with editorial product themes */
.tab-nav button.reconcileiq-tab:hover {
    background: rgba(91, 110, 174, 0.08);
    color: var(--riq-primary);
}

.tab-nav button.ledgeriq-tab:hover {
    background: rgba(74, 144, 128, 0.08);
    color: var(--liq-primary);
}

.tab-nav button.codeiq-tab:hover {
    background: rgba(196, 87, 106, 0.08);
    color: var(--ciq-primary);
}

/* CodeIQ tab attention animation */
.tab-nav button.codeiq-tab:not(.active) {
    position: relative;
    animation: codeiqGlow 9s infinite ease-in-out;
}

.tab-nav button.codeiq-tab:not(.active)::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -30%;
    width: 40%;
    height: 200%;
    background: linear-gradient(120deg, transparent, rgba(196, 87, 106, 0.35), transparent);
    transform: rotate(25deg) translateX(-150%);
    pointer-events: none;
    animation: codeiqSparkle 9s infinite ease-in-out;
}

@keyframes codeiqGlow {
    0%, 84% { box-shadow: none; }
    85%, 90% { box-shadow: 0 0 0 0 rgba(196, 87, 106, 0), 0 0 18px rgba(196, 87, 106, 0.3); }
    100% { box-shadow: none; }
}

@keyframes codeiqSparkle {
    0%, 84% { transform: rotate(25deg) translateX(-150%); opacity: 0; }
    85% { opacity: 1; }
    90% { transform: rotate(25deg) translateX(250%); opacity: 0.85; }
    100% { opacity: 0; transform: rotate(25deg) translateX(250%); }
}

/* Active states with editorial product colors */
.tab-nav button.reconcileiq-tab.active {
    background: var(--riq-primary);
    color: #fff;
    box-shadow: var(--ed-shadow-sm);
}

.tab-nav button.ledgeriq-tab.active {
    background: var(--liq-primary);
    color: #fff;
    box-shadow: var(--ed-shadow-sm);
}

.tab-nav button.codeiq-tab.active {
    background: var(--ciq-primary);
    color: #fff;
    box-shadow: var(--ed-shadow-sm);
}

.tab-nav button.active:hover {
    transform: none;
}

/* Tier badges: inherited from iq-suite-editorial.css */

/* ============================================
   OVERLAYS, SPINNERS, MODALS
   ============================================ */
#loadingOverlayBack {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 9998;
}

#loadingOverlayFront {
    position: fixed;
    top: 0;
    width: calc(100% - 200px);
    height: 100%;
    pointer-events: none;
    display: none;
    z-index: 9999;
}

.spinner-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 5px solid var(--rule);
    border-top-color: var(--liq-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#successCheck {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 3px solid var(--ed-success);
    border-radius: 50%;
    padding: 1rem 1.5rem;
    box-shadow: var(--ed-shadow-lg);
    z-index: 10001;
}

@media (min-width: 993px) {
    #loadingOverlayFront { left: 200px; width: calc(100% - 200px); }
    #successCheck { left: calc(50% + 100px); }
}

#successCheck::before {
    content: "✓";
    font-size: 2rem;
    color: var(--ed-success);
}

/* Modal Base */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    backdrop-filter: none;
    z-index: 10002;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
    box-shadow: var(--ed-shadow-lg);
    color: var(--ink);
    padding: 2rem;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: fadeInScale 0.3s ease-out forwards;
}

@media (min-width: 993px) {
    .modal-content { left: calc(50% + 100px); }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-content, .modal-content p, .modal-content li, .modal-content .instructions-content, .modal-content span, .modal-content label {
    color: var(--ink);
}

.modal-content h2, .modal-content h3 {
    color: var(--ink);
    font-family: var(--ed-font-serif);
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ivory);
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.close-btn:hover {
    background: var(--paper);
}

.close-btn:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--rule);
}

.modal-content h2 {
    padding-bottom: 3rem;
    position: relative;
    margin-top: 0;
    font-family: var(--ed-font-serif);
}

#paypal-button-container {
    margin-bottom: 2rem;
    position: relative;
    z-index: 10003;
}

.instructions-content {
    white-space: pre-wrap;
    font-family: var(--ed-font-mono);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-top: 20px;
}

/* Terms Modal */
#termsModal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    background: rgba(26, 26, 26, 0.5);
    z-index: 11000;
    backdrop-filter: blur(4px);
}

#termsModal .modal-content {
    position: static;
    transform: none;
    top: auto;
    left: auto;
    margin: 0 auto;
}

.terms-scroll {
    max-height: 300px;
    overflow-y: auto;
    margin: 20px 0;
    padding: 10px;
    border: 1px solid var(--rule);
}

.accept-btn {
    padding: 10px 20px;
    background: var(--liq-primary);
    color: white;
    border: none;
    border-radius: var(--ed-radius);
    cursor: pointer;
}

/* Login/Register Modals */
#loginModal, #registerModal { display: none; }

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-form label {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.modal-form input[type="email"],
.modal-form input[type="password"] {
    padding: 0.5rem;
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
}

.modal-form button {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: var(--ed-radius);
    background: var(--liq-primary);
    color: #fff;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.modal-form button:hover {
    background: var(--liq-deep);
}

.close-modal {
    background: var(--ed-error);
    color: #fff;
    margin-left: 0.5rem;
    cursor: pointer;
}

.login-notification {
    background-color: var(--ed-error-light);
    color: var(--ed-error);
    padding: 10px 15px;
    margin: -2rem -2rem 2rem -2rem;
    border-radius: var(--ed-radius) var(--ed-radius) 0 0;
    text-align: center;
    font-weight: 500;
    border-bottom: 1px solid rgba(220, 38, 38, 0.2);
}

.register-prompt {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rule);
    text-align: center;
}

.register-link {
    color: var(--liq-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.register-link:hover {
    color: var(--liq-deep);
    text-decoration: underline;
}

#loginModal .modal-content {
    max-height: 90vh;
}

/* ============================================
   RESULTS AREA
   ============================================ */
#results {
    margin-top: 32px;
}

.result-section {
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
    padding: 24px;
    box-shadow: var(--ed-shadow-sm);
}

.result-section h2 {
    font-family: var(--ed-font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--ink);
    border-bottom: 1px solid var(--rule);
}

/* Table Styling */
table {
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: var(--liq-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 12px 16px;
}

td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--ivory);
}

td:nth-child(2),
td:nth-child(3) {
    font-family: var(--ed-font-mono);
}

tr:hover td {
    background: var(--cream);
}

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress-container {
    background: var(--ivory);
    padding: 1.5rem;
    border-radius: var(--ed-radius);
    margin: 2rem 0;
    border: 1px solid var(--rule);
    display: none;
}

.progress-bar {
    height: 0.75rem;
    background: linear-gradient(to right, var(--liq-primary), var(--liq-deep));
    border-radius: var(--ed-radius-pill);
    transition: width 0.3s ease-out;
    box-shadow: var(--ed-shadow-sm);
}

.progress-text {
    text-align: center;
    margin-top: 1rem;
    font-family: var(--ed-font-mono);
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--ink-muted);
}

/* ============================================
   ERROR MESSAGES
   ============================================ */
.error,
#error {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background: var(--ed-error-light);
    color: var(--ed-error);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--ed-radius);
    font-size: 0.875rem;
    font-weight: 500;
    align-items: center;
    gap: 0.5rem;
    animation: shake 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================
   SUCCESS CONTAINER
   ============================================ */
.success-container {
    max-width: 600px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: var(--ed-radius);
    border: 1px solid var(--rule);
    box-shadow: var(--ed-shadow-sm);
    text-align: center;
}

.success-message { margin-bottom: 2rem; }
.success-message svg { width: 48px; height: 48px; color: var(--ed-success); margin: 0 auto 1rem auto; display: block; }
.success-message h2 { font-family: var(--ed-font-serif); font-size: 1.5rem; color: var(--ink); margin-bottom: 0.5rem; }
.success-message p { color: var(--ink-muted); font-size: 1.1rem; }

.results-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.view-results-btn, .download-summary-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--ed-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.view-results-btn {
    background: var(--liq-primary);
    color: white;
}

.view-results-btn:hover {
    background: var(--liq-deep);
}

.download-summary-btn {
    background: white;
    color: var(--liq-primary);
    border: 1px solid var(--liq-primary);
}

.download-summary-btn:hover {
    background: var(--liq-light);
}

.view-results-btn.disabled {
    background-color: var(--rule);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ============================================
   USER ACCOUNT MODAL
   ============================================ */
.user-modal {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 400px;
    max-width: calc(100vw - 40px);
    background: white;
    border: 1px solid var(--rule);
    border-radius: var(--ed-radius);
    box-shadow: var(--ed-shadow-lg);
    display: none;
    z-index: 10005;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 1.5rem;
}

.user-modal.active,
.user-modal[style*="block"] {
    display: block;
}

.user-close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 1;
    color: var(--ink-muted);
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-close-modal:hover {
    color: var(--ink);
    background: var(--ivory);
    border-radius: var(--ed-radius);
}

/* ============================================
   VIEW ANALYSIS BUTTON
   ============================================ */
#viewAnalysisButtonContainer {
    margin-top: 1.5rem;
    text-align: center;
}

#viewAnalysisButton {
    padding: 0.75rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: var(--liq-primary);
    color: white;
    border: none;
    border-radius: var(--ed-radius);
    cursor: pointer;
    transition: background-color 0.2s;
    display: none;
}

#viewAnalysisButton:hover {
    background-color: var(--liq-deep);
}

/* ============================================
   CREDIT DEDUCTION ANIMATIONS
   ============================================ */
.credit-deduction {
    position: fixed;
    font-size: 24px;
    font-weight: bold;
    color: var(--ed-error);
    pointer-events: none;
    z-index: 10000;
    animation: floatUp 2s ease-out forwards;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.credit-deduction.bonus {
    color: var(--riq-primary);
}

@keyframes floatUp {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-100px); }
}

.credit-updating {
    animation: creditPulse 0.5s ease-in-out;
}

@keyframes creditPulse {
    0%, 100% { transform: scale(1); color: inherit; }
    50% { transform: scale(1.2); color: var(--ed-error); }
}

.credit-updating.bonus {
    animation: bonusCreditPulse 0.5s ease-in-out;
}

@keyframes bonusCreditPulse {
    0%, 100% { transform: scale(1); color: inherit; }
    50% { transform: scale(1.2); color: var(--riq-primary); }
}

/* ============================================
   SIDEBAR OVERLAY
   ============================================ */
#sidebarOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.3);
    z-index: 9997;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    backdrop-filter: blur(4px);
}

#sidebarOverlay.active {
    display: block;
    opacity: 1;
}

/* Sub-account credentials modal */
#subAccountCredentialsModal .modal-content { border-left: 5px solid var(--ed-success); }
#subAccountCredentialsModal code { font-size: 1rem; letter-spacing: 0.05em; font-family: var(--ed-font-mono); }
#copyPasswordBtn { background-color: var(--ivory); border: 1px solid var(--rule); color: var(--ink); }
#copyPasswordBtn:hover { background-color: var(--paper); }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 992px) {
    header.top-bar { overflow: visible; }

    header.top-bar nav.top-nav .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        right: 0;
        background: #fff;
        border: 1px solid var(--rule);
        box-shadow: var(--ed-shadow-lg);
        border-radius: 0 0 var(--ed-radius) var(--ed-radius);
        width: 250px;
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem 0;
        gap: 0;
        z-index: 9999;
    }

    header.top-bar nav.top-nav .nav-links.active {
        display: flex;
        animation: fadeInDown 0.3s ease-out;
    }

    header.top-bar nav.top-nav .nav-links a {
        padding: 0.8rem 1.5rem;
        border-radius: 0;
        border-bottom: 1px solid var(--ivory);
        text-align: left;
        width: 100%;
        box-sizing: border-box;
        color: var(--ink);
    }

    header.top-bar nav.top-nav .nav-links a:last-child { border-bottom: none; }
    header.top-bar nav.top-nav .nav-links a:hover { background: var(--ivory); }

    .mobile-menu-toggle { display: block; }

    .sidebar {
        position: fixed;
        left: -250px;
        top: 56px;
        height: calc(100vh - 56px);
        width: 250px;
        z-index: 9998;
        transition: left 0.3s ease-in-out;
        margin-top: 0;
        border-right: 1px solid var(--rule);
        background: var(--cream);
    }

    .sidebar.active { left: 0; }
    .sidebar-toggle { display: block; }
    .main-content { margin-left: 0; transition: margin-left 0.3s ease-in-out; padding: 10px; }
    #loadingOverlayFront { left: 0; width: 100%; }
    .modal-content { left: 50%; transform: translate(-50%, -50%); }
}

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

@media (max-width: 768px) {
    body { padding-top: 56px; }

    .main-content {
        padding: 16px;
        padding-left: 16px;
        padding-top: calc(16px + 48px);
    }

    .input-section {
        padding: 20px;
        padding-top: 3.5rem;
    }

    .view-history-tab {
        left: 1rem;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
    }

    .credit-counts {
        flex-direction: column;
        gap: 12px;
    }

    .credit-item {
        min-width: auto;
        width: 100%;
    }

    .user-modal {
        top: 60px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
}

@media (max-width: 640px) {
    .container { padding: 1rem; margin: 1rem auto; }
    .header-title { font-size: 1.5rem; }
    .input-section, .guide-section, .result-section { padding: 1rem; }
    .file-label { padding: 0.8rem; }
    .file-text { font-size: 0.9rem; }
    .file-button { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
    .file-name { padding-left: calc(1.5rem + 0.8rem); }
    .analyze-button { font-size: 0.9rem; padding: 0.8rem; }
    .guide-button, .download-button { font-size: 0.9rem; padding: 0.6rem 1.2rem; }
    .header-description { font-size: 1rem; }
    .results-actions { flex-direction: column; }
    .success-container { margin: 1rem; padding: 1.5rem; }
}

/* ============================================
   ANIMATIONS - SUBTLE
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Remove excessive animations */
.input-section,
.file-label,
.analyze-button {
    animation: none;
}

/* ============================================
   LOGGED-IN HEADER ELEMENT FIXES
   (inline color:white removed from HTML; CSS now controls)
   ============================================ */
#userInfo {
    padding: 0.5rem 0.8rem;
    color: var(--ink);
}

#userGreeting {
    display: block;
    margin-bottom: 0.3rem;
}

#logoutLink {
    color: var(--ink);
    padding: 0.3rem 0.6rem;
    border-radius: var(--ed-radius);
    background: rgba(0, 0, 0, 0.06);
    text-decoration: none;
}

#logoutLink:hover {
    background: rgba(0, 0, 0, 0.1);
}

#userSettingsIcon {
    color: var(--ink-muted);
    padding: 8px;
}

#userSettingsIcon i,
#userSettingsIcon svg {
    width: 24px;
    height: 24px;
}

/* Language selector overrides for JS-injected dark-theme styles */
header.top-bar .lang-toggle {
    background: var(--ivory);
    border: 1px solid var(--rule);
}

header.top-bar .lang-toggle:hover {
    background: var(--paper);
}

header.top-bar .lang-dropdown {
    background: #fff;
    border: 1px solid var(--rule);
    box-shadow: var(--ed-shadow-md);
}

header.top-bar .lang-dropdown a {
    color: var(--ink-light);
}

header.top-bar .lang-dropdown a:hover {
    background: var(--ivory);
    color: var(--ink);
}

/* Tour button - spacing only, inherits .guide-button white bg + border */
.btn-tour {
    margin-left: 0.5rem;
}

/* ============================================
   REFERRAL BANNER
   ============================================ */
.referral-banner {
    margin-bottom: 1.5rem;
    background-color: var(--liq-light);
    border: 1px solid var(--liq-primary);
    border-radius: var(--ed-radius);
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: var(--ed-shadow-sm);
    transition: all 0.2s ease;
}

.referral-link {
    color: var(--liq-deep);
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.referral-link i {
    width: 16px;
    height: 16px;
}

.referral-link:hover {
    color: var(--liq-primary);
}

/* ============================================
   ACCESS NOTICE
   ============================================ */
.access-notice {
    margin-bottom: 1.5rem;
    background-color: var(--ed-warning-light);
    border: 1px solid var(--ed-warning);
    border-radius: var(--ed-radius);
    padding: 0.75rem 1rem;
    text-align: center;
    box-shadow: var(--ed-shadow-sm);
}

.access-notice-text {
    color: #92400e;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.access-notice-text i {
    width: 16px;
    height: 16px;
}

/* ============================================
   CREDIT COST NOTICE
   ============================================ */
.credit-cost-notice {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--ed-warning-light);
    border: 1px solid var(--ed-warning);
    border-radius: var(--ed-radius);
    box-shadow: var(--ed-shadow-sm);
}

.credit-cost-inner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #92400e;
}

.credit-cost-inner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.credit-cost-inner span {
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============================================
   ICON SIZING UTILITIES
   (replaces inline style="width:Xpx; height:Xpx")
   ============================================ */
.icon-inline {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    margin-right: 0.3em;
}

.icon-inline-search {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    margin-right: 0.25em;
}

.icon-inline-btn {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    margin-right: 0.3em;
}

.icon-18 {
    width: 18px;
    height: 18px;
}

.icon-16 {
    width: 16px;
    height: 16px;
}

.icon-14 {
    width: 14px;
    height: 14px;
}

.icon-12 {
    width: 12px;
    height: 12px;
}

.icon-20 {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.icon-32 {
    width: 32px;
    height: 32px;
}

.icon-2rem {
    width: 2rem;
    height: 2rem;
}

/* Default Lucide icon sizing (prevents 0x0 icons) */
header.top-bar i[data-lucide],
header.top-bar svg.lucide {
    width: 20px;
    height: 20px;
}

.sidebar i[data-lucide],
.sidebar svg.lucide {
    width: 18px;
    height: 18px;
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none;
        transition: none;
    }
}
