/* ==========================================================================
 * SovraCam — Sistema Grafico Unificato "Scuro Tecnico Sobrio" (Stile Studio Pezzo)
 * Palette B2B industriale uniforme (#070d18 / #0b1120 / #111827 / #1f2937),
 * zero bordi neon multicolore, progressive disclosure tramite menu e modali.
 * ========================================================================== */

:root {
    --sc-bg-page: #070d18;
    --sc-panel-bg: #111827;
    --sc-panel-alt: #0b1120;
    --sc-surface-inp: #080d19;
    --sc-accent: #FF4B12;
    --sc-accent-hover: #e03e08;
    --sc-cyan: #38bdf8;
    --sc-blue: #2563eb;
    --sc-yellow: #f59e0b;
    --sc-success: #10b981;
    --sc-danger: #ef4444;
    --sc-text-main: #f1f5f9;
    --sc-text-sec: #cbd5e1;
    --sc-text-muted: #94a3b8;
    --sc-text-dim: #64748b;
    --sc-border: #1f2937;
    --sc-border-strong: #2d3b4e;
}

body.sc-clean-ui {
    background: var(--sc-bg-page) !important;
    background-image: none !important;
    color: var(--sc-text-main) !important;
    font-family: 'Barlow', 'Segoe UI', system-ui, -apple-system, sans-serif !important;
    line-height: 1.45;
}

/* Override sobrio cornice principale e controlli top-bar */
body.sc-clean-ui .sc-screen-frame,
.sc-screen-frame.sp-clean-frame {
    background: #0b1120 !important;
    border-color: rgba(255, 75, 18, 0.85) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55) !important;
    padding: 16px 18px 26px 18px !important;
}

body.sc-clean-ui .sc-top-global-right .hdr-btn,
body.sc-clean-ui .sc-top-global-right .nav-btn,
body.sc-clean-ui .sc-top-global-right .sc-coach-top-btn,
body.sc-clean-ui .sc-top-global-right .sc-diag-btn {
    background: #0f172a !important;
    border: 1px solid var(--sc-border-strong) !important;
    color: var(--sc-text-sec) !important;
    font-weight: 700 !important;
    box-shadow: none !important;
}
body.sc-clean-ui .sc-top-global-right .hdr-btn:hover,
body.sc-clean-ui .sc-top-global-right .nav-btn:hover,
body.sc-clean-ui .sc-top-global-right .sc-coach-top-btn:hover,
body.sc-clean-ui .sc-top-global-right .sc-diag-btn:hover {
    background: #1e293b !important;
    border-color: #475569 !important;
    color: #ffffff !important;
}
body.sc-clean-ui .sc-top-global-right .sc-profile-highlight-btn {
    background: #1e293b !important;
    border: 1px solid var(--sc-cyan) !important;
    color: #f8fafc !important;
    box-shadow: none !important;
    font-weight: 700 !important;
}
body.sc-clean-ui .sc-top-global-right .sc-profile-highlight-btn:hover {
    background: #0284c7 !important;
    color: #ffffff !important;
    transform: none !important;
}
body.sc-clean-ui .sc-top-global-right .sc-profile-highlight-btn.is-current-profile {
    background: rgba(56, 189, 248, 0.16) !important;
    border-color: var(--sc-accent) !important;
    color: #ffffff !important;
    box-shadow: none !important;
}
body.sc-clean-ui .sc-top-global-right .sc-logout-btn {
    background: rgba(239, 68, 68, 0.08) !important;
    border: 1px solid rgba(239, 68, 68, 0.35) !important;
    color: #fca5a5 !important;
}

/* ==========================================================================
 * CARD SOBRIE UNIFORMI (Stile Studio Pezzo)
 * ========================================================================== */
