/* ArkiScopio CRM — palette e font dalla guida di stile ArkiScopio 2026 */
:root {
  --accent: #426A87; --accent-strong: #345671; --accent-soft: #E5EDF3;
  --dark: #233846; --darkest: #172631;
  --pearl: #F3F5F7; --surface: #FFFFFF; --surface-2: #EDF1F4;
  --text: #293B46; --muted: #5C6972; --border: #DCE3E8; --border-strong: #BDC9D2;
  --on-dark-muted: #B9C7D2;
  --run: #B07A1E; --run-bg: #FBF1DE;
  --ok: #2F7A57;  --ok-bg: #E2F2EA;
  --ko: #A6403A;  --ko-bg: #F8E4E2;
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(23,38,49,.06), 0 6px 18px rgba(23,38,49,.06);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--text); background: var(--pearl);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { color: var(--dark); line-height: 1.2; margin: 0 0 6px; letter-spacing: -.01em; }
h1 { font-size: 28px; font-weight: 700; }
.h2 { font-size: 19px; margin: 36px 0 12px; }
.h3 { font-size: 16px; font-weight: 500; margin-bottom: 4px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.wrap { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.page { flex: 1; padding-top: 28px; padding-bottom: 56px; }

/* ---------- topbar ---------- */
.topbar { background: var(--darkest); position: sticky; top: 0; z-index: 20; }
.nav { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 700; font-size: 19px; }
.brand svg { width: 28px; height: 28px; }
.brand b { color: #9CC0DA; }
.brand small { font-size: 11px; font-weight: 500; letter-spacing: .12em; color: var(--on-dark-muted); margin-left: 4px; border: 1px solid rgba(255,255,255,.2); padding: 1px 6px; border-radius: 4px; vertical-align: 2px; }
.links { display: flex; align-items: center; gap: 2px; }
.links a, .linkbtn {
  color: var(--on-dark-muted); text-decoration: none; font: inherit; font-size: 14px; font-weight: 500;
  padding: 7px 11px; border-radius: var(--r-sm); background: none; border: 0; cursor: pointer;
}
.links a:hover, .linkbtn:hover { color: #fff; background: rgba(255,255,255,.07); }
.links a.on { color: #fff; background: rgba(156,192,218,.16); }
.links .user em { font-style: normal; font-size: 11px; color: #9CC0DA; margin-left: 3px; }
.links .sep { width: 1px; height: 20px; background: rgba(255,255,255,.15); margin: 0 6px; }
.linkbtn.dark { color: var(--accent); padding: 0; font-size: 14px; }
.linkbtn.dark:hover { background: none; text-decoration: underline; color: var(--accent-strong); }
.inline { display: inline; margin: 0; }
.menu-toggle, .menu-btn { display: none; }

/* ---------- footer ---------- */
.foot { background: var(--darkest); color: var(--on-dark-muted); padding: 28px 0 22px; font-size: 12px; text-align: center; }
.foot .partners { width: 100%; max-width: 620px; height: auto; margin: 0 auto 10px; display: block; opacity: .9; }
.foot p { margin: 0; letter-spacing: .04em; }

/* ---------- elementi ---------- */
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.crumb { margin-bottom: 8px; font-size: 14px; }
.crumb a { text-decoration: none; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 14px; padding: 9px 16px; border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--dark);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.danger { color: var(--ko); border-color: #E3B9B5; }
.btn.danger:hover { background: var(--ko-bg); color: var(--ko); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.full { width: 100%; }
.flash { padding: 11px 14px; border-radius: var(--r-sm); margin-bottom: 16px; font-size: 14px; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #BFE0CF; color: #1F5A3F; }
.flash.error { background: var(--ko-bg); border-color: #EBC3BF; color: #7E2C27; }

/* form */
input, select, textarea {
  font: inherit; font-size: 15px; color: var(--text); width: 100%;
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(66,106,135,.35); outline-offset: 0; border-color: var(--accent); }
input[readonly], textarea[readonly] { background: var(--surface-2); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--dark); }
label small { font-weight: 400; }
.form { padding: 22px; margin-bottom: 24px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 16px; }
.span2 { grid-column: span 2; } .span4 { grid-column: 1 / -1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.narrow { max-width: 460px; }
.actions { display: flex; gap: 10px; align-items: center; }
.row { display: flex; gap: 6px; }
.row input { padding: 6px 9px; font-size: 13px; min-width: 130px; }
.danger-zone { margin-top: -8px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1 1 260px; }
.filters select { width: auto; flex: 0 1 220px; }
.filters .inl { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--muted); }
.filters .inl input { width: auto; }

/* tabelle */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #FAFBFC; white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #F8FAFB; }
tr.off td { opacity: .55; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.act { text-align: right; white-space: nowrap; }
.act a { text-decoration: none; font-weight: 500; margin-left: 10px; }
.act form { display: inline; margin-left: 10px; }
.note { max-width: 260px; color: var(--muted); white-space: pre-line; }
.empty { text-align: center; color: var(--muted); padding: 36px 14px; }
tfoot td { font-weight: 700; color: var(--dark); background: #FAFBFC; border-top: 1px solid var(--border-strong); }

/* status */
.badge { display: inline-block; font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.s-in_corso { background: var(--run-bg); color: #7E5512; }
.badge.s-definitiva { background: var(--ok-bg); color: #1F5A3F; }
.badge.s-inconcludente { background: var(--ko-bg); color: #7E2C27; }
.badge.ok { background: var(--ok-bg); color: #1F5A3F; }
.badge.mute { background: var(--surface-2); color: var(--muted); }
.c-ok { color: var(--ok); } .c-ko { color: var(--ko); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.tile { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); text-decoration: none; color: var(--muted); box-shadow: var(--shadow); }
.tile strong { font-size: 24px; color: var(--dark); font-variant-numeric: tabular-nums; }
.tile .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tile.s-in_corso .dot { background: var(--run); }
.tile.s-definitiva .dot { background: var(--ok); }
.tile.s-inconcludente .dot { background: var(--ko); }
.tile:hover, .tile.sel { border-color: var(--accent); }
.tile.sel { box-shadow: 0 0 0 2px rgba(66,106,135,.25); }

/* report */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.kpi span { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi strong { font-size: 26px; color: var(--dark); font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: 13px; }
.barcell { min-width: 200px; }
.barcell { display: table-cell; }
.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.barcell .num { display: block; text-align: left; }

/* login */
.login-body { align-items: center; justify-content: center; padding: 32px 16px; background: linear-gradient(180deg, var(--pearl), #E6ECF1); }
.login-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 24px 60px rgba(23,38,49,.12); }
.login-card h1 { font-size: 22px; margin-top: 18px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; color: var(--dark); }
.login-brand svg { width: 32px; height: 32px; }
.login-brand b { color: var(--accent); }
.login-partners { width: 100%; max-width: 560px; height: auto; margin-top: 36px; opacity: .95; }
.errbox { padding: 32px; max-width: 520px; margin: 40px auto; text-align: center; }

/* ---------- mobile ---------- */
@media (max-width: 980px) {
  .menu-btn { display: flex; width: 40px; height: 40px; align-items: center; justify-content: center; cursor: pointer; }
  .menu-btn span, .menu-btn span::before, .menu-btn span::after { content: ""; display: block; width: 20px; height: 2px; background: #fff; position: relative; }
  .menu-btn span::before { position: absolute; top: -6px; } .menu-btn span::after { position: absolute; top: 6px; }
  .links { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--darkest); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; border-top: 1px solid rgba(255,255,255,.08); }
  .menu-toggle:checked ~ .links { display: flex; }
  .links .sep { width: auto; height: 1px; margin: 6px 0; }
  .links .linkbtn { width: 100%; text-align: left; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 680px) {
  .wrap { padding: 0 16px; }
  h1 { font-size: 23px; }
  .tiles { grid-template-columns: 1fr; }
  .grid2, .grid4 { grid-template-columns: 1fr; }
  .span2, .span4 { grid-column: auto; }
  .filters select, .filters .btn { flex: 1 1 auto; }
  /* tabelle → schede impilate */
  .table-wrap { overflow: visible; background: none; border: 0; box-shadow: none; }
  table, tbody, tr, td, tfoot { display: block; width: 100%; }
  thead { display: none; }
  tbody tr, tfoot tr { background: #fff; border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 10px; padding: 6px 0; box-shadow: var(--shadow); }
  td { border: 0; padding: 6px 14px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12px; text-align: left; flex: none; }
  td.empty { display: block; text-align: center; }
  td.act { justify-content: flex-end; }
  .barcell { display: flex; } .barcell .bar { display: none; }
  .note { max-width: none; }
  tfoot td { background: none; border: 0; }
}

/* etichette: testo + nota sempre su una sola riga sopra il campo */
label > span { display: block; }
a.strong { font-weight: 700; color: var(--dark); text-decoration: none; }
a.strong:hover { color: var(--accent); text-decoration: underline; }
.grid4 { align-items: end; }

/* stampa / PDF del report */
@media print {
  .topbar, .foot, .no-print, .flash { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .page { padding: 0; }
  .card, .kpi { box-shadow: none; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  tr { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
