/* Bulk validation portal (sign-in + upload pages). Builds on Bootstrap 5.1. */

:root {
    --pv-primary: #4f46e5;
    --pv-primary-hover: #4338ca;
    --pv-primary-soft: #eef2ff;
    --pv-primary-ring: rgba(79, 70, 229, .25);
    --pv-ink: #0f172a;
    --pv-text: #334155;
    --pv-muted: #64748b;
    --pv-border: #e2e8f0;
    --pv-bg: #f5f7fb;
    --pv-surface: #ffffff;
    --pv-success: #16a34a;
    --pv-success-soft: #dcfce7;
    --pv-danger: #dc2626;
    --pv-danger-soft: #fee2e2;
    --pv-warning: #d97706;
    --pv-warning-soft: #fef3c7;
    --pv-radius: 16px;
    --pv-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
    --pv-font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --pv-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

[hidden] { display: none !important; }

body.portal {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    font-family: var(--pv-font);
    font-size: 15px;
    color: var(--pv-text);
    background:
        radial-gradient(1100px 480px at 8% -8%, #e0e7ff 0%, transparent 60%),
        radial-gradient(900px 420px at 108% -4%, #ede9fe 0%, transparent 55%),
        var(--pv-bg);
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
}

.icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.portal code {
    font-family: var(--pv-mono);
    font-size: .85em;
    color: var(--pv-primary-hover);
    background: var(--pv-primary-soft);
    padding: 1px 6px;
    border-radius: 5px;
}

/* ---------- Header / footer ---------- */

.portal-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(255, 255, 255, .85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--pv-border);
}

.portal-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--pv-ink);
    font-weight: 700;
    font-size: 17px;
    line-height: 1.2;
    text-decoration: none;
}

.brand:hover { color: var(--pv-ink); }

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}

.brand-sub {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--pv-muted);
}

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

.session-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--pv-muted);
}

.session-pill::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--pv-success);
    box-shadow: 0 0 0 3px var(--pv-success-soft);
}

.portal-main { flex: 1; }

.portal-footer {
    text-align: center;
    font-size: 13px;
    color: var(--pv-muted);
    padding: 24px;
}

/* ---------- Buttons and inputs ---------- */

.portal .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 10px;
    font-weight: 600;
    padding: .6rem 1.1rem;
    transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
}

.portal .btn-lg { padding: .8rem 1.4rem; font-size: 1rem; }

.portal .btn-primary {
    color: #fff;
    background: var(--pv-primary);
    border-color: var(--pv-primary);
    box-shadow: 0 6px 16px rgba(79, 70, 229, .25);
}

.portal .btn-primary:hover { background: var(--pv-primary-hover); border-color: var(--pv-primary-hover); }

.portal .btn-primary:disabled,
.portal .btn-primary.disabled {
    color: #fff;
    background: #a5b4fc;
    border-color: #a5b4fc;
    box-shadow: none;
    opacity: 1;
}

.portal .btn-outline {
    color: var(--pv-ink);
    background: #fff;
    border: 1px solid var(--pv-border);
}

.portal .btn-outline:hover {
    color: var(--pv-primary-hover);
    background: var(--pv-primary-soft);
    border-color: #c7d2fe;
}

.portal .btn-ghost {
    color: var(--pv-text);
    background: transparent;
    border: 1px solid transparent;
    padding: .45rem .8rem;
}

.portal .btn-ghost:hover { background: #f1f5f9; color: var(--pv-ink); }

.portal .btn:focus,
.portal .btn:focus-visible { box-shadow: 0 0 0 4px var(--pv-primary-ring); outline: none; }

.portal .btn .spinner { display: none; }

.portal .btn.is-loading .spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pv-spin .7s linear infinite;
}

.portal .btn.is-loading .btn-icon { display: none; }

.portal .form-label { font-weight: 600; font-size: 14px; color: var(--pv-ink); }

.portal .form-check-input:checked { background-color: var(--pv-primary); border-color: var(--pv-primary); }

