/* =================================================================
   GIARELLI FABIO — Area riservata (gestione rapportini)
   UI chiara e leggibile per uso quotidiano, accenti brand giallo.
   ================================================================= */

:root {
    --brand:      #f3e600;
    --brand-deep: #cabf00;
    --ink:        #1c1c1b;
    --charcoal:   #242423;
    --charcoal-2: #313130;
    --bg:         #eef0f3;
    --card:       #ffffff;
    --text:       #1f2430;
    --muted:      #707784;
    --line:       #e4e7ec;
    --line-2:     #eef1f4;
    --green:      #1a9d52;
    --green-bg:   #e7f6ee;
    --red:        #d23b3b;
    --red-bg:     #fdecec;
    --amber:      #b5751a;
    --label:      #8a6d00;   /* colore etichette/titoli, distinto dal testo inserito */

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px -16px rgba(16,24,40,.25);
    --shadow-lg: 0 24px 48px -24px rgba(16,24,40,.4);
    --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --display: "Saira Condensed", "Arial Narrow", sans-serif;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }
/* dimensione di default delle icone inline (le regole specifiche la sovrascrivono) */
svg { width: 18px; height: 18px; flex: none; }
h1,h2,h3,h4 { font-family: var(--display); text-transform: uppercase; letter-spacing: .3px; margin: 0; line-height: 1.05; }

.wrap { max-width: 1140px; margin-inline: auto; padding: 26px 20px 60px; }