.sp-card,
body.sc-clean-ui .card,
body.sc-clean-ui .sec-card,
body.sc-clean-ui .sec-panel,
body.sc-clean-ui .panel,
body.sc-clean-ui .profile-sec-card,
body.sc-clean-ui .off-section-panel,
body.sc-clean-ui .info-panel {
    background: var(--sc-panel-bg) !important;
    border: 1px solid var(--sc-border) !important;
    border-radius: 12px !important;
    padding: 16px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18) !important;
}

.sp-card-head,
body.sc-clean-ui .sec-head,
body.sc-clean-ui .section-divider {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding-bottom: 10px;
    margin-bottom: 14px;
    border-bottom: 1px solid #1e293b !important;
}

.sp-card-title {
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sc-text-sec);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.sp-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 21px;
    height: 21px;
    border-radius: 5px;
    background: #1e293b;
    border: 1px solid #334155;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sp-meta-pill {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--sc-text-muted);
    background: var(--sc-panel-alt);
    border: 1px solid var(--sc-border);
    padding: 3px 9px;
    border-radius: 6px;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
 * PULSANTI E CONTROLLI SOBRI
 * ========================================================================== */
.hdr-btn,
.sp-btn {
    background: #0f172a;
    border: 1px solid var(--sc-border-strong);
    color: var(--sc-text-sec);
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
}
.hdr-btn:hover,
.sp-btn:hover {
    background: #1e293b;
    border-color: #475569;
    color: #ffffff;
}
.hdr-btn.primary,
.sp-btn-primary {
    background: var(--sc-accent) !important;
    border: 1px solid #ff6230 !important;
    color: #ffffff !important;
    font-weight: 800;
}
.hdr-btn.primary:hover,
.sp-btn-primary:hover {
    background: var(--sc-accent-hover) !important;
    color: #ffffff !important;
}
.sp-btn-primary {
    padding: 10px 18px;
    border-radius: 9px;
    font-size: 0.84rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.15s ease;
}
.sp-btn-primary:disabled {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #94a3b8 !important;
    cursor: not-allowed;
}
.sp-btn-secondary {
    background: var(--sc-panel-alt);
    color: var(--sc-text-sec);
    border: 1px solid var(--sc-border-strong);
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.sp-btn-secondary:hover {
    background: #1e293b;
    border-color: #475569;
    color: #ffffff;
}
.sp-inline-link {
    background: none;
    border: none;
    color: var(--sc-cyan);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.sp-inline-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
 * INPUT, SELECT & CAMPI FORM (Esclude i fogli bianchi di stampa/ricetta)
 * ========================================================================== */
body.sc-clean-ui input[type="text"]:not(.big-input),
body.sc-clean-ui input[type="number"]:not(.big-input):not(.cell-input),
body.sc-clean-ui input[type="email"],
body.sc-clean-ui input[type="tel"],
body.sc-clean-ui input[type="url"],
body.sc-clean-ui input[type="password"],
body.sc-clean-ui input[type="date"],
body.sc-clean-ui select,
body.sc-clean-ui textarea {
    background: var(--sc-surface-inp);
    border: 1px solid var(--sc-border-strong);
    color: var(--sc-text-main);
    border-radius: 7px;
    padding: 7px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
body.sc-clean-ui input:hover,
body.sc-clean-ui select:hover,
body.sc-clean-ui textarea:hover {
    border-color: #3b4d66;
}
body.sc-clean-ui input:focus,
body.sc-clean-ui select:focus,
body.sc-clean-ui textarea:focus {
    outline: none;
    border-color: var(--sc-cyan);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

/* Preserva input dentro i fogli bianchi (Scheda Lavorazione / Offerta) */
#cam_live_recipe_container input,
#cam_live_recipe_container select,
#cam_live_recipe_container textarea,
.ricetta-card input,
.ricetta-card select,
.fb-card input,
.fb-card select,
.fb-card textarea {
    background: #ffffff !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

/* ==========================================================================
 * SWITCH A PILLOLA & BARRA SOTTO-SCHEDE SOBRIA
 * ========================================================================== */
.pill-switch {
    display: inline-flex;
    background: var(--sc-surface-inp);
    border: 1px solid var(--sc-border-strong);
    border-radius: 8px;
    padding: 3px;
    gap: 3px;
    flex-wrap: wrap;
}
.pill-switch button,
.pill-switch a {
    background: transparent;
    border: none;
    color: var(--sc-text-muted);
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.77rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}
.pill-switch button:hover,
.pill-switch a:hover {
    color: var(--sc-text-main);
}
.pill-switch button.active,
.pill-switch a.active {
    background: #1e293b;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

/* Sotto-tab sobrie per Profilo, CAM, Fornitori, Macchine */
body.sc-clean-ui .tab-bar,
body.sc-clean-ui .tabs-bar,
body.sc-clean-ui .tabs-container,
body.sc-clean-ui .officina-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    background: var(--sc-panel-bg) !important;
    border: 1px solid var(--sc-border) !important;
    border-radius: 10px !important;
    padding: 5px !important;
    margin-bottom: 16px !important;
}
body.sc-clean-ui .tab-bar .tab-btn,
body.sc-clean-ui .tabs-bar .tab-btn,
body.sc-clean-ui .tabs-container .tab-btn,
body.sc-clean-ui .officina-tabs .off-tab-btn {
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 7px !important;
    color: var(--sc-text-muted) !important;
    padding: 7px 13px !important;
    font-size: 0.8rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
    box-shadow: none !important;
    transition: all 0.15s ease;
}
body.sc-clean-ui .tab-bar .tab-btn:hover,
body.sc-clean-ui .tabs-bar .tab-btn:hover,
body.sc-clean-ui .tabs-container .tab-btn:hover,
body.sc-clean-ui .officina-tabs .off-tab-btn:hover {
    color: var(--sc-text-main) !important;
    background: rgba(255, 255, 255, 0.03) !important;
}
body.sc-clean-ui .tab-bar .tab-btn.active,
body.sc-clean-ui .tabs-bar .tab-btn.active,
body.sc-clean-ui .tabs-container .tab-btn.active,
body.sc-clean-ui .officina-tabs .off-tab-btn.active {
    background: #1e293b !important;
    border-color: #334155 !important;
    color: #ffffff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) !important;
}

/* ==========================================================================
 * PROGRESSIVE DISCLOSURE 1: ACCORDION ESPANDIBILI (<details class="sp-accordion">)
 * ========================================================================== */
.sp-accordion {
    background: var(--sc-panel-bg);
    border: 1px solid var(--sc-border);
    border-radius: 11px;
    overflow: visible;
    margin-bottom: 12px;
}
.sp-accordion > summary {
    list-style: none;
    cursor: pointer;
    padding: 11px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--sc-text-sec);
    user-select: none;
    border-radius: 11px;
    transition: background 0.15s ease, color 0.15s ease;
}
.sp-accordion > summary::-webkit-details-marker {
    display: none;
}
.sp-accordion > summary:hover {
    background: rgba(255, 255, 255, 0.025);
    color: #ffffff;
}
.sp-acc-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.sp-acc-left svg {
    color: var(--sc-text-dim);
    flex-shrink: 0;
}
.sp-acc-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.sp-acc-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--sc-text-muted);
    background: var(--sc-panel-alt);
    border: 1px solid var(--sc-border);
    padding: 2px 8px;
    border-radius: 999px;
}
.sp-acc-chev {
    color: var(--sc-text-dim);
    transition: transform 0.18s ease;
    flex-shrink: 0;
}
.sp-accordion[open] > summary {
    border-bottom: 1px solid #1e293b;
    border-radius: 11px 11px 0 0;
}
.sp-accordion[open] .sp-acc-chev {
    transform: rotate(180deg);
}
.sp-acc-body {
    padding: 14px 16px;
    background: #0d1422;
    border-radius: 0 0 11px 11px;
}

/* ==========================================================================
 * PROGRESSIVE DISCLOSURE 2: MENU A TENDINA COMPATTI (<details class="sp-menu-dd">)
 * ========================================================================== */
.sp-menu-dd {
    position: relative;
    display: inline-block;
}
.sp-menu-dd > summary {
    list-style: none;
    cursor: pointer;
    background: #0f172a;
    border: 1px solid var(--sc-border-strong);
    color: var(--sc-text-sec);
    padding: 6px 11px;
    border-radius: 7px;
    font-size: 0.76rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.sp-menu-dd > summary::-webkit-details-marker {
    display: none;
}
.sp-menu-dd > summary:hover,
.sp-menu-dd[open] > summary {
    background: #1e293b;
    border-color: #475569;
    color: #ffffff;
}
.sp-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 5px);
    z-index: 1200;
    min-width: 225px;
    background: #111827;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.68);
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.sp-menu-panel.align-left {
    right: auto;
    left: 0;
}
.sp-menu-item {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--sc-text-sec);
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.77rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    transition: background 0.12s ease, color 0.12s ease;
}
.sp-menu-item:hover {
    background: #1e293b;
    color: #ffffff;
}
.sp-menu-item.danger {
    color: #fca5a5;
}
.sp-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.16);
    color: #fecaca;
}
.sp-menu-sep {
    height: 1px;
    background: #1e293b;
    margin: 3px 4px;
}

