/* ===== DNCA Tools Design Tokens ===== */
:root {
    --blue: #0073B5;
    --blue-dark: #005A8E;
    --blue-light: #E8F4FD;
    --slate: #354048;
    --slate-light: #4A5568;
    --gray-50: #F7F7F7;
    --gray-100: #EDEDED;
    --gray-200: #D5D5D5;
    --gray-300: #B0B0B0;
    --gray-400: #888;
    --gray-600: #555;
    --white: #FFFFFF;
    --green: #22C55E;
    --green-bg: #F0FDF4;
    --orange: #F59E0B;
    --orange-bg: #FFFBEB;
    --red: #EF4444;
    --red-bg: #FEF2F2;
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Cormorant Garamond', Georgia, serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --transition: 150ms ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    color: var(--slate);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Topbar ===== */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.topbar-brand {
    font-family: var(--font-serif);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--slate);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-logo {
    height: 32px;
    width: auto;
}
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-link {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-600);
    text-decoration: none;
    transition: all var(--transition);
}
.nav-link:hover { background: var(--gray-50); color: var(--slate); }
.nav-link.active { background: var(--blue-light); color: var(--blue); }
.nav-link--logout { color: var(--gray-400); }
.nav-link--logout:hover { color: var(--red); }

/* ===== Main content ===== */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    min-height: calc(100vh - 56px - 48px);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 12px 24px;
    font-size: 0.8rem;
    color: var(--gray-400);
    border-top: 1px solid var(--gray-100);
}

/* ===== Page header ===== */
.page-header { margin-bottom: 32px; }
.page-header h1 {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: 700;
    color: var(--slate);
}
.page-subtitle {
    color: var(--gray-400);
    margin-top: 4px;
}