.portal .form-check-input:focus { box-shadow: 0 0 0 4px var(--pv-primary-ring); border-color: var(--pv-primary); }

.icon-button {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--pv-muted);
    transition: background-color .15s, color .15s;
}

.icon-button:hover { background: #f1f5f9; color: var(--pv-ink); }

.icon-button:disabled { opacity: .4; pointer-events: none; }

.message {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.45;
}

.message .icon { margin-top: 1px; }
.message.is-error { background: var(--pv-danger-soft); color: #991b1b; }
.message.is-warning { background: var(--pv-warning-soft); color: #92400e; }
.message a { color: inherit; font-weight: 700; }

/* ---------- Upload page layout ---------- */

.portal-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 32px;
}

.page-heading h1 {
    margin: 0 0 6px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--pv-ink);
}

.page-heading p {
    margin: 0 0 28px;
    font-size: 16px;
    color: var(--pv-muted);
}

.portal-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: start;
}

.portal-primary,
.portal-aside {
    display: grid;
    gap: 24px;
    min-width: 0;
}

.panel {
    background: var(--pv-surface);
    border: 1px solid var(--pv-border);
    border-radius: var(--pv-radius);
    box-shadow: var(--pv-shadow);
    padding: 28px;
}

.panel-compact { padding: 22px; }

.panel h2 {
    margin: 0 0 14px;
    font-size: 16px;
    font-weight: 700;
    color: var(--pv-ink);
}

/* ---------- Drop zone ---------- */

.dropzone {
    border: 2px dashed #c7d2fe;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfcff, #f5f7ff);
    padding: 52px 24px;
    text-align: center;
    cursor: pointer;
    outline: none;
    transition: border-color .15s, background-color .15s, transform .15s, box-shadow .15s;
}

.dropzone:hover { border-color: var(--pv-primary); background: var(--pv-primary-soft); }

.dropzone:focus-visible { border-color: var(--pv-primary); box-shadow: 0 0 0 4px var(--pv-primary-ring); }

.dropzone.is-dragover {
    border-style: solid;
    border-color: var(--pv-primary);
    background: #e0e7ff;
    transform: scale(1.01);
    box-shadow: 0 12px 32px rgba(79, 70, 229, .18);
}

.dropzone.is-shake { animation: pv-shake .35s; }

.dropzone-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 18px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #fff;
    color: var(--pv-primary);
    box-shadow: 0 8px 20px rgba(79, 70, 229, .15);
}

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

.dropzone.is-dragover .dropzone-icon { animation: pv-bob .7s ease-in-out infinite alternate; }

.dropzone-title {
    margin: 0 0 4px;
    font-size: 19px;
    font-weight: 700;
    color: var(--pv-ink);
}

.dropzone .when-dragover { display: none; }
.dropzone.is-dragover .when-idle { display: none; }
.dropzone.is-dragover .when-dragover { display: inline; }

.dropzone-sub { margin: 0 0 20px; color: var(--pv-muted); }

.dropzone-sub .link {
    color: var(--pv-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.dropzone-formats {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: var(--pv-muted);
}

.format-chip {
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--pv-border);
    background: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--pv-text);
}

/* ---------- Selected file ---------- */

.file-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--pv-border);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff, #fafbff);
    animation: pv-rise .25s ease-out;
}

.file-badge {
    width: 48px;
    height: 58px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .05em;
    color: #fff;
    background: linear-gradient(160deg, #60a5fa, #2563eb);
    box-shadow: 0 6px 14px rgba(37, 99, 235, .25);
}

.file-badge.is-xlsx {
    background: linear-gradient(160deg, #34d399, #059669);
    box-shadow: 0 6px 14px rgba(5, 150, 105, .25);
}

.file-badge.is-small {
    width: 34px;
    height: 40px;
    border-radius: 8px;
    font-size: 9px;
    box-shadow: none;
}

.file-info { flex: 1; min-width: 0; }

.file-name {
    font-weight: 600;
    color: var(--pv-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta { font-size: 13px; color: var(--pv-muted); }

/* ---------- Progress ---------- */

.progress-panel { margin-top: 20px; }

.progress-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--pv-ink);
}

.progress-row #progress-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: #eef2f7;
    overflow: hidden;
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6366f1, #8b5cf6);
    transition: width .2s ease;
}

.progress-fill.is-indeterminate {
    width: 40% !important;
    animation: pv-indeterminate 1.1s ease-in-out infinite;
}

.panel-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 22px;
}

