/* ==========================================
   Layout overrides
   ========================================== */
.page-container-bg-solid {
    background: #ffffff !important;
}
.container-lf-space {
    padding-left: 30px;
    padding-right: 30px;
}
.page-header {
    width: 100%;
    height: 82px;
    min-height: 82px;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid rgba(220, 224, 236, 0.9) !important;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(12px);
    z-index: 1100;
}
.page-header-main {
    display: flex;
    align-items: center;
    flex: 1 1 auto;
    min-width: 0;
    transition: filter 0.2s ease;
}
.page-container {
    margin-top: 82px;
}
.page-footer.gray {
    background: #ffffff;
}

/* Burger menu overlay */
.burger-trigger {
    position: relative;
    flex-shrink: 0;
}
.burger-trigger .menu-trigger {
    width: 50px;
    height: 50px;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: #f8fafc;
    border: 1px solid #dce0ec !important;
    border-radius: 16px;
    outline: 0;
    padding: 0;
    margin-right: 18px;
    cursor: pointer;
    float: left;
    transition: all 0.2s ease;
}
.burger-trigger .menu-trigger:hover {
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    transform: translateY(-1px);
}
.burger-trigger .menu-trigger .menu-trigger-line {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #1f2937;
    display: block;
}
.burger-trigger .menu-close {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    font-size: 32px;
    color: #1f2937;
    background: #f8fafc;
    border: 1px solid #dce0ec;
    border-radius: 16px;
    outline: 0;
    cursor: pointer;
    z-index: auto;
    transition: all 0.2s ease;
}
.burger-trigger .menu-close:hover {
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
}
.burger-trigger .menu-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 2000;
    visibility: hidden;
    backface-visibility: hidden;
    transform: none;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}