/* ==========================================================================
 * PROGRESSIVE DISCLOSURE 3: FINESTRE MODALI SOBRIE
 * ========================================================================== */
.modal-overlay,
.sp-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.82);
    backdrop-filter: blur(4px);
    z-index: 9500;
    justify-content: center;
    align-items: center;
    padding: 16px;
}
.modal-box,
.sp-modal-box {
    background: var(--sc-panel-bg) !important;
    border: 1px solid #334155 !important;
    border-radius: 12px !important;
    max-width: 820px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.72) !important;
}
.modal-head,
.sp-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 11px;
    margin-bottom: 15px;
}
.modal-head h3,
.sp-modal-head h3 {
    color: #f8fafc;
    font-size: 0.98rem;
    font-weight: 800;
}

/* ==========================================================================
 * STATUS BAR, PALLINI STATO, STRISCE KPI & TABELLE INDUSTRIALI
 * ========================================================================== */
.sp-status-bar {
    padding: 9px 12px;
    background: var(--sc-panel-alt);
    border: 1px solid var(--sc-border);
    border-radius: 8px;
    font-size: 0.78rem;
    color: var(--sc-text-sec);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.sp-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 6px;
    vertical-align: middle;
}
.sp-dot-ok   { background: #10b981; }
.sp-dot-warn { background: #f59e0b; }
.sp-dot-err  { background: #ef4444; }
.sp-dot-info { background: #38bdf8; }

.sp-kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.sp-kpi-item,
body.sc-clean-ui .kpi-card {
    background: var(--sc-panel-bg) !important;
    border: 1px solid var(--sc-border) !important;
    border-radius: 10px !important;
    padding: 11px 14px !important;
}
.sp-kpi-item small,
body.sc-clean-ui .kpi-card small {
    display: block;
    font-size: 0.69rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--sc-text-dim);
}
.sp-kpi-item strong,
body.sc-clean-ui .kpi-card strong {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.18rem !important;
    font-weight: 800;
    color: #f8fafc;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
}

/* Tabelle sobrie (esclude tabelle dentro i fogli bianchi di stampa/scheda) */
body.sc-clean-ui table:not(.ricetta-card table) th {
    background: #0b1120 !important;
    color: var(--sc-text-muted) !important;
    font-size: 0.71rem !important;
    font-weight: 800 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--sc-border-strong) !important;
}
body.sc-clean-ui table:not(.ricetta-card table) td {
    border-bottom: 1px solid #1a2333 !important;
}
body.sc-clean-ui table:not(.ricetta-card table) tbody tr:hover {
    background: rgba(255, 255, 255, 0.018);
}

@media print {
    .sp-menu-dd,
    .no-print {
        display: none !important;
    }
}
