:root {
    --control-height: 44px;
    --blue: #8EAFDA;
    --blue-dark: #6f95c8;
    --green: #92dba5;
    --orange: #ffbc6a;
    --purple: #b69df4;
    --text: #111827;
    --muted: #555;
}

html {
    min-height: 100%;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    margin: 0;
    padding: 40px 0;
    font-family: "Segoe UI", Arial, sans-serif;
    background-color: #f2f2f2;
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image: url("https://sajvwebsiteblobstorage.blob.core.windows.net/blog/tools-2375/featured-background_blur.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0.69;
    z-index: -1;
}

.container {
    position: relative;
    width: calc(100% - 32px);
    max-width: 1120px;
    margin: 0 auto;
    padding: 20px;
    background: rgba(255,255,255,0.86);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
}

.header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

h1 {
    text-align: center;
    margin: 10px 0;
}

h2 {
    margin: 0;
    font-size: 21px;
}

.subtitle {
    text-align: center;
    font-size: 0.95em;
    color: var(--muted);
    margin-bottom: 20px;
}

.searchbox {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

#headerInput {
    min-height: 240px;
    max-height: 70vh;
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    resize: vertical;
    font: 14px/1.45 Consolas, "Courier New", monospace;
    background: rgba(255,255,255,0.94);
    color: var(--text);
    opacity: 1;
    overflow: auto;
    transition: min-height .22s ease, max-height .22s ease, padding .22s ease, border-width .22s ease, opacity .16s ease, margin .22s ease;
}

#headerInput:focus,
button:focus-visible,
summary:focus-visible {
    outline: 3px solid rgba(142,175,218,0.38);
    outline-offset: 2px;
}

.action-row {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    height: var(--control-height);
    padding: 0 20px;
    font-size: 16px;
    background-color: var(--blue);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover:not(:disabled) {
    background-color: var(--blue-dark);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
}

.action-row > button,
.action-row > .export-control {
    flex: 1 1 150px;
    max-width: 190px;
}




.input-toggle {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    justify-content: flex-start;
    gap: 10px;
    border: 1px solid #dbe3dd;
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    color: #4b5563;
    box-shadow: 0 0 10px rgba(0,0,0,0.06);
    transition: background-color .18s ease, box-shadow .18s ease;
}

.input-toggle:hover:not(:disabled) {
    background: #f8faf9;
    box-shadow: 0 0 12px rgba(0,0,0,0.09);
}

.input-toggle[hidden] {
    display: none;
}

.input-toggle-triangle {
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid currentColor;
    transform-origin: 3px 6px;
    transition: transform .2s ease;
}

.input-toggle[aria-expanded="true"] .input-toggle-triangle {
    transform: rotate(90deg);
}

.input-toggle-text {
    font-size: 14px;
    font-weight: 600;
}


.input-collapsed #headerInput {
    min-height: 0;
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    opacity: 0;
    margin: 0;
    overflow: hidden;
    pointer-events: none;
}


.bulk-btn {
    background-color: var(--orange);
}

.bulk-btn:hover:not(:disabled) {
    background-color: #f0a957;
}

.details-btn {
    background-color: var(--purple);
}

.details-btn:hover:not(:disabled) {
    background-color: #a88ce9;
}

.export-control {
    position: relative;
    display: flex;
}

.export-trigger {
    width: 100%;
    background-color: var(--green);
}

.export-trigger:hover:not(:disabled) {
    background-color: #7ccf95;
}

.export-caret {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    margin-left: 2px;
}

.export-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 150px;
    padding: 6px;
    background: #fff;
    border: 1px solid #dbe3dd;
    border-radius: 8px;
    box-shadow: 0 14px 28px rgba(0,0,0,0.18);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0s linear 0.16s;
    z-index: 100;
}

.export-control.open .export-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition-delay: 0s;
}

.export-menu button {
    width: 100%;
    height: 38px;
    margin: 0;
    padding: 0 12px;
    justify-content: flex-start;
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: 6px;
}

.export-menu button:hover,
.export-menu button:focus {
    background: #eef8f1;
    color: #166534;
}

.infobox,
.analysis-box {
    background-color: #e0f0ff;
    border: 1px solid #aad;
    padding: 12px;
    margin-bottom: 18px;
    border-radius: 5px;
}

.analysis-box[hidden] {
    display: none;
}

.analysis-box {
    display: grid;
    gap: 8px;
}

.analysis-box strong {
    display: block;
}

.analysis-box p {
    margin: 0;
}

.analysis-box-success {
    background-color: #eef8f1;
    border-color: #b7dfc2;
}

.analysis-box-warning {
    background-color: #fff7e6;
    border-color: #ffe0a3;
}

.analysis-box-error {
    background-color: #fdeeee;
    border-color: #f2b8b8;
}