.burger-trigger .menu-bg-overlay {
    position: fixed;
    width: 100%;
    height: 100%;
    visibility: hidden;
    top: 0;
    left: 0;
    z-index: 1000;
    opacity: 0;
    background: rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(4px);
    transition: all 0.3s;
}
.burger-trigger .menu-overlay-show {
    visibility: visible;
}
.burger-trigger .menu-overlay-show ~ .menu-bg-overlay {
    opacity: 1;
    visibility: visible;
}
.burger-trigger .menu-overlay-bg-transparent .menu-overlay-panel {
    width: min(100%, 360px);
    min-height: calc(100vh - 40px);
    margin-right: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-radius: 28px;
    border: 1px solid rgba(220, 224, 236, 0.95);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 30px 70px rgba(15, 23, 42, 0.18);
    transform: translateX(-28px);
    opacity: 0;
    transition: all 0.3s ease;
}
.burger-trigger .menu-overlay-bg-transparent.menu-overlay-show .menu-overlay-panel {
    transform: translateX(0);
    opacity: 1;
}
.burger-trigger .menu-overlay-bg-transparent.menu-overlay-show ~ .menu-bg-overlay {
    background: rgba(15, 23, 42, 0.28);
}
.menu-overlay-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}
.menu-overlay-brand {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.menu-overlay-brand img:first-child {
    height: 32px;
    width: auto;
}
.menu-overlay-brand img:last-child {
    height: 40px;
    width: auto;
}
.menu-overlay-content {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.menu-overlay-eyebrow {
    margin-bottom: 16px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #64748b;
}
.burger-trigger .menu-overlay-nav {
    text-align: left;
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.burger-trigger .menu-overlay-nav > li {
    display: block;
    font-size: 15px;
    font-weight: 700;
    padding: 0;
}
.burger-trigger .menu-overlay-nav > li > a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 18px;
    color: #1f2937;
    text-decoration: none;
    border-radius: 18px;
    background: #f8fafc;
    border: 1px solid rgba(220, 224, 236, 0.95);
    transition: all 0.2s ease;
}
.burger-trigger .menu-overlay-nav > li > a::after {
    content: "›";
    font-size: 22px;
    line-height: 1;
    color: #94a3b8;
}
.burger-trigger .menu-overlay-nav > li > a:hover {
    color: #0f172a;
    background: #ffffff;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
    transform: translateX(4px);
}

/* Utility classes */
.margin-top-20 { margin-top: 20px; }
.margin-bottom-20 { margin-bottom: 20px; }
.widget-bg-color-white { background-color: #fff; }

.tessitura {
    position: relative;
    overflow: visible;
}

.tessitura-status-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 16px;
    margin-top: 8px;
}

.tessitura-legend-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.tessitura-gauge-wrap {
    flex: 0 0 250px;
    text-align: center;
}

.tessitura-gantt-col {
    padding-left: 0;
    padding-right: 0;
}

.tessitura-gantt-wrap {
    width: 100%;
}

/* ==========================================
   App-specific styles
   ========================================== */
.page-logo {
    height: auto;
    max-height: none;
    line-height: 1;
    float: none;
    display: flex;
    align-items: center;
    margin-right: 20px;
    flex-shrink: 0;
}
.page-logo .brand-link {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
}
.page-logo .brand-logo {
    height: 54px;
    width: auto;
    max-width: none;
    display: block;
}
.top-menu {
    float: none !important;
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 auto;
    width: auto;
    height: auto;
    max-height: none;
    line-height: 1.15;
    font-size: clamp(1rem, 1.8vw, 1.6rem);
    font-weight: 800;
    letter-spacing: 0.12em;
    color: #1f2937;
}

.titolo {
    float: left !important;
    margin-left: 20px;
    margin-top: 10px;
    left: 30%;
    font-size: 2vw;
}

.orologio {
    float: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    margin-right: 0;
    margin-top: 0;
    left: auto;
    font-size: clamp(0.8rem, 0.95vw, 0.95rem);
    font-weight: 700;
    color: #334155;
    background: #f8fafc;
    border: 1px solid rgba(220, 224, 236, 0.95);
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.index-topbar-print-button {
    position: fixed;
    top: 23px;
    right: 196px;
    height: 36px;
    min-width: 36px;
    padding: 0 8px;
    border: 1px solid #dce0ec;
    border-radius: 12px;
    background-color: #f8fafc;
    color: #1f2937;
    cursor: pointer;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
    transition: all 0.2s ease;
    z-index: 1200;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.index-topbar-print-button:hover {
    background-color: #ffffff;
    transform: translateY(-1px);
}
.print-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.print-popup-container {
    width: min(520px, calc(100vw - 32px));
    background: #f8fbff;
    border: 1px solid #dbe7f5;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}
.print-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 1px solid #dbe7f5;
}
.print-popup-header h4 {
    margin: 0;
    color: #1f2937;
    font-size: 1.05rem;
    font-weight: 700;
}
.print-popup-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid #dce0ec;
    background: #ffffff;
    color: #1f2937;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.print-popup-body {
    padding: 16px;
    display: grid;
    gap: 12px;
}
.print-popup-field {
    display: grid;
    gap: 6px;
}
.print-popup-field label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
}
.print-popup-field input,
.print-popup-field select {
    height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0 10px;
    background: #ffffff;
    color: #0f172a;
}
.print-popup-info {
    padding: 10px 12px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 10px;
    font-size: 0.9rem;
}
.print-popup-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 16px 16px;
}
.print-popup-action {
    height: 36px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0 14px;
    background: #ffffff;
    color: #0f172a;
    cursor: pointer;
}
.print-popup-action-primary {
    border-color: #1d4ed8;
    background: #1d4ed8;
    color: #ffffff;
}

.print-popup-machines-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.print-popup-machines-actions {
    display: inline-flex;
    gap: 6px;
}

.print-popup-mini-btn {
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #0f172a;
    border-radius: 8px;
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.4;
}

.print-popup-mini-btn:disabled {
    opacity: 0.6;
}

.print-popup-machine-search {
    width: 100%;
    margin-top: 6px;
}

.print-popup-machines-list {
    margin-top: 4px;
    max-height: 180px;
    overflow: auto;
    border: 1px solid #dbe7f5;
    border-radius: 10px;
    padding: 2px 8px;
    background: #ffffff;
}

.print-popup-machine-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    min-height: 16px;
    font-size: 0.88rem;
    line-height: 1;
}

