:root {
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-strong: #101827;
    --text: #142033;
    --muted: #687385;
    --line: #dfe5ec;
    --primary: #315bdf;
    --primary-dark: #2144b7;
    --success: #16825d;
    --success-soft: #e7f6f0;
    --danger: #c43f4f;
    --danger-soft: #fdecef;
    --warning: #b97814;
    --warning-soft: #fff5dc;
    --info: #236fbd;
    --info-soft: #e9f3ff;
    --neutral: #5f6979;
    --neutral-soft: #eef1f5;
    --radius: 18px;
    --radius-small: 10px;
    --shadow: 0 12px 35px rgba(23, 34, 56, .07);
    --sidebar: 246px;
    --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 85% 0%, rgba(49, 91, 223, .08), transparent 28rem),
        var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 3vw, 3rem); line-height: 1.05; margin-bottom: .65rem; letter-spacing: -.045em; }
h2 { font-size: 1.35rem; line-height: 1.2; margin-bottom: .45rem; letter-spacing: -.025em; }
h3 { font-size: 1.02rem; margin-bottom: .35rem; }
p { color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 18px;
    background: #0e1727;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 28px;
    z-index: 50;
}

.brand { display: flex; gap: 12px; align-items: center; padding: 0 8px; }
.brand strong, .brand small { display: block; }
.brand small { color: #8fa0bb; font-size: .75rem; margin-top: 1px; }
.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    background: linear-gradient(145deg, #4d7aff, #274ec1);
    color: #fff;
    font-weight: 800;
    letter-spacing: -.04em;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 10px 25px rgba(49,91,223,.35);
}
.brand-mark--large { width: 58px; height: 58px; border-radius: 18px; font-size: 1.25rem; margin-bottom: 32px; }

.nav { display: grid; gap: 5px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 12px;
    border-radius: 10px;
    color: #a9b7cb;
    transition: .18s ease;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav a.is-active { color: #fff; background: #253450; box-shadow: inset 3px 0 0 #5a83ff; }
.nav-icon { width: 23px; text-align: center; color: #7f98c0; }

.sidebar-note {
    margin-top: auto;
    padding: 14px;
    border: 1px solid rgba(255,255,255,.09);
    background: rgba(255,255,255,.04);
    border-radius: 14px;
}
.sidebar-note strong, .sidebar-note span, .sidebar-note small { display: block; }
.sidebar-note span { margin-top: 4px; color: #b7c3d6; }
.sidebar-note small { margin-top: 6px; color: #788ba8; }

.main-column { min-width: 0; }
.topbar {
    height: 70px;
    padding: 0 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(223,229,236,.88);
    background: rgba(244,246,248,.82);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar-context { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .09em; font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-avatar, .resource-avatar {
    width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
    background: #dfe7ff; color: #2549bd; font-weight: 800;
}
.user-copy strong, .user-copy small { display: block; }
.user-copy strong { font-size: .87rem; }
.user-copy small { font-size: .7rem; color: var(--muted); text-transform: lowercase; }

.menu-toggle { display: none; border: 0; background: transparent; font-size: 1.35rem; color: var(--text); }

.page { padding: 34px; max-width: 1680px; margin: 0 auto; }
.page-heading {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 24px;
    margin-bottom: 26px;
}
.page-heading p { max-width: 820px; margin-bottom: 0; }
.page-heading--compact { align-items: center; }
.heading-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-block; color: var(--primary); font-size: .82rem; margin-bottom: 14px; font-weight: 700; }
.eyebrow, .area-label {
    color: var(--primary);
    font-size: .7rem;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: .11em;
    font-weight: 800;
}
.area-label { color: #6e7c91; }
.muted { color: var(--muted); }

.button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    font-size: .86rem;
    transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--primary); color: #fff; box-shadow: 0 8px 18px rgba(49,91,223,.2); }
.button-primary:hover { background: var(--primary-dark); }
.button-danger { background: #fff; color: var(--danger); border-color: #efb5be; }
.button-danger:hover { background: var(--danger-soft); }
.button-secondary { color: #2346b4; background: #eef2ff; border-color: #d9e1ff; }
.button-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.button-small { min-height: 34px; padding: 7px 10px; font-size: .76rem; }
.button-block { width: 100%; }

.panel {
    background: var(--panel);
    border: 1px solid rgba(223,229,236,.9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.panel-heading {
    min-height: 74px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin-bottom: 0; }
.panel-heading a { color: var(--primary); font-size: .8rem; font-weight: 700; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}
.kpi-card {
    padding: 20px;
    min-height: 138px;
    border: 1px solid rgba(223,229,236,.9);
    background: linear-gradient(145deg, #fff, #fbfcfe);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi-card::after {
    content: "";
    width: 68px; height: 68px; border-radius: 50%;
    position: absolute; right: -18px; top: -18px;
    background: rgba(49,91,223,.07);
}
.kpi-card--danger::after { background: rgba(196,63,79,.09); }
.kpi-card span, .kpi-card small { display: block; color: var(--muted); }
.kpi-card strong { display: block; font-size: 2.25rem; line-height: 1.1; margin: 13px 0 7px; letter-spacing: -.05em; }
.kpi-card small { font-size: .76rem; }

.dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.panel-span-2 { grid-column: span 2; }
.panel-span-3 { grid-column: span 3; }

.critical-list, .timeline-list { display: grid; }
.critical-row {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto 18px;
    gap: 12px;
    align-items: center;
    padding: 15px 22px;
    border-bottom: 1px solid var(--line);
}
.critical-row:hover, .timeline-row:hover { background: #fafbfc; }
.risk-dot { width: 9px; height: 9px; border-radius: 50%; }
.risk-dot--rosso { background: var(--danger); box-shadow: 0 0 0 5px var(--danger-soft); }
.risk-dot--giallo { background: var(--warning); box-shadow: 0 0 0 5px var(--warning-soft); }
.critical-main strong, .critical-main small { display: block; }
.critical-main small { color: var(--muted); margin-top: 3px; }
.critical-metrics { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.row-arrow { color: #97a2b3; font-size: 1.5rem; }

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: .67rem;
    line-height: 1;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .045em;
    white-space: nowrap;
}
.badge-large { min-height: 34px; padding: 7px 12px; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted, .badge-neutral { background: var(--neutral-soft); color: var(--neutral); }

.timeline-row { display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.timeline-date { width: 42px; height: 48px; border: 1px solid var(--line); border-radius: 10px; display: grid; place-content: center; text-align: center; background: #fbfcfd; }
.timeline-date strong { font-size: 1.2rem; line-height: 1; }
.timeline-date small { font-size: .62rem; color: var(--muted); margin-top: 3px; }
.timeline-row > span:last-child strong, .timeline-row > span:last-child small { display: block; }
.timeline-row > span:last-child small { color: var(--muted); font-size: .76rem; margin-top: 2px; }

.phase-summary-grid { padding: 20px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
.phase-summary-card { border: 1px solid var(--line); border-radius: 13px; padding: 14px; }
.phase-summary-card strong { display: block; min-height: 43px; margin-top: 6px; }
.phase-summary-card small { display: block; margin-top: 7px; color: var(--muted); font-size: .74rem; }
.mini-progress { height: 6px; border-radius: 999px; background: #edf0f4; overflow: hidden; }
.mini-progress span { display: block; height: 100%; background: linear-gradient(90deg, #315bdf, #7c9bff); border-radius: inherit; }

.filter-bar {
    padding: 15px 18px;
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--line);
}
.filter-bar label { display: grid; gap: 5px; color: var(--muted); font-size: .72rem; font-weight: 700; }
.filter-bar input, .filter-bar select { min-height: 40px; }
.search-field {
    min-width: min(420px, 100%);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
    padding: 0 11px;
}
.search-field input { border: 0 !important; outline: none; width: 100%; padding-inline: 0 !important; }
input, select, textarea {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    padding: 9px 10px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #8ca7ff; box-shadow: 0 0 0 3px rgba(49,91,223,.1); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th {
    padding: 11px 15px;
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
    color: #69768b;
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: left;
    white-space: nowrap;
}
.data-table td { padding: 14px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:hover { background: #fbfcfe; }
.data-table td strong, .data-table td small { display: block; }
.data-table td small { color: var(--muted); font-size: .74rem; margin-top: 3px; }
.progress-cell { min-width: 130px; }
.progress-cell small { text-align: right; }
.row-link { color: var(--primary); font-weight: 800; font-size: .8rem; white-space: nowrap; }
.text-danger { color: var(--danger) !important; }

.order-hero {
    background: linear-gradient(120deg, #111a2a 0%, #192743 70%, #223560 100%);
    color: #fff;
    border-radius: 22px;
    padding: 27px;
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: minmax(0,1.45fr) minmax(330px,1fr);
    gap: 28px;
    box-shadow: 0 16px 45px rgba(14,23,39,.18);
}
.order-hero p { color: #aebbd0; max-width: 630px; }
.order-progress { display: flex; gap: 22px; align-items: center; }
.ring-progress {
    --progress: 0;
    width: 116px; height: 116px; border-radius: 50%; flex: 0 0 auto;
    display: grid; place-content: center; text-align: center;
    background: radial-gradient(closest-side, #15223a 78%, transparent 79% 100%),
                conic-gradient(#6b8cff calc(var(--progress) * 1%), rgba(255,255,255,.11) 0);
}
.ring-progress strong, .ring-progress span { display: block; }
.ring-progress strong { font-size: 1.7rem; }
.ring-progress span { color: #9facc1; font-size: .66rem; }
.order-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.order-facts div { padding: 14px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.04); border-radius: 12px; }
.order-facts dt { color: #8fa0ba; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; }
.order-facts dd { margin: 4px 0 0; font-weight: 800; font-size: 1rem; }

.tabs { display: flex; gap: 5px; margin: 18px 0; padding: 5px; width: fit-content; background: #e9edf2; border-radius: 12px; }
.tabs button { border: 0; background: transparent; padding: 9px 14px; border-radius: 8px; color: var(--muted); font-weight: 800; }
.tabs button.is-active { color: var(--text); background: #fff; box-shadow: 0 4px 14px rgba(23,34,56,.07); }

.workflow-list { display: grid; gap: 12px; }
.workflow-step {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 7px 22px rgba(23,34,56,.045);
    display: grid;
    grid-template-columns: 62px minmax(0,1fr);
    overflow: hidden;
}
.workflow-step--blocked { border-color: #f2bbc3; }
.workflow-index { display: grid; place-items: start center; padding-top: 23px; background: #f7f9fc; color: #95a0b0; font-weight: 800; }
.workflow-content { padding: 20px 22px; }
.workflow-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; }
.workflow-heading h3 { font-size: 1.18rem; margin-top: 6px; }
.workflow-heading p { margin-bottom: 0; font-size: .78rem; }
.phase-meta-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 10px; margin: 17px 0; }
.phase-meta-grid > div { padding: 11px 13px; background: #f8fafc; border: 1px solid #edf0f4; border-radius: 10px; }
.phase-meta-grid span, .phase-meta-grid strong, .phase-meta-grid small { display: block; }
.phase-meta-grid span { font-size: .65rem; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; }
.phase-meta-grid strong { font-size: .82rem; margin-top: 5px; }
.phase-meta-grid small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.phase-progress-control .mini-progress { margin: 8px 0; }
.phase-editor { display: grid; grid-template-columns: minmax(160px,.8fr) minmax(250px,1.5fr) minmax(160px,.8fr) auto; gap: 10px; align-items: end; border-top: 1px dashed var(--line); padding-top: 15px; }
.phase-editor label, .form-grid label, .stack label { display: grid; gap: 6px; }
.phase-editor label > span, .form-grid label > span, .stack label > span { color: var(--muted); font-size: .7rem; font-weight: 800; }
.range-label > span { display: flex; justify-content: space-between; }
.range-label output { color: var(--primary); font-weight: 800; }
input[type="range"] { padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }

.two-column-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 18px; }
.detail-list { margin: 0; padding: 4px 22px 18px; }
.detail-list div { display: flex; justify-content: space-between; gap: 20px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; font-weight: 800; text-align: right; }
.component-list { padding: 0 20px 18px; }
.component-list article { padding: 14px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(140px,.7fr) 1fr 1.2fr; gap: 12px; }
.component-list span, .component-list small { color: var(--muted); }

.planning-legend { padding: 14px 18px; display: flex; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.planning-legend span { display: flex; gap: 6px; align-items: center; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-dot--green { background: var(--success); }
.legend-dot--blue { background: var(--info); }
.legend-dot--yellow { background: var(--warning); }
.legend-dot--red { background: var(--danger); }
.legend-dot--grey { background: #9ea7b3; }
.planning-wrap { overflow: auto; max-width: 100%; }
.planning-table { border-collapse: separate; border-spacing: 0; min-width: 1700px; width: 100%; }
.planning-table th { padding: 10px 7px; min-width: 106px; max-width: 128px; background: #f6f8fb; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); font-size: .62rem; color: #67748a; text-align: center; line-height: 1.25; }
.planning-table td { padding: 7px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: center; }
.planning-product-col { position: sticky; left: 0; z-index: 2; min-width: 270px !important; max-width: 270px !important; text-align: left !important; background: #fff !important; box-shadow: 8px 0 15px rgba(16,24,39,.04); }
.planning-table thead .planning-product-col { z-index: 4; background: #f6f8fb !important; }
.planning-product-col strong, .planning-product-col small { display: block; }
.planning-product-col small { color: var(--muted); font-size: .7rem; margin-top: 3px; }
.planning-cell { min-height: 52px; border-radius: 8px; padding: 7px 5px; display: grid; place-content: center; border: 1px solid transparent; }
.planning-cell strong, .planning-cell small { display: block; }
.planning-cell strong { font-size: .74rem; }
.planning-cell small { font-size: .63rem; opacity: .75; }
.planning-cell--verde { background: var(--success-soft); color: var(--success); border-color: #c9ebdd; }
.planning-cell--blu { background: var(--info-soft); color: var(--info); border-color: #cde4fb; }
.planning-cell--giallo { background: var(--warning-soft); color: var(--warning); border-color: #f2dfad; }
.planning-cell--rosso { background: var(--danger-soft); color: var(--danger); border-color: #f5ccd2; }
.planning-cell--grigio { background: var(--neutral-soft); color: var(--neutral); }
.planning-empty { color: #c2c9d3; }

.resource-grid, .machine-grid, .supplier-grid {
    display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-bottom: 18px;
}
.resource-card, .machine-card, .supplier-card {
    border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); padding: 18px;
}
.resource-card { display: grid; grid-template-columns: 46px minmax(0,1fr); gap: 12px; }
.resource-avatar { width: 46px; height: 46px; }
.resource-card p, .machine-card p, .supplier-card p { font-size: .77rem; margin-bottom: 0; }
.resource-stats, .supplier-stats { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 8px; }
.resource-stats span, .supplier-stats span { flex: 1; padding: 9px; border-radius: 9px; background: #f8fafc; border: 1px solid #edf0f4; }
.resource-stats strong, .resource-stats small, .supplier-stats strong, .supplier-stats small { display: block; }
.resource-stats small, .supplier-stats small { color: var(--muted); font-size: .66rem; }
.machine-card-top { display: flex; justify-content: space-between; margin-bottom: 18px; }
.machine-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #eef2ff; color: var(--primary); font-size: 1.2rem; }
.machine-card h3, .supplier-card h3 { margin-top: 8px; }
.supplier-stats { display: grid; grid-template-columns: repeat(3,1fr); }
.record-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; }
.modal.is-open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; z-index: 0; background: rgba(5,12,23,.62); backdrop-filter: blur(5px); }
.modal-card { position: relative; z-index: 1; width: min(760px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 20px; box-shadow: 0 25px 80px rgba(0,0,0,.28); }
.modal-card-wide { width: min(980px, 100%); }
.modal-heading { padding: 20px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-heading h2 { margin: 4px 0 0; }
.icon-button { border: 0; width: 36px; height: 36px; border-radius: 50%; background: #f1f4f8; color: var(--muted); font-size: 1.35rem; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; padding: 22px; }
.form-span-2 { grid-column: span 2; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #f5c7ce; }
.empty-state { padding: 34px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--text); }

.toast {
    position: fixed; right: 24px; bottom: 24px; z-index: 200;
    background: #122036; color: #fff; min-width: 260px; max-width: 420px;
    padding: 12px 15px; border-radius: 11px; box-shadow: 0 18px 45px rgba(0,0,0,.22);
    transform: translateY(30px); opacity: 0; pointer-events: none; transition: .22s ease;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.is-error { background: #8f2e3b; }

.login-body { background: #0d1625; color: #fff; }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0,1.3fr) minmax(440px,.7fr); }
.login-visual {
    padding: clamp(40px, 7vw, 110px);
    display: flex; flex-direction: column; justify-content: center;
    background:
        linear-gradient(130deg, rgba(13,22,37,.95), rgba(25,39,67,.86)),
        radial-gradient(circle at 75% 25%, #3b66e7, transparent 32rem);
}
.login-visual .eyebrow { color: #7798ff; }
.login-visual h1 { max-width: 760px; font-size: clamp(2.8rem, 5.2vw, 5.4rem); }
.login-visual p { max-width: 690px; color: #aab7cb; font-size: 1.08rem; }
.login-flow { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 35px; }
.login-flow span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 999px; color: #d9e1ef; background: rgba(255,255,255,.04); }
.login-flow b { color: #5f7ed9; }
.login-card { background: #fff; color: var(--text); padding: clamp(38px, 5vw, 80px); display: flex; flex-direction: column; justify-content: center; }
.login-card h2 { font-size: 2rem; margin: 6px 0 8px; }
.stack { display: grid; gap: 14px; margin-top: 28px; }
.stack input { min-height: 46px; }
.demo-credentials { margin-top: 22px; padding: 14px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 11px; }
.demo-credentials strong { display: block; margin-bottom: 7px; }
.demo-credentials code { display: block; color: var(--primary); }

@media (max-width: 1180px) {
    .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .dashboard-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .panel-span-3 { grid-column: span 2; }
    .phase-summary-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .resource-grid, .machine-grid, .supplier-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .order-hero { grid-template-columns: 1fr; }
    .phase-editor { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 820px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: .22s ease; width: min(var(--sidebar), 86vw); box-shadow: 20px 0 50px rgba(0,0,0,.25); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .menu-toggle { display: inline-block; margin-right: 10px; }
    .topbar { padding: 0 18px; }
    .page { padding: 20px 16px 30px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .panel-span-2, .panel-span-3 { grid-column: span 1; }
    .critical-row { grid-template-columns: 12px minmax(0,1fr) 16px; }
    .critical-metrics { grid-column: 2; justify-content: flex-start; }
    .phase-summary-grid { grid-template-columns: 1fr; }
    .two-column-grid { grid-template-columns: 1fr; }
    .resource-grid, .machine-grid, .supplier-grid { grid-template-columns: 1fr; }
    .component-list article { grid-template-columns: 1fr; gap: 3px; }
    .user-copy { display: none; }
    .login-shell { grid-template-columns: 1fr; }
    .login-visual { min-height: 48vh; }
    .login-visual h1 { font-size: clamp(2.3rem, 11vw, 4rem); }
}

@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-heading h1 { font-size: 2.25rem; }
    .order-progress { align-items: flex-start; flex-direction: column; }
    .order-facts { grid-template-columns: 1fr; }
    .phase-meta-grid, .phase-editor, .form-grid { grid-template-columns: 1fr; }
    .form-span-2 { grid-column: span 1; }
    .workflow-step { grid-template-columns: 42px minmax(0,1fr); }
    .workflow-content { padding: 17px 15px; }
    .workflow-heading { flex-direction: column; }
    .tabs { width: 100%; overflow-x: auto; }
    .tabs button { flex: 1; white-space: nowrap; }
    .login-card { padding: 34px 24px; }
}

/* v2: amministrazione, workflow, tabelle e sicurezza */
.workflow-admin-grid { grid-template-columns: minmax(280px,.38fr) minmax(0,1.62fr); align-items: start; }
.panel-span-workflow { min-width: 0; }
.workflow-selector { display: grid; gap: 8px; }
.workflow-selector-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 5px 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; }
.workflow-selector-item:hover, .workflow-selector-item.is-active { border-color: #99acec; background: #f7f9ff; }
.workflow-selector-item div { min-width: 0; }
.workflow-selector-item strong, .workflow-selector-item small { display: block; }
.workflow-selector-item > small { grid-column: 1 / -1; color: var(--muted); }
.workflow-master-form { padding: 15px; margin-bottom: 15px; background: #f8faff; border: 1px solid var(--line); border-radius: 12px; }
.workflow-table input, .workflow-table select { min-width: 92px; }
.input-compact { width: 88px; }
.import-grid { grid-template-columns: minmax(320px,.55fr) minmax(0,1.45fr); align-items: start; }
.import-kpis { grid-template-columns: repeat(auto-fit,minmax(125px,1fr)); margin-bottom: 16px; }
.import-kpis .kpi-card { padding: 14px; }
.import-kpis .kpi-card strong { font-size: 1.75rem; }
.sample-import { display: grid; gap: 7px; margin-top: 18px; padding: 14px; border: 1px dashed #9aabe0; background: #f8faff; border-radius: 11px; }
.sample-import code { color: var(--primary); overflow-wrap: anywhere; }
.panel-heading-spaced { margin-top: 26px; }
.compact-list { display: grid; gap: 7px; }
.compact-list-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); text-decoration: none; }
.compact-list-row.is-active, .compact-list-row:hover { border-color: #9aabe0; background: #f7f9ff; }
.compact-list-row strong, .compact-list-row small { display: block; }
.command-block { display: grid; gap: 5px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.command-block span { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.command-block code { display: block; padding: 10px 12px; border-radius: 8px; background: #111c2c; color: #dce6f9; overflow-x: auto; }
.permission-matrix-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; }
.permission-matrix { border-collapse: collapse; min-width: 960px; width: 100%; }
.permission-matrix th, .permission-matrix td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: center; }
.permission-matrix th:first-child, .permission-matrix td:first-child { text-align: left; position: sticky; left: 0; background: #fff; z-index: 1; min-width: 290px; }
.permission-matrix td strong, .permission-matrix td small { display: block; }
.permission-module td { background: #eef2fb !important; color: #465777; font-weight: 700; text-transform: uppercase; font-size: .76rem; letter-spacing: .05em; }
.matrix-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 15px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.check-label { display: flex !important; flex-direction: row !important; align-items: center; gap: 7px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; }
.check-label input { width: auto; min-height: 0; }
.audit-json { max-width: 620px; max-height: 300px; overflow: auto; white-space: pre-wrap; background: #111c2c; color: #dce6f9; padding: 12px; border-radius: 8px; font-size: .78rem; }
details summary { cursor: pointer; color: var(--primary); }
textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); font: inherit; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
fieldset legend { padding: 0 6px; font-weight: 700; color: var(--text); }
.alert-info { background: #eef4ff; border-color: #b9c9f3; color: #2e477e; }

@media (max-width: 1180px) {
    .workflow-admin-grid, .import-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    .checkbox-grid { grid-template-columns: 1fr; }
}
