/* Rope&Co — stile "cantiere moderno": base chiara e pulita, identità nero / giallo / grigio.
   Regola: il giallo non si usa mai come testo su fondo chiaro (illeggibile). Sempre nero su giallo o giallo su nero. */

@font-face { font-family: 'Inter Tight'; font-weight: 400; font-display: swap; src: url(../fonts/inter-tight-400.woff2) format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-weight: 500; font-display: swap; src: url(../fonts/inter-tight-500.woff2) format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-weight: 700; font-display: swap; src: url(../fonts/inter-tight-700.woff2) format('woff2'); }
@font-face { font-family: 'Inter Tight'; font-weight: 800; font-display: swap; src: url(../fonts/inter-tight-800.woff2) format('woff2'); }

:root {
  --yellow: #ffc700;
  --black: #141414;
  --bg: #f2f2ef;
  --surface: #ffffff;
  --surface-2: #f2f2ef;
  --text: #141414;
  --muted: #6e6e6a;
  --line: #e4e4e0;
  --chrome: #141414;
  --chrome-2: #262626;
  --chrome-muted: #8d8d8a;
  --ok: #12663b; --ok-bg: #e3f4ea;
  --warn: #8a5a00; --warn-bg: #fff3c4;
  --bad: #b42318; --bad-bg: #fde8e7;
  --radius: 18px;
  --radius-sm: 12px;
  --tabbar-h: 62px;
  --font: 'Inter Tight', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
/* Tema: data-theme su <html> = light (predefinito, più leggibile al sole) | dark | auto (segue il telefono). */
:root[data-theme="dark"] {
    --bg: #181818; --surface: #242424; --surface-2: #303030; --text: #f2f2ef; --muted: #adada9; --line: #3a3a3a;
    --chrome: #0f0f0f; --chrome-2: #2a2a2a;
    --ok: #5fd39a; --ok-bg: #12301f; --warn: #ffd54a; --warn-bg: #3a2f08; --bad: #ff8a80; --bad-bg: #3d1614;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #181818; --surface: #242424; --surface-2: #303030; --text: #f2f2ef; --muted: #adada9; --line: #3a3a3a;
    --chrome: #0f0f0f; --chrome-2: #2a2a2a;
    --ok: #5fd39a; --ok-bg: #12301f; --warn: #ffd54a; --warn-bg: #3a2f08; --bad: #ff8a80; --bad-bg: #3d1614;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 16px/1.45 var(--font);
  background: var(--bg); color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); }
