:root {
    --cg-accent:      #5BB8B0;
    --cg-accent-dark: #4AA09A;
    --cg-dark:        #0f172a;
    --cg-navy:        #1D2E50;
    --cg-soft:        #EBF7F6;

    /* Bootstrap primary override */
    --bs-primary:              #5BB8B0;
    --bs-primary-rgb:          91, 184, 176;
    --bs-link-color:           #5BB8B0;
    --bs-link-color-rgb:       91, 184, 176;
    --bs-link-hover-color:     #4AA09A;
    --bs-primary-text-emphasis: #2E6B66;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(91, 184, 176, 0.15), transparent 28%),
        radial-gradient(circle at right bottom, rgba(74, 160, 154, 0.10), transparent 22%),
        #f8fafc;
}

/* ── Bootstrap component overrides ───────────────────── */
.btn-primary {
    --bs-btn-bg:                  #5BB8B0;
    --bs-btn-border-color:        #5BB8B0;
    --bs-btn-hover-bg:            #4AA09A;
    --bs-btn-hover-border-color:  #4AA09A;
    --bs-btn-active-bg:           #3D8F89;
    --bs-btn-active-border-color: #3D8F89;
    --bs-btn-disabled-bg:         #5BB8B0;
    --bs-btn-disabled-border-color: #5BB8B0;
    --bs-btn-color: #fff;
    --bs-btn-hover-color: #fff;
    --bs-btn-active-color: #fff;
    --bs-btn-disabled-color: #fff;
}

.btn-outline-secondary {
    --bs-btn-color:              #5BB8B0;
    --bs-btn-border-color:       #dee2e6;
}

.link-primary {
    color: #5BB8B0 !important;
}
.link-primary:hover {
    color: #4AA09A !important;
}

.form-control:focus {
    border-color: #5BB8B0;
    box-shadow: 0 0 0 0.25rem rgba(91, 184, 176, 0.25);
}

/* ── Layout ───────────────────────────────────────────── */
.app-shell {
    min-height: 100vh;
}

/* ── Brand logos ──────────────────────────────────────── */
.placeholder-logo {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--cg-accent), #6de0d8);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
}

.hero-brand-logo {
    max-width: 300px;
    width: 100%;
    border-radius: 10px;
    display: block;
}

.navbar-brand-logo {
    height: 46px;
    width: auto;
    display: block;
    border-radius: 6px;
}

/* ── Cards ────────────────────────────────────────────── */
.hero-card {
    border: 0;
    background: linear-gradient(150deg, rgba(30, 90, 85, 0.97) 0%, rgba(60, 148, 140, 0.95) 100%);
}

.hero-card .list-group-item {
    background: transparent;
    color: rgba(255, 255, 255, 0.9);
}

.stat-card,
.soft-card {
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: 0 1rem 3rem rgba(15, 23, 42, 0.06);
}

.soft-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
}

/* ── Misc components ──────────────────────────────────── */
.permission-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    background: var(--cg-soft);
    color: var(--cg-accent-dark);
}

.login-wrapper {
    min-height: 100vh;
}

.login-teal-card {
    max-width: 480px;
    background: linear-gradient(150deg, #1E5A55 0%, #3C948C 100%);
}

.login-card-logo {
    max-width: 260px;
    width: 100%;
    border-radius: 10px;
    display: inline-block;
}

.login-panel {
    max-width: 460px;
}

.login-brand {
    text-decoration: none;
}

.page-header {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.90));
    border-bottom: 1px solid rgba(91, 184, 176, 0.15);
    backdrop-filter: blur(12px);
}

.nav-link.active-card {
    background: rgba(91, 184, 176, 0.12);
    color: var(--cg-accent-dark);
    border-radius: 0.75rem;
}

.module-card {
    transition: transform 180ms ease, box-shadow 180ms ease;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 1rem 2rem rgba(15, 23, 42, 0.09);
}

.table-role-badge {
    min-width: 6rem;
}