.print-popup-machine-item input[type="checkbox"] {
    margin: 0;
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.print-popup-machine-code {
    font-weight: 600;
    color: #0f172a;
    line-height: 1;
}

.print-popup-machine-desc {
    color: #475569;
    line-height: 1;
}

@media screen and (max-width: 1024px) {
    .titolo, .legendatess {
        display: none !important;
    }

    .page-header {
        height: 76px;
        min-height: 76px;
        padding: 0 12px;
    }

    .page-container {
        margin-top: 76px;
    }

    .page-logo {
        margin-right: 12px;
    }

    .page-logo .brand-logo {
        height: 42px;
    }

    .top-menu {
        font-size: clamp(0.95rem, 2.3vw, 1.2rem);
        letter-spacing: 0.08em;
    }
}

@media screen and (max-width: 767px) {
    .page-header {
        justify-content: flex-start;
    }

    .page-logo {
        margin-right: 0;
        flex: 1 1 auto;
        min-width: 0;
    }

    .page-logo .brand-link {
        gap: 8px;
        width: 100%;
    }

    .page-logo .brand-logo {
        height: 32px;
    }

    .page-logo .brand-logo:first-child {
        max-width: calc(100% - 54px);
        object-fit: contain;
    }

    .page-logo .brand-logo:last-child {
        flex-shrink: 0;
    }

    .top-menu {
        display: none !important;
    }
}

@media screen and (max-width: 575px) {
    .burger-trigger .menu-overlay {
        padding: 12px;
    }

    .burger-trigger .menu-overlay-bg-transparent .menu-overlay-panel {
        min-height: calc(100vh - 24px);
        width: 100%;
        border-radius: 24px;
        padding: 18px;
    }
}
@media screen and (max-width: 991px) {
    .tessitura-page-row .tessitura-status-row {
        margin-top: 8px;
    }

    .tessitura-page-row .tessitura-gauge-wrap > div:last-child {
        margin-top: 0 !important;
        line-height: 1.1;
    }
}

/* Scale tessiture to fit mobile viewport */
@media screen and (max-width: 767px) {
    .tessitura-page-row > .tessitura-page-col {
        margin-bottom: 0 !important;
    }

    .tessitura-page-row .tessitura {
        margin-bottom: -210px;
    }

    .tessitura-page-row .tessitura-gauge-wrap .k-gauge,
    .tessitura-page-row .tessitura-gauge-wrap .k-chart {
        height: 122px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap > div:last-child {
        margin-top: -6px !important;
    }
}
@media screen and (max-width: 480px) {
    .tessitura-page-row .tessitura {
        margin-bottom: -320px;
    }

    .tessitura-page-row .tessitura-gauge-wrap .k-gauge,
    .tessitura-page-row .tessitura-gauge-wrap .k-chart {
        height: 112px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap > div:last-child {
        margin-top: -8px !important;
    }
}

/* Tablet landscape / iPad-like widths: keep desktop layout but compact it */
@media screen and (min-width: 992px) and (max-width: 1366.98px) {
    .andon-tessiture-row .confini,
    .andon-tessiture-row .brunelleschi,
    .tessitura-page-row .confini,
    .tessitura-page-row .brunelleschi,
    .tessitura-page-row .brunelleschi2 {
        height: 360px !important;
    }

    .andon-tessiture-row .tessitura-canvas,
    .tessitura-page-row .tessitura-canvas {
        transform: translateY(0px) scale(0.515) !important;
        transform-origin: left top !important;
    }

    .andon-tessiture-row .machine-marker,
    .tessitura-page-row .machine-marker {
        transform: scale(0.9) !important;
        transform-origin: center !important;
    }

    .andon-tessiture-row .ramosa-indicator {
        top: auto !important;
        bottom: 40px !important;
        left: 76px !important;
        transform: scale(0.62) !important;
        transform-origin: left bottom !important;
    }

    .andon-tessiture-row > .col-12.col-lg-2 {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .andon-tessiture-row > .col-12.col-lg-2 > .text-center {
        width: 100%;
        max-width: 172px;
        padding-top: 0 !important;
        margin: 0 0 4px 0;
        line-height: 1.05;
    }

    .andon-tessiture-row > .col-12.col-lg-2 > .text-center a {
        display: block;
        margin-top: 1px;
        font-size: 13px;
        line-height: 1.02;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .k-gauge,
    .andon-tessiture-row > .col-12.col-lg-2 .k-chart {
        height: 128px !important;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .legend-all {
        font-size: 11px;
        gap: 3px;
        padding: 3px;
        width: 100%;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .legend-all-item {
        gap: 5px;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .legend-all-color {
        width: 16px;
        height: 16px;
        flex-basis: 16px;
    }

    .tessitura-status-row {
        margin-top: 8px;
        gap: 8px;
        align-items: flex-start;
    }

    .tessitura-gauge-wrap {
        flex: 0 0 165px;
        max-width: 165px;
    }

    .tessitura-page-row .tessitura-gauge-wrap {
        margin-top: -16px;
        align-self: flex-start;
    }

    .tessitura-page-row .tessitura-gantt-col {
        overflow: hidden;
        padding-right: 0 !important;
    }

    .tessitura-page-row .tessitura-gantt-wrap {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden !important;
    }

    .tessitura-page-row .tessitura-gantt-wrap .gantt-img-fill {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        object-fit: contain;
    }

    .tessitura-legend-wrap .legend-all {
        font-size: 11px;
        gap: 3px;
        padding: 3px;
    }
}

/* iPad Pro M4 (13") - force tablet layout in both orientations */
@media only screen and (device-width: 1536px) and (device-height: 1152px),
       only screen and (device-width: 1152px) and (device-height: 1536px) {
    .andon-tessiture-row .confini,
    .andon-tessiture-row .brunelleschi,
    .tessitura-page-row .confini,
    .tessitura-page-row .brunelleschi,
    .tessitura-page-row .brunelleschi2 {
        height: 360px !important;
    }

    .andon-tessiture-row .tessitura-canvas,
    .tessitura-page-row .tessitura-canvas {
        transform: translateY(0px) scale(0.515) !important;
        transform-origin: left top !important;
    }

    .andon-tessiture-row .machine-marker,
    .tessitura-page-row .machine-marker {
        transform: scale(0.9) !important;
        transform-origin: center !important;
    }

    .andon-tessiture-row .ramosa-indicator {
        top: auto !important;
        bottom: 10px !important;
        left: 26px !important;
        transform: scale(0.72) !important;
        transform-origin: left bottom !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap {
        margin-top: -16px !important;
        align-self: flex-start !important;
    }

    .tessitura-page-row .tessitura-gantt-col,
    .tessitura-page-row .tessitura-gantt-wrap {
        overflow: hidden !important;
    }

    .tessitura-page-row .tessitura-gantt-wrap .gantt-img-fill {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: auto !important;
        object-fit: contain;
    }

    .andon-tessiture-row > .col-12.col-lg-2 > .text-center {
        max-width: 172px;
        margin: 0 0 4px 0;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .k-gauge,
    .andon-tessiture-row > .col-12.col-lg-2 .k-chart {
        height: 128px !important;
    }

    .andon-tessiture-row > .col-12.col-lg-2 .legend-all,
    .tessitura-legend-wrap .legend-all {
        font-size: 11px;
        gap: 3px;
        padding: 3px;
    }
}

/* iPad Pro landscape explicit fallback */
@media only screen and (device-width: 1366px) and (device-height: 1024px) and (device-pixel-ratio: 2) and (orientation: landscape) {
    .andon-tessiture-row .confini,
    .andon-tessiture-row .brunelleschi {
        height: 360px !important;
    }

    .andon-tessiture-row .tessitura-canvas {
        transform: translateY(0px) scale(0.515) !important;
        transform-origin: left top !important;
    }
}

/* Below lg breakpoint (992px), tessiture go full width col-12. */
@media screen and (max-width: 991px) {
    .confini, .brunelleschi, .brunelleschi2 {
        height: auto;
        min-height: 450px;
    }

    .andon-tessiture-row,
    .tessitura-page-row {
        --mobile-machine-shift-x: 0px;
        --mobile-machine-shift-y: 0px;
        --mobile-machine-compression: 0.84;
        --mobile-marker-x-compensation: 1.04;
        --mobile-marker-y-compensation: 1.04;
    }

    .andon-tessiture-row .tessitura-canvas,
    .tessitura-page-row .tessitura-canvas {
        transform: scale(var(--mobile-machine-compression));
        transform-origin: left top;
    }

    .andon-tessiture-row .machine-marker,
    .tessitura-page-row .machine-marker {
        transform: translate(var(--mobile-machine-shift-x), var(--mobile-machine-shift-y)) scale(var(--mobile-marker-x-compensation), var(--mobile-marker-y-compensation));
        transform-origin: center;
    }

    .row > .col-12.col-lg-2 {
        order: 10;
    }
    .row > .col-12.col-lg-10 {
        order: 11;
    }
    .tessitura-status-row {
        flex-wrap: nowrap;
        justify-content: center;
        align-items: flex-start;
        gap: 12px;
        margin-top: 38px;
    }
    .tessitura-legend-wrap {
        flex: 1 1 auto;
        min-width: 0;
        display: block;
    }
    .tessitura-gauge-wrap {
        flex: 0 0 150px;
        max-width: 150px;
        margin: 0px 0 0;
        align-self: flex-start;
    }
    .tessitura-gantt-wrap {
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
    }
}

/* Scale tessiture to fit mobile viewport */
@media screen and (max-width: 767px) {
    .tessitura {
        transform: scale(0.65);
        transform-origin: 0 0;
        width: calc(100% / 0.65);
        max-width: none;
        height: 450px;
        margin-bottom: -140px;
    }

    .andon-tessiture-row .andon-tess-col .tessitura {
        height: 620px;
    }

    .andon-tessiture-row .andon-tess-col {
        margin-top: .5rem !important;
        margin-bottom: .5rem !important;
    }
}
@media screen and (max-width: 480px) {
    .tessitura {
        transform: scale(0.5);
        transform-origin: 0 0;
        width: 200%;
        max-width: none;
        height: 450px;
        margin-bottom: -280px;
    }

    .andon-tessiture-row .andon-tess-col .tessitura {
        height: 590px;
    }

    .andon-tessiture-row .andon-tess-col {
        margin-top: .25rem !important;
        margin-bottom: .25rem !important;
    }
}

/* iPhone 13 mini in landscape */
/* 2340x1080 pixels at 476ppi */
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-min-device-pixel-ratio: 3) and (orientation : landscape) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}

/* iPhone 13 mini in portrait */
/* 2340x1080 pixels at 476ppi */
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-min-device-pixel-ratio: 3) and (orientation : portrait) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}

/* iPhone 12/13/pro in landscape */
/* 2532x1170 pixels at 460ppi */
@media only screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation : landscape) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}
@media only screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation : portrait) {
    #divAzienda {
        -ms-zoom: 0.6 !important;
        -moz-transform: scale(0.6) !important;
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.6) !important;
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.6) !important;
        -webkit-transform-origin: 0 0;
    }
    page-container {
        width: 100%;
    }
}

