/* ==========================================================================
   Export Intelligence & Trade Toolkit — Modern SaaS UI Design System
   ========================================================================== */

:root {
    --bg: #f8fafc;
    --bg-gradient: radial-gradient(1200px 700px at 80% -10%, #e0e7ff 0%, rgba(241, 245, 249, 0) 65%),
                   linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-focus: #3b82f6;

    --text: #0f172a;
    --text-secondary: #334155;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --muted-strong: #475569;   /* AA-compliant secondary text: 7.6:1 on white */

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-active: #1e40af;
    --primary-light: #eff6ff;
    --primary-border: #bfdbfe;

    --accent: #0284c7;
    --accent-light: #f0f9ff;
    
    --success: #059669;
    --success-hover: #047857;
    --success-light: #ecfdf5;
    --success-border: #a7f3d0;

    --warning: #d97706;
    --warning-light: #fffbeb;
    --warning-border: #fde68a;

    --danger: #dc2626;
    --danger-light: #fef2f2;
    --danger-border: #fecaca;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 18px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 28px -6px rgba(15, 23, 42, 0.10), 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    --ring: 0 0 0 3px rgba(37, 99, 235, 0.18);

    --transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.55;
    font-size: 0.95rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* ---- Header Hero ---- */
.header {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 28px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.header::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, #2563eb, #0284c7, #10b981);
}

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

.brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    height: 44px;
    width: auto;
    display: block;
    mix-blend-mode: multiply;
}

.brand-title {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 500;
    margin-top: 2px;
}

.fx-benchmark-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    box-shadow: var(--shadow-xs);
}

.fx-benchmark-pill .fx-label {
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.fx-benchmark-pill .fx-rate {
    font-weight: 800;
    color: #047857;
    font-variant-numeric: tabular-nums;
}

.fx-benchmark-pill .fx-badge {
    background: #10b981;
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.fx-benchmark-pill .fx-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #ffffff;
    display: inline-block;
    animation: pulse 1.8s infinite;
}

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

.formula-badge {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-hover);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-full);
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.header-action-btn {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.header-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-xs);
}

.early-access-pill {
    background: linear-gradient(135deg, #ecfdf5, #eff6ff);
    border-color: #a7f3d0;
    color: #065f46;
}

.early-access-pill:hover {
    background: linear-gradient(135deg, #d1fae5, #dbeafe);
    border-color: #6ee7b7;
    color: #047857;
}

.badge-tag {
    background: #f59e0b;
    color: #ffffff;
    font-size: 0.64rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---- Primary Navigation ---- */
.nav-toggle {
    display: none;
    width: 100%;
    margin-bottom: 12px;
    padding: 12px 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.tabs-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
}

.nav-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.nav-group-label {
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 4px;
}

.source-picker-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.source-picker {
    appearance: none;
    -webkit-appearance: none;
    padding: 9px 34px 9px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    background-image: url("data:svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}

.source-picker:hover {
    border-color: var(--primary);
    background-color: var(--surface);
}

.source-picker:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

.source-chip {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-full);
    padding: 4px 10px;
    white-space: nowrap;
}

.tools-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.tab-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 600;
    padding: 9px 15px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text);
    background: var(--surface-2);
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    box-shadow: 0 4px 12px -2px rgba(37, 99, 235, 0.45);
}

.tab-content {
    display: none;
    animation: tabFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
    display: block;
}

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

/* ---- Feature Spotlight Banner ---- */
.feature-spotlight-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #f0fdf4 0%, #eff6ff 100%);
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 14px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
}

.spotlight-content {
    flex: 1;
    min-width: 260px;
}

.spotlight-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 800;
    color: #047857;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.spotlight-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.spotlight-desc {
    font-size: 0.84rem;
    color: var(--muted);
}

.spotlight-btn {
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.25);
    transition: var(--transition);
    white-space: nowrap;
}

.spotlight-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(5, 150, 105, 0.35);
}

/* ---- Cards & Sections ---- */
.autofetch-card,
.multi-toggle-card,
.upload-section,
.mode-info-card,
.sample-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
    transition: border-color var(--transition);
}

.autofetch-header {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.autofetch-sub,
.autofetch-desc {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 18px;
}

.card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.source-badge {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

/* ---- Collapsible Coverage Details ---- */
.coverage-details {
    margin-bottom: 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.82rem;
}

.coverage-details summary {
    font-weight: 600;
    color: var(--primary);
    cursor: pointer;
    user-select: none;
}

.coverage-content {
    margin-top: 10px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.coverage-content p + p {
    margin-top: 8px;
}

/* ---- Source Mode Nav ---- */
.source-mode-nav {
    display: inline-flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-xs);
}

.source-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.source-btn:hover {
    color: var(--text);
}

.source-btn.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

/* ---- Forms & Inputs ---- */
.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    flex: 1;
}

.form-group label,
label {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 13px;
    font-size: 0.92rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    line-height: 1.4;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--ring);
}