/* ===== Dashboard hero ===== */
.dashboard-hero {
    position: relative;
    background: linear-gradient(135deg, #004D71 0%, #00628f 50%, #0073B5 100%);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    margin-bottom: 32px;
    overflow: hidden;
}
.dashboard-hero__content { position: relative; z-index: 1; }
.dashboard-hero__title {
    font-family: var(--font-serif);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -0.01em;
}
.dashboard-hero__subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.95rem;
    margin-top: 6px;
    font-weight: 400;
}
.dashboard-hero__pattern {
    position: absolute;
    inset: 0;
    opacity: 0.06;
    background-image:
        linear-gradient(30deg, #fff 12%, transparent 12.5%, transparent 87%, #fff 87.5%, #fff),
        linear-gradient(150deg, #fff 12%, transparent 12.5%, transparent 87%, #fff 87.5%, #fff),
        linear-gradient(30deg, #fff 12%, transparent 12.5%, transparent 87%, #fff 87.5%, #fff),
        linear-gradient(150deg, #fff 12%, transparent 12.5%, transparent 87%, #fff 87.5%, #fff),
        linear-gradient(60deg, rgba(255,255,255,0.6) 25%, transparent 25.5%, transparent 75%, rgba(255,255,255,0.6) 75%, rgba(255,255,255,0.6)),
        linear-gradient(60deg, rgba(255,255,255,0.6) 25%, transparent 25.5%, transparent 75%, rgba(255,255,255,0.6) 75%, rgba(255,255,255,0.6));
    background-size: 40px 70px;
    background-position: 0 0, 0 0, 20px 35px, 20px 35px, 0 0, 20px 35px;
}

/* ===== Module grid ===== */
@keyframes cardReveal {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}
.module-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: 0;
    text-decoration: none;
    color: inherit;
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    animation: cardReveal 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.module-card__accent {
    width: 4px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #0073B5, #004D71);
    border-radius: 0;
}
.module-card__accent--muted {
    background: var(--gray-200);
}
.module-card__inner {
    padding: 24px 28px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.module-card__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.module-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.module-icon-wrap--active {
    background: var(--blue-light);
    color: var(--blue);
}
.module-icon-wrap--muted {
    background: var(--gray-50);
    color: var(--gray-300);
}
.module-card h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--slate);
}
.module-card p {
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.6;
    flex: 1;
}
.module-card__arrow {
    margin-top: 16px;
    color: var(--blue);
    opacity: 0;
    transform: translateX(-6px);
    transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}
.module-card--active:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}
.module-card--active:hover .module-card__arrow {
    opacity: 1;
    transform: translateX(0);
}
.module-card--active:hover .module-card__accent {
    width: 5px;
}
.module-card--disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.module-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.module-badge--active {
    background: var(--green-bg);
    color: var(--green);
    box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.15);
}
.module-badge--soon {
    background: var(--gray-50);
    color: var(--gray-400);
    box-shadow: 0 0 0 1px var(--gray-100);
}
.module-badge--wip {
    background: var(--orange-bg);
    color: var(--orange);
    box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
}
.module-card__accent--wip {
    background: linear-gradient(180deg, #F59E0B, #D97706);
}
.module-icon-wrap--wip {
    background: var(--orange-bg);
    color: var(--orange);
}
.module-card--wip {
    border-color: rgba(245, 158, 11, 0.3);
}
.module-card--wip:hover {
    border-color: var(--orange);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}
.module-card--wip:hover .module-card__arrow {
    opacity: 1;
    transform: translateX(0);
}
.module-card--wip:hover .module-card__accent {
    width: 5px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
}
.btn--primary { background: var(--blue); color: var(--white); }
.btn--primary:hover { background: var(--blue-dark); }
.btn--primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn--outline { background: var(--white); color: var(--slate); border: 1px solid var(--gray-200); }
.btn--outline:hover { border-color: var(--blue); color: var(--blue); }
.btn--danger { background: var(--red); color: var(--white); }
.btn--outline.btn--danger { background: var(--white); color: var(--red); border-color: var(--gray-200); }
.btn--outline.btn--danger:hover { border-color: var(--red); background: var(--red-bg); }
.btn--sm { padding: 6px 14px; font-size: 0.8rem; }
.btn--full { width: 100%; }
.btn--icon { padding: 8px; }

/* ===== Cards ===== */
.card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }

/* ===== Forms ===== */
label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-600);
    margin-bottom: 6px;
}
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: var(--font-sans);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--slate);
    transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(0, 115, 181, 0.1);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 16px;
}
.alert--error { background: var(--red-bg); color: var(--red); border: 1px solid #FECACA; }
.alert--success { background: var(--green-bg); color: var(--green); border: 1px solid #BBF7D0; }
.alert--warning { background: var(--orange-bg); color: var(--orange); border: 1px solid #FDE68A; }

/* ===== Login ===== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-50);
}
.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo {
    width: 220px;
    height: auto;
}
.login-form label { margin-top: 12px; }
.login-form input { margin-bottom: 20px; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 99px;
    letter-spacing: 0.3px;
}
.badge--green { background: var(--green-bg); color: var(--green); }
.badge--orange { background: var(--orange-bg); color: var(--orange); }
.badge--red { background: var(--red-bg); color: var(--red); }
.badge--blue { background: var(--blue-light); color: var(--blue); }
.badge--gray { background: var(--gray-100); color: var(--gray-600); }

.badge--regex { background: #EDE9FE; color: #7C3AED; }
.badge--llm { background: var(--blue-light); color: var(--blue); }
.badge--table { background: var(--green-bg); color: var(--green); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
th {
    text-align: left;
    padding: 10px 14px;
    background: var(--slate);
    color: var(--white);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
th:first-child { border-radius: var(--radius) 0 0 0; }
th:last-child { border-radius: 0 var(--radius) 0 0; }
td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--gray-100);
}
tr:hover td { background: var(--gray-50); }

/* ===== Progress bar ===== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--gray-100);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar__fill {
    height: 100%;
    background: var(--blue);
    border-radius: 99px;
    transition: width 300ms ease;
}

/* ===== Stats grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow);
}
.stat-card__label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card__value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--slate);
    margin-top: 4px;
    font-family: var(--font-mono);
}
.stat-card__sub {
    font-size: 0.8rem;
    color: var(--gray-400);
    margin-top: 2px;
}
.stat-card__help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-600);
    font-size: 0.6rem;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
}
.tooltip-wrap {
    position: relative;
    display: inline-flex;
    margin-left: 4px;
}
.tooltip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 260px;
    padding: 10px 14px;
    background: var(--slate);
    color: var(--white);
    font-size: 0.78rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.5;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    pointer-events: none;
}
.tooltip::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--slate);
}
.tooltip-wrap:hover .tooltip {
    display: block;
}

/* ===== Upload zone ===== */
.upload-zone {
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--white);
}
.upload-zone:hover,
.upload-zone.dragover,
.upload-zone--dragover {
    border-color: var(--blue);
    background: var(--blue-light);
}
.upload-zone__icon { font-size: 2.5rem; color: var(--gray-300); margin-bottom: 12px; }
.upload-zone__text { color: var(--gray-600); font-size: 0.9rem; }
.upload-zone__text strong { color: var(--blue); }
.upload-zone__file {
    margin-top: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--slate);
}

/* ===== KID file list ===== */
.kid-file-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kid-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--gray-50);
    border-radius: var(--radius);
    transition: background var(--transition);
}
.kid-file-item:hover {
    background: var(--gray-100);
}
.kid-file-item__icon {
    color: var(--gray-400);
    flex-shrink: 0;
    display: flex;
}
.kid-file-item__name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--slate);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.kid-file-item__size {
    flex-shrink: 0;
}
.kid-file-item__remove {
    border: none;
    background: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    transition: all var(--transition);
}
.kid-file-item__remove:hover {
    color: var(--red);
    background: var(--red-bg);
}

