:root {
  --bg: #f4f6f3; --card: #ffffff; --ink: #1e2a26; --muted: #6b7a74; --line: #e1e7e3;
  --brand: #2f5d50; --brand-ink: #ffffff; --ok: #2e7d32; --warn: #b26a00; --err: #b3261e;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); padding-bottom: 76px; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: .6em 0 .4em; }
h2 { font-size: 1.1rem; margin: 1em 0 .5em; }
h3 { font-size: .95rem; margin: 1em 0 .4em; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
p { margin: .5em 0; }
.small { font-size: .85rem; }
.muted { color: var(--muted); }
.faded { opacity: .55; }
.grow { flex: 1; min-width: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre { white-space: pre-wrap; font: inherit; font-size: .85rem; background: var(--bg); padding: .6em; border-radius: 8px; }

.envbar { background: #b26a00; color: #fff; text-align: center; font-size: .8rem; font-weight: 600; padding: 4px 10px; letter-spacing: .03em; }

/* header */
.top { background: var(--brand); color: var(--brand-ink); padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; }
.brand img { border-radius: 8px; background: #fff; }
.nav { display: flex; gap: 2px 14px; flex-wrap: wrap; overflow-x: auto; }
.nav a { color: rgba(255,255,255,.85); padding: 4px 2px; white-space: nowrap; font-size: .92rem; border-bottom: 2px solid transparent; }
.nav a.on { color: #fff; border-bottom-color: #fff; }
.nav a.muted { color: rgba(255,255,255,.6); margin-left: auto; }
.client-nav { display: none; }

/* layout */
.wrap { max-width: 1100px; margin: 0 auto; padding: 8px 16px 24px; }
body.wide .wrap { max-width: 1400px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin: 12px 0; }
.card.narrow, .narrow { max-width: 560px; }
.cols { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; } .cols > .card { margin: 0; } }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.head h1 { margin: .4em 0; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px; }

/* flash */
.flash { padding: 10px 14px; border-radius: 10px; margin: 10px 0; background: #e6f1e8; color: #1f4d2a; border: 1px solid #c9e0cf; }
.flash.err { background: #fbe9e7; color: #7a1f16; border-color: #f1c7c2; }
.flash.warn { background: #fff4e0; color: #6b4000; border-color: #f3dcb0; }

/* forms */
.form label { display: block; margin: 10px 0 6px; font-size: .92rem; color: var(--muted); }
.form input:not([type=checkbox]), .form select, .form textarea, .inline-form input, .inline-form select {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid rgba(47,93,80,.35); border-color: var(--brand); }
.form label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.form label.check input { width: 18px; height: 18px; margin: 0; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form input, .inline-form select { width: auto; min-width: 8em; margin: 0; }
.inline-form label { margin: 0; }
form.inline { display: inline-flex; gap: 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; border-color: #bfcac4; background: #fafbfa; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #27503f; }
.btn.danger { color: var(--err); border-color: #efc9c5; }
.btn.danger:hover { background: #fdf1f0; }
.btn.warn { color: var(--warn); border-color: #efd9b0; }
.btn.ok { color: var(--ok); border-color: #bfe3c4; background: #eef8ef; }
.btn.tiny { padding: 4px 9px; font-size: .8rem; border-radius: 8px; }
.btn.small { font-size: .85rem; }
.btn.big { width: 100%; padding: 12px; font-size: 1rem; margin-top: 14px; }
.btn.disabled { opacity: .4; pointer-events: none; }

/* badges & lists */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; background: #eef1ee; color: #3d4a45; white-space: nowrap; border-left: 4px solid var(--c, transparent); }
.badge.ok { background: #e6f3e8; color: #1f5a2a; }
.badge.warn { background: #fff1d6; color: #6b4000; }
.badge.err { background: #fbe4e1; color: #7a1f16; }
.list { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.big { width: 14px; height: 14px; display: inline-block; vertical-align: middle; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl th { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; border-top: 0; }
.tbl.small { font-size: .85rem; }
@media (max-width: 640px) { .tbl { display: block; overflow-x: auto; white-space: nowrap; } }

/* tiles (crediti) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin: 10px 0; }
.tile { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; border-top: 5px solid var(--c, var(--brand)); }
.tile .num { font-size: 2.2rem; font-weight: 700; line-height: 1; text-align: left; color: var(--c, var(--brand)); }
.tile .lbl { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.tile.empty { grid-column: 1 / -1; border-top-color: var(--line); }
.pkg { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.pkg:first-of-type { border-top: 0; }
.credits { text-align: right; white-space: nowrap; }
.credits .big { font-size: 1.6rem; font-weight: 700; }
.pkg-box { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.pkg-box summary { cursor: pointer; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pkg-body { margin-top: 8px; }
details > summary { cursor: pointer; }

/* settimana */
.weeknav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.weeknav h1 { margin: .4em 4px; font-size: 1.2rem; }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 16px; margin: 10px 0; }
.day h2 { margin: .2em 0 .3em; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.day.today { border-left: 5px solid var(--brand); }

/* calendario a griglia (desktop) */
.grid-cal { display: none; }
.list-cal { display: block; }
@media (min-width: 900px) {
  .list-cal { display: none; }
  .grid-cal { display: grid; grid-template-columns: 56px repeat(7, 1fr); background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 10px 0; }
  .gc-head { padding: 8px 6px; font-size: .85rem; font-weight: 600; text-align: center; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
  .gc-head.today { background: #eaf3ee; color: var(--brand); }
  .gc-hours, .gc-day { position: relative; height: calc(var(--hours) * var(--px) + var(--px)); border-left: 1px solid var(--line); }
  .gc-hour { position: absolute; right: 6px; font-size: .72rem; color: var(--muted); transform: translateY(-50%); }
  .gc-slot { position: absolute; left: 0; right: 0; border-top: 1px dashed #e8ece9; display: block; }
  .gc-slot:hover { background: rgba(47,93,80,.06); }
  .gc-day.today { background: #f7faf8; }
  .gc-ev { position: absolute; left: 3px; right: 3px; border-radius: 7px; padding: 3px 6px; overflow: hidden; color: #fff; background: var(--c); font-size: .74rem; line-height: 1.25; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
  .gc-ev:hover { text-decoration: none; filter: brightness(1.08); z-index: 2; }
  .gc-ev .t { font-weight: 600; display: flex; justify-content: space-between; }
  .gc-ev .cap { opacity: .9; }
  .gc-ev .n { opacity: .95; }
  .gc-ev .p span { display: inline-block; background: rgba(255,255,255,.22); border-radius: 4px; padding: 0 4px; margin: 2px 2px 0 0; }
  .gc-ev.cancelled { background: #9aa39f; text-decoration: line-through; }
  .gc-ev.done { opacity: .6; }
}

/* tab bar clienti (telefono) */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.tabbar a { flex: 1; text-align: center; padding: 8px 0 6px; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.tabbar a .ic { font-size: 1.15rem; line-height: 1; }
.tabbar a.on { color: var(--brand); font-weight: 600; }
@media (min-width: 700px) { .tabbar { display: none; } .client-nav { display: flex; } body { padding-bottom: 0; } }