/* iPhone 12/13/pro in landscape */
/* 1792x828px at 326ppi */
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation : landscape) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}

/* iPhone 12/13/pro in portrait */
/* 1792x828px at 326ppi */
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation : portrait) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}

/* iPhone 6, 7, & 8 in landscape */
@media screen and (min-device-width : 375px) and (max-device-width : 667px) and (orientation : landscape) {
    #divAzienda {
        -ms-zoom: 0.3;
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}


/* iPhone 6, 7, & 8 in portrait */
@media screen and (min-device-width : 375px) and (max-device-width : 667px) and (orientation : portrait) { /* STYLES GO HERE */
    #divAzienda {
        -ms-zoom: 0.6;
        -moz-transform: scale(0.6);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.6);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.6);
        -webkit-transform-origin: 0 0;
    }

}

@media screen and (max-width: 640px) and (-webkit-min-device-pixel-ratio: 1) {
    #divAzienda {
        zoom: 0.3;
        -ms-zoom: 1;
        -ms-transform: scale(0.3);
        transform: scale(0.3);
        -moz-transform: scale(0.3);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.3);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.3);
        -webkit-transform-origin: 0 0;
    }
}

@media screen and (min-width: 641px) and (max-width: 1024px) {
    #divAzienda {
        zoom: 0.5;
        -ms-zoom: 1;
        -ms-transform-origin: 0 0;
        transform: scale(0.5);
        -moz-transform: scale(0.5);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.5);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.5);
        -webkit-transform-origin: 0 0;
    }
}

