/* ═══════════════════════════════════════════════════════════════════
   Trade Compliance Dashboard — Design System
   Professional navy/slate palette for trade & compliance work.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ─────────────────────────────────────────────── */
:root {
    --navy: #0f1d36;
    --navy-light: #152544;
    --slate: #1e2d4a;
    --steel: #4a6a8a;
    --steel-light: #7a93ae;
    --amber: #e8a838;
    --emerald: #2d9d6b;
    --coral: #d4556e;
    --sky: #5b9bd5;
    --offwhite: #f4f6f9;
    --white: #ffffff;
    --gray-50: #f8f9fb;
    --gray-100: #e8ecf1;
    --gray-200: #d1d7e0;
    --gray-300: #a0aab8;
    --gray-600: #6b7c93;
    --gray-800: #2d3748;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
    --shadow: 0 2px 8px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,.12);
    --transition: 0.2s ease;
    --sidebar-w: 240px;
}

/* ── Reset & Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--offwhite);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--sky); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: "JetBrains Mono", "Fira Code", "Cascadia Code", monospace; }
pre { background: #f1f3f6; border-radius: var(--radius); padding: 16px; overflow-x: auto; font-size: 0.85rem; }
code { font-size: 0.9em; background: #f1f3f6; padding: 2px 6px; border-radius: 4px; }
pre code { background: none; padding: 0; }

/* ── Layout ────────────────────────────────────────────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--navy);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
}
.brand-link:hover { text-decoration: none; opacity: .9; }
.brand-icon { font-size: 1.5rem; }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--steel-light);
    text-decoration: none;
    font-size: 0.95rem;
    transition: var(--transition);
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: var(--slate);
    color: var(--white);
    text-decoration: none;
}
.nav-item.active {
    background: var(--slate);
    color: var(--white);
    border-left-color: var(--sky);
}
.nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-info { font-size: 0.75rem; color: var(--steel); line-height: 1.8; }

/* ── Mobile Header ─────────────────────────────────────────────────── */
.mobile-header {
    display: none;
    background: var(--navy);
    color: var(--white);
    padding: 12px 16px;
    align-items: center;
    gap: 12px;
}
.menu-toggle {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}
.mobile-brand { font-weight: 700; }

/* ── Main Content ──────────────────────────────────────────────────── */
.content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px 40px;
    max-width: 1200px;
    width: 100%;
}

/* ── Hero ──────────────────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 32px 0 40px;
}
.hero h1 { font-size: 2rem; color: var(--navy); margin-bottom: 8px; }
.hero-subtitle { color: var(--steel); font-size: 1.05rem; line-height: 1.7; }

/* ── Skill Cards (Home) ────────────────────────────────────────────── */
.skill-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 48px;
}
.skill-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 1px solid var(--gray-100);
    transition: var(--transition);
}
.skill-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.skill-card-icon { font-size: 2.5rem; }
.skill-card-body h2 { font-size: 1.25rem; color: var(--navy); margin-bottom: 8px; }
.skill-card-body ul { list-style: none; color: var(--gray-600); font-size: 0.9rem; }
.skill-card-body li { padding: 4px 0; padding-left: 16px; position: relative; }
.skill-card-body li::before { content: "·"; position: absolute; left: 4px; color: var(--sky); font-weight: bold; }
.skill-card .btn { align-self: flex-start; margin-top: auto; }

/* ── Quick Templates ───────────────────────────────────────────────── */
.quick-templates h2, .recent-activity h2 { font-size: 1.15rem; color: var(--navy); margin-bottom: 16px; }
.template-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 48px;
}
.template-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-100);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition);
}
.template-card:hover { box-shadow: var(--shadow); }
.template-card-header { display: flex; justify-content: space-between; align-items: center; }
.template-icon { font-size: 1.5rem; }
.template-card h3 { font-size: 0.95rem; color: var(--navy); }
.template-card p { font-size: 0.8rem; color: var(--gray-600); flex: 1; }