input::placeholder, textarea::placeholder {
    color: var(--muted-2);
}

input[disabled] {
    background: var(--surface-3);
    color: var(--muted);
    cursor: not-allowed;
}

.hint {
    font-size: 0.78rem;
    color: var(--muted);
    margin-top: 4px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ---- Financial Year Chips ---- */
.year-preset-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.preset-pill {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

.preset-pill:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-border);
}

.years-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.year-cb-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.year-cb-label:hover {
    border-color: var(--primary-border);
    background: var(--primary-light);
}

.current-year-highlight {
    border-color: var(--success-border);
    background: var(--success-light);
    color: #065f46;
}

.curr-badge {
    background: var(--success);
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: var(--radius-full);
    letter-spacing: 0.04em;
}

.multi-badge {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

/* ---- Buttons & Chips ---- */
.submit-btn,
.autofetch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 22px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    gap: 8px;
}

.submit-btn:hover,
.autofetch-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
    filter: brightness(1.03);
}

.submit-btn:active,
.autofetch-btn:active {
    transform: scale(0.99);
}

.submit-btn:disabled,
.autofetch-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-btn,
.sample-btn {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 15px;
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.secondary-btn:hover,
.sample-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
}

.chip-btn {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 6px 13px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.chip-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-border);
    color: var(--primary);
    transform: translateY(-1px);
}

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
    margin: 6px 0 12px;
}

.chip-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
}

.hsn-history-section {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
}

/* ---- File Upload Zone ---- */
.file-box {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--muted);
    font-size: 0.88rem;
}

.file-box:hover,
.file-box.has-file {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}

.file-list-preview {
    font-size: 0.84rem;
    color: var(--muted);
    margin-top: 8px;
}

.file-status-text {
    font-size: 0.82rem;
    color: var(--success);
    margin-top: 6px;
    font-weight: 700;
}

/* ---- Status / Feedback Alerts ---- */
.status-msg {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    display: none;
    line-height: 1.5;
}

.status-msg.success {
    display: block;
    background: var(--success-light);
    color: #065f46;
    border: 1px solid var(--success-border);
}

.status-msg.error {
    display: block;
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid var(--danger-border);
}

.status-msg.loading {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--primary-border);
}