/* ===== Fund list ===== */
.fund-item {
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
}
.fund-item__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--white);
    cursor: pointer;
    user-select: none;
}
.fund-item__header:hover { background: var(--gray-50); }
.fund-item__name { font-weight: 600; font-size: 0.9rem; }
.fund-item__details {
    padding: 16px;
    background: var(--gray-50);
    border-top: 1px solid var(--gray-100);
    font-size: 0.85rem;
}
.fund-field { display: flex; padding: 4px 0; align-items: baseline; }
.fund-field__label { width: 200px; color: var(--gray-400); font-weight: 500; flex-shrink: 0; }
.fund-field__value { color: var(--slate); flex: 1; }

/* ===== Extraction phases ===== */
.phases {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}
.phase {
    flex: 1;
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    text-align: center;
    background: var(--gray-100);
    color: var(--gray-400);
}
.phase--active { background: var(--blue-light); color: var(--blue); }
.phase--done { background: var(--green-bg); color: var(--green); }

/* ===== Section headings ===== */
.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}

/* ===== Utilities ===== */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--gray-400); }
.text-center { text-align: center; }
.hidden { display: none; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .topbar-inner { padding: 0 16px; }
    .topbar-nav { gap: 2px; }
    .nav-link { padding: 6px 8px; font-size: 0.8rem; }
    .main-content { padding: 20px 16px; }
    .module-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .fund-field { flex-direction: column; }
    .fund-field__label { width: auto; margin-bottom: 2px; }
}

/* ===== Setup page ===== */
.setup-grid {
    display: grid;
    gap: 24px;
}
.setup-section {
    background: var(--white);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}
.setup-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}
.form-group { margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; align-items: end; }
.form-row > * { flex: 1; }

/* ===== Model selector grid ===== */
.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.model-card {
    display: flex;
    flex-direction: column;
    padding: 14px 16px 12px;
    border: 1.5px solid var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    background: var(--white);
    position: relative;
}
.model-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.model-card:hover {
    border-color: var(--blue);
    box-shadow: var(--shadow-md);
}
.model-card--selected,
.model-card:has(input[type="radio"]:checked) {
    border-color: var(--blue);
    background: var(--blue-light);
    box-shadow: 0 0 0 1px var(--blue);
}
.model-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 10px;
}
.model-card__name {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--slate);
}
.model-card__provider {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--gray-50);
    color: var(--gray-600);
    border: 1px solid var(--gray-100);
    white-space: nowrap;
}
.model-card__pricing {
    display: flex;
    gap: 16px;
}
.model-card__price {
    display: flex;
    align-items: baseline;
    gap: 5px;
}
.model-card__price-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--gray-300);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.model-card__price-value {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--gray-600);
}

/* ===== Raw section text ===== */
.raw-section {
    margin: 8px 0 16px;
}
.raw-section__toggle {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--blue);
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}
.raw-section__toggle:hover {
    text-decoration: underline;
}
.raw-section__text {
    background: var(--gray-50);
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 14px 18px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--gray-600);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 8px;
}

/* ===== Source location breadcrumb ===== */
.source-loc {
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--gray-400);
    cursor: pointer;
    margin-top: 4px;
}
.source-loc:hover {
    color: var(--blue);
    text-decoration: underline;
}