@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (-webkit-min-device-pixel-ratio: 2) {
    #divAzienda {
        -ms-zoom: 0.5;
        -moz-transform: scale(0.5);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.5);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.5);
        -webkit-transform-origin: 0 0;
    }
}

@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (-webkit-min-device-pixel-ratio: 3) {
    #divAzienda {
        -ms-zoom: 0.5;
        -moz-transform: scale(0.5);
        -moz-transform-origin: 0 0;
        -o-transform: scale(0.5);
        -o-transform-origin: 0 0;
        -webkit-transform: scale(0.5);
        -webkit-transform-origin: 0 0;
    }
}



.num {
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    font-weight: bold;
    position: absolute;
    text-align: center;
    top: 26px;
    left: 0px;
    width: 48px;
    z-index: 100;
}

.numgraph {
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    font-weight: bold;
    position: absolute;
    text-align: center;
    top: 26px;
    left: 0px;
    width: 48px;
    z-index: 100;
}

.sm0 {
    background: #09C892;
    color: #ffffff;
    width: 48px;
    height: 48px;
}

.sm1 {
    background: #70ff00;
    color: #000000;
    width: 48px;
    height: 48px;
}

.sm2 {
    background: #ffd800;
    color: #000000;
    width: 48px;
    height: 48px;
}