.status-msg.loading::before {
    content: "";
    width: 16px;
    height: 16px;
    border: 2px solid var(--primary-border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.status-msg.warning {
    display: block;
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid var(--warning-border);
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

thead th {
    background: var(--surface-2);
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

tbody tr:hover {
    background: var(--surface-2);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ---- Modals & Overlays ---- */
.custom-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    overflow-y: auto;
}

.custom-modal > .modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: transparent;
    cursor: pointer;
    display: block;
}

.custom-modal > .modal-dialog,
.modal-dialog {
    position: relative;
    z-index: 2;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 680px;
    margin: auto;
    overflow: hidden;
    animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border);
    max-height: 88vh;
    display: flex;
    flex-direction: column;
}

.custom-modal > .modal-dialog.modal-lg,
.modal-dialog.modal-lg {
    max-width: 920px;
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.modal-body {
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    line-height: 1.65;
    max-height: 75vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--surface-2);
}

.close-btn {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 32px;
    height: 32px;
    font-size: 1rem;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.close-btn:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger-border);
}

/* ---- Floating Cookie Consent Bar ---- */
.cookie-bar {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px 18px;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    color: #e2e8f0;
    box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.4);
    animation: cookieSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.cookie-text {
    font-size: 0.82rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.cookie-text a {
    color: #60a5fa;
    text-decoration: underline;
}

.cookie-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.cookie-link {
    color: #94a3b8;
    font-size: 0.8rem;
    text-decoration: underline;
}

/* ---- Ad slots (Cleaned & Collapsible) ---- */
.ad-slot {
    margin: 16px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.ad-slot:empty,
.ad-slot:not(:has(ins)) {
    display: none !important;
}

.ad-placeholder {
    display: none !important;
}

/* ---- Footer ---- */
.footer {
    text-align: center;
    color: var(--muted-strong);
    font-size: 0.82rem;
    padding: 32px 0 12px;
    border-top: 1px solid var(--border);
    margin-top: 36px;
}

.footer a {
    color: var(--muted-strong);
    text-decoration: none;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* ---- Screen-reader-only text: gives otherwise-empty table headers a name ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- WCAG 1.4.1: links inside a block of text must be distinguishable by more than
   colour alone. Without this, inline links fail `link-in-text-block` (axe, serious).
   Scoped to text contexts so nav/button-styled links keep their appearance. ---- */
.autofetch-card a,
main p a,
main li a {
    text-decoration: underline;
}

/* ---- Utilities ---- */
code {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.84em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---- Responsive (Mobile & Tablet) ---- */
@media (max-width: 900px) {
    .container {
        padding: 16px 14px 40px;
    }

    .header {
        padding: 20px;
    }

    .tabs-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .nav-group {
        width: 100%;
        justify-content: space-between;
    }

    .tools-group {
        overflow-x: auto;
        padding-bottom: 4px;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        /* A flex item defaults to min-width:auto, which kept this row at its full
           1812px content width and pushed the last tabs (Find Buyers) off-screen
           instead of scrolling inside the nav. */
        min-width: 0;
        width: 100%;
        max-width: 100%;
        scrollbar-width: thin;
    }

    .source-picker {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 12px 10px 48px;
    }

    .header-top-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .brand-title {
        font-size: 1.35rem;
    }

    .form-group {
        min-width: 100%;
    }

    .cookie-bar {
        left: 12px;
        right: 12px;
        bottom: 12px;
        max-width: none;
    }

    .custom-modal,
    .modal-dialog {
        margin: 10px;
        border-radius: var(--radius);
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 16px;
    }

    .header-actions {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 6px;
        -webkit-overflow-scrolling: touch;
    }

    .header-action-btn {
        white-space: nowrap;
    }
}

/* ==========================================================================
   Restored action buttons & tables
   These classes are still emitted by web_app.py — HSN Copy/Open buttons,
   download-result panels, the WhatsApp summary button, the importer-discovery
   directory links, and the Port-to-Port table. They were dropped during the
   UI rewrite, which left those elements unstyled.
   ========================================================================== */
.open-btn, .whatsapp-btn, .copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    font-size: 0.84rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}
.open-btn { background: var(--success); color: #fff; }
.open-btn:hover { background: var(--success-hover); }
.whatsapp-btn { background: #25d366; color: #04310f; }
.whatsapp-btn:hover { filter: brightness(0.95); }
.copy-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.copy-btn:hover { background: var(--primary-light); border-color: var(--primary-border); }

.port-table { width: 100%; }
.port-table th, .port-table td { padding: 8px 10px; }
.port-table th { text-align: left; }

/* Secondary-page (PAGE_TEMPLATE) header links */
.brand-subtitle a { color: inherit; text-decoration: none; }
.brand-subtitle a:hover { color: var(--primary); text-decoration: underline; }

/* ==========================================================================
   Accessibility
   ========================================================================== */
.skip-link {
    position: absolute;
    left: -9999px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
    background: var(--surface);
    color: var(--text);
    border: 2px solid var(--border-focus);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-weight: 700;
    z-index: 500;
}
.skip-link:focus {
    left: 12px;
    top: 12px;
    width: auto;
    height: auto;
    overflow: visible;
}
/* Visible keyboard focus on every interactive element (mouse clicks stay clean) */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: 4px;
}
/* Status messages announced politely; error text keeps AA contrast on light backgrounds */
.status-msg.error { color: #991b1b; }
.status-msg.success { color: #065f46; }
.status-msg.loading { color: #1e40af; }
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Reporter-country autocomplete (replaces the plain <select> in the nav)
   ========================================================================== */
.ac {
    position: relative;
    display: inline-block;
    width: 100%;
    min-width: 230px;
    max-width: 320px;
}
.ac-input {
    width: 100%;
    padding: 9px 34px 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: text;
    transition: var(--transition);
    background-image: url("data:svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-4.35-4.35M17 11a6 6 0 11-12 0 6 6 0 0112 0z'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
}
.ac-input::placeholder { color: var(--muted-2); font-weight: 500; }
.ac-input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--surface);
    box-shadow: var(--ring);
}
.ac-list {
    position: absolute;
    z-index: 80;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: none;
    padding: 4px;
}
.ac-list.open { display: block; }
.ac-item {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.86rem;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ac-item:hover,
.ac-item.active {
    background: var(--primary-light);
    color: var(--primary-active);
    font-weight: 600;
}

@media (max-width: 860px) {
    .ac { max-width: none; }
}

/* ---------------------------------------------------------------- wide result tables
   Port activity, freight indices and TARIC measures are 3–4 column tables with long text. On a
   phone they either crush or scroll; scrolling with a stated hint is the honest choice, and the
   hint disappears on a wide screen where there is nothing to scroll. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll table {
    min-width: 460px;
}

@media (max-width: 640px) {
    .table-scroll::after {
        content: "← scroll the table sideways →";
        display: block;
        font-size: 0.7rem;
        color: var(--muted-strong);
        margin-top: 3px;
    }
}

/* ---------------------------------------------------------------- print: the report, not the app
   Printing exists so a report can be handed to someone. Navigation, ads, forms and prompts are
   noise on paper; the preview keeps its own source line and figures. */
@media print {
    .tab-bar, .tab-btn, .ad-slot, .cookie-bar, .feature-spotlight-card, .spotlight-card,
    .modal-backdrop, .custom-modal, .status-msg, #tdp_search,
    .autofetch-card:not(#td_preview .autofetch-card) {
        display: none !important;
    }

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

    #td_preview {
        margin: 0;
    }

    .table-scroll {
        overflow: visible !important;
    }

    .table-scroll table {
        min-width: 0 !important;
    }

    .table-scroll::after {
        content: none;
    }

    body {
        background: #fff;
    }
}