.boot { text-align: center; padding: 40vh 0; color: var(--muted); }
a { color: inherit; text-decoration-color: var(--yellow); text-decoration-thickness: 2px; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; }
h4 { font-size: .72rem; font-weight: 700; margin: 16px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
p { margin: 4px 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.pre { white-space: pre-wrap; }

/* ---------- Barra superiore, fascia cantiere, barra di navigazione ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--chrome); color: #fff;
}
.topbar h1 { flex: 1; font-size: 1.05rem; font-weight: 800; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hazard { height: 5px; background: repeating-linear-gradient(-45deg, var(--yellow) 0 9px, var(--black) 9px 18px); }
.logo { width: 40px; display: grid; place-items: center; }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit;
  font-size: 1.35rem; cursor: pointer; display: grid; place-items: center; flex: none;
}
.icon-btn.accent { background: var(--yellow); color: var(--black); font-weight: 800; }
.topbar .icon-btn:not(.accent) { background: var(--chrome-2); }
.list-item .icon-btn { font-size: 1.05rem; background: var(--surface-2); width: 36px; height: 36px; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: center;
  background: var(--chrome); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1; max-width: 128px; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: .7rem; font-weight: 500; color: var(--chrome-muted); text-decoration: none;
}
.tabbar svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--yellow); font-weight: 700; }

/* Bacheca: intestazione con saluto e ricerca */
.hero { background: var(--chrome); color: #fff; padding: calc(14px + env(safe-area-inset-top)) 16px 18px; }
.hero-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; letter-spacing: -0.01em; }
.hero h1 { font-size: 1.6rem; font-weight: 800; margin-top: 16px; }
.hero p { color: var(--chrome-muted); font-size: .9rem; }
.hero input[type=search] { margin-top: 14px; background: var(--chrome-2); border-color: var(--chrome-2); color: #fff; }
.hero input[type=search]::placeholder { color: var(--chrome-muted); }

/* ---------- Layout ---------- */
.page { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 16px;
  color: inherit; text-decoration: none; display: block;
}
.card.alert { background: var(--bad-bg); box-shadow: inset 0 0 0 1.5px var(--bad); }
.card.list { padding: 2px 16px; }
.section { margin: 10px 0 -2px; }
.row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }

/* Annunci */
.job-card { display: flex; flex-direction: column; gap: 8px; overflow: hidden; }
.job-cover { width: calc(100% + 32px); margin: -16px -16px 4px; height: 140px; object-fit: cover; display: block; }
.job-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.job-top .muted { font-size: .85rem; margin-top: 2px; }
.pay { font-weight: 800; font-size: 1.1rem; white-space: nowrap; letter-spacing: -0.02em; }
.pay small { font-size: .7rem; font-weight: 500; color: var(--muted); }
.meta { font-size: .82rem; color: var(--muted); }
.job-foot { display: flex; flex-wrap: wrap; gap: 6px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 4px; }
.stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 11px; }
.stats small { display: block; color: var(--muted); font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stats strong { font-weight: 800; letter-spacing: -0.01em; }
.stats .pay-box { background: var(--yellow); color: var(--black); }
.stats .pay-box small { color: var(--black); opacity: .75; }
.stats .pay-box strong { font-size: 1.15rem; }
.note { background: var(--surface-2); border-radius: var(--radius-sm); padding: 9px 12px; font-size: .9rem; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.small { font-size: .82rem; }
.quote { color: var(--muted); font-style: italic; }

/* Dettaglio con foto: la scheda sale sopra l'immagine */
.detail-hero { position: relative; }
.detail-hero + .page { margin-top: -22px; position: relative; }
.gallery { display: flex; gap: 0; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery a { flex: 0 0 100%; scroll-snap-align: start; }
.gallery img { width: 100%; height: 240px; object-fit: cover; display: block; }
.gallery-count { position: absolute; right: 12px; top: 12px; background: rgba(0,0,0,.6); color: #fff; font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kpis div { background: var(--surface); border-radius: var(--radius-sm); padding: 12px 10px; text-align: center; }
.kpis strong { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.kpis small { color: var(--muted); font-size: .72rem; font-weight: 500; }
.kpis .warn { background: var(--yellow); color: var(--black); }
.kpis .warn small { color: var(--black); }

.list-item { display: flex; align-items: center; gap: 10px; padding: 13px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.list-item:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; }
.list-main strong { font-weight: 700; }

.applicant { border-top: 1px solid var(--line); padding: 14px 0; display: flex; flex-direction: column; gap: 8px; }
.applicant-head { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.applicant-head > div:nth-child(2) { flex: 1; }
.avatar {
  width: 42px; height: 42px; border-radius: var(--radius-sm); background: var(--black); color: var(--yellow);
  display: grid; place-items: center; font-weight: 800; flex: none;
}
.avatar.lg { width: 64px; height: 64px; font-size: 1.6rem; border-radius: 18px; }
.profile-head { display: flex; align-items: center; gap: 14px; }

/* ---------- Badge e chip ---------- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text); border-radius: 99px;
  padding: 7px 13px; font: inherit; font-size: .85rem; font-weight: 500; cursor: pointer;
}
.chip.on { background: var(--black); border-color: var(--black); color: var(--yellow); }
.chip.static { cursor: default; padding: 4px 10px; font-size: .76rem; background: var(--surface-2); border-color: transparent; color: var(--muted); }
.chip.static.yes { background: var(--black); color: var(--yellow); }
.chip.static.no { background: transparent; border: 1.5px dashed #b4b4b0; color: var(--muted); }
.qual-picker { display: flex; flex-direction: column; gap: 12px; }
.qual-group small { display: block; margin-bottom: 6px; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Form ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .78rem; font-weight: 700; }
.field > span:first-child { text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-size: .7rem; }
.field small { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 13px; width: 100%; min-height: 48px;
}
.page.form input, .page.form select, .page.form textarea, .sheet input, .sheet select, .sheet textarea { background: var(--surface); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--black); box-shadow: 0 0 0 3px var(--yellow); }
input[type=checkbox] { width: auto; min-height: 0; accent-color: var(--black); }
.toggle { display: flex; align-items: center; gap: 6px; font-size: .88rem; white-space: nowrap; flex: none !important; padding: 12px 0; }
.filters { display: flex; flex-direction: column; gap: 8px; }
.error { color: var(--bad); font-size: .9rem; font-weight: 500; }

.btn {
  font: inherit; font-weight: 800; border-radius: 14px; padding: 13px 18px; border: 1.5px solid transparent;
  cursor: pointer; text-align: center; text-decoration: none; display: inline-block; min-height: 50px; letter-spacing: -0.01em;
}
.btn.block { width: 100%; display: block; }
.btn.primary { background: var(--black); color: var(--yellow); }
.btn.ghost { background: var(--surface); border-color: var(--line); color: var(--text); font-weight: 700; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); font-weight: 700; }
.btn.link { background: none; color: var(--muted); font-weight: 400; font-size: .85rem; }
.btn:disabled { opacity: .55; }
:root[data-theme="dark"] .btn.primary { background: var(--yellow); color: var(--black); }
:root[data-theme="dark"] :is(.chip.on, .chip.static.yes, .avatar) { box-shadow: inset 0 0 0 1px #444; }
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .btn.primary { background: var(--yellow); color: var(--black); }
  :root[data-theme="auto"] :is(.chip.on, .chip.static.yes, .avatar) { box-shadow: inset 0 0 0 1px #444; }
}

.segmented { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.segmented button { flex: 1; border: 0; background: transparent; padding: 10px; border-radius: 11px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.segmented.small button { padding: 7px; font-size: .85rem; }
.segmented button.on { background: var(--black); color: var(--yellow); }
.page > .segmented, .auth .segmented { background: var(--surface); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { font-size: 2.4rem; margin-bottom: 8px; }
.empty strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 1.1rem; font-weight: 800; }

/* ---------- Pannello dal basso ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg); width: 100%; max-width: 640px; max-height: 90vh; overflow: auto;
  border-radius: 24px 24px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: up .2s ease-out;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 1.15rem; font-weight: 800; }
.sheet-head .icon-btn { background: var(--surface); font-size: 1rem; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Accesso ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth-hero { background: var(--chrome); color: #fff; text-align: left; padding: calc(36px + env(safe-area-inset-top)) 20px 28px; }
.auth-hero h1 { font-size: 2.1rem; font-weight: 800; margin-top: 18px; }
.auth-hero p { color: var(--chrome-muted); max-width: 34ch; margin-top: 8px; }
.auth-body { padding: 18px 16px 32px; display: flex; flex-direction: column; gap: 14px; }
.role-pick { display: flex; gap: 8px; }
.role-pick button {
  flex: 1; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); border-radius: 14px; padding: 13px;
  cursor: pointer; font: inherit; display: flex; flex-direction: column; text-align: left; gap: 2px;
}
.role-pick strong { font-weight: 800; }
.role-pick button.on { border-color: var(--black); background: var(--yellow); color: var(--black); }
.role-pick small { color: var(--muted); }
.role-pick button.on small { color: var(--black); opacity: .75; }
.demo-box { text-align: center; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }

/* ---------- Foto annunci (editor) ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; }
.photo.add { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #b4b4b0; background: var(--surface); color: var(--text); font-size: 1.6rem; cursor: pointer; }
.photo.add span { font-size: .75rem; font-weight: 700; }

/* ---------- Caselle di selezione ---------- */
.check-list { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-sm); padding: 2px 12px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; font-weight: 500; font-size: .9rem; cursor: pointer; }
.check-list .check-row + .check-row { border-top: 1px solid var(--line); }
.check-row span { flex: 1; }
.check-row input { width: 20px; height: 20px; flex: none; }
.consent { align-items: flex-start; font-size: .85rem; font-weight: 400; padding: 0; }
.consent input { margin-top: 2px; }

/* ---------- Privacy ---------- */
.legal-links { text-align: center; font-size: .85rem; color: var(--muted); margin: 0; }
.legal-links a { color: var(--muted); }
.legal ul { padding-left: 20px; margin: 4px 0; }
.legal li { margin: 4px 0; }
.legal p, .legal li { font-size: .92rem; }
.legal h4 { color: var(--text); text-transform: none; letter-spacing: -0.01em; font-size: 1rem; font-weight: 800; }
.list-item.as-btn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); font: inherit; color: inherit; text-align: left; cursor: pointer; }
.list-item.as-btn:last-child { border-bottom: 0; }
.danger-text .list-main { color: var(--bad); }
.stats strong small { display: inline; text-transform: none; letter-spacing: 0; font-size: .75rem; font-weight: 500; }

/* ---------- Avvisi ---------- */
.alerts h4 { margin-top: 0; }
.alert-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); text-decoration: none; font-size: .9rem; }
.alert-row:first-of-type { border-top: 0; }
.alert-row span:nth-child(2) { flex: 1; }
.alert-row strong { font-weight: 700; }
.chev { color: var(--muted); font-size: 1.2rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.dot.bad { background: var(--bad); }
.dot.warn { background: var(--yellow); box-shadow: 0 0 0 1.5px var(--black); }
.dot.ok { background: var(--ok); }
.tab-icon { position: relative; display: grid; }
.tab-badge {
  position: absolute; top: -5px; right: -10px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--yellow); color: var(--black); font-size: .66rem; font-weight: 800; display: grid; place-items: center;
}

/* ---------- Rubrica tecnici ---------- */
.worker-card { display: flex; flex-direction: column; gap: 10px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); }
.chip.static.hl { box-shadow: 0 0 0 2px var(--yellow); }

/* ---------- DPI ---------- */
.thumb { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; flex: none; }
.empty-thumb { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: .7rem; font-weight: 800; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); }
.report-table { border-collapse: collapse; width: 100%; font-size: .78rem; min-width: 760px; }
.report-table th, .report-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.report-table th { background: var(--black); color: var(--yellow); font-weight: 700; white-space: nowrap; }
@media print {
  .topbar, .hazard, .tabbar, .no-print { display: none !important; }
  body, .page, .table-wrap { background: #fff !important; color: #000 !important; }
  #app { max-width: none; padding: 0; }
  .report-table { min-width: 0; font-size: 9pt; }
  .report-table th { background: #141414 !important; color: #ffc700 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  @page { size: A4 landscape; margin: 12mm; }
}
.doc-link { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; }
.doc-link .chev { grid-row: 1 / span 2; grid-column: 2; }
.chip.static.work { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); }

/* Livelli di esperienza */
.dots { display: inline-flex; gap: 2px; margin-left: 7px; vertical-align: middle; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--black); }
:root[data-theme="dark"] .dots i.on { background: var(--yellow); }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] .dots i.on { background: var(--yellow); } }
.levels { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.level-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name pick" "name lvl"; gap: 2px 10px; align-items: center; }
.level-row > span { grid-area: name; font-size: .9rem; font-weight: 500; }
.level-name { grid-area: lvl; text-align: right; }
.level-pick { grid-area: pick; display: flex; gap: 4px; }
.level-pick button { width: 34px; height: 34px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.level-pick button.on { background: var(--black); border-color: var(--black); color: var(--yellow); }
