/* Gestione Commesse - backoffice in stile PrestaShop 1.7 */
:root {
  --dark: #363a41; --dark2: #282b30; --nav-text: #bebebe; --primary: #25b9d7; --primary-d: #1a9ab4;
  --bg: #eff1f2; --text: #363a41; --muted: #6c868e; --line: #dbe6e9; --head: #fafbfc;
  --ok: #70b580; --warn: #fab000; --ko: #f54c3e; --nav-w: 210px; --hdr-h: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--primary-d); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- header e menu laterale ---------- */
.bo-header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--hdr-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #fff; border-bottom: 1px solid var(--line);
}
.bo-brand { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bo-brand small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
.bo-brand:hover { text-decoration: none; }
.bo-header-right { margin-left: auto; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.hdr-user { color: var(--muted); }
.hdr-link { font-weight: 600; }
.nav-toggle { display: none; border: 0; background: none; font-size: 22px; padding: 4px 8px; cursor: pointer; }

.bo-nav {
  position: fixed; top: var(--hdr-h); left: 0; bottom: 0; width: var(--nav-w); z-index: 20;
  background: var(--dark); overflow-y: auto; display: flex; flex-direction: column;
}
.bo-nav ul { list-style: none; margin: 0; padding: 8px 0; }
.bo-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 16px; color: var(--nav-text); font-weight: 600; border-left: 4px solid transparent; }
.bo-nav a:hover { background: var(--dark2); color: #fff; text-decoration: none; }
.bo-nav li.active a { background: var(--dark2); color: #fff; border-left-color: var(--primary); }
.bo-nav svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.bo-version { margin-top: auto; padding: 12px 16px; color: #7a7f87; font-size: 12px; }
.nav-backdrop { display: none; }

.bo-main { margin-left: var(--nav-w); padding-top: var(--hdr-h); min-height: 100vh; }
.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; padding: 16px 24px; border-bottom: 1px solid var(--line);
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }
.bo-content { padding: 20px 24px 40px; }

/* ---------- pannelli ---------- */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 0 4px 0 rgba(0,0,0,.06); padding: 0 16px 16px; margin-bottom: 18px; }
.panel-heading {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 -16px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line);
  font-weight: 600; text-transform: uppercase; font-size: 13px; letter-spacing: .02em; color: var(--text);
}
.panel-heading .badge { text-transform: none; letter-spacing: 0; }
.count { background: var(--bg); color: var(--muted); border-radius: 10px; padding: 0 8px; font-size: 12px; }
.ph-link, .ph-right { margin-left: auto; text-transform: none; font-weight: 600; letter-spacing: 0; }
.ph-right input { height: 30px; }
.panel-footer { display: flex; justify-content: flex-end; gap: 10px; margin: 16px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--head); border-radius: 0 0 5px 5px; }
.panel-footer .btn-danger-o { margin-right: auto; }
.help { color: var(--muted); margin: 0 0 14px; }
.empty { color: var(--muted); padding: 14px 0; margin: 0; }
.muted { color: #b0bec3; }

.cols { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
.cols > .panel { margin-bottom: 18px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 14px 16px; border-top: 3px solid var(--primary); }
.kpi-label { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 600; letter-spacing: .02em; }
.kpi-num { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.kpi-num small { font-size: 14px; color: var(--muted); margin-left: 3px; font-weight: 400; }

/* ---------- tabelle ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; padding: 8px 10px; border-bottom: 2px solid var(--line); background: var(--head); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #eef2f3; vertical-align: middle; }
.table tbody tr:hover td { background: #f6fbfc; }
.table tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: var(--head); }
.table.compact td { padding: 6px 10px; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .sub, .sub { color: var(--muted); font-size: 13px; }
.table tr.off td { opacity: .55; }
.table tr.sep td { border-top: 2px solid var(--line); }
.row-link { cursor: pointer; }
.nowrap { white-space: nowrap; }
.late { color: var(--ko); font-weight: 600; }
.w-prog { width: 240px; }
.matrix td { white-space: nowrap; }
.matrix th { white-space: normal; vertical-align: bottom; min-width: 70px; }
.matrix th:first-child { min-width: 160px; }
.matrix.days th, .matrix.days td { padding: 6px 5px; font-size: 13px; }
.matrix.days th small { display: block; font-weight: 400; }
.matrix .we { background: #f4f6f7; }
.table.edit td { padding: 6px 8px; }
.table.edit input:not([type=checkbox]):not([type=color]) { width: 100%; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }

.prog { display: inline-block; width: 80px; height: 8px; background: #e7edef; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 8px; }
.prog-bar { height: 100%; background: var(--ok); }
.prog.warn .prog-bar { background: var(--warn); }
.prog.over .prog-bar { background: var(--ko); }
.ore-txt { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ore-txt b { color: var(--muted); font-weight: 600; margin-left: 4px; }
.prog.over + .ore-txt b { color: var(--ko); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12px; font-weight: 600; color: #fff; background: var(--muted); white-space: nowrap; }
.st-preventivo { background: #b0bec3; }
.st-progettazione { background: #6c5ce7; }
.st-produzione { background: var(--warn); }
.st-installazione { background: var(--primary); }
.st-chiusa { background: #8a9a9f; }
.st-sospesa { background: var(--ko); }
.lt-da_fare { background: #b0bec3; }
.lt-in_corso { background: var(--warn); }
.lt-completato { background: var(--ok); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 24px; }
.info-grid span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.note-box { margin-top: 14px; padding: 10px 12px; background: #fffbea; border: 1px solid #f7e6a8; border-radius: 4px; }

/* ---------- moduli ---------- */
input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea {
  height: 36px; padding: 6px 10px; border: 1px solid #bbcdd2; border-radius: 4px; background: #fff; max-width: 100%;
}
textarea { height: auto; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,185,215,.2); }
input[type=color] { width: 40px; height: 32px; padding: 2px; border: 1px solid #bbcdd2; border-radius: 4px; background: #fff; }
.form { max-width: 900px; }
.form.narrow { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid label, .auth label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid label .help { display: inline; margin: 0; font-weight: 400; }
.form-grid input, .form-grid select { width: 100%; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { min-width: 260px; flex: 1; }
.filters label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.inline-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.inline-add .grow { flex: 1; min-width: 180px; }
.inline-add input[name=codice] { width: 120px; }
.short { width: 110px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid #bbcdd2; border-radius: 4px; background: #fff; color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: #f4f9fa; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger-o { color: var(--ko); border-color: #f5b5ae; }
.btn-danger-o:hover { background: #fdeceb; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; height: 44px; }
.btn-link { font-weight: 600; }

.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; border-left: 4px solid; background: #fff; }
.alert-success { border-color: var(--ok); background: #eaf6ee; }
.alert-danger { border-color: var(--ko); background: #feeceb; }
.panel > .alert { margin-top: 0; }

.pager { display: flex; gap: 4px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager b, .pager span { min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 4px; padding: 0 6px; }
.pager a { border: 1px solid var(--line); }
.pager b { background: var(--primary); color: #fff; }

/* ---------- login / installazione ---------- */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--dark); }
.auth-box { width: 100%; max-width: 380px; }
.auth-logo { color: #fff; text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 18px; }
.auth-logo small { display: block; font-size: 13px; font-weight: 400; color: #bbcdd2; margin-top: 2px; }
.auth .panel { padding: 18px; }
.auth .panel-heading { margin: -18px -18px 16px; }
.auth form { display: flex; flex-direction: column; gap: 14px; }
.auth input:not([type=checkbox]) { width: 100%; height: 44px; font-size: 16px; }
.auth-foot { text-align: center; color: #7a7f87; font-size: 12px; }

/* ---------- schermi piccoli ---------- */
@media (max-width: 1100px) {
  .cols { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .bo-nav { transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .bo-nav { transform: none; }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: var(--hdr-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 15; }
  .bo-main { margin-left: 0; }
  .hdr-user, .bo-brand small { display: none; }
  .page-head, .bo-content { padding-left: 16px; padding-right: 16px; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .w-prog { width: auto; }
  .filters input[type=search] { min-width: 0; width: 100%; }
}
@media (max-width: 480px) {
  .kpi-num { font-size: 22px; }
  .info-grid { grid-template-columns: 1fr; }
  .hdr-link:first-child { display: none; }
}

/* ---------- stampa ---------- */
@media print {
  .bo-header, .bo-nav, .toolbar, .filters, .no-print, .actions, .pager { display: none !important; }
  .bo-main { margin: 0; padding: 0; }
  body { background: #fff; font-size: 12px; }
  .panel, .kpi { box-shadow: none; break-inside: avoid; }
  .page-head { padding: 0 0 10px; border: 0; }
  .bo-content { padding: 0; }
  .table-wrap { overflow: visible; }
  a { color: inherit; }
}
.table td:first-child b, .table td:first-child a { white-space: nowrap; }
