/* TreeMates Planning – stile */
@font-face { font-family: 'Barlow'; font-weight: 400; font-display: swap; src: url(fonts/barlow-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 500; font-display: swap; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 600; font-display: swap; src: url(fonts/barlow-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow'; font-weight: 700; font-display: swap; src: url(fonts/barlow-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-weight: 700; font-display: swap; src: url(fonts/barlow-condensed-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #F3F2EC;
  --surface: #FFFFFF;
  --ink: #1B1F1C;
  --muted: #5A615C;
  --line: #E2E0D6;
  --line-strong: #CFCDC3;
  --field: #FBFAF7;
  --green: #2E6B3B;
  --green-dark: #1F4D29;
  --green-soft: #E3EEE4;
  --orange-text: #9A4E0C;
  --orange-dark: #6E3A0B;
  --orange-soft: #FBE6CF;
  --private-bg: #FFF7EC;
  --private-line: #D9A86A;
  --blue: #2F5D8A;
  --blue-dark: #1E3F60;
  --blue-soft: #E2EBF4;
  --gray-dot: #7C807C;
  --gray-soft: #ECEBE4;
  --danger: #A12C1F;
  --radius: 16px;
  --nav-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.35; -webkit-text-size-adjust: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
h1, h2, h3 { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 8px); }
.screen.with-footer { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 108px); }

/* Header */
.top { padding: 20px 20px 10px; display: flex; flex-direction: column; gap: 8px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 30px; line-height: 1.05; }
.subtitle { margin: 0; color: var(--muted); font-size: 15px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.avatar { width: 44px; height: 44px; border-radius: 999px; border: none; background: var(--green-soft); color: var(--green-dark); font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.offline { background: var(--orange-soft); color: var(--orange-dark); }
.pill.sync { background: var(--blue-soft); color: var(--blue-dark); }
.demo-banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 12px; background: var(--orange-soft); color: var(--orange-dark); font-size: 13px; font-weight: 600; }

/* Cards & sections */
.content { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.tight { padding: 8px 16px; gap: 0; }
.card.private { background: var(--private-bg); border: 2px dashed var(--private-line); }
.card.tip { background: var(--green-soft); border-color: #BFD6C3; }
.label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.req { font-size: 12px; font-weight: 700; color: var(--orange-text); }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }
.section-title { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; font-size: 20px; text-transform: uppercase; letter-spacing: 0.3px; }

/* Fields */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--field); color: var(--ink); font-size: 16px; }
.input { height: 48px; padding: 0 12px; }
.textarea { padding: 10px 12px; resize: vertical; min-height: 64px; }
.private .input, .private .textarea { border-color: #DCC6A6; background: #fff; }
.input:focus, .textarea:focus { outline: 3px solid rgba(46,107,59,0.35); outline-offset: 1px; border-color: var(--green); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }

/* Buttons */
.btn { min-height: 52px; border-radius: 12px; border: 2px solid var(--green); background: var(--green); color: #fff; font-weight: 700; font-size: 16px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--green-dark); }
.btn.ghost { background: var(--field); color: var(--ink); border: 1px solid var(--line-strong); font-weight: 600; }
.btn.dark { background: var(--ink); border-color: var(--ink); }
.btn.danger { background: #fff; color: var(--danger); border-color: var(--danger); }
.btn[disabled] { background: var(--bg); border-color: #D6D4CA; color: #8A8F8B; cursor: default; }
.btn.small { min-height: 44px; font-size: 15px; padding: 0 12px; }
.btn.block { width: 100%; }
.link-btn { min-height: 44px; padding: 0 6px; border: none; background: transparent; color: var(--green); font-weight: 700; font-size: 15px; }
.icon-btn { width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn.primary { background: var(--green); border-color: var(--green); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 46px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); font-size: 15px; font-weight: 500; }
.chip.on { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.chip.dark.on { background: var(--ink); border-color: var(--ink); }
.chip.square { border-radius: 10px; padding: 0 6px; }
.tool { min-height: 44px; padding: 0 14px 0 10px; border-radius: 10px; border: 1px dashed #A9A79C; background: #fff; color: var(--muted); font-size: 15px; display: inline-flex; align-items: center; gap: 6px; }
.tool.on { border: 1px solid var(--green); background: var(--green-soft); color: var(--green-dark); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper .val { width: 36px; text-align: center; font-size: 20px; font-weight: 700; }

.check { display: flex; align-items: center; gap: 14px; min-height: 54px; font-size: 17px; border-top: 1px solid #EEECE4; }
.check:first-of-type { border-top: none; }
.check input { width: 24px; height: 24px; accent-color: var(--green); margin: 0; flex-shrink: 0; }

.choice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: #fff; text-align: left; width: 100%; }
.choice.on { border: 2px solid var(--green); background: var(--green-soft); color: var(--green-dark); }
.choice.on.warm { border-color: var(--orange-text); background: var(--private-bg); color: var(--orange-dark); }
.choice strong { display: block; font-size: 16px; }
.choice span.s { display: block; font-size: 13px; }

/* Wizard */
.steps { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.step { min-height: 44px; padding: 0; border: none; background: transparent; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.step .bar { height: 6px; border-radius: 999px; background: #D6D4CA; }
.step.done .bar { background: var(--green); }
.step.cur .bar { background: var(--ink); }
.step .lbl { font-size: 12px; color: var(--muted); text-align: center; }
.step.cur .lbl { color: var(--ink); font-weight: 700; }
.wiz-footer { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b)); background: var(--bg); padding: 10px 16px 10px; border-top: 1px solid var(--line); }
.wiz-footer-inner { max-width: 528px; margin: 0 auto; display: flex; flex-direction: column; gap: 4px; }
.photos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.photo { position: relative; aspect-ratio: 1 / 1; border-radius: 12px; overflow: hidden; background: #CBD3C3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .del { position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border-radius: 999px; border: none; background: rgba(27,31,28,0.75); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.photo-add { aspect-ratio: 1 / 1; border-radius: 12px; border: 2px dashed var(--green); background: #F5F9F5; color: var(--green-dark); font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-size: 14px; }
.loc { display: flex; align-items: center; gap: 12px; }
.loc .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--green-soft); color: var(--green); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Bottom nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 6px 4px calc(10px + var(--safe-b)); z-index: 20; }
.nav-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.nav a.on { color: var(--green); font-weight: 700; }

/* Map */
.map-wrap { margin: 0 16px; border-radius: 18px; overflow: hidden; border: 1px solid #D6DACB; height: 46vh; min-height: 280px; background: #E4E8DC; }
#map { width: 100%; height: 100%; }
.leaflet-container { font-family: inherit; }
.cluster-icon { background: var(--green); color: #fff; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(46,107,59,0.25); }
.home-icon { background: var(--ink); color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.num-icon { background: #fff; color: var(--green-dark); border: 3px solid var(--green); border-radius: 999px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }

/* Lists */
.job-row { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 6px 0; border: none; border-top: 1px solid #EEECE4; background: transparent; width: 100%; text-align: left; text-decoration: none; color: inherit; }
.job-row:first-child { border-top: none; }
.job-row .main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.job-row .t { font-size: 16px; font-weight: 600; }
.job-row .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.box { width: 26px; height: 26px; border-radius: 7px; border: 2px solid #A9A79C; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.box.on { background: var(--green); border-color: var(--green); color: #fff; }
.num { width: 28px; height: 28px; border-radius: 999px; border: 2px solid var(--green); color: var(--green-dark); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.badge.preventivo { background: var(--gray-soft); color: #3E433F; }
.badge.accettato { background: var(--orange-soft); color: var(--orange-dark); }
.badge.programmato { background: var(--green); color: #fff; }
.badge.fatto { background: var(--ink); color: #fff; }
.badge.crit { background: var(--orange-soft); color: var(--orange-dark); }
.badge.priv { background: var(--orange-soft); color: var(--orange-dark); }
.badge.shared { background: var(--blue-soft); color: var(--blue-dark); }
.job-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: #fff; text-decoration: none; color: inherit; }
.job-card .t { font-size: 17px; font-weight: 700; }
.tabs { overflow-x: auto; padding: 4px 16px 8px; -webkit-overflow-scrolling: touch; }
.tabs-inner { display: flex; gap: 8px; width: max-content; }
.search { display: flex; align-items: center; gap: 10px; height: 50px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 14px; background: #fff; }
.search input { border: none; outline: none; flex: 1; font-size: 16px; background: transparent; min-width: 0; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 15px; }

/* Week strip */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.day { min-height: 66px; border-radius: 12px; border: 1px solid var(--line); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 4px 0; }
.day .d { font-size: 12px; font-weight: 600; color: var(--muted); }
.day .n { font-size: 20px; font-weight: 700; }
.day.on { background: var(--green); border-color: var(--green); color: #fff; }
.day.on .d { color: #fff; }
.day.past { opacity: 0.45; }
.dots { display: flex; gap: 3px; min-height: 7px; }
.dot { width: 7px; height: 7px; border-radius: 999px; display: inline-block; }
.dot.g { background: var(--green); }
.day.on .dot.g { background: #fff; }
.dot.b { background: var(--blue); }
.dot.x { background: var(--gray-dot); }
.dot.a, .stripe-sw { width: 12px; height: 7px; border-radius: 2px; border: 1px dashed var(--muted); background: repeating-linear-gradient(135deg, #F1EFE8 0 2px, #C9C7BD 2px 4px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.note-line { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin: 0; }

/* Calendar */
.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px; border-radius: 12px; background: #E6E4DB; flex: 1; }
.seg button { min-height: 40px; border-radius: 9px; border: none; background: transparent; color: var(--muted); font-size: 14px; font-weight: 500; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 700; }
.cal-day { display: flex; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; min-height: 54px; }
.cal-date { width: 46px; min-height: 50px; align-self: flex-start; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 0; border-radius: 10px; }
.cal-date .d { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-date .n { font-size: 20px; font-weight: 700; line-height: 1; }
.cal-date.today { background: var(--ink); color: #fff; }
.cal-date.today .d { color: #fff; }
.cal-items { display: flex; flex-direction: column; gap: 6px; flex: 1; justify-content: center; min-width: 0; }
.ev { display: flex; flex-direction: column; gap: 2px; border-radius: 10px; padding: 8px 10px; text-decoration: none; border: none; text-align: left; width: 100%; }
.ev .t { display: flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; }
.ev .s { font-size: 13px; }
.ev.mine { background: var(--green-soft); color: var(--green-dark); }
.ev.other { background: var(--blue-soft); color: var(--blue-dark); }
.ev.busy { background: var(--gray-soft); color: #3E433F; }
.ev.away { border: 1px dashed var(--muted); background: repeating-linear-gradient(135deg, #F7F6F1 0 8px, #ECEAE2 8px 16px); color: var(--ink); }
.month { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; display: flex; flex-direction: column; gap: 6px; }
.month-head, .month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.month-head span { font-size: 12px; font-weight: 700; color: var(--muted); }
.mcell { min-height: 54px; border-radius: 10px; border: none; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 6px; }
.mcell .n { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; border-radius: 999px; }
.mcell.today .n { background: var(--ink); color: #fff; font-weight: 700; }
.mcell.out { visibility: hidden; }

/* Detail */
.kv { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-top: 1px solid #EEECE4; }
.kv:first-child { border-top: none; padding-top: 0; }
.kv .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.kv .v { font-size: 16px; }
.list-plain { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; }
.actions { display: flex; flex-direction: column; gap: 10px; }

/* Sheet */
.overlay { position: fixed; inset: 0; background: rgba(27,31,28,0.5); z-index: 40; display: flex; flex-direction: column; justify-content: flex-end; }
.sheet { background: #fff; border-radius: 22px 22px 0 0; padding: 12px 20px calc(24px + var(--safe-b)); display: flex; flex-direction: column; gap: 16px; max-width: 560px; width: 100%; margin: 0 auto; max-height: 92vh; overflow-y: auto; }
.sheet .handle { align-self: center; width: 44px; height: 5px; border-radius: 999px; background: #D6D4CA; }

/* Auth */
.auth { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 32px 20px; gap: 20px; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.brand .logo { width: 72px; height: 72px; border-radius: 20px; background: var(--green); color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.brand h1 { font-family: 'Barlow Condensed', sans-serif; font-size: 34px; }
.error { background: #FBE3DF; color: #7A1F15; border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; margin: 0; }
.ok { background: var(--green-soft); color: var(--green-dark); border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 600; margin: 0; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 120px); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; max-width: 90vw; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 999px; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } #toast { transition: none; } }