.message-summary {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.spam-summary {
    background-color: #e0f0ff;
    border: 1px solid #aad;
    padding: 12px;
    border-radius: 5px;
}

.spam-summary {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px 12px;
    align-items: start;
}

.spam-summary .badge {
    grid-row: span 2;
    align-self: start;
}

.spam-summary-success {
    background-color: #eef8f1;
    border-color: #b7dfc2;
}

.spam-summary-warning {
    background-color: #fff7e6;
    border-color: #ffe0a3;
}

.spam-summary strong {
    display: block;
}

.spam-summary span {
    color: #4b5563;
}

.summary-link,
.summary-link:visited {
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.summary-link:hover {
    text-decoration: underline;
}

#messageSummaryTable th:first-child,
#messageSummaryTable td:first-child {
    width: 170px;
}

.section-title-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    margin: 22px 0 8px;
}

.section-title-row p {
    max-width: 720px;
    margin: 0;
    color: #555;
    font-size: 14px;
    line-height: 1.45;
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 8px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
}

.wide-table table {
    min-width: 760px;
    table-layout: auto;
}

thead {
    background-color: #f8f9fa;
}

th,
td {
    padding: 12px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
    overflow-wrap: anywhere;
}

th {
    text-align: left;
}

tbody tr:nth-child(even):not(.row-success):not(.row-warning):not(.row-error):not(.row-info) {
    background-color: #f6f6f6;
}

.row-success {
    background-color: #eef8f1;
}

.row-warning {
    background-color: #fff7e6;
}

.row-error {
    background-color: #fdeeee;
}

.row-info {
    background-color: #f2f7fb;
}

tbody tr.row-success:nth-child(even) {
    background-color: #e5f4ea;
}

tbody tr.row-warning:nth-child(even) {
    background-color: #fff0d1;
}

tbody tr.row-error:nth-child(even) {
    background-color: #fbe4e4;
}

tbody tr.row-info:nth-child(even) {
    background-color: #eaf2f8;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 74px;
    padding: 5px 9px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
}

.badge-success {
    color: #166534;
    background: #e6f5eb;
}

.badge-warning {
    color: #8a5b00;
    background: #fff3cd;
}

.badge-info {
    color: #185d8a;
    background: #e0f0ff;
}

.badge-error {
    color: #991b1b;
    background: #fde8e7;
}

.status-cell {
    text-align: left;
}

.status-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    vertical-align: middle;
    cursor: help;
}

.status-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.status-success {
    color: #18803a;
    background: #e6f5eb;
}

.status-warning {
    color: #9a6700;
    background: #fff3cd;
}

.status-error {
    color: #b42318;
    background: #fde8e7;
}

.status-info {
    color: #185d8a;
    background: #e0f0ff;
}

.status-result {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    white-space: nowrap;
}

.status-result strong {
    font-size: 14px;
}

#authTable th:last-child,
#authTable td:last-child {
    width: 82px;
    text-align: left;
}

#authTable th:first-child,
#authTable td:first-child {
    width: 130px;
}

.value-list {
    margin: 0;
    padding-left: 18px;
}

.value-list li + li {
    margin-top: 4px;
}


.antispam-table th:first-child,
.antispam-table td:first-child {
    width: 230px;
}

.antispam-table th:last-child,
.antispam-table td:last-child {
    width: 120px;
    text-align: left;
}

.antispam-table .antispam-details {
    font-size: 16px;
    line-height: 1.45;
}

.antispam-main > strong {
    font-size: 16px;
}

.antispam-description {
    margin-top: 3px;
    color: #4b5563;
    font-size: 16px;
    line-height: 1.45;
}

.inline-details summary {
    cursor: pointer;
    color: #374151;
    font-weight: 600;
}

.inline-details code {
    display: block;
    margin-top: 8px;
    padding: 9px 10px;
    border-radius: 6px;
    background: #f6f7f8;
    font: 12px/1.5 Consolas, "Courier New", monospace;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.raw-details {
    margin-top: 22px;
}

summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text);
}

.footer {
    text-align: center;
    font-size: 9px;
    color: #777;
    margin-top: 40px;
}

.footer a {
    color: #777;
    text-decoration: none;
}

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

#resultsSection {
    animation: fadeIn 0.35s ease;
}

@media (max-width: 760px) {
    body {
        padding: 20px 0;
    }

    .container {
        width: calc(100% - 20px);
        padding: 16px;
    }

    .action-row > button,
    .action-row > .export-control {
        max-width: none;
    }

    .antispam-table th:first-child,
    .antispam-table td:first-child {
        width: 190px;
    }

    table {
        min-width: 660px;
    }
}

/* Authentication and antispam tables: details in the middle, status on the right */
#authTable,
.antispam-table {
    table-layout: auto;
}

#authTable th,
.antispam-table th {
    text-align: left;
}