/* ---------------- Topbar ---------------- */
.topbar {
    background: var(--charcoal);
    color: #fff;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 0 rgba(255,255,255,.06);
}
.topbar__in {
    max-width: 1140px; margin-inline: auto;
    display: flex; align-items: center; gap: 18px;
    padding: 0 20px; height: 62px;
}
.topbar__logo img { height: 30px; }
.topbar__nav { display: flex; gap: 4px; margin-left: 10px; flex: 1; overflow-x: auto; }
.topbar__nav a {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 14px; border-radius: 9px;
    color: #cfcfca; font-weight: 600; font-size: .92rem; white-space: nowrap;
    transition: background .15s, color .15s;
}
.topbar__nav a svg { width: 18px; height: 18px; }
.topbar__nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.topbar__nav a.active { background: var(--brand); color: #1c1c1b; }
.topbar__user { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: #cfcfca; white-space: nowrap; }
.topbar__user b { color: #fff; }
.topbar__user a.logout { color: #cfcfca; display: inline-flex; align-items: center; gap: 6px; }
.topbar__user a.logout:hover { color: var(--brand); }
.topbar__user a.logout svg { width: 18px; height: 18px; }

/* ---------------- Page head ---------------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { font-size: 2.1rem; }
.page-head .crumb { color: var(--muted); font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.page-head .crumb a:hover { color: var(--ink); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font); font-weight: 600; font-size: .94rem;
    padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
    cursor: pointer; transition: transform .12s, box-shadow .2s, background .15s, border-color .15s;
    line-height: 1; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #1c1c1b; box-shadow: 0 8px 20px -10px rgba(243,230,0,.8); }
.btn-primary:hover { background: #ffef1f; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: #c9ced6; background: #fafbfc; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f6cccc; }
.btn-danger:hover { background: #fbdede; }
.btn-sm { padding: 7px 11px; font-size: .86rem; border-radius: 8px; }
.btn-lg { padding: 13px 22px; font-size: 1.05rem; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------------- Cards ---------------- */
.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { padding: 18px 22px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__head h2, .card__head h3 { font-size: 1.35rem; }
.card__body { padding: 22px; }
.card + .card { margin-top: 18px; }

/* ---------------- Stat tiles ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat__ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: rgba(243,230,0,.18); color: #8a8200; margin-bottom: 12px; }
.stat__ic svg { width: 22px; height: 22px; }
.stat__val { font-family: var(--display); font-size: 2.15rem; line-height: 1; color: var(--ink); }
.stat__lbl { color: var(--muted); font-size: .86rem; font-weight: 600; margin-top: 5px; }
.stat.accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.accent .stat__val { color: var(--brand); }
.stat.accent .stat__lbl { color: #b9bcc2; }
.stat.accent .stat__ic { background: rgba(243,230,0,.16); color: var(--brand); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.tbl th, table.tbl td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
table.tbl th { font-size: .76rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; white-space: nowrap; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: #fafbfc; cursor: pointer; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl .strong { font-weight: 600; color: var(--ink); }
.row-link { color: var(--ink); font-weight: 600; }
.row-link:hover { color: var(--brand-deep); }

/* ---------------- Badges / chips ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.gray { background: #eef1f4; color: var(--muted); }
.badge.yellow { background: rgba(243,230,0,.22); color: #8a8200; }
.money-pos { color: var(--green); font-weight: 700; }
.money-neg { color: var(--red); font-weight: 700; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 600; font-size: .86rem; color: var(--text); }
.field .hint { font-weight: 500; color: var(--muted); font-size: .78rem; }
.field input, .field select, .field textarea {
    font: inherit; color: var(--text);
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 11px 13px; transition: border-color .15s, box-shadow .15s; width: 100%;
}
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand-deep); box-shadow: 0 0 0 3px rgba(243,230,0,.25);
}
.input-prefix { position: relative; }
.input-prefix span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.input-prefix input { padding-left: 30px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
fieldset { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 16px; margin: 0; }
fieldset legend { font-weight: 700; font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 0 6px; }

/* ---------------- Flash ---------------- */
.flash-stack { margin-bottom: 18px; display: grid; gap: 10px; }
.flash { padding: 13px 16px; border-radius: 10px; font-weight: 600; font-size: .93rem; display: flex; gap: 10px; align-items: center; }
.flash svg { width: 19px; height: 19px; flex: none; }
.flash.ok { background: var(--green-bg); color: var(--green); border: 1px solid #bce6cd; }
.flash.err { background: var(--red-bg); color: var(--red); border: 1px solid #f3c9c9; }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 48px; height: 48px; margin: 0 auto 14px; color: #c7ccd4; }
.empty h3 { font-size: 1.4rem; color: var(--text); margin-bottom: 6px; }

/* ---------------- Filters bar ---------------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { gap: 5px; }
.filters .field label { font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.filters .field input, .filters .field select { padding: 9px 11px; }

/* ---------------- Detail list (client info, report view) ---------------- */
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 22px; }
.dl dt { color: var(--label); font-weight: 700; font-size: .9rem; }
.dl dd { margin: 0; font-weight: 500; color: var(--text); }
.report-body { white-space: pre-wrap; line-height: 1.6; color: var(--text); }

/* Etichetta di sezione (es. LAVORI SVOLTI) — colore distinto dal testo inserito */
.sec-lbl { color: var(--label); font-size: .82rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; margin-bottom: 6px; }

/* split layout */
.split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; align-items: start; }

/* link to new client toggle */
.toggle-new { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--brand-deep); cursor: pointer; font-size: .9rem; }
.toggle-new:hover { text-decoration: underline; }

/* FAB on mobile */
.fab { display: none; }

/* ---------------- Foto allegate ---------------- */
.foto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.foto-item { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: #f1f2f4; }
.foto-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s ease; }
.foto-item a:hover img { transform: scale(1.06); }
.foto-del-form { position: absolute; top: 6px; right: 6px; margin: 0; }
.foto-del { display: grid; place-items: center; width: 30px; height: 30px; padding: 0; border: none; border-radius: 8px; cursor: pointer; background: rgba(20,20,20,.55); color: #fff; -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: background .15s; }
.foto-del:hover { background: var(--red); }
.foto-del svg { width: 16px; height: 16px; }
input[type=file] { font: inherit; padding: 10px 12px; border: 1px dashed #c7ccd4; border-radius: 10px; background: #fff; width: 100%; cursor: pointer; color: var(--muted); }
input[type=file]:hover { border-color: var(--brand-deep); }

/* ---------------- Richieste (lead dal sito) ---------------- */
.ric-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.ric-name { font-family: var(--display); font-size: 1.5rem; text-transform: uppercase; letter-spacing: .3px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; line-height: 1; }
.ric-date { color: var(--muted); font-size: .88rem; margin-top: 6px; display: flex; align-items: center; gap: 6px; }
.ric-date svg { width: 15px; height: 15px; }
.ric-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ric-msg { margin-top: 14px; background: #fafbfc; border: 1px solid var(--line-2); border-radius: 10px; padding: 13px 15px; white-space: pre-wrap; line-height: 1.55; }
.ric-contacts { display: flex; gap: 8px 24px; flex-wrap: wrap; margin-top: 14px; }
.ric-contacts a, .ric-contacts span { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: .96rem; }
.ric-contacts svg { width: 17px; height: 17px; color: var(--label); }
.ric-foot { display: flex; gap: 8px; margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 14px; flex-wrap: wrap; }

/* ---------------- Righe lavoro (form rapportino) ---------------- */
.lav-righe { display: flex; flex-direction: column; gap: 8px; }
.lav-riga { display: grid; grid-template-columns: 1fr 120px 40px; gap: 8px; align-items: center; }
.lav-riga input { margin: 0; }
.lav-riga .lav-ore { text-align: right; }
.lav-del { display: grid; place-items: center; height: 42px; border: 1px solid var(--line); background: #fff; border-radius: 9px; cursor: pointer; color: var(--muted); padding: 0; }
.lav-del:hover { border-color: #f3c9c9; color: var(--red); background: var(--red-bg); }
.lav-add { margin-top: 10px; }
.lnk-add { background: none; border: none; color: var(--brand-deep); font: inherit; font-weight: 600; font-size: .8rem; cursor: pointer; padding: 0; margin-left: 6px; }
.lnk-add:hover { text-decoration: underline; }
.lav-tot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; padding: 11px 15px; background: #fbfbe8; border: 1px solid #ece6b8; border-radius: 10px; font-weight: 600; color: var(--label); }
.lav-tot b { font-family: var(--display); font-size: 1.6rem; color: var(--ink); }
.lav-riga-head { display: grid; grid-template-columns: 1fr 120px 40px; gap: 8px; font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; color: var(--label); font-weight: 700; }
.lav-riga-head span:nth-child(2) { text-align: right; }

/* righe lavoro in visualizzazione/lettura */
.lav-view-row { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px dashed var(--line-2); }
.lav-view-row:last-of-type { border-bottom: none; }
.lav-view-row .h { color: var(--label); font-weight: 700; white-space: nowrap; }
.lav-view-tot { display: flex; justify-content: space-between; font-weight: 700; padding-top: 10px; margin-top: 4px; border-top: 2px solid var(--line); }
.lav-view-tot .h { color: var(--ink); }

/* selettore tipo cliente (privato / azienda) */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { padding: 9px 18px; cursor: pointer; font-weight: 600; font-size: .92rem; background: #fff; transition: background .12s, color .12s; }
.seg label.on { background: var(--ink); color: #fff; }
.seg input { display: none; }

/* ---------------- Responsive ---------------- */
@media (max-width: 820px) {
    .form-grid, .split { grid-template-columns: 1fr; }
    .topbar__user b, .topbar__user .uname { display: none; }
    .page-head h1 { font-size: 1.7rem; }
}
@media (max-width: 600px) {
    .topbar__in { gap: 8px; }
    .topbar__nav a span { display: none; }       /* solo icone su mobile */
    .topbar__nav a { padding: 9px 11px; }
    .wrap { padding: 18px 14px 90px; }
    .card__body { padding: 16px; }
    .hide-sm { display: none; }
    .fab {
        display: inline-flex; position: fixed; right: 16px; bottom: 16px; z-index: 60;
        width: 56px; height: 56px; border-radius: 50%; align-items: center; justify-content: center;
        background: var(--brand); color: #1c1c1b; box-shadow: var(--shadow-lg); border: none;
    }
    .fab svg { width: 26px; height: 26px; }
}

/* ---------------- Auth (login) ---------------- */
.auth-bg {
    min-height: 100vh; display: grid; place-items: center; padding: 24px;
    background:
        radial-gradient(800px 500px at 80% 10%, rgba(243,230,0,.12), transparent 60%),
        linear-gradient(180deg, #1b1b1a, #111);
    background-attachment: fixed;
}
.auth-card {
    width: 100%; max-width: 410px; background: var(--card);
    border-radius: 18px; box-shadow: var(--shadow-lg); overflow: hidden;
}
.auth-card__top { background: var(--charcoal); padding: 30px 30px 26px; text-align: center; }
.auth-card__top img { height: 50px; margin: 0 auto; }
.auth-card__body { padding: 28px 30px 32px; }
.auth-card__body h1 { font-size: 1.7rem; margin-bottom: 4px; }
.auth-card__body p.sub { color: var(--muted); font-size: .92rem; margin: 0 0 22px; }
.auth-card .field { margin-bottom: 15px; }
