/* =====================================================================
   Gestionale Appartamenti — foglio di stile
   Palette professionale, layout pulito, componenti coerenti.
   ===================================================================== */

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --border:    #e6e9f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --primary:   #4f46e5;
  --primary-d: #4338ca;
  --primary-l: #eef2ff;
  --success:   #16a34a;
  --success-l: #ecfdf3;
  --warning:   #d97706;
  --warning-l: #fff7ed;
  --danger:    #dc2626;
  --danger-l:  #fef2f2;
  --sidebar-1: #1e293b;
  --sidebar-2: #0f172a;
  --radius:    14px;
  --shadow:    0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ---------- Layout con sidebar ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 6px 8px 22px;
  color: #fff;
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700; color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.5);
}
.brand .brand-logo { width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(13,148,170,.35); }
.brand .brand-name { font-weight: 800; font-size: 18px; letter-spacing: 3px;
  background: linear-gradient(135deg, #f3e7bf, #e3c87f 55%, #b9923f);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand .brand-sub { font-size: 11px; color: #94a3b8; letter-spacing: .3px; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px;
  flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
.nav::-webkit-scrollbar { width: 7px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 4px; }

/* ---------- Sezioni a tendina (apri/chiudi) ---------- */
.sezione { background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 20px; margin-bottom: 16px; }
.sezione > summary { cursor: pointer; font-size: 17px; font-weight: 700; padding: 2px 0;
  display: flex; align-items: center; gap: 8px; user-select: none; }
.sezione > summary:hover { color: var(--primary); }
.sezione > summary::-webkit-details-marker { color: var(--muted); }
.sezione-body { margin-top: 12px; }
.nav-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: #64748b; margin: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px;
  color: #cbd5e1; font-weight: 500; font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item .ic { width: 20px; text-align: center; opacity: .9; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.45); }
.nav-item.soon { opacity: .5; cursor: default; }
.nav-item.soon:hover { background: transparent; color: #cbd5e1; }
.badge-soon {
  margin-left: auto; font-size: 10px; background: rgba(255,255,255,.12);
  padding: 2px 7px; border-radius: 999px; color: #cbd5e1;
}
.sidebar-foot { margin-top: auto; font-size: 12px; color: #64748b; padding: 12px 10px 0; }

/* ---------- Area principale ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topbar .sub { font-size: 13px; color: var(--muted); }
.user-chip { display: flex; align-items: center; gap: 12px; }
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary-l); color: var(--primary);
  display: grid; place-items: center; font-weight: 700;
}
.user-chip .who { text-align: right; line-height: 1.2; }
.user-chip .who .name { font-weight: 600; font-size: 14px; }
.user-chip .who .role { font-size: 12px; color: var(--muted); }
.btn-logout {
  margin-left: 8px; padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--border); color: var(--muted); font-size: 13px;
  background: var(--surface); transition: all .15s;
}
.btn-logout:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-l); }

.content { padding: 28px; }

/* ---------- Card statistiche ---------- */
.stat-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-bottom: 24px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat .value { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .icon {
  float: right; width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center; font-size: 20px;
}
.i-indigo { background: var(--primary-l); color: var(--primary); }
.i-green  { background: var(--success-l); color: var(--success); }
.i-amber  { background: var(--warning-l); color: var(--warning); }

.stat.highlight {
  background: linear-gradient(135deg, #4f46e5, #6366f1); color: #fff; border: none;
}
.stat.highlight .label, .stat.highlight .hint { color: rgba(255,255,255,.85); }

/* ---------- Pannello + tabella ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-head h2 { font-size: 16px; margin: 0; font-weight: 650; }
.panel-head .sub { font-size: 13px; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; padding: 12px 22px; background: #fafbfd;
}
tbody td { padding: 14px 22px; border-top: 1px solid var(--border); font-size: 14px; }
tbody tr:hover { background: #fafbff; }
.addr { color: var(--muted); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
}
.pill-green { background: var(--success-l); color: var(--success); }
.pill-amber { background: var(--warning-l); color: var(--warning); }
.pill-gray  { background: #f1f5f9; color: var(--muted); }
.pill-indigo{ background: var(--primary-l); color: var(--primary); }

.occ-bar { height: 7px; border-radius: 999px; background: #eef1f6; overflow: hidden; width: 90px; }
.occ-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #312e81 0%, #0f172a 55%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(2,6,23,.45);
  padding: 36px 32px;
}
.login-card .logo-lg {
  width: 54px; height: 54px; border-radius: 14px; margin: 0 auto 16px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: grid; place-items: center; color: #fff; font-size: 26px; font-weight: 700;
  box-shadow: 0 8px 20px rgba(79,70,229,.5);
}
.login-card .logo-lg-img { width: 76px; height: 76px; border-radius: 18px; margin: 0 auto 16px;
  display: block; box-shadow: 0 12px 30px rgba(13,148,170,.45); }
.login-card h1 { text-align: center; font-size: 20px; margin: 0 0 4px; }
.brand-title { text-align: center; font-size: 32px; font-weight: 800; letter-spacing: 7px; margin: 0 0 4px;
  background: linear-gradient(135deg, #f3e7bf, #e3c87f 55%, #b9923f);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card .muted { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 24px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 14px; font-family: inherit; transition: border .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }

.btn-primary {
  width: 100%; padding: 12px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.btn-primary:hover { background: var(--primary-d); }

.alert {
  background: var(--danger-l); color: var(--danger); border: 1px solid #fecaca;
  padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 18px;
}

.empty { padding: 40px 22px; text-align: center; color: var(--muted); }

/* ---------- Pagina Occupazione ---------- */
.occ-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.year-switch { display: inline-flex; background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; padding: 4px; box-shadow: var(--shadow); }
.year-btn { padding: 7px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.year-btn.active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(79,70,229,.4); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.sw-green { background: #16a34a; }
.sw-amber { background: #f59e0b; }
.sw-red   { background: #dc2626; }
.sw-empty { background: #eef1f6; border: 1px solid var(--border); }

.panel-occ { overflow: visible; margin-bottom: 22px; }
.occ-wrap { padding: 8px 22px 18px; }

.occ-row { display: grid; grid-template-columns: 130px 1fr; align-items: center; border-top: 1px solid var(--border); }
.occ-row.occ-head { border-top: none; }
.occ-rowlabel { font-size: 13px; font-weight: 600; padding: 0 12px; color: var(--text); }

.occ-track { position: relative; display: grid; grid-template-columns: repeat(12, 1fr); height: 44px; align-items: center; }
.occ-head .occ-track { height: 30px; }
.occ-monthname { grid-row: 1; text-align: center; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.occ-month { grid-row: 1; height: 100%; border-right: 1px dashed #eef1f6; }
.occ-month:nth-of-type(12) { border-right: none; }

.occ-bar2 {
  grid-row: 1; height: 30px; margin: 0 3px; border-radius: 8px; z-index: 2;
  display: flex; align-items: center; justify-content: center; cursor: default;
  color: #fff; font-size: 11px; font-weight: 600; position: relative;
  box-shadow: 0 2px 6px rgba(15,23,42,.18);
}
.occ-bar2.ok     { background: linear-gradient(135deg, #16a34a, #15803d); }
.occ-bar2.prob   { background: repeating-linear-gradient(45deg, #f59e0b, #f59e0b 8px, #fbbf24 8px, #fbbf24 16px); }
.occ-bar2.moroso { background: linear-gradient(135deg, #dc2626, #b91c1c); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }

/* Tooltip al passaggio del mouse */
.tip {
  display: none; position: absolute; bottom: 124%; left: 50%; transform: translateX(-50%);
  width: 240px; background: #0f172a; color: #e2e8f0; border-radius: 12px;
  padding: 12px 14px; box-shadow: 0 12px 30px rgba(2,6,23,.5); z-index: 60; text-align: left;
}
.tip::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 7px solid transparent; border-top-color: #0f172a; }
.occ-bar2:hover .tip { display: block; }
.tip-name { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.tip-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; margin: 4px 0; }
.tip-row span { color: #94a3b8; }
.tip-row b { color: #fff; font-weight: 600; text-align: right; }
.t-green { color: #4ade80 !important; }
.t-red { color: #f87171 !important; }
.tip-note { margin-top: 8px; font-size: 11px; color: #fbbf24; border-top: 1px solid #1e293b; padding-top: 7px; }

/* ---------- Bottoni, form, dettagli (Fase 1) ---------- */
.page-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.page-actions h2 { margin: 0; font-size: 17px; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit; text-decoration: none; transition: all .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary2 { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary2:hover { background: var(--primary-d); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
form.inline { display: inline; }

.card2 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 18px; }
.card2 h3 { margin: 0 0 16px; font-size: 15px; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-field input, .form-field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; font-family: inherit; background: #fff; }
.form-field input:focus, .form-field select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }
.hint-row { font-size: 12px; color: var(--muted); margin-top: 6px; }

.pill-red { background: var(--danger-l); color: var(--danger); }

.filtri { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filtri select { padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-family: inherit; font-size: 14px; background: #fff; color: var(--text); }
.filtri select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }

.dl { display: grid; grid-template-columns: 220px 1fr; }
.dl dt { color: var(--muted); font-size: 13px; padding: 11px 0; border-top: 1px solid var(--border); }
.dl dd { margin: 0; padding: 11px 0; border-top: 1px solid var(--border); font-weight: 600; font-size: 14px; }

.workflow { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.flowstep { font-size: 12px; padding: 5px 11px; border-radius: 999px; background: #f1f5f9; color: var(--muted); font-weight: 600; }
.flowstep.done { background: var(--success-l); color: var(--success); }
.flowstep.curr { background: var(--primary); color: #fff; }
.flow-arrow { color: var(--border); }

.note-box { background: var(--warning-l); border: 1px solid #fed7aa; color: #9a3412;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-top: 16px; }
.copybox { background: #fafbfd; border: 1px solid var(--border); border-radius: 8px; padding: 3px 8px; font-family: ui-monospace, monospace; font-size: 13px; }

/* ---------- CRM: board pipeline + chat ---------- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: flex-start; }
.board-col { flex: 1 1 0; min-width: 200px; background: #f1f4f9; border: 1px solid var(--border);
  border-radius: 12px; padding: 10px; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.board-count { font-size: 12px; color: var(--muted); font-weight: 700; }
.lead-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow); transition: transform .1s, border-color .15s; }
.lead-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.lead-name { font-weight: 650; font-size: 14px; }
.lead-meta { font-size: 12px; color: var(--muted); margin: 2px 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-tags { display: flex; gap: 6px; }
.tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  background: var(--primary-l); color: var(--primary); padding: 2px 7px; border-radius: 999px; }
.board-empty { color: #b6bfcc; text-align: center; font-size: 13px; padding: 10px 0; }

.risposta-box { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  font-family: inherit; font-size: 13px; line-height: 1.5; background: #fafbfd; resize: vertical; }
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 80%; padding: 9px 12px; border-radius: 12px; font-size: 13px; }
.msg-meta { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg-body { white-space: pre-wrap; }
.msg-in { align-self: flex-start; background: #f1f5f9; border: 1px solid var(--border); }
.msg-out { align-self: flex-end; background: var(--primary-l); border: 1px solid #dfe4ff; }

/* ---------- Occupazione v2: calendario unico ---------- */
.sw-blue { background: #2563eb; }
.sw-gray { background: #64748b; }
.sw-stripe { background: repeating-linear-gradient(45deg, #16a34a, #16a34a 4px, #dc2626 4px, #dc2626 8px); }

.occ2 { --labelw: 200px; }
.occ2-head { display: grid; grid-template-columns: var(--labelw) 1fr; position: sticky; top: 0; z-index: 20;
  background: #fff; border-bottom: 2px solid var(--border); box-shadow: 0 2px 4px rgba(15,23,42,.04); }
.occ2-corner { font-size: 12px; font-weight: 700; color: var(--muted); padding: 11px 14px; align-self: center; }
.occ2-track { display: grid; grid-template-columns: repeat(12, 1fr); position: relative; }
.occ2-month { grid-row: 1; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--muted); padding: 10px 0; }

.occ2-app { display: flex; align-items: center; gap: 10px; background: #eef2f8;
  border-top: 3px solid #94a3b8; padding: 9px 14px; font-weight: 700; font-size: 14px; }
.occ2-app-name { margin-right: auto; }

.occ2-row { display: grid; grid-template-columns: var(--labelw) 1fr; align-items: center; border-top: 1px solid var(--border); }
.occ2-label { font-size: 13px; font-weight: 600; padding: 0 14px; color: var(--text); }
.occ2-row .occ2-track { height: 42px; align-items: center; }
.occ2-cell { grid-row: 1; height: 100%; border-right: 1px dashed #eef1f6; }
.occ2-cell:nth-of-type(12) { border-right: none; }

.seg { grid-row: 1; height: 28px; margin: 0 3px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 11px; font-weight: 600; position: relative; cursor: default;
  z-index: 2; box-shadow: 0 1px 4px rgba(15,23,42,.22); }
.seg.attivo { background: linear-gradient(135deg, #16a34a, #15803d); }
.seg.futuro { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.seg.concluso { background: linear-gradient(135deg, #94a3b8, #64748b); }
.seg.attivo.moroso   { background: repeating-linear-gradient(45deg, #16a34a, #16a34a 7px, #dc2626 7px, #dc2626 14px); }
.seg.futuro.moroso   { background: repeating-linear-gradient(45deg, #2563eb, #2563eb 7px, #dc2626 7px, #dc2626 14px); }
.seg.concluso.moroso { background: repeating-linear-gradient(45deg, #64748b, #64748b 7px, #dc2626 7px, #dc2626 14px); }
.seg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 7px; }

.tip-mora { margin-top: 8px; border-top: 1px solid #1e293b; padding-top: 7px; }
.tip-mora-head { font-size: 11px; font-weight: 700; color: #fbbf24; margin-bottom: 5px; }
.tip-mora-tot { border-top: 1px dashed #334155; margin-top: 5px; padding-top: 5px; }

/* ---------- Finestra modale (dettaglio inquilino su Occupazione) ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(2,6,23,.55);
  z-index: 200; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal-box { background: var(--surface); border-radius: 16px; width: 100%; max-width: 760px;
  box-shadow: 0 24px 70px rgba(2,6,23,.5); padding: 22px 24px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 14px; }
.modal-title { font-size: 19px; font-weight: 700; }
.modal-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.modal-close { border: none; background: #f1f5f9; width: 34px; height: 34px; border-radius: 9px;
  cursor: pointer; font-size: 15px; color: var(--muted); }
.modal-close:hover { background: var(--danger-l); color: var(--danger); }
.modal-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.mtab { border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  padding: 8px 14px; border-radius: 9px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }
.mtab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.doc-upload { display: flex; flex-direction: column; gap: 14px; }
.doc-upload label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.lbl-note { font-weight: 400; color: var(--muted); font-size: 12px; }

/* --- schermata revisione dati estratti (OCR) --- */
.ok-box { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin: 6px 0 14px; line-height: 1.5; }
.discr-box { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 16px; }
.discr-box ul { margin: 8px 0 6px; padding-left: 18px; }
.discr-box li { margin: 3px 0; }
.discr-note { font-size: 12px; color: #b45309; }
.estr-h { margin: 16px 0 8px; font-size: 14px; }
.estr-info { font-size: 12px; color: var(--muted); margin-top: 10px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; }
.field-warn input { border-color: #f59e0b !important; background: #fffbeb; }
.field-old { display: block; font-size: 11px; color: #b45309; margin-top: 3px; }

/* =========================================================
   MOBILE (solo schermi piccoli; il desktop resta invariato)
   ========================================================= */
@media (max-width: 860px) {
  /* la sidebar non sparisce più: diventa una barra in alto, scorrevole */
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: column; padding: 10px 12px;
  }
  .brand { padding: 6px 6px 8px; }
  .brand .brand-sub { display: none; }
  .nav {
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    gap: 8px; margin-top: 2px; padding: 2px 0 6px;
    -webkit-overflow-scrolling: touch;
  }
  .nav-label { display: none; }
  .nav-item { flex: 0 0 auto; white-space: nowrap; padding: 9px 13px; font-size: 13px; }
  .sidebar-foot { display: none; }

  /* topbar: non più sticky, va a capo se serve */
  .topbar { position: static; height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .topbar h1 { font-size: 17px; }
  .topbar .sub { font-size: 12px; }
  /* logo GESTA dell'area proprietario: riga propria, centrato e PROPORZIONATO */
  .topbar > img {
    position: static !important; transform: none !important;
    height: 26px !important; width: 100% !important; object-fit: contain;
    flex-basis: 100%; order: 3; margin: 4px 0 0 !important;
  }
  .user-chip { gap: 8px; }

  .content { padding: 16px; }
  .card2 { padding: 16px; }

  /* form e descrizioni a colonna singola */
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { border-top: 1px solid var(--border); padding-bottom: 0; }
  .dl dd { border-top: none; padding-top: 2px; }

  /* contenitori e tabelle scorrevoli in orizzontale, non compressi */
  .panel, .card2, .sezione-body, .modal-box, .mtab-body { overflow-x: auto; }
  table { min-width: 520px; }
  thead th, tbody td { padding: 10px 12px; }

  /* calendario occupazione scorrevole */
  .panel-occ { overflow-x: auto; }
  .occ2 { min-width: 680px; }

  /* finestre/modali a tutta larghezza */
  .modal-overlay { padding: 16px 10px !important; }
  .modal-box { max-width: 100%; padding: 16px; }
}

/* ---- Dotazioni stanza: griglia ordinata di caselle ---- */
.dotazioni-grid{
  display:grid;
  grid-template-columns:repeat(3,max-content);
  justify-content:start;
  gap:2px 44px;
  margin-top:8px;
}
.dotazione-item{
  display:flex;
  align-items:center;
  gap:7px;
  font-weight:400;
  padding:6px 6px;
  border-radius:8px;
  cursor:pointer;
  transition:background .12s;
}
.dotazione-item:hover{ background:var(--surface-2, #f3f4f6); }
.dotazione-item input[type=checkbox]{
  flex:0 0 auto;
  width:16px; height:16px;
  margin:0;
}
.dotazione-item span{ line-height:1.25; }
@media (max-width:860px){
  .dotazioni-grid{ grid-template-columns:repeat(2,minmax(0,1fr)); }
}
@media (max-width:520px){
  .dotazioni-grid{ grid-template-columns:1fr; }
}