.sm3 {
    background: #ff6a00;
    color: #000000;
    width: 48px;
    height: 48px;
}

.sm4 {
    background: #ff0000;
    color: #000000;
    width: 48px;
    height: 48px;
}

.sm5 {
    background: #000000;
    color: #ffffff;
    width: 48px;
    height: 48px;
}

.sm98 {
    background: #000000;
    color: #cc99ff;
    width: 48px;
    height: 48px;
}

.sm99 {
    background: #000000;
    color: #cc99ff;
    width: 48px;
    height: 48px;
}

/* HTML machine marker used in tessiture */
.machine-marker {
    position: relative;
    width: 36px;
    height: 36px;
}

.machine-num {
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 14px;
    font-weight: bold;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    color: #000000;
    z-index: 2;
    line-height: 1;
}

.machine-num-compact {
    font-size: 12px;
    transform: translate(-50%, -50%) scaleX(0.8);
    transform-origin: center;
}

.machine-num-light {
    color: #ffffff;
}

.machine-circle {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 28px;
    border-radius: 999px;
    box-sizing: border-box;
    border: none;
}

.machine-circle.sm0,
.machine-circle.sm1,
.machine-circle.sm2,
.machine-circle.sm3,
.machine-circle.sm4,
.machine-circle.sm5,
.machine-circle.sm98,
.machine-circle.sm99 {
    width: 28px;
    height: 28px;
    border-radius: 999px;
}