/* ── Skill Badge ───────────────────────────────────────────────────── */
.skill-badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-customs { background: #e8f4fd; color: #1a6fb5; }
.badge-chokepoint { background: #fef3e2; color: #b5761a; }

/* ── Verdict Badge ─────────────────────────────────────────────────── */
.verdict-badge {
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.8rem;
    text-align: center;
}
.verdict-commit { background: #d4f5e6; color: #1a6b3c; }
.verdict-pilot { background: #dceafb; color: #1a4d8f; }
.verdict-watch { background: #fef3cd; color: #856404; }
.verdict-pass { background: #fde2e4; color: #9b1c2e; }
.verdict-lg { font-size: 1.1rem; padding: 8px 24px; }
.verdict-display { text-align: center; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--slate); }
.btn-secondary { background: var(--white); color: var(--navy); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-ghost { background: transparent; color: var(--steel); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }

/* ── Page Header ───────────────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; color: var(--navy); }
.page-desc { color: var(--steel); font-size: 0.9rem; margin-top: 4px; }
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 16px; }
.back-link { color: var(--steel); font-size: 0.85rem; display: inline-block; margin-bottom: 8px; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.analysis-form { display: flex; flex-direction: column; gap: 20px; }
.form-section {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.form-section legend {
    font-weight: 700;
    font-size: 1rem;
    color: var(--navy);
    padding: 0 8px;
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.form-group.flex-1 { flex: 1; min-width: 160px; }
.form-group.flex-2 { flex: 2; min-width: 200px; }
.form-group label { font-size: 0.85rem; font-weight: 600; color: var(--gray-800); }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--gray-800);
    background: var(--white);
    transition: var(--transition);
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--sky);
    box-shadow: 0 0 0 3px rgba(91, 155, 213, 0.15);
}
.form-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 8px 0 32px;
}

/* ── HS Quick Bar ──────────────────────────────────────────────────── */
.hs-quick-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.quick-label { font-size: 0.8rem; font-weight: 600; color: var(--steel); }
.hs-chip {
    padding: 4px 12px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    color: var(--gray-800);
}
.hs-chip:hover { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ── Checkbox Grid ─────────────────────────────────────────────────── */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.check-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}
.check-card:hover { border-color: var(--sky); background: #f7faff; }
.check-card input[type="checkbox"] { margin-top: 3px; }
.check-label { display: flex; flex-direction: column; }
.check-label strong { font-size: 0.85rem; }
.check-label small { color: var(--gray-600); font-size: 0.75rem; }
.checkbox-inline { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; }

/* ── Score Grid ────────────────────────────────────────────────────── */
.score-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}
.score-col h3 { font-size: 0.95rem; margin-bottom: 16px; color: var(--navy); }

.slider-group { margin-bottom: 16px; }
.slider-header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.slider-label { font-size: 0.85rem; font-weight: 600; }
.slider-hint { font-size: 0.75rem; color: var(--gray-600); flex: 1; min-width: 150px; }
.slider-val {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--navy);
    min-width: 24px;
    text-align: center;
}
.score-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 3px;
    background: var(--gray-200);
    outline: none;
}
.score-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--sky);
    cursor: pointer;
    border: 2px solid var(--white);
    box-shadow: var(--shadow-sm);
}
.factor-slider .score-slider { accent-color: var(--emerald); }
.penalty-slider .score-slider { accent-color: var(--coral); }
.slider-ticks {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--gray-300);
    padding: 0 2px;
}

/* ── Floating Score Panel ──────────────────────────────────────────── */
.score-panel {
    position: sticky;
    top: 20px;
    float: right;
    width: 200px;
    background: var(--white);
    border: 2px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    z-index: 10;
    margin-left: 24px;
}
.score-panel-title { font-size: 0.75rem; color: var(--steel); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; }
.score-big { font-size: 3rem; font-weight: 800; color: var(--navy); line-height: 1.1; }
.score-detail { display: flex; justify-content: center; gap: 16px; margin-top: 8px; font-size: 0.8rem; color: var(--gray-600); }

/* ── Landed Cost Summary ───────────────────────────────────────────── */
.landed-summary {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 12px;
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
}
.landed-row { font-size: 0.9rem; }
.landed-row span { color: var(--gray-600); }
.landed-row strong { color: var(--navy); font-size: 1rem; }

/* ── Action Bar ────────────────────────────────────────────────────── */
.action-bar {
    display: flex;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 20px;
}
.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-600);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--sky); }

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