#authTable th:first-child,
#authTable td:first-child {
    width: 155px;
}

#authTable th:last-child,
#authTable td:last-child {
    width: 120px;
    text-align: left;
}

#authTable .auth-check {
    vertical-align: middle;
}

#authTable .auth-details {
    font-size: 16px;
    line-height: 1.45;
}

.auth-explanation {
    color: inherit;
    font-size: 16px;
    line-height: 1.45;
}

.auth-technical {
    margin-top: 3px;
    color: #7a7f87;
    font-size: 11px;
    line-height: 1.4;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (max-width: 640px) {
    #authTable th:first-child,
    #authTable td:first-child {
        width: 115px;
    }

    #authTable th:last-child,
    #authTable td:last-child,
    .antispam-table th:last-child,
    .antispam-table td:last-child {
        width: 105px;
    }

    .antispam-table th:first-child,
    .antispam-table td:first-child {
        width: 180px;
    }
}

/* Five-block report layout */
.report-block-title {
    margin-top: 36px;
    margin-bottom: 10px;
}

#resultsSection > .report-block-title:first-child {
    margin-top: 18px;
}

.report-block-title h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
}

.report-block-title p {
    max-width: 760px;
}

/* Combined anti-spam report */
.antispam-group-row th {
    padding: 10px 12px;
    text-align: left !important;
    background: #eef1f4;
    color: #374151;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .01em;
}

.antispam-empty-row td,
.advanced-empty-row td {
    padding: 18px 12px;
    text-align: left;
    vertical-align: middle;
    color: #6b7280;
    background: #fafafa;
    font-style: italic;
}

/* Advanced details: one collapsed block containing security + other headers */
.advanced-details {
    margin-top: 8px;
    border: 1px solid #e3e6e8;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 0 10px rgba(0,0,0,0.08);
    overflow: hidden;
}

.advanced-details > summary {
    position: relative;
    padding: 14px 44px 14px 18px;
    list-style: none;
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    background: #f8f9fa;
    user-select: none;
}

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

.advanced-details > summary::after {
    content: "";
    position: absolute;
    right: 18px;
    top: 50%;
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 8px solid #4b5563;
    transform: translateY(-50%);
    transition: transform .2s ease;
}

.advanced-details[open] > summary::after {
    transform: translateY(-50%) rotate(90deg);
}

.advanced-details .advanced-table-wrapper {
    margin-top: 0;
    border-radius: 0;
    box-shadow: none;
    border-top: 1px solid #e5e7eb;
}

#advancedTable th:first-child,
#advancedTable td:first-child {
    width: 230px;
}

@media (max-width: 640px) {
    .report-block-title h2 {
        font-size: 20px;
    }

    #advancedTable th:first-child,
    #advancedTable td:first-child {
        width: 190px;
    }
}

/* Collapsible technical anti-spam rows */
.antispam-technical-toggle-row td {
    padding: 0;
    text-align: left;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
}

.antispam-technical-toggle {
    width: 100%;
    padding: 12px 16px;
    border: 0;
    background: transparent;
    color: #4b5563;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.antispam-technical-toggle:hover {
    background: #f3f4f6;
}

.antispam-toggle-triangle {
    display: inline-block;
    margin-right: 7px;
    font-size: 10px;
    transition: transform 0.18s ease;
}

.antispam-technical-toggle[aria-expanded="true"] .antispam-toggle-triangle {
    transform: rotate(90deg);
}

.antispam-technical-subheading th {
    padding: 8px 12px;
    text-align: left !important;
    background: #f7f8fa;
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
}

.antispam-technical-row[hidden] {
    display: none;
}



/* File import and drag/drop */
.searchbox {
    position: relative;
}

.searchbox.file-drag-active::after {
    content: "Drop EML or MSG file to import headers";
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    padding: 24px;
    border: 2px dashed var(--blue-dark);
    border-radius: 10px;
    background: rgba(238, 247, 255, 0.96);
    color: #315f99;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
}

.import-status {
    width: 100%;
    margin-top: 2px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    text-align: center;
}

.import-status-info { background: #eef6ff; color: #315f99; }
.import-status-success { background: #eef8f1; color: #166534; }
.import-status-warning { background: #fff7e6; color: #8a5b00; }
.import-status-error { background: #fdeeee; color: #991b1b; }

.delivery-summary {
    margin-bottom: 0;
}

.summary-technical {
    grid-column: 2;
    color: #7a7f87;
    font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Email summary: delivery/filter verdicts live inside the table */
#messageSummaryTable .summary-status-row td {
    vertical-align: top;
}

.summary-status-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.summary-status-detail {
    line-height: 1.45;
}

.summary-row-technical {
    margin-top: 3px;
    color: #7a7f87;
    font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    overflow-wrap: anywhere;
}
