/* Osservolav - foglio di stile */

@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/plex-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/plex-500.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/plex-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/plex-700.woff2") format("woff2"); }

:root {
  --blue-900: #0a2f5c;
  --blue-800: #0b3c73;
  --blue-700: #0b4a8f;
  --blue-600: #1f5fa8;
  --blue-100: #dde8f5;
  --blue-50:  #eef4fb;
  --green:    #2e8b57;
  --red:      #b3261e;
  --red-50:   #fbeeed;
  --ok-50:    #eaf5ee;
  --ink:      #1a2330;
  --ink-2:    #4a5566;
  --muted:    #6b7685;
  --line:     #d9e0ea;
  --line-2:   #e9eef4;
  --bg:       #f3f5f8;
  --surface:  #ffffff;
  --radius:   8px;
  --shadow:   0 1px 2px rgba(10, 47, 92, .06), 0 2px 8px rgba(10, 47, 92, .05);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--blue-700); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; background: var(--blue-50); padding: 1px 5px; border-radius: 4px; }
h1 { font-size: 24px; line-height: 1.25; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.h2 { font-size: 17px; font-weight: 600; margin: 28px 0 12px; }
.panel .h2 { margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blue-600); outline-offset: 2px; }

/* ---------- Marchio ---------- */
.wm { display: inline-flex; align-items: baseline; gap: 0; font-weight: 700; font-size: 20px; letter-spacing: -.02em; line-height: 1; white-space: nowrap; }
.wm-a { color: var(--ink); }
.wm-b { color: var(--blue-700); }
.wm-big { font-size: 34px; }
.icon-micro { width: 100%; height: 100%; color: var(--blue-700); }

