:root {
  --bg: #fafaf7;
  --card: #ffffff;
  --ink: #222222;
  --muted: #717171;
  --line: #ebebe6;
  --teal: #008489;
  --teal-dark: #006a6e;
  --teal-soft: #e6f4f4;
  --accent: #c2185b;
  --accent-soft: #fdecf2;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --chat-bg: #efeae2;
  --bubble-me: #d9fdd3;
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: rgba(250,250,247,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; font-size: 24px; letter-spacing: -0.03em; text-decoration: none; }
.logo .p { color: #6e6e6e; }
.logo .u { color: var(--teal); }
.tag {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--teal); background: var(--teal-soft); padding: 4px 10px; border-radius: 999px;
}
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.who strong { color: var(--ink); }

/* Buttons */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 12px;
  padding: 11px 18px; font-weight: 600; cursor: pointer;
  background: var(--teal); color: #fff; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--teal-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: #f1f1ec; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: transparent; color: var(--accent); border-color: #f3c6d6; }
.btn.danger:hover { background: var(--accent-soft); }

/* Login */
.center { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 24px 16px; }
.login {
  width: 100%; max-width: 440px; background: var(--card); border-radius: 24px;
  padding: 36px 32px; box-shadow: var(--shadow);
}
.login h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 6px; }
.login p.lead { color: var(--muted); margin: 0 0 24px; }
.err { color: var(--accent); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* Form fields */
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field > span .req { color: var(--accent); font-weight: 700; margin-left: 2px; }
.input, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid #dcdcd6; border-radius: var(--radius-sm);
  background: #fff; padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 76px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,132,137,.15);
}
.field input::placeholder, .field textarea::placeholder { color: #a9a9a3; }

/* Steps */
.steps {
  display: flex; gap: 8px; padding: 16px 24px 0; max-width: 1240px; margin: 0 auto;
  overflow-x: auto;
}
.step {
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  padding: 10px 16px 10px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600; color: var(--muted);
}
.step .n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: #f1f1ec; color: var(--muted); font-size: 14px;
}
.step[aria-selected="true"] { color: var(--ink); border-color: var(--teal); box-shadow: 0 0 0 1px var(--teal) inset; }
.step[aria-selected="true"] .n { background: var(--teal); color: #fff; }

.page { max-width: 1240px; margin: 0 auto; padding: 20px 24px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h2 { margin: 0; font-size: 28px; letter-spacing: -0.02em; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

/* Hotel editor */
.editor { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.side { position: sticky; top: 90px; background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.progress { height: 10px; border-radius: 999px; background: #f1f1ec; overflow: hidden; margin: 8px 0 6px; }
.progress > i { display: block; height: 100%; background: var(--teal); border-radius: 999px; transition: width .3s; }
.pct { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.pct-label { color: var(--muted); font-size: 14px; }
.toc { list-style: none; padding: 0; margin: 16px 0; }
.toc a {
  display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 10px;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.toc a:hover { background: #f4f4ef; }
.toc .dot { width: 8px; height: 8px; border-radius: 50%; background: #d9d9d3; margin-top: 8px; flex: none; }
.toc .dot.full { background: var(--teal); }
.side .btn { width: 100%; margin-top: 8px; }
.saved { font-size: 13px; color: var(--muted); margin-top: 12px; min-height: 18px; }
.saved.ok { color: var(--ok); }
.saved.bad { color: var(--accent); }

.cards { display: grid; gap: 20px; }
.card { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); scroll-margin-top: 90px; }
.card h3 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.card .hint { color: var(--muted); margin: 2px 0 18px; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid2 .wide { grid-column: 1 / -1; }

/* Chat */
.chat-wrap { display: grid; grid-template-columns: minmax(0, 440px) 1fr; gap: 28px; align-items: start; }
.phone {
  background: #fff; border-radius: 32px; box-shadow: var(--shadow); overflow: hidden;
  border: 8px solid #1d1d1d; height: min(720px, calc(100vh - 240px)); min-height: 500px;
  display: flex; flex-direction: column;
}
.phone-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--teal); color: #fff; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.phone-head .t { font-weight: 700; line-height: 1.2; }
.phone-head .s { font-size: 13px; opacity: .85; }
.msgs {
  flex: 1; overflow-y: auto; padding: 16px 12px; background: var(--chat-bg);
  display: flex; flex-direction: column; gap: 8px;
}
.bubble {
  max-width: 82%; padding: 8px 12px 6px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word;
  font-size: 15px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.08); background: #fff; align-self: flex-start;
}
.bubble.me { align-self: flex-end; background: var(--bubble-me); }
.bubble .time { display: block; text-align: right; font-size: 11px; color: #8a8a85; margin-top: 2px; }
.pill-reception {
  align-self: flex-start; font-size: 12px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 4px 10px; margin: -2px 0 4px 4px;
}
.sysnote {
  align-self: center; font-size: 12.5px; color: #5d5d58; background: #fff8d6;
  border-radius: 8px; padding: 6px 10px; text-align: center; max-width: 90%;
}
.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #9a9a95; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { display: flex; gap: 8px; padding: 10px; background: #f0f0f0; }
.composer textarea {
  flex: 1; resize: none; border: none; border-radius: 22px; padding: 11px 16px; outline: none;
  max-height: 120px; min-height: 44px; line-height: 1.4; background: #fff;
}
.send {
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--teal); color: #fff;
  cursor: pointer; display: grid; place-items: center; flex: none;
}
.send:disabled { opacity: .5; }

.panel { background: var(--card); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.rev-wrap > .panel + .panel { margin-top: 0; }
.panel h3 { margin: 0 0 4px; font-size: 18px; }
.panel p.hint { color: var(--muted); margin: 0 0 14px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px;
  font-size: 14px; cursor: pointer; text-align: left;
}
.chip:hover { border-color: var(--teal); color: var(--teal-dark); }
.chip.tricky { border-style: dashed; }
.checklist { margin: 0; padding-left: 20px; color: #444; }
.checklist li { margin-bottom: 6px; }

/* Reviews */
.rev-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.answer {
  white-space: pre-wrap; background: #f7f7f3; border-radius: var(--radius-sm); padding: 16px 18px;
  min-height: 160px; font-size: 16px; line-height: 1.55; border: 1px solid var(--line);
}
.answer.empty { color: var(--muted); display: grid; place-items: center; text-align: center; }
.tweaks { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* Teacher */
.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.team { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.team .num { font-size: 13px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .06em; }
.team .tn { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.team .hn { color: var(--muted); font-size: 15px; min-height: 22px; }
.team .meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.team .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.team.empty .tn { color: #b0b0aa; }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 20px; font-size: 15px; }

dialog {
  border: none; border-radius: 24px; padding: 0; width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 48px); box-shadow: 0 24px 80px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20,20,20,.45); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 18px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.dlg-head h3 { margin: 0; font-size: 20px; flex: 1; }
.dlg-body { padding: 8px 24px 24px; }
.dlg-body h4 { margin: 18px 0 6px; font-size: 15px; color: var(--teal-dark); }
.kv { display: grid; grid-template-columns: 200px 1fr; gap: 4px 16px; font-size: 15px; }
.kv .k { color: var(--muted); }
.kv .v { white-space: pre-wrap; }
.kv .v.missing { color: var(--accent); font-style: italic; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 50; box-shadow: var(--shadow);
}

@media (max-width: 900px) {
  .editor, .chat-wrap, .rev-wrap { grid-template-columns: 1fr; }
  .side { position: static; }
  .grid2 { grid-template-columns: 1fr; }
  .phone { height: 600px; }
}
@media (max-width: 560px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .tag { display: none; }
  .steps, .page { padding-left: 16px; padding-right: 16px; }
  .card, .panel, .login { padding: 20px 18px; }
  .kv { grid-template-columns: 1fr; }
  .kv .k { margin-top: 6px; }
  .phone { border-width: 0; border-radius: 20px; }
}

/* ---------- v2: pubblicazione, prezzi dinamici, upselling ---------- */
.missing { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.45; }
.missing b { color: var(--accent); font-weight: 600; }
.pub-status { font-size: 13px; color: var(--muted); margin: 8px 0 4px; line-height: 1.4; }
.pub-status.ok { color: var(--ok); }
.pub-status.warn { color: var(--warn); background: var(--warn-soft); padding: 8px 10px; border-radius: 10px; }

.locked {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  text-align: center; padding: 32px 24px; background: var(--chat-bg); color: #444;
}
.locked p { margin: 0 0 8px; font-size: 14px; color: var(--muted); max-width: 260px; }
.lock-ico { width: 56px; height: 56px; border-radius: 50%; background: #fff; display: grid; place-items: center; color: var(--teal); box-shadow: var(--shadow); margin-bottom: 6px; }

h4.sub { margin: 22px 0 10px; font-size: 15px; color: var(--teal-dark); }
.card h4.sub:first-of-type { margin-top: 4px; }
.mini { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }

.thead, .trow { display: grid; gap: 8px; align-items: center; }
.thead { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.trow { margin-bottom: 8px; }
.rooms { grid-template-columns: 1.1fr 1.8fr 90px 130px 36px; }
.events { grid-template-columns: 1.6fr 150px 150px 100px 36px; }
.upsell { grid-template-columns: 1.3fr 0.8fr 2fr 36px; }
.trow input, .nin, .pctin input, .euro input {
  width: 100%; border: 1px solid #dcdcd6; border-radius: 10px; background: #fff; padding: 9px 11px; outline: none;
}
.trow input:focus, .nin:focus, .pctin input:focus, .euro input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0,132,137,.15); }
.x { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; }
.x:hover:not(:disabled) { color: var(--accent); border-color: #f3c6d6; }
.x:disabled { opacity: .35; cursor: default; }
.add { margin-top: 2px; }
.euro { position: relative; }
.euro::after { content: "€"; position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.euro input { padding-right: 26px; }
.pctin { position: relative; width: 100px; flex: none; }
.pctin span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.pctin input { padding-right: 26px; text-align: right; }
.nin { width: 64px; display: inline-block; padding: 4px 8px; margin: 0 2px; text-align: center; }

.rules { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.rule { display: flex; align-items: center; gap: 16px; padding: 12px 14px; }
.rule + .rule { border-top: 1px solid var(--line); }
.rl { flex: 1; min-width: 0; }
.rl b { display: block; font-size: 15px; }
.rl small { color: var(--muted); font-size: 13px; }
.minmax { display: flex; gap: 8px; width: 220px; flex: none; }
.months { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.mchip { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 8px; font-size: 12.5px; cursor: pointer; color: var(--muted); }
.mchip.on { background: var(--teal); border-color: var(--teal); color: #fff; }

.preview { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.preview-head { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 12px; }
.preview-head select { border: 1px solid #dcdcd6; border-radius: 10px; padding: 7px 10px; background: #fff; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cw { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cd {
  border-radius: 8px; padding: 6px 6px 5px; min-height: 52px; display: flex; flex-direction: column; justify-content: space-between;
  background: rgba(0,132,137,var(--lv, .1)); color: #10393a; cursor: default;
}
.cd span { font-size: 11px; opacity: .8; }
.cd b { font-size: 14px; font-weight: 700; text-align: right; }
.cd[style*="--lv:0.5"], .cd[style*="--lv:0.6"], .cd[style*="--lv:0.7"], .cd[style*="--lv:0.8"] { color: #fff; }
.cd.past { background: #f4f4ef; color: #b5b5ae; }

.chip-group + .chip-group { margin-top: 14px; }
.cg-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.chip:disabled { opacity: .45; cursor: default; }
.pill { align-self: flex-start; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; margin: -2px 0 4px 4px; }
.pill-price { color: var(--teal-dark); background: var(--teal-soft); }

.kv .v.list { white-space: normal; }

@media (max-width: 900px) {
  .rooms { grid-template-columns: 1fr 80px 110px 36px; }
  .rooms input[data-f="descrizione"] { grid-column: 1 / -1; grid-row: 2; }
  .thead.rooms span:nth-child(2) { display: none; }
  .events { grid-template-columns: 1fr 1fr 90px 36px; }
  .events input[data-f="nome"] { grid-column: 1 / -1; }
  .thead.events { display: none; }
  .upsell { grid-template-columns: 1fr 110px 36px; }
  .upsell input[data-f="quando"] { grid-column: 1 / -1; grid-row: 2; }
  .thead.upsell span:nth-child(3) { display: none; }
  .trow { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
}
@media (max-width: 560px) {
  .rule { flex-direction: column; align-items: stretch; gap: 8px; }
  .pctin, .minmax { width: 100%; }
  .cd { min-height: 44px; padding: 4px; }
  .cd b { font-size: 11.5px; }
}
.team .st { font-weight: 600; }
.team .st.ok { color: var(--ok); }
.team .st.warn { color: var(--warn); }

/* niente scroll orizzontale su telefono */
.editor > *, .cards, .card, .trow > *, .thead > *, .rule > *, .chat-wrap > *, .rev-wrap > * { min-width: 0; }
.cal { grid-template-columns: repeat(7, minmax(0, 1fr)); }
.trow input { min-width: 0; }
@media (max-width: 900px) {
  .rooms { grid-template-columns: minmax(0, 1fr) 70px 100px 36px; }
  .events { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 90px 36px; }
  .upsell { grid-template-columns: minmax(0, 1fr) 100px 36px; }
}
@media (max-width: 560px) {
  .cd span { font-size: 10px; }
  .cal { gap: 3px; }
}

/* ---------- diretta docente ---------- */
.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.lcol { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; height: calc(100vh - 290px); min-height: 460px; overflow: hidden; min-width: 0; }
.lhead { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.lhead .lt { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lhead .num { font-size: 13px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: .06em; }
.lhead .st { font-size: 12px; font-weight: 600; color: var(--muted); }
.lhead .st.ok { color: var(--ok); } .lhead .st.warn { color: var(--warn); }
.lhead .ln { font-weight: 700; font-size: 16px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lstats { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.lbody { flex: 1; overflow-y: auto; background: var(--chat-bg); padding: 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.lempty { margin: auto; color: var(--muted); font-size: 14px; }
.lsep { align-self: center; font-size: 11.5px; color: #5d5d58; background: #fff8d6; border-radius: 8px; padding: 3px 9px; margin: 6px 0; }
.lmsg { max-width: 88%; background: #fff; border-radius: 10px; padding: 7px 10px 5px; box-shadow: 0 1px 1px rgba(0,0,0,.07); align-self: flex-start; font-size: 14px; line-height: 1.42; }
.lmsg.me { align-self: flex-end; background: var(--bubble-me); }
.lmsg .lt { white-space: pre-wrap; word-wrap: break-word; }
.lmsg .ltime { font-size: 10.5px; color: #8a8a85; text-align: right; margin-top: 2px; }
.lmsg.price .ltime { color: var(--teal-dark); font-weight: 600; }
.lmsg.rec .ltime { color: var(--accent); font-weight: 600; }
.lrev { background: #fff; border-radius: 10px; padding: 9px 11px; font-size: 13.5px; border-left: 3px solid var(--teal); }
.lrh { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.lrq { color: #666; font-style: italic; margin-bottom: 6px; white-space: pre-wrap; }
.lra { white-space: pre-wrap; }
