/* Email Verifier -- application stylesheet.
 *
 * Hand-rolled: no framework, no external fonts, no build step. The
 * Content-Security-Policy for this application allows 'self' only, so
 * everything here must be served from this file.
 *
 * Sections:
 *   1. tokens          8.  badges
 *   2. reset / base    9.  progress
 *   3. layout          10. metrics
 *   4. header          11. alerts
 *   5. cards           12. job page
 *   6. forms           13. login page
 *   7. buttons         14. table
 *                      15. responsive
 */

/* ============================================================ 1. tokens === */
:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;

    --border: #e4e9f0;
    --border-strong: #d5dde7;

    --text: #16233a;
    --text-muted: #66718a;
    --text-subtle: #8a94a8;

    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eef4ff;
    --primary-ring: rgba(37, 99, 235, 0.28);

    --success: #157347;
    --success-soft: #ecfdf3;
    --success-border: #c3ead4;

    --danger: #b42318;
    --danger-soft: #fef3f2;
    --danger-border: #f5cdc8;

    --warning: #b25e09;
    --warning-soft: #fff8ec;
    --warning-border: #f2ddb8;

    --neutral: #5c6880;
    --neutral-soft: #f1f4f8;
    --neutral-border: #dfe5ee;

    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;

    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
    --shadow-raised: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.07);

    --content-width: 1080px;
    --content-pad: 24px;
}

/* ==================================================== 2. reset / base === */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.015em; font-weight: 640; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0; }

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

code {
    background: var(--neutral-soft);
    border: 1px solid var(--border);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: 0.88em;
}

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* One visible, consistent focus treatment everywhere. Never removed without
   a replacement -- keyboard users depend on it. */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ============================================================ 3. layout === */
.wrap {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 var(--content-pad);
}

.page { flex: 1 0 auto; padding: 32px 0 48px; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin-bottom: 4px; }
.page-head p { color: var(--text-muted); font-size: 14.5px; }

.stack-lg { display: flex; flex-direction: column; gap: 20px; }

.site-footer {
    flex-shrink: 0;
    padding: 20px 0 32px;
    color: var(--text-subtle);
    font-size: 12.5px;
    line-height: 1.6;
}

/* ============================================================ 4. header === */
.site-header {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 62px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    font-weight: 640;
    font-size: 15.5px;
    letter-spacing: -0.015em;
    text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
}

.brand-mark svg { display: block; }

.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    min-width: 0;
}

.header-user .user {
    color: var(--text-muted);
    font-size: 13.5px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================= 5. cards === */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}

.card + .card { margin-top: 20px; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.card-head h2 { margin-bottom: 2px; }
.card-head p { color: var(--text-muted); font-size: 13.5px; }

/* A second heading inside one card needs breathing room above it. */
.card-head-spaced { margin-top: 26px; }

.section-label {
    font-size: 12px;
    font-weight: 640;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-subtle);
}

/* ============================================================= 6. forms === */
.field { display: block; margin-bottom: 16px; }
.field:last-of-type { margin-bottom: 0; }

/* The label sits ABOVE the control, always. `label` is inline by default,
   which is what previously made the login form read as one cramped line. */