/* ── Striscia pillole fasi ─────────────────────────────── */
.phase-pills {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    text-decoration: none;
    line-height: 1;
}
.phase-pill {
    width: 8px;
    height: 22px;
    border-radius: 3px;
    display: inline-block;
    border: 1px solid transparent;
    transition: transform .1s ease;
    text-decoration: none;
}
.phase-pills:hover .phase-pill { opacity: .95; }
.phase-pill:hover { transform: scaleY(1.12) scaleX(1.35); }
.phase-pill.pill-future  { background: transparent; border-color: rgba(15, 23, 42, 0.22); }
.phase-pill.pill-neutral { background: #9FE1CB; border-color: #5DCAA5; }
.phase-pill.pill-green   { background: #1D9E75; }
.phase-pill.pill-yellow  { background: #EF9F27; }
.phase-pill.pill-red     { background: #E24B4A; }
.phase-pill.pill-current { outline: 2px solid rgba(15, 23, 42, 0.35); outline-offset: 1px; }
.phase-final {
    margin-left: 6px;
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
}
.phase-final.pf-done { color: #1D9E75; }
.phase-final.pf-open { color: #D4537E; }

/* L'ancora di una fase deve fermarsi SOTTO l'header fisso, con un po' di spazio
   sopra: sia arrivando dalle pillole (deep-link) sia dopo aver salvato una fase. */
[id^="fase-"] { scroll-margin-top: 92px; }

/* Righe tabella cliccabili → aprono il lavoro */
tr[data-job-href] { cursor: pointer; }

/* ── Guida a scomparsa (riutilizzabile) ───────────────────────────────────
   Convenzione fissa in tutto il gestionale: indaco + 💡 + "＋/–", così
   l'utente impara a riconoscere "qui c'è una spiegazione se serve". */
.guida-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 1px solid rgba(79, 70, 229, 0.4);
    background: rgba(79, 70, 229, 0.06);
    color: #4338CA;
    font-size: .82rem;
    font-weight: 600;
    padding: .3rem .7rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background .12s ease;
}
.guida-toggle:hover { background: rgba(79, 70, 229, 0.12); }
.guida-toggle .guida-ico::before { content: "＋"; font-weight: 700; }
.guida-toggle[aria-expanded="true"] .guida-ico::before { content: "–"; }
.guida-box {
    margin-top: .5rem;
}
.guida-inner {
    border: 1px solid rgba(79, 70, 229, 0.25);
    border-left-width: 4px;
    background: rgba(79, 70, 229, 0.04);
    border-radius: .6rem;
    padding: .85rem 1rem;
    font-size: .875rem;
}
.guida-inner :last-child { margin-bottom: 0; }
.guida-inner dt { font-weight: 700; margin-top: .5rem; }
.guida-inner dt:first-child { margin-top: 0; }
.guida-inner dd { margin-bottom: .1rem; color: var(--bs-secondary-color, #555); }

/* ── Dashboard alert: pensata per l'uso in cantiere ───────────────────────
   Pulsanti alti e distanziati, tocabili anche di fretta o con i guanti.
   48px è la dimensione minima raccomandata per un bersaglio touch. */
.alert-action {
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    font-weight: 600;
    white-space: nowrap;
}
/* L'ancora della notifica push deve fermarsi sotto l'header fisso */
.alert-card { scroll-margin-top: 92px; }
.alert-card-evidenza {
    animation: alert-flash 2.6s ease-out;
}
@keyframes alert-flash {
    0%, 40% { box-shadow: 0 0 0 4px rgba(239, 159, 39, .55); }
    100%    { box-shadow: 0 0 0 0 rgba(239, 159, 39, 0); }
}

/* ── Timeline degli alert (configurazione soglie) ─────────────────────────
   Ogni riga è un livello di avviso; i pallini si trascinano per spostare
   l'orario e le distanze si aggiornano da sole nei campi numerici. */
.tl-wrap {
    overflow-x: auto;
    padding-bottom: .25rem;
}
.tl {
    min-width: 560px;
    position: relative;
    padding: 0 1.25rem;
}
.tl-axis {
    position: relative;
    height: 1.4rem;
    margin-left: 7.5rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.15);
}
.tl-tick {
    position: absolute;
    transform: translateX(-50%);
    font-size: .7rem;
    color: var(--bs-secondary-color, #6b7280);
    white-space: nowrap;
}
.tl-tick::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -5px;
    width: 1px;
    height: 5px;
    background: rgba(15, 23, 42, 0.2);
}
.tl-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .85rem;
}
.tl-label {
    flex: 0 0 7rem;
    font-size: .78rem;
    line-height: 1.15;
    text-align: right;
    color: var(--bs-secondary-color, #6b7280);
}
.tl-label strong { display: block; color: var(--bs-body-color, #111); }
.tl-track {
    position: relative;
    flex: 1 1 auto;
    height: 2.1rem;
}
.tl-line {
    position: absolute;
    top: 50%;
    height: 3px;
    border-radius: 3px;
    transform: translateY(-50%);
    background: rgba(91, 184, 176, 0.35);
}
.tl-line.tl-open {
    background: linear-gradient(90deg, rgba(226, 75, 74, 0.45), rgba(226, 75, 74, 0));
}
.tl-dot {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 .35rem;
    border-radius: 999px;
    border: 2px solid #fff;
    font-size: .7rem;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    cursor: grab;
    touch-action: none;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
}
.tl-dot:active { cursor: grabbing; }
.tl-dot:focus-visible { outline: 3px solid rgba(15, 23, 42, .45); outline-offset: 2px; }
.tl-dot.tl-main { background: #1D9E75; }
.tl-dot.tl-rep  { background: #9FC7C3; color: #123; min-width: 1.5rem; height: 1.5rem; }
.tl-dot.tl-more { background: transparent; color: #E24B4A; border-color: transparent; box-shadow: none; cursor: default; }
.tl-livello-2 .tl-dot.tl-main { background: #EF9F27; }
.tl-livello-3 .tl-dot.tl-main { background: #E24B4A; }

/* Galleria foto (sopralluogo): griglia che si adatta anche da telefono */
.doc-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: .5rem;
}
.doc-thumb img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: .6rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: rgba(15, 23, 42, 0.04);
    display: block;
}
.doc-thumb figcaption {
    font-size: .72rem;
    margin-top: .15rem;
}

/* Indicatore "extra" nella striscia fasi */
.extra-badge {
    margin-left: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.08);
    color: var(--bs-secondary-color, #5F5E5A);
    line-height: 1.3;
}
.extra-badge.extra-charged {
    background: #FAC775;
    color: #633806;
}

/* iOS ingrandisce automaticamente la pagina quando si tocca un campo con
   testo < 16px. Su dispositivi touch forziamo 16px per evitare lo zoom
   involontario (desktop invariato). */
@media (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea,
    .form-control,
    .form-control-sm,
    .form-select,
    .form-select-sm {
        font-size: 16px !important;
    }
}

@media (max-width: 991.98px) {
    .login-wrapper {
        padding: 1.5rem 0;
    }
}