/* ---------- Results ---------- */

.result-panel { animation: pv-rise .35s ease-out; }

.result-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.result-icon {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: var(--pv-success);
    background: var(--pv-success-soft);
}

.result-icon .icon { width: 26px; height: 26px; }

.result-header h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    color: var(--pv-ink);
    outline: none;
}

.result-header p {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--pv-muted);
    word-break: break-word;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.stat {
    padding: 14px 16px;
    border: 1px solid var(--pv-border);
    border-radius: 12px;
    background: #fbfcfe;
}

.stat-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--pv-muted);
}

.stat-value {
    display: block;
    margin-top: 4px;
    font-size: 27px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--pv-ink);
    font-variant-numeric: tabular-nums;
}

.stat-pct { font-size: 13px; color: var(--pv-muted); }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.stat-valid .dot { background: var(--pv-success); }
.stat-invalid .dot { background: var(--pv-danger); }
.stat-missing .dot { background: var(--pv-warning); }
.stat-valid .stat-value { color: #15803d; }
.stat-invalid .stat-value { color: #b91c1c; }
.stat-missing .stat-value { color: #b45309; }

.distribution {
    display: flex;
    height: 10px;
    margin: 20px 0 26px;
    border-radius: 999px;
    overflow: hidden;
    background: #eef2f7;
}

.seg { width: 0; height: 100%; transition: width .7s ease; }
.seg-valid { background: var(--pv-success); }
.seg-invalid { background: var(--pv-danger); }
.seg-missing { background: var(--pv-warning); }

.result-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.result-note {
    margin: 20px 0 0;
    font-size: 13px;
    line-height: 1.7;
    color: var(--pv-muted);
}

/* ---------- Sidebar ---------- */

.steps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

.steps li { display: flex; gap: 12px; }

.steps-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }

.step-num {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    color: var(--pv-primary);
    background: var(--pv-primary-soft);
}

.steps strong { display: block; font-size: 14px; color: var(--pv-ink); }
.steps div span { font-size: 13px; color: var(--pv-muted); }

.aside-text { margin: 0 0 10px; font-size: 13.5px; color: var(--pv-muted); }
.small-print { margin: 12px 0 0; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.chips span {
    padding: 3px 8px;
    border-radius: 6px;
    font-family: var(--pv-mono);
    font-size: 12px;
    color: var(--pv-primary-hover);
    background: var(--pv-primary-soft);
}

.checklist {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    display: grid;
    gap: 9px;
    font-size: 13.5px;
}

.checklist li { display: flex; gap: 9px; align-items: flex-start; }
.checklist .icon { width: 16px; height: 16px; margin-top: 2px; color: var(--pv-success); }

.recent { list-style: none; margin: 0; padding: 0; }

.recent li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-top: 1px solid var(--pv-border);
}

.recent li:first-child { padding-top: 0; border-top: 0; }
.recent li:last-child { padding-bottom: 0; }

.recent-info { flex: 1; min-width: 0; }

.recent-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--pv-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-meta { font-size: 12.5px; color: var(--pv-muted); }

.api-details summary {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    color: var(--pv-ink);
}

.api-details summary::-webkit-details-marker { display: none; }

.api-details summary::after {
    content: "";
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-right: 2px solid var(--pv-muted);
    border-bottom: 2px solid var(--pv-muted);
    transform: rotate(45deg);
    transition: transform .2s;
}

.api-details[open] summary { margin-bottom: 14px; }
.api-details[open] summary::after { transform: rotate(-135deg); }

.code-block { position: relative; }

.code-block pre {
    margin: 0;
    padding: 14px 14px 40px;
    border-radius: 10px;
    background: #0f172a;
    white-space: pre-wrap;
    word-break: break-all;
}

.code-block pre code {
    word-break: break-all; /* Bootstrap resets this to normal, which stops long URLs wrapping */
    padding: 0;
    font-size: 12px;
    color: #e2e8f0;
    background: none;
}

.copy-button {
    position: absolute;
    right: 8px;
    bottom: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, .15);
    border-radius: 7px;
    background: rgba(255, 255, 255, .08);
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
}

.copy-button:hover { background: rgba(255, 255, 255, .16); }
.copy-button .icon { width: 14px; height: 14px; }

/* ---------- Sign-in page ---------- */

.auth {
    min-height: calc(100vh - 70px);
    display: grid;
    place-items: center;
    padding: 40px 20px 8px;
}

.auth-card {
    width: 100%;
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--pv-border);
    border-radius: 24px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .12);
}