/* ---------- Pulsanti ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { border-color: #b9c6d6; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--blue-700); border-color: var(--blue-700); color: #fff; }
.btn-primary:hover { background: var(--blue-800); border-color: var(--blue-800); }
.btn-primary:disabled { background: #7f9cc1; border-color: #7f9cc1; cursor: default; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue-700); }
.btn-ghost:hover { background: var(--blue-50); border-color: transparent; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: #e4b4b0; background: var(--red-50); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-block { display: flex; width: 100%; }
form.inline { display: inline; }

/* ---------- Messaggi ---------- */
.flash { padding: 12px 14px; border-radius: 6px; margin: 0 0 16px; border: 1px solid; font-size: 14px; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash-ok { background: var(--ok-50); border-color: #bfdcc9; color: #1d5c39; }
.flash-err { background: var(--red-50); border-color: #ecc4c0; color: #8a1d17; }
.empty { padding: 28px; text-align: center; color: var(--ink-2); background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty p { margin: 4px 0; }

/* =================== DESKTOP =================== */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; align-items: center; gap: 28px; min-height: 60px; }
.brand { display: inline-flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.mainnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: 8px 12px; border-radius: 6px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.mainnav a:hover { background: var(--blue-50); color: var(--blue-800); }
.mainnav a[aria-current="page"] { background: var(--blue-50); color: var(--blue-800); box-shadow: inset 0 -2px 0 var(--blue-700); border-radius: 6px 6px 0 0; }
.usermenu { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.usermenu a { color: var(--ink-2); text-decoration: none; }
.usermenu a:hover { color: var(--blue-700); text-decoration: underline; }
.who { display: flex; flex-direction: column; line-height: 1.2; text-align: right; font-weight: 500; color: var(--ink); }
.who small { color: var(--muted); font-weight: 400; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 28px 24px 48px; }
.foot { max-width: 1280px; margin: 0 auto; padding: 0 24px 24px; font-size: 12px; color: var(--muted); }
.pagehead { margin-bottom: 20px; }
.pagehead.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.lead { margin: 4px 0 0; color: var(--ink-2); }
.crumb { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.crumb a { color: var(--muted); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel.narrow { max-width: 520px; }
.panel.narrow h1 { margin-bottom: 16px; font-size: 20px; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpis-sm { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 18px 0; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; }
.kpis-sm .kpi { background: var(--blue-50); border-color: var(--blue-100); }
.kpi-n { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--blue-900); line-height: 1.15; }
.kpi-l { font-size: 13px; color: var(--ink-2); }

/* Menu principale */
.menu-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.menu-card { display: flex; flex-direction: column; gap: 6px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--blue-700);
  border-radius: var(--radius); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s; }
.menu-card:hover { border-color: var(--blue-600); transform: translateY(-1px); }
.menu-t { font-weight: 600; font-size: 16px; color: var(--blue-800); }
.menu-d { font-size: 14px; color: var(--ink-2); }

/* Tabelle */
.table-wrap { overflow-x: auto; scrollbar-gutter: stable; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel .table-wrap { box-shadow: none; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
.grid th, .grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; white-space: nowrap; }
.grid thead th { background: #f6f8fb; font-weight: 600; color: var(--ink-2); font-size: 13px; border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child td, .grid tbody tr:last-child th { border-bottom: 0; }
.grid tbody tr:hover td { background: #fafbfd; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .act { text-align: right; }
.grid .act .btn + form, .grid .act .btn + .btn { margin-left: 6px; }
.grid.compact th, .grid.compact td { padding: 6px 10px; font-size: 13px; }
.muted-table td { color: var(--muted); }

.weekly th.rowh { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 190px; font-weight: 500; }
.weekly thead th.rowh { background: #f6f8fb; }
.weekly thead th small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }
.weekly tr.strong td, .weekly tr.strong th { font-weight: 600; }
.weekly tr.minor td, .weekly tr.minor th { color: var(--muted); font-size: 13px; }
.weekly .tot { background: var(--blue-50); font-weight: 600; }
.weekly thead .tot { background: var(--blue-100); color: var(--blue-900); }
.weekly sup { color: var(--blue-700); font-weight: 600; }
.note { font-size: 13px; color: var(--ink-2); margin: 10px 2px 0; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--line-2); color: var(--ink-2); }
.tag-gestore { background: var(--blue-100); color: var(--blue-900); }

/* Moduli */
.form { display: grid; gap: 16px; }
.form-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; max-width: 880px; }
.form-3 { grid-template-columns: 2fr 1fr auto; align-items: end; max-width: 880px; }
.span2 { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 14px; }
.form label small, .form small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type="text"], input[type="password"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: #fff; border: 1px solid #c9d3df; border-radius: 6px; padding: 9px 11px; width: 100%; min-height: 40px; }
textarea { line-height: 1.5; resize: vertical; font-size: 14px; }
input, select, textarea { font-weight: 400; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(31, 95, 168, .15); }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; font-family: ui-monospace, Menlo, Consolas, monospace; }
.actions { display: flex; gap: 10px; align-items: center; }
.actions.end { justify-content: flex-start; }
fieldset { border: 0; padding: 0; margin: 0 0 8px; }
legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 4px; }
fieldset textarea { margin-top: 6px; }
.form label.radio, label.radio { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
input[type="radio"], input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--blue-700); margin: 0; }

/* Filtri visualizzazione */
.filters { display: grid; grid-template-columns: auto minmax(220px, 1fr) auto; gap: 18px 28px; align-items: end; }
.filters > * { min-width: 0; }
.dates input { min-width: 0; }
.filters legend, .filters .sel-wrap, .filters .f-comp { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.filters .sel-wrap, .filters .f-comp { display: flex; flex-direction: column; gap: 6px; }
.f-vista { grid-column: 1 / 3; }
.f-sel { grid-column: 1 / 3; }
.f-periodo { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; grid-column: 1 / 3; }
.f-periodo legend { width: 100%; margin-bottom: 2px; }
.f-periodo .radio { margin: 0; }
.dates { display: inline-flex; gap: 8px; }
.dates input { width: 160px; }
.dates.dim input { opacity: .55; }
.f-comp { grid-column: 3; grid-row: 1; min-width: 260px; }
.f-modo { grid-column: 3; grid-row: 2; }
.f-go { grid-column: 3; grid-row: 3; display: flex; justify-content: flex-end; }
.f-go .btn { min-width: 160px; }
.seg { display: inline-flex; border: 1px solid #c9d3df; border-radius: 7px; overflow: hidden; background: #fff; }
.seg label { margin: 0; cursor: pointer; display: flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px 14px; font-size: 14px; font-weight: 500; color: var(--ink-2); border-left: 1px solid #c9d3df; }
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--blue-700); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--blue-600); outline-offset: -3px; }

.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.intest { display: grid; grid-template-columns: auto 1fr; gap: 3px 16px; margin: 0; font-size: 14px; }
.intest dt { color: var(--muted); }
.intest dd { margin: 0; font-weight: 600; }
.result-tools { display: flex; gap: 8px; }
.chart-box { position: relative; height: 320px; margin: 4px 0 18px; }
.chart-hint { margin: -10px 0 16px; text-align: center; }

/* =================== TELEFONINO =================== */
body.mob { background: #fff; }
.phone { max-width: 440px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 20px 22px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
.m-head { position: relative; display: flex; justify-content: center; padding: 18px 0 8px; }
.m-back { position: absolute; left: -6px; top: 50%; transform: translateY(-40%); font-size: 34px; line-height: 1; text-decoration: none; color: var(--blue-700); padding: 4px 10px; }
.m-icon { width: 120px; height: 120px; margin: 28px auto 24px; }
.m-icon.small { width: 72px; height: 72px; margin: 14px auto 10px; }
.m-form { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.m-form input { min-height: 50px; font-size: 17px; padding: 12px 14px; }
.m-form .btn { min-height: 52px; font-size: 18px; font-weight: 600; margin-top: 6px; }
.m-note { text-align: center; color: var(--muted); font-size: 12px; margin-top: auto; padding-top: 28px; }
.m-body { flex: 1; display: flex; flex-direction: column; }
.m-body h1.m-title { font-size: 22px; margin: 20px 0 16px; text-align: center; }
.m-body .form .btn { min-height: 50px; font-size: 17px; }
.step { display: flex; flex-direction: column; gap: 14px; padding-top: 18px; }
.m-q { font-size: 21px; line-height: 1.35; font-weight: 500; text-align: center; margin: 14px 0 6px; }
.m-q.big { font-size: 26px; font-weight: 600; margin-top: 28px; }
.m-sub { text-align: center; font-size: 17px; color: var(--ink-2); margin: 0 0 12px; }
.m-progress { text-align: center; font-size: 13px; color: var(--muted); margin: 0; letter-spacing: .02em; }
.m-num { min-height: 54px; font-size: 22px !important; text-align: left; padding: 10px 14px !important; }
.m-num:disabled { background: #f1f3f6; color: var(--muted); }
.m-na { display: flex; align-items: center; gap: 10px; font-size: 17px; padding: 6px 2px; cursor: pointer; }
.m-na input { width: 22px; height: 22px; }
.m-err { color: var(--red); font-size: 15px; min-height: 0; margin: 0; text-align: center; }
.m-err:empty { display: none; }
.step .btn { min-height: 52px; font-size: 18px; font-weight: 600; }
.m-row { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.m-stack { display: flex; flex-direction: column; gap: 14px; margin-top: 8px; }
.btn-xl { min-height: 64px !important; font-size: 20px !important; }
.m-recap { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.m-recap li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line-2); font-size: 15px; }
.m-recap li:last-child { border-bottom: 0; }
.m-recap li strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-list { margin: 0; padding-left: 22px; font-size: 17px; line-height: 1.5; }
.m-list li { margin-bottom: 10px; }
.m-label { font-size: 16px; color: var(--ink-2); margin: 10px 0 0; font-weight: 500; }
.m-card { margin: 0; padding: 16px 18px; border-radius: var(--radius); background: var(--blue-50); border-left: 4px solid var(--blue-700); font-size: 18px; line-height: 1.45; font-weight: 500; color: var(--blue-900); }
.m-card.warn { background: #fff7e8; border-left-color: #c77d0a; color: #4a3305; display: flex; flex-direction: column; gap: 6px; }
.m-card.warn strong { font-size: 18px; }
.m-card.warn span { font-weight: 400; font-size: 17px; }
.m-foot { margin-top: auto; padding-top: 28px; display: flex; justify-content: center; gap: 18px; font-size: 13px; color: var(--muted); }
.m-foot a { color: var(--ink-2); }
.phone > .flash { margin-top: 12px; }

/* =================== RESPONSIVE =================== */
@media (max-width: 1100px) {
  .topbar-in { flex-wrap: wrap; gap: 8px 20px; padding: 10px 20px; }
  .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .mainnav a { white-space: nowrap; }
  .usermenu { margin-left: auto; }
}
@media (max-width: 860px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-2, .form-3 { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .f-vista, .f-sel, .f-periodo, .f-comp, .f-modo, .f-go { grid-column: 1; grid-row: auto; }
  .f-go { justify-content: stretch; }
  .f-go .btn { width: 100%; }
  .wrap { padding: 20px 16px 40px; }
  .seg { display: flex; flex-wrap: wrap; }
  .seg label { flex: 1; text-align: center; }
  .dates input { width: 100%; }
  .dates { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .who { display: none; }
}
@media (max-width: 520px) {
  .kpis-sm { grid-template-columns: 1fr 1fr; }
  .chart-box { height: 260px; }
  .seg span { padding: 8px 8px; font-size: 13px; }
}

/* =================== STAMPA =================== */
@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .filters, .result-tools, .foot, .flash, .pagehead .lead { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .panel { border: 0; box-shadow: none; padding: 0; }
  .table-wrap { overflow: visible; border: 0; }
  .grid th, .grid td { padding: 3px 5px; }
  .chart-box { height: 260px; page-break-inside: avoid; }
}