/* ===== Share class table: PDF vs derived columns ===== */
.th-group {
    text-align: center;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 6px 8px;
}
.th-group--pdf {
    background: var(--blue-light);
    color: var(--blue);
}
.th-group--derived {
    background: var(--orange-bg);
    color: var(--orange);
}
.th-derived {
    background: var(--orange-bg);
    color: var(--orange);
}
.td-derived {
    background: var(--orange-bg);
}

/* ===== Extraction log ===== */
.extraction-log {
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    overflow: hidden;
}
.extraction-log__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: var(--gray-50);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--gray-100);
}
.extraction-log__body {
    max-height: 280px;
    overflow-y: auto;
    background: var(--slate);
    padding: 12px 16px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.7;
    color: #c8d0d8;
}
.extraction-log__line {
    white-space: pre-wrap;
    word-break: break-word;
}
.extraction-log__line--section {
    color: var(--white);
    font-weight: 600;
    margin-top: 4px;
}
.extraction-log__line--ok {
    color: #6ee7b7;
}
.extraction-log__line--err {
    color: #fca5a5;
}

/* ===== Export buttons ===== */
.export-bar {
    display: flex;
    gap: 8px;
    padding: 16px 0;
}

/* ===== KID Log ===== */
.kid-log {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--gray-100);
    border-radius: var(--radius);
    padding: 8px 0;
    font-size: 0.82rem;
    font-family: var(--font-sans);
    background: var(--gray-50);
}
.kid-log__line {
    padding: 3px 12px;
    line-height: 1.5;
}
.kid-log__line--file {
    color: var(--slate);
}
.kid-log__line--skip {
    color: var(--orange);
    padding-left: 24px;
    font-size: 0.78rem;
}
.kid-log__line--error {
    color: var(--red);
    padding-left: 24px;
    font-size: 0.78rem;
}
.kid-log__line--done {
    color: var(--green);
    font-weight: 600;
    margin-top: 4px;
}
.kid-log__line--info {
    color: var(--gray-400);
    font-size: 0.78rem;
}

/* ===== KID Parser Progress ===== */
.kid-progress__bar {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
}
.kid-progress__fill {
    height: 100%;
    background: var(--blue);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.kid-progress__text {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--slate-light);
}

/* ===== KID Results Table ===== */
.table-wrapper {
    overflow-x: auto;
    margin-top: 12px;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.data-table th {
    background: var(--slate);
    color: var(--white);
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
.data-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--gray-100);
    white-space: nowrap;
}
.data-table tbody tr:hover {
    background: var(--gray-50);
}
.text-mono {
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* ===== KID Comparison ===== */
.compare-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}
.compare-badge--ok {
    background: var(--green-bg);
    color: var(--green);
}
.compare-badge--diff {
    background: var(--orange-bg);
    color: var(--orange);
}
.compare-badge--absent {
    background: var(--gray-100);
    color: var(--gray-400);
}
.compare-row--diff {
    background: var(--orange-bg) !important;
}
.compare-row--absent {
    background: var(--gray-50) !important;
    color: var(--gray-400);
}

/* Sortable table headers */
.th-sort {
    cursor: pointer;
    user-select: none;
}
.th-sort:hover {
    opacity: 0.8;
}
.sort-icon {
    font-size: 0.6em;
    opacity: 0.5;
}

/* PDF tag link */
.pdf-tag {
    display: inline-block;
    padding: 1px 6px;
    margin-left: 8px;
    background: var(--red-bg);
    color: var(--red);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none;
    border-radius: 3px;
    letter-spacing: 0.5px;
    vertical-align: middle;
}
.pdf-tag:hover {
    background: var(--red);
    color: var(--white);
}

/* Filter selects aligned with buttons */
.filter-select {
    height: 32px;
    padding: 4px 8px;
    font-size: 0.8rem;
    max-width: 220px;
}

/* Comparison table without horizontal scroll */
.data-table--wrap td,
.data-table--wrap th {
    white-space: normal;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
}
.alert--success {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid var(--green);
}
.alert--error {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid var(--red);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.modal-content--lg {
    width: 95vw;
    max-width: 1100px;
    height: 85vh;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 4px;
    border-radius: var(--radius);
    transition: all var(--transition);
}
.modal-close:hover {
    background: var(--gray-50);
    color: var(--slate);
}
.modal-body {
    padding: 20px;
    flex: 1;
    overflow: auto;
}