.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.input,
input[type="text"],
input[type="email"],
input[type="password"] {
    display: block;
    width: 100%;
    height: 46px;
    padding: 0 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    line-height: 1.4;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder,
input::placeholder { color: var(--text-subtle); }

.input:hover,
input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover { border-color: #c2cddb; }

.input:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

.input:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible { outline: none; }

/* Chrome paints autofilled inputs bright yellow, which wrecks the palette.
   An inset shadow the size of the field repaints it without touching the
   value or blocking the autofill behaviour itself. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    -webkit-box-shadow: 0 0 0 40px var(--surface) inset;
    box-shadow: 0 0 0 40px var(--surface) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.field-error {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--danger);
}

.input-invalid,
input.input-invalid { border-color: var(--danger); }

/* =========================================================== 7. buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover { background: var(--surface-muted); border-color: #c2cddb; text-decoration: none; }
.btn:active { background: #eef2f7; }

.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary:active { background: #1a45c4; }

.btn-block { width: 100%; }

.btn-link {
    height: auto;
    padding: 6px 2px;
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
}

.btn-link:hover { background: none; color: var(--text); text-decoration: underline; }

.btn.disabled,
.btn[aria-disabled="true"],
.btn:disabled {
    background: var(--neutral-soft);
    border-color: var(--border);
    color: var(--text-subtle);
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary.disabled,
.btn-primary[aria-disabled="true"] {
    background: var(--neutral-soft);
    border-color: var(--border);
    color: var(--text-subtle);
}

/* ============================================================ 8. badges === */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border: 1px solid var(--neutral-border);
    border-radius: 999px;
    background: var(--neutral-soft);
    color: var(--neutral);
    font-size: 12.5px;
    font-weight: 640;
    line-height: 1.4;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.badge-completed { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge-failed    { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }

.badge-queued,
.badge-importing,
.badge-processing,
.badge-exporting {
    background: var(--primary-soft);
    border-color: #cfe0ff;
    color: var(--primary);
}

/* Active states get a slow, low-contrast pulse -- enough to read as "live",
   not enough to distract. Disabled entirely for reduced-motion users. */
.badge-importing::before,
.badge-processing::before,
.badge-exporting::before {
    animation: pulse 1.8s ease-in-out infinite;
}

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

/* ========================================================== 9. progress === */
.status-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 10px;
}

.progress-value {
    font-size: 14px;
    font-weight: 640;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.progress {
    height: 8px;
    background: #e8edf4;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--primary);
    border-radius: 999px;
    transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.is-complete { background: var(--success); }
.progress-bar.is-failed { background: var(--danger); }

.job-message {
    margin-top: 10px;
    font-size: 13.5px;
    color: var(--text-muted);
}

/* ========================================================== 10. metrics === */
.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 0;
}

.metrics + .metrics { margin-top: 12px; }

.metric {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 15px;
    min-width: 0;
}

.metric dt {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 560;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric dd {
    margin: 5px 0 0;
    font-size: 23px;
    font-weight: 640;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* Outcome metrics carry BOTH a colour and a distinct dot, and their label
   text already names the outcome -- so they never rely on colour alone. */
.metric-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-subtle);
    flex-shrink: 0;
}

.metric-good     { background: var(--success-soft); border-color: var(--success-border); }
.metric-good dd  { color: var(--success); }
.metric-good .metric-dot { background: var(--success); }

.metric-bad      { background: var(--danger-soft); border-color: var(--danger-border); }
.metric-bad dd   { color: var(--danger); }
.metric-bad .metric-dot { background: var(--danger); }

.metric-warn     { background: var(--warning-soft); border-color: var(--warning-border); }
.metric-warn dd  { color: var(--warning); }
.metric-warn .metric-dot { background: var(--warning); }

.metric-neutral    { background: var(--neutral-soft); border-color: var(--neutral-border); }
.metric-neutral dd { color: var(--neutral); }
.metric-neutral .metric-dot { background: var(--neutral); }

/* =========================================================== 11. alerts === */
.alert {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    line-height: 1.5;
}

.alert + * { margin-top: 16px; }

.alert-error   { background: var(--danger-soft);  border-color: var(--danger-border);  color: #8c231a; }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: #12603a; }
.alert-info    { background: var(--surface-muted); border-color: var(--border); color: var(--text-muted); }

.alert svg { flex-shrink: 0; margin-top: 1px; }

.note {
    display: flex;
    gap: 10px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.55;
}

.note svg { flex-shrink: 0; margin-top: 2px; color: var(--text-subtle); }

/* ========================================================= 12. job page === */
.job-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

/* A long uploaded filename must never widen the card or force a scrollbar. */
.job-file {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.job-file strong { color: var(--text); font-weight: 600; }

.summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 13px 15px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    font-size: 13.5px;
    color: var(--text-muted);
}

.summary strong { color: var(--text); font-weight: 640; }

.summary-sep { color: var(--border-strong); }

.downloads {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.summary + .downloads { margin-top: 16px; }

.downloads-hint { margin-top: 12px; }

.job-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.job-actions a { font-size: 14px; font-weight: 600; }

/* ------------------------------------------------------------- dropzone */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 34px 20px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

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

.dropzone:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Visually hidden, but still focusable and still the real control -- the
   form works exactly the same with JavaScript disabled. */
.dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.dropzone-icon { color: var(--text-subtle); margin-bottom: 3px; }
.dropzone.is-dragging .dropzone-icon,
.dropzone:hover .dropzone-icon { color: var(--primary); }

.dropzone-title { font-weight: 600; font-size: 14.5px; }
.dropzone-title em { font-style: normal; color: var(--primary); }
.dropzone-hint { color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.dropzone-hint.has-file { color: var(--text); font-weight: 600; }

.upload-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.upload-meta { color: var(--text-subtle); font-size: 12.5px; }

/* ======================================================== 13. login page === */
.auth {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 44px 20px 56px;
}

.auth-inner { width: 100%; max-width: 420px; }

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 22px;
    color: var(--text);
    font-size: 16px;
    font-weight: 640;
    letter-spacing: -0.015em;
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-raised);
    padding: 30px 28px;
}

.auth-card h1 { font-size: 21px; margin-bottom: 5px; }
.auth-card .auth-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }

.auth-card form { margin: 0; }
.auth-card .btn-block { margin-top: 22px; height: 46px; }

.auth-note { margin-top: 18px; }

/* ============================================================ 14. table === */
.table-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table thead th {
    color: var(--text-subtle);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom-color: var(--border-strong);
    white-space: nowrap;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-muted); }

.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.table .cell-file {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 560;
}

.empty-state {
    padding: 34px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

.empty-state strong { display: block; color: var(--text); font-weight: 620; margin-bottom: 4px; }

/* ======================================================== 15. responsive === */
@media (max-width: 900px) {
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    :root { --content-pad: 16px; }

    .page { padding: 22px 0 34px; }
    .card { padding: 20px 18px; }
    h1 { font-size: 21px; }

    .header-inner { min-height: 56px; }
    .header-user .user { display: none; }

    .status-line { align-items: center; }

    .downloads { flex-direction: column; align-items: stretch; }
    .downloads .btn { width: 100%; }

    .job-actions { flex-direction: column; align-items: flex-start; gap: 10px; }

    .upload-actions { flex-direction: column; align-items: stretch; }
    .upload-actions .btn { width: 100%; }

    .auth { padding: 28px 16px 40px; }
    .auth-card { padding: 24px 20px; }

    .table .cell-file { max-width: 160px; }
}

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

/* Respect the operating-system preference: no pulse, no eased transitions. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