.auth-aside {
    position: relative;
    overflow: hidden;
    padding: 48px 44px;
    color: #fff;
    background:
        radial-gradient(600px 300px at 0% 0%, rgba(255, 255, 255, .18), transparent 60%),
        linear-gradient(150deg, #4f46e5 0%, #7c3aed 100%);
}

.auth-aside::after {
    content: "";
    position: absolute;
    right: -130px;
    bottom: -130px;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    border: 50px solid rgba(255, 255, 255, .08);
}

.auth-aside .brand { color: #fff; }

.auth-aside .brand-mark {
    background: rgba(255, 255, 255, .18);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}

.auth-aside h1 {
    margin: 44px 0 30px;
    font-size: 31px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -.02em;
}

.auth-features {
    position: relative;
    z-index: 1;
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 22px;
}

.auth-features li { display: flex; gap: 14px; }

.feature-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, .16);
}

.auth-features strong { display: block; font-size: 15px; }
.auth-features span { font-size: 14px; color: rgba(255, 255, 255, .8); }

.auth-form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 56px 52px;
}

.auth-form h2 {
    margin: 0 0 6px;
    font-size: 27px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--pv-ink);
}

.auth-form .lead-text { margin: 0 0 26px; color: var(--pv-muted); }
.auth-form .message { margin: 0 0 20px; }

.auth-mobile-brand { display: none; margin-bottom: 28px; }

.input-icon { position: relative; }

.input-icon > .icon {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: var(--pv-muted);
    pointer-events: none;
}

.input-icon .form-control {
    height: 52px;
    padding-left: 46px;
    padding-right: 52px;
    border-color: var(--pv-border);
    border-radius: 12px;
    font-size: 15px;
}

.input-icon .form-control:focus {
    border-color: var(--pv-primary);
    box-shadow: 0 0 0 4px var(--pv-primary-ring);
}

.input-action {
    position: absolute;
    top: 50%;
    right: 7px;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--pv-muted);
}

.input-action:hover,
.input-action.is-active { background: var(--pv-primary-soft); color: var(--pv-primary); }

.auth-remember { margin: 18px 0 24px; }
.auth-remember .form-check-label { font-size: 14px; }

.auth-help {
    margin: 26px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--pv-muted);
}

/* ---------- Animations ---------- */

@keyframes pv-spin { to { transform: rotate(360deg); } }
@keyframes pv-bob { to { transform: translateY(-6px); } }
@keyframes pv-rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes pv-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pv-indeterminate { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 991.98px) {
    .portal-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
    .auth-card { grid-template-columns: 1fr; max-width: 480px; }
    .auth-aside { display: none; }
    .auth-mobile-brand { display: inline-flex; }
    .auth-form { padding: 40px 28px; }
}

@media (max-width: 767.98px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .steps-row { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

@media (max-width: 575.98px) {
    .portal-header-inner { padding: 10px 16px; }
    .brand-sub, .session-pill { display: none; }
    .portal-container { padding: 28px 16px 24px; }
    .page-heading h1 { font-size: 25px; }
    .panel { padding: 20px; }
    .dropzone { padding: 36px 16px; }
    .panel-actions .btn, .result-actions .btn { width: 100%; }
}