.brunelleschi {
    border: 1px solid #dbe4ff;
    color: #1f2937;
    height: 700px;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    border-radius: 18px;
    background-color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.confini {
    border: 1px solid #ffd8de;
    color: #1f2937;
    height: 700px;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    border-radius: 18px;
    background-color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.brunelleschi2 {
    border: 1px solid #d4ebff;
    color: #1f2937;
    height: 700px;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    border-radius: 18px;
    background-color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
}

.brunelleschi,
.confini,
.brunelleschi2 {
    position: relative;
    overflow: hidden;
}

/* bordo uniforme su tutti i lati, senza accent line in alto */
.brunelleschi::before,
.confini::before,
.brunelleschi2::before {
    content: none;
}

table.tableLegenda {
    border-collapse: collapse;
    border: dashed;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
}

    table.tableLegenda td, table.tableLegenda th {
        padding: 5px;
    }

.legend-all {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    padding: 5px;
    border: 2px dashed #333;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
    text-align: left;
}

.legend-all-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-all-color {
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
}

@media (max-width: 991.98px) {
    .legend-all {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px 12px;
        width: min(100%, 360px);
        max-width: 100%;
        padding: 0;
        border: none;
        font-size: 11px;
    }

    .legend-all-item {
        gap: 4px;
        white-space: nowrap;
    }

    .legend-all-color {
        width: 14px;
        height: 14px;
        flex-basis: 14px;
    }

    .tessitura-legend-wrap .legend-all {
        width: 170px;
        justify-content: flex-start;
        gap: 6px 8px;
        margin-top: 0;
    }
}

/* Gantt image fill width on desktop */
.gantt-img-fill {
    display: block;
    width: 100%;
    height: auto;
}

/* Prevent horizontal overflow on mobile */
@media (max-width: 991.98px) {
    body {
        overflow-x: hidden;
    }

    .tessitura-gantt-wrap .gantt-img-fill {
        width: auto;
        max-width: none;
        min-width: 720px;
    }
}


.testata-brunelleschi {
    color: #2922f8;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
}

.testata-confini {
    color: #f82037;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
}

.testata-brunelleschi2 {
    color: #0094ff;
    font-family: "Segoe UI", "Segoe WP", Arial, Sans-Serif;
    font-size: 16px;
}

/* Machine popup overlay - modern */
.popup-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.42);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.popup-container {
    position: relative;
    width: min(980px, calc(100vw - 32px));
    height: min(470px, calc(100vh - 32px));
    background: #f8fbff;
    border: 1px solid #dbe7f5;
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}
.popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.72);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.popup-close:hover {
    background: rgba(15, 23, 42, 0.9);
    transform: scale(1.05);
}
.popup-iframe {
    width: 100%;
    height: 100%;
    border: none;
    overflow: hidden;
    background: #f8fbff;
}

@media screen and (max-width: 991px) {
    .popup-container {
        width: min(96vw, calc(100vw - 20px));
        height: min(88vh, calc(100vh - 20px));
        border-radius: 16px;
    }

    .popup-close {
        top: 8px;
        right: 8px;
        width: 34px;
        height: 34px;
    }
}

/* Tessitura title labels - push below fixed header (only Tessiture page) */
.tessitura.tessiture-page > div:first-child {
    top: -20px !important;
}

/* Machine popup details */
.machine-detail-loading {
    padding: 24px;
    text-align: center;
    color: #64748b;
    font-weight: 600;
}