/* ── Markdown Body ─────────────────────────────────────────────────── */
.markdown-body { line-height: 1.75; }
.markdown-body h2 { font-size: 1.2rem; color: var(--navy); margin: 24px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--gray-100); }
.markdown-body h3 { font-size: 1rem; color: var(--navy); margin: 16px 0 8px; }
.markdown-body p { margin-bottom: 12px; }
.markdown-body ul, .markdown-body ol { margin-bottom: 12px; padding-left: 24px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.9rem; }
.markdown-body th { background: var(--navy); color: var(--white); padding: 10px 14px; text-align: left; font-weight: 600; }
.markdown-body td { padding: 8px 14px; border-bottom: 1px solid var(--gray-100); }
.markdown-body tr:nth-child(even) td { background: var(--gray-50); }
.markdown-body strong { color: var(--navy); }
.markdown-body blockquote {
    border-left: 3px solid var(--sky);
    padding: 8px 16px;
    margin: 12px 0;
    background: #f7faff;
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--steel);
}

/* ── Findings ──────────────────────────────────────────────────────── */
.findings-list { display: flex; flex-direction: column; gap: 16px; }
.finding-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 20px;
}
.finding-card h3 { font-size: 1rem; color: var(--navy); margin-bottom: 8px; }

/* ── Raw JSON ──────────────────────────────────────────────────────── */
.raw-json {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 20px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}
details { margin-bottom: 12px; }
details summary { cursor: pointer; font-weight: 600; color: var(--steel); padding: 8px 0; }

/* ── Data Table ────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--steel);
    border-bottom: 2px solid var(--gray-200);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.data-table td { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); }
.data-table tr:hover td { background: var(--gray-50); }
.td-date { white-space: nowrap; color: var(--steel); font-size: 0.85rem; }
.td-summary { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-actions { white-space: nowrap; }

/* ── Filter Bar ────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.filter-pill {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--gray-200);
    color: var(--steel);
    text-decoration: none;
    transition: var(--transition);
}
.filter-pill:hover { background: var(--gray-50); text-decoration: none; }
.filter-pill.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* ── Empty State ───────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-600); }

/* ── Result Meta ───────────────────────────────────────────────────── */
.result-meta { display: flex; gap: 24px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--gray-100); font-size: 0.8rem; color: var(--gray-600); flex-wrap: wrap; }

/* ── Data Disclaimer ───────────────────────────────────────────────── */
.data-disclaimer {
    margin-top: 24px;
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-disclaimer summary {
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--steel);
    cursor: pointer;
    user-select: none;
}
.data-disclaimer summary:hover { color: var(--navy); }
.disclaimer-content {
    padding: 0 16px 16px;
    font-size: 0.8rem;
    color: var(--gray-600);
    line-height: 1.8;
}
.disclaimer-content p { margin-bottom: 8px; }
.disclaimer-content ul { padding-left: 20px; margin-bottom: 8px; }
.disclaimer-content li { margin-bottom: 2px; }
.disclaimer-content strong { color: var(--navy); }

/* ── Template Detail Grid ──────────────────────────────────────────── */
.template-detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.template-detail-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.template-detail-card h3 { font-size: 1.05rem; color: var(--navy); }
.template-desc { font-size: 0.85rem; color: var(--steel); }
.template-preview { background: var(--gray-50); border-radius: var(--radius); padding: 12px; }
.template-preview h4 { font-size: 0.75rem; color: var(--steel); margin-bottom: 8px; text-transform: uppercase; }
.preview-table { width: 100%; font-size: 0.8rem; }
.preview-table td { padding: 2px 8px; }
.preview-table td:first-child { color: var(--steel); width: 120px; }
.preview-table code { font-size: 0.8rem; }
.template-actions { margin-top: auto; }

/* ── Skeleton Loading ──────────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-50) 50%, var(--gray-100) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Flash Messages ────────────────────────────────────────────────── */
.flash-messages { margin-bottom: 16px; }
.flash-msg {
    background: #fef3cd;
    border: 1px solid #ffc107;
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .skill-cards { grid-template-columns: 1fr; }
    .template-grid { grid-template-columns: repeat(2, 1fr); }
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
    .score-grid { grid-template-columns: 1fr; }
    .template-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform var(--transition); }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .content { margin-left: 0; padding: 20px 16px; }
    .form-row { flex-direction: column; }
    .template-grid { grid-template-columns: 1fr; }
    .checkbox-grid { grid-template-columns: 1fr; }
    .score-panel { float: none; width: 100%; margin: 0 0 16px 0; position: static; }
    .page-header-row { flex-direction: column; }
}
