/* MO.SA - stile base. Colori di marca dal logo: blu #0B2545, teal #0B8A96. */
:root {
  color-scheme: light;
  --navy: #0B2545; --teal: #0B8A96; --teal-text: #08707a;
  --bg: #f5f4ef; --card: #fff; --line: #d3e0e6; --line-strong: #b4c6cf;
  --band: #dcf0f2; --band-line: #a9d8dd; --band-text: #0B2545;
  --fg: #0e1b2b; --muted: #5b6b7b; --faint: #8794a1;
  --accent: var(--teal-text); --primary: var(--teal-text); --on-primary: #fff;
  --ok: #1e6b2a; --warn: #8a5300; --err: #b3261e; --info: #08707a;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; color: var(--navy); }
h2 { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--band-text); background: var(--band); border: 1px solid var(--band-line); border-left: 5px solid var(--teal); border-radius: var(--radius); padding: 8px 12px; margin: 26px 0 10px; }
p { margin: 0 0 12px; } .muted { color: var(--muted); } .faint { color: var(--faint); font-size: 13px; }
.icon { vertical-align: -3px; flex: none; }

/* Intestazione */
.topbar { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; padding: 8px 20px; background: var(--navy); border-bottom: 4px solid var(--teal); color: #fff; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; background: #fff; border-radius: 6px; padding: 4px 10px; }
.badge-command { white-space: nowrap; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--navy); background: #7fd6df; border-radius: 99px; padding: 2px 10px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: var(--radius); border-bottom: 3px solid transparent; color: #c9dbe6; text-decoration: none; font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.topbar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.topbar nav a.current { color: #fff; border-bottom-color: #3fc1cf; border-radius: var(--radius) var(--radius) 0 0; background: rgba(255,255,255,.1); }
.user { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #c9dbe6; flex-wrap: wrap; }
.topbar .user a, .topbar .link-btn { color: #7fd6df; }
form.inline { display: inline; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; display: inline-flex; align-items: center; gap: 4px; }

main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
.narrow { max-width: 420px; margin: 8vh auto 0; }
.card { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: 12px; padding: 20px; }
.msg { background: var(--card); border: 1px solid var(--line-strong); border-left: 4px solid var(--info); padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; }
.msg.error { border-left-color: var(--err); }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { display: flex; align-items: center; gap: 8px; margin: 0; }

/* Pulsanti e campi */
.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--radius); border: 1px solid var(--primary); background: var(--primary); color: var(--on-primary); font: inherit; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.secondary:hover { background: var(--band); border-color: var(--teal); color: var(--band-text); }
.btn.secondary { background: transparent; color: var(--fg); border-color: var(--line-strong); font-weight: 500; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.block { width: 100%; height: 42px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input[type=text], input[type=password], input[type=email], input[type=search], select { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--fg); font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.helptext, .field-help { font-size: 12px; color: var(--faint); margin: 4px 0 0; display: block; }
.errorlist { list-style: none; padding: 0; margin: 4px 0 0; color: var(--err); font-size: 13px; }
ul.checks { list-style: none; padding: 0; margin: 0; } ul.checks label { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; margin: 4px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Contatori e tabelle */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 14px; }
.tile { display: block; text-decoration: none; color: inherit; background: var(--card); border: 1px solid var(--line); border-left: 5px solid var(--teal); border-radius: var(--radius); padding: 10px 12px; }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.tile .value { font-size: 24px; font-weight: 600; line-height: 1.2; }
.tile .value.warn { color: var(--warn); } .tile .value.err { color: var(--err); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters .grow { flex: 2; min-width: 200px; } .filters select { flex: 1; min-width: 140px; width: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { font-weight: 700; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--band-text); background: var(--band); border-bottom: 2px solid var(--band-line); }
tbody tr:nth-child(even) td { background: rgba(11,138,150,.04); } tbody tr:hover td { background: rgba(11,138,150,.10); } tr:last-child td { border-bottom: 0; }
td.nowrap, th.nowrap { white-space: nowrap; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--faint); }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.warn { background: var(--warn); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.cred { font-family: ui-monospace, Consolas, monospace; font-size: 18px; background: var(--bg); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 10px 14px; letter-spacing: .02em; word-break: break-all; }
.pager { text-align: center; margin-top: 12px; }

@media (max-width: 700px) {
  main { padding: 0 12px; } th, td { padding: 8px; } table { font-size: 13px; display: block; overflow-x: auto; white-space: nowrap; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .topbar { gap: 10px; padding: 8px 12px; } .btn { height: 44px; }
}

/* Schede: coppie etichetta/valore */
dl.kv { margin: 0; display: grid; grid-template-columns: 1fr 1.4fr; gap: 6px 12px; font-size: 14px; }
dl.kv dt { color: var(--muted); font-size: 13px; } dl.kv dd { margin: 0; }
input[type=file] { width: 100%; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--fg); }
textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--fg); font: inherit; }
input[type=date], input[type=number] { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--card); color: var(--fg); font: inherit; }
input[type=checkbox] { width: auto; height: auto; }
.tile .value.err { color: var(--err); }

/* Home: accessi rapidi e grafici */
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-bottom: 8px; }
.quick-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-height: 92px; padding: 12px 8px; background: var(--card); border: 1px solid var(--line-strong); border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: 13px; }
.quick-item .icon { color: var(--accent); }
a.quick-item:hover { border-color: var(--accent); }
.quick-item.disabled { border-style: dashed; border-color: var(--line); color: var(--muted); }
.quick-item.disabled .icon { color: var(--faint); } .soon { font-size: 11px; color: var(--faint); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; margin-top: 8px; }
.chart { background: var(--card); border: 1px solid var(--line); border-top: 4px solid var(--teal); border-radius: var(--radius); padding: 14px; }
.chart h3 { font-size: 13px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--band-text); margin: 0 0 12px; }
.bar-row { margin-bottom: 10px; } .bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.bar-track { height: 10px; background: var(--bg); border-radius: 5px; } .bar-fill { height: 10px; background: var(--accent); border-radius: 5px; } .bar-fill.muted { background: var(--line-strong); }
.donut-wrap { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut { width: 112px; height: 112px; border-radius: 50%; display: flex; align-items: center; justify-content: center; position: relative; flex: none; }
.donut span { width: 72px; height: 72px; border-radius: 50%; background: var(--card); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 16px; }
.legend-list { list-style: none; padding: 0; margin: 0; font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.dot.muted { background: var(--faint); }
.col-chart { display: flex; align-items: flex-end; gap: 16px; height: 130px; padding: 0 8px; }
.col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.col-bar { width: 100%; max-height: 100px; border-radius: 4px 4px 0 0; } .col-bar.accent { background: var(--accent); } .col-bar.err { background: var(--err); } .col-bar.muted { background: var(--faint); }
.col-label { font-size: 12px; color: var(--muted); margin-top: 4px; text-align: center; }

/* Interventi, programmata e calendario */
.status { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .03em; white-space: nowrap; }
.st-open { background: #f9d6d3; color: #8c1d16; } .st-assigned { background: #dbe7fb; color: #17408b; }
.st-work { background: #fdeebb; color: #6b4600; } .st-wait { background: #eadcf6; color: #5a2d82; }
.st-closed { background: #cfeed3; color: #15551f; } .st-valid { background: #b9e5ea; color: #0b4b53; }
tr.r-open td { background: #fdecea !important; } tr.r-work td { background: #fff8dc !important; } tr.r-closed td { background: #eaf8ec !important; }
.sla { font-size: 12px; font-weight: 700; } .sla.ok { color: var(--ok); } .sla.warn { color: var(--warn); } .sla.err { color: var(--err); }
.legend-bar { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; margin: 0 0 12px; } .legend-bar span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
.filterbox { background: var(--band); border: 1px solid var(--band-line); border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.filterbox .form-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.steps { display: flex; gap: 0; margin: 4px 0 18px; flex-wrap: wrap; padding: 0; } .steps li { list-style: none; flex: 1; min-width: 120px; text-align: center; padding: 8px 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--band); color: var(--faint); border: 1px solid var(--band-line); }
.steps li.done { background: var(--teal); color: #fff; border-color: var(--teal); } .steps li.now { background: var(--navy); color: #fff; border-color: var(--navy); }
.two { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; } @media (max-width: 800px) { .two { grid-template-columns: 1fr; } }
.timeline { list-style: none; padding: 0; margin: 0; font-size: 13px; } .timeline li { border-left: 3px solid var(--teal); padding: 0 0 12px 12px; margin-left: 4px; } .timeline b { display: block; }
.timer { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; } .timer:last-child { border: 0; }
table.cal th, table.cal td { text-align: center; padding: 6px 4px; font-size: 12px; } table.cal td.l, table.cal th.l { text-align: left; }
.pc { display: inline-block; min-width: 26px; padding: 2px 4px; border-radius: 4px; font-weight: 700; font-size: 11px; }
.pc.P { background: #dbe7fb; color: #17408b; } .pc.E { background: #cfeed3; color: #15551f; } .pc.R { background: #fdeebb; color: #6b4600; } .pc.X { background: #f9d6d3; color: #8c1d16; }
.tabs { display: flex; gap: 4px; margin-bottom: 14px; border-bottom: 2px solid var(--band-line); } .tabs a { padding: 8px 16px; text-decoration: none; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-radius: 8px 8px 0 0; } .tabs a.on { background: var(--navy); color: #fff; }
.month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; } .month div { min-height: 78px; background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 11px; } .month .h { min-height: 0; background: var(--band); border-color: var(--band-line); font-weight: 700; text-align: center; text-transform: uppercase; }
.month .off { background: transparent; border-style: dashed; color: var(--faint); } .month .n { font-weight: 700; font-size: 12px; display: block; margin-bottom: 2px; } .chip { display: block; margin-top: 2px; padding: 1px 5px; border-radius: 4px; font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.signature { display: block; width: 100%; height: 120px; background: #fff; border: 1px dashed var(--line-strong); border-radius: var(--radius); touch-action: none; cursor: crosshair; }
.sig-img { max-height: 90px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.month .today { outline: 2px solid var(--teal); } .month a.chip { text-decoration: none; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; } .inline-form select, .inline-form input[type=text] { width: auto; height: 34px; }
.sig-row { display: flex; gap: 8px; margin-top: 4px; }
@media print { .topbar, .actions, .no-print { display: none !important; } body { background: #fff; } .card { border: 1px solid #999; border-top-width: 1px; } }