.machine-detail-popup {
    background: linear-gradient(180deg, #f8fbff 0%, #f3f8ff 100%);
    border: 1px solid #dbe7f5;
    border-bottom: none;
    border-radius: 20px;
    padding: 16px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.machine-detail-header {
    background: #ffffff;
    border: 1px solid #dbe7f5;
    border-radius: 14px;
    padding: 14px;
    text-align: center;
    margin-bottom: 12px;
}

.machine-detail-title {
    color: #0f2f7b;
    font-size: clamp(1.5rem, 2.8vw, 2.2rem);
    font-weight: 800;
    line-height: 1.05;
}

.machine-detail-subtitle {
    color: #334155;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    font-weight: 700;
    margin-top: 4px;
}

.machine-detail-status {
    background: #ffffff;
    border: 1px solid #dbe7f5;
    border-radius: 12px;
    padding: 10px 12px;
    text-align: center;
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #b91c1c;
}

.machine-detail-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.machine-detail-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border: 1px solid #dbe7f5;
    border-radius: 12px;
    padding: 10px 12px;
    min-height: 60px;
}

.machine-detail-label {
    color: #0f2f7b;
    font-size: 1.03rem;
    font-weight: 600;
}

.machine-detail-value {
    color: #b91c1c;
    font-size: 1.25rem;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.machine-detail-footer {
    margin-top: 12px;
    padding: 10px 12px;
    background: #ffffff;
    border: 1px solid #dbe7f5;
    border-radius: 12px;
    color: #1e3a8a;
    font-size: 1.05rem;
    text-align: right;
}

@media screen and (max-width: 767px) {
    .machine-detail-popup {
        border-radius: 16px;
        padding: 12px;
    }

    .machine-detail-grid {
        grid-template-columns: 1fr;
    }

    .machine-detail-row {
        grid-template-columns: 1fr;
        gap: 6px;
        min-height: 0;
    }

    .machine-detail-label,
    .machine-detail-value {
        text-align: left;
    }

    .machine-detail-value {
        font-size: 1.2rem;
    }

    .machine-detail-status {
        font-size: 1.05rem;
    }

    .machine-detail-footer {
        text-align: left;
    }
}

/* Machine popup overlay - FancyBox style */

@media screen and (max-width: 767px) {
    .andon-tessiture-row .ramosa-indicator {
        transform: translateY(-70px);
    }
}

@media screen and (max-width: 480px) {
    .andon-tessiture-row .ramosa-indicator {
        transform: translateY(-90px);
    }
}

.app-content-menu-open {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
    transition: filter 0.2s ease;
}

.settings-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 76px;
    flex-wrap: wrap;
}

.settings-toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-toolbar-right {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.settings-hint {
    color: #6b7280;
    font-size: 13px;
}

.settings-selected {
    color: #0f766e;
    font-size: 13px;
    font-weight: 600;
}

.settings-status {
    margin-top: 8px;
    font-size: 13px;
    color: #334155;
}

.settings-tessiture-row {
    margin-bottom: 12px;
}

.settings-tessitura {
    user-select: none;
}

.settings-title {
    position: absolute;
    top: -25px;
    left: 0;
    font-weight: 700;
}

.settings-canvas {
    width: 100%;
    height: 100%;
}

.settings-machine-wrap {
    position: absolute;
}

.settings-machine-marker {
    cursor: grab;
    outline: none;
}

.settings-machine-marker:active {
    cursor: grabbing;
}

.settings-machine-selected {
    border: 2px solid #3b82f6;
    border-radius: 8px;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.settings-machine-selected .machine-circle {
    background: #000000 !important;
    box-shadow: none;
}

.settings-machine-selected .machine-num {
    color: #ffffff;
}

@media screen and (max-width: 991.98px) {
    .index-topbar-print-button {
        top: auto;
        right: 12px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        z-index: 2000;
    }
}

.print-popup-machines-list {
    margin-top: 4px;
    max-height: 180px;
    overflow: auto;
    border: 1px solid #dbe7f5;
    border-radius: 10px;
    padding: 2px 8px;
    background: #ffffff;
}

.print-popup-machine-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0;
    margin: 0;
    min-height: 16px;
    font-size: 0.88rem;
    line-height: 1;
}

.print-popup-machine-item input[type="checkbox"] {
    margin: 0;
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
}

.print-popup-machine-code {
    font-weight: 600;
    color: #0f172a;
    line-height: 1;
}

.print-popup-machine-desc {
    color: #475569;
    line-height: 1;
}

@media screen and (max-width: 767px) {
    .print-popup-machines-list {
        max-height: 160px;
    }
}

/* Fix mirata smartphone: riduce gap verticali in Tessitura (pagina singola) */
@media screen and (max-width: 767px) {
    .tessitura-page-row .tessitura-status-row {
        margin-top: 2px !important;
        margin-bottom: 20px !important;
    }

    .tessitura-page-row .tessitura {
        margin-bottom: -220px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap .k-gauge,
    .tessitura-page-row .tessitura-gauge-wrap .k-chart {
        height: 120px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap > div:last-child {
        margin-top: -6px !important;
        line-height: 1.05;
    }

    .tessitura-page-row .tessitura-gantt-col {
        margin-top: -8px !important;
        padding-top: 0 !important;
    }
}

@media screen and (max-width: 480px) {
    .tessitura-page-row .tessitura {
        margin-bottom: -320px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap .k-gauge,
    .tessitura-page-row .tessitura-gauge-wrap .k-chart {
        height: 108px !important;
    }

    .tessitura-page-row .tessitura-gauge-wrap > div:last-child {
        margin-top: -10px !important;
    }

    .tessitura-page-row .tessitura-gantt-col {
        margin-top: -12px !important;
    }
}
