:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);

    /* digit-ale.com brand palette (blu petrolio + rosso, dal logo aziendale)
       source: web/digit-ale.com_v2/assets/css/site.css, :root block.
       Namespaced with --pn- prefix to avoid clashing with the vars above. */
    --pn-blue-900: #08283a;
    --pn-blue-800: #0d3a52;
    --pn-blue-700: #14567a;
    --pn-blue-600: #1a6d97;
    --pn-blue-500: #2189b8;
    --pn-red-700: #9d040f;
    --pn-red-600: #c00512;
    --pn-red-500: #e30613;
    --pn-red-400: #f4353f;
    --pn-ink-900: #0f1115;
    --pn-ink-800: #15181e;
    --pn-text-dim: #98a2ad;
    --pn-radius: 10px;
}

/* ===================================================================
   Header / Footer / Tabs — vanilla CSS translation of the shared React
   demo template (MorpheusICAO.Web / PhotoNormKit.Web, src/components/
   Header.tsx & Footer.tsx). Kept separate from the existing header/footer
   rules above so both can coexist during rollout; index.html picks which
   markup (and therefore which ruleset) is actually rendered.
   =================================================================== */

.pn-header {
    /* Pieno, non semi-trasparente (23/09/2026): il rgba(2,6,23,.6) + blur veniva dal
       template React, dove sotto l'header c'e' una pagina scura — qui invece il corpo
       della pagina e' bianco, quindi il nero al 60% con sfocatura diventava un grigio
       slavato invece di un blocco scuro pieno come su MorpheusICAO. */
    border-bottom: 1px solid rgba(255,255,255,.10);
    background: var(--pn-ink-900);
}

.pn-header__inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.pn-header__top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.pn-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
}

.pn-brand img {
    height: 44px;
    width: auto;
}

.pn-brand h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fff;
}

.pn-brand p {
    margin: 0;
    font-size: .75rem;
    color: var(--pn-text-dim);
}

@media (min-width: 640px) {
    .pn-brand h1 { font-size: 1.25rem; }
    .pn-brand p  { font-size: .875rem; }
}

.pn-tabs {
    display: flex;
    gap: .5rem;
}

.pn-tab {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    border-radius: var(--pn-radius);
    padding: .5rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    background: rgba(255,255,255,.05);
    color: #cbd5e1;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.10);
}

.pn-tab:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
}

/* Original React template uses teal (#14b8a6) for contrast on dark backgrounds.
   Swap to var(--pn-blue-500) below if the site's blue-petrolio should be used instead. */
.pn-tab.active {
    background: #14b8a6;
    color: #0f172a;
    box-shadow: 0 1px 8px rgba(20,184,166,.30);
}

/* Footer — replica of Footer.tsx: a single copyright/contacts line, nothing else.
   Sfondo scuro pieno come l'header (23/09/2026): il testo --pn-text-dim e' calibrato
   per un fondo scuro (Footer.tsx originale ha 7,87 di contrasto su slate-950), sul
   fondo quasi bianco della pagina qui sotto sarebbe illeggibile. */
.pn-footer {
    border-top: 1px solid rgba(255,255,255,.10);
    background: var(--pn-ink-900);
    padding: 1.5rem 0;
    text-align: center;
}

.pn-footer p {
    max-width: 48rem;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .25rem;
    font-size: .75rem;
    color: var(--pn-text-dim);
}

.pn-footer a {
    color: var(--pn-text-dim);
    text-decoration: none;
}

.pn-footer a:hover {
    color: var(--pn-red-400);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow-lg);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.12);
    padding: 4px;
    flex-shrink: 0;
}

.header-text {
    flex: 1;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.subtitle {
    opacity: 0.85;
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.engine-badge {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    flex-shrink: 0;
}

.engine-badge-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.75;
}

.engine-badge-value {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

main {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

/* Upload section */
.upload-section {
    margin-bottom: 1.5rem;
}

/* Galleria di foto campione (23/09/2026) — griglia di miniature, coerente con lo
   stile a card del resto della pagina (radius, ombra, hover). */
.gallery-section {
    margin-bottom: 1.5rem;
}

.gallery-hint {
    color: var(--gray-500);
    font-size: .9rem;
    margin: 0 0 1rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: .75rem;
}

.gallery-thumb {
    aspect-ratio: 3 / 4;
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: transform .12s ease, box-shadow .12s ease;
}

.gallery-thumb:hover {
    transform: scale(1.03);
    box-shadow: var(--shadow-lg);
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-empty {
    color: var(--gray-500);
    font-size: .9rem;
    text-align: center;
    padding: 2rem;
}

@media (max-width: 900px) {
    .gallery-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 520px) {
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    background: white;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, transform 0.15s;
}

.drop-zone:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-zone.drag-over {
    border-color: var(--primary);
    background: #dbeafe;
    transform: scale(1.01);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--gray-500);
    margin-bottom: 1rem;
}

.drop-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
}

.drop-hint {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.supported-formats {
    color: var(--gray-500);
    font-size: 0.8rem;
    margin-top: 0.75rem;
}

/* Action bar */
.action-bar {
    margin-bottom: 1.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.65rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-700);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-900);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-300);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-100);
    border-color: var(--gray-500);
}

/* Results section */
.results-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.image-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.image-panel {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.image-panel h3 {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-200);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.image-container {
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    background: var(--gray-100);
    position: relative;
}

.image-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 4px;
    object-fit: contain;
}

.face-overlay {
    position: absolute;
    pointer-events: none;
}

/* Quality panel */
.quality-panel {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    animation: fadeIn 0.4s ease;
}

.score-display {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.score-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border: 4px solid var(--gray-300);
    flex-shrink: 0;
    transition: border-color 0.3s;
}

.score-circle.good {
    border-color: var(--success);
    background: #f0fdf4;
}

.score-circle.medium {
    border-color: var(--warning);
    background: #fffbeb;
}

.score-circle.bad {
    border-color: var(--danger);
    background: #fef2f2;
}

.score-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.score-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.face-status {
    font-size: 1rem;
    font-weight: 600;
}

.face-status.found {
    color: var(--success);
}

.face-status.not-found {
    color: var(--danger);
}

/* Checks table */
.checks-table h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
}

.checks-table table {
    width: 100%;
    border-collapse: collapse;
}

.checks-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--gray-200);
}

.checks-table td {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
}

.checks-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.pass {
    background: #dcfce7;
    color: var(--success);
}

.status-badge.fail {
    background: #fef2f2;
    color: var(--danger);
}

.status-badge.na {
    background: var(--gray-100);
    color: var(--gray-500);
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error toast */
.error-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-width: 90%;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.25rem;
    opacity: 0.8;
}

.toast-close:hover {
    opacity: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 1.25rem;
    color: var(--gray-500);
    font-size: 0.85rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.footer-logo {
    width: 22px;
    height: 22px;
    border-radius: 4px;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    main {
        padding: 1rem;
    }

    .header-content {
        flex-wrap: wrap;
    }

    .engine-badge {
        align-items: flex-start;
        width: 100%;
    }

    .image-comparison {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        text-align: center;
    }

    .score-display {
        flex-direction: column;
        text-align: center;
    }
}
