/* === reset & base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: #f5f5f5;
  color: #333;
}

a { color: #4594e8; text-decoration: none; }
a:hover { text-decoration: underline; }

/* === topbar === */
#topbar {
  background: #282828;
  color: #fff;
  padding: 0 1.5em;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#topbar .brand {
  font-size: 1.1em;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #b83014;
}
#topbar a {
  color: #ccc;
  font-size: 0.9em;
}
#topbar a:hover { color: #fff; text-decoration: none; }

/* === filtri === */
#filtri {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.75em 1.5em;
  display: flex;
  gap: 1.5em;
  align-items: center;
}
#filtri label {
  font-size: 0.85em;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.5em;
}
#filtri select {
  padding: 5px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
  font-size: 0.95em;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
#filtri select:focus { border-color: #b83014; }

/* === contenuto principale === */
#main {
  padding: 1.5em;
}

/* === tabella === */
.table-wrap {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  overflow: auto;
}

#aa {
  width: 100%;
  border-collapse: collapse;
}

#aa th {
  background: #282828;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#aa td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
  line-height: 1.5;
}

#aa tr:last-child td { border-bottom: none; }
#aa tr:hover td { background: #fafafa; }

/* === classi contratto === */
#aa td.arancio  { border-left: 5px solid #ff8c00; }
#aa td.verde    { border-left: 5px solid #4CAF50; }
#aa td.blu      { border-left: 5px solid #4594e8; }
#aa td.marrone  { border-left: 5px solid #964b00; }
#aa td.solo     { border-left: 5px solid #00acad; }
#aa td.pro      { border-left: 5px solid #99ddff; }
#aa td.business { border-left: 5px solid #066C9C; }
#aa td.dedicated { border-left: 5px solid #52B9E8; }
#aa td.progetto  { border-left: 5px solid #FFB3FF; }
#aa td.cloud5    { border-left: 5px solid #ddc616; }
#aa td.cloud50   { border-left: 5px solid #b8a800; }
#aa td.cloud70   { border-left: 5px solid #DFFF00; }
#aa td.blackbelt { border-left: 5px solid #111; }
#aa td.servizi   { border-left: 5px solid #b83014; }
#aa td.interno   { border-left: 5px solid #cc2200; color: #cc2200; }

/* === locked === */
#aa td.locked { color: #b83014; font-weight: 600; }

/* === quota === */
.quota {
  display: block;
  font-size: 0.8em;
  color: #888;
  margin-top: 1px;
}

/* === totali === */
#totali {
  margin-top: 1.5em;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1em 1.5em;
}
#totali h3 {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.75em;
}
#totali-lista {
  list-style: none;
  display: inline-flex;
  flex-direction: column;
  min-width: 280px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}
#totali-lista li {
  font-size: 0.9em;
  color: #555;
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 6px 10px;
  border-bottom: 1px solid #f0f0f0;
}
#totali-lista li:last-child { border-bottom: none; }
#totali-lista li:nth-child(even) { background: #fafafa; }
.legenda-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: #ccc;
  flex-shrink: 0;
}
.legenda-nome { flex: 1; }
.legenda-count { font-weight: 600; color: #333; }

/* colori pallini legenda */
.dot-arancio   { background: #ff8c00; }
.dot-verde     { background: #4CAF50; }
.dot-blu       { background: #4594e8; }
.dot-marrone   { background: #964b00; }
.dot-solo      { background: #00acad; }
.dot-pro       { background: #99ddff; border: 1px solid #ccc; }
.dot-business  { background: #066C9C; }
.dot-dedicated { background: #52B9E8; }
.dot-progetto  { background: #FFB3FF; border: 1px solid #ccc; }
.dot-cloud5    { background: #ddc616; }
.dot-cloud50   { background: #b8a800; }
.dot-cloud70   { background: #DFFF00; border: 1px solid #ccc; }
.dot-blackbelt { background: #111; }
.dot-servizi   { background: #b83014; }
#totale-count {
  font-weight: 700;
  color: #b83014;
}

/* === bottone dettaglio === */
.btn-detail {
  font-size: 0.8em;
  padding: 3px 8px;
  border: 1px solid #ccc;
  border-radius: 3px;
  color: #555;
  white-space: nowrap;
}
.btn-detail:hover { border-color: #b83014; color: #b83014; text-decoration: none; }

/* === pagina dettaglio === */
.detail-back { margin-bottom: 1em; font-size: 0.9em; }

.detail-card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1.5em;
  margin-bottom: 1.5em;
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 1em;
}
.detail-header h1 { font-size: 1.4em; margin: 0; }

.detail-badge {
  font-size: 0.8em;
  padding: 3px 10px;
  border-radius: 20px;
  background: #eee;
  color: #555;
  border-left: 4px solid #ccc;
}
.detail-badge.arancio   { border-color: #ff8c00; background: #fff4e0; }
.detail-badge.verde     { border-color: #4CAF50; background: #f0fff0; }
.detail-badge.blu       { border-color: #4594e8; background: #eef5ff; }
.detail-badge.marrone   { border-color: #964b00; background: #f5ede0; color: #fff; background: #964b00; }
.detail-badge.solo      { border-color: #00acad; background: #e0f7f7; }
.detail-badge.pro       { border-color: #99ddff; background: #eafaff; }
.detail-badge.business  { border-color: #066C9C; background: #e0f0f8; }
.detail-badge.dedicated { border-color: #52B9E8; background: #eaf6fd; }
.detail-badge.progetto  { border-color: #FFB3FF; background: #fdf0ff; }
.detail-badge.cloud5    { border-color: #ddc616; background: #fffde0; }
.detail-badge.cloud50   { border-color: #b8a800; background: #fffce0; }
.detail-badge.cloud70   { border-color: #DFFF00; background: #fafff0; }
.detail-badge.blackbelt { border-color: #111; background: #f0f0f0; }
.detail-badge.servizi   { border-color: #b83014; background: #fff0ee; }

.detail-locked {
  font-size: 0.8em;
  padding: 3px 10px;
  border-radius: 20px;
  background: #fff0ee;
  color: #b83014;
  font-weight: 600;
}

.detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4em 1em;
  font-size: 0.9em;
}
.detail-meta dt { color: #888; font-weight: 600; }
.detail-meta dd { color: #333; }

.detail-section {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1.5em;
  margin-bottom: 1.5em;
}
.detail-section h2 {
  font-size: 1em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 0.75em;
}
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
}
.detail-table th {
  background: #f5f5f5;
  color: #555;
  padding: 7px 10px;
  text-align: left;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.detail-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f0;
}
.detail-table tr:last-child td { border-bottom: none; }
.detail-table tr:hover td { background: #fafafa; }

/* === dettaglio sito === */
.detail-sito {
  margin-bottom: 1.5em;
  padding-bottom: 1.5em;
  border-bottom: 1px solid #f0f0f0;
}
.detail-sito:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.detail-sito-header {
  display: flex;
  align-items: center;
  gap: 1em;
  margin-bottom: 0.75em;
  font-size: 1em;
  font-weight: 600;
}
.quota-inline { font-size: 0.85em; color: #888; font-weight: normal; }

/* === moduli dolibarr === */
.btn-moduli {
  background: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8em;
  padding: 1px 5px;
  margin-left: 4px;
  color: #888;
  vertical-align: middle;
  transition: border-color 0.2s, color 0.2s;
}
.btn-moduli:hover { border-color: #b83014; color: #b83014; }

.moduli-panel {
  margin-top: 6px;
  overflow-x: auto;
}
.moduli-table {
  border-collapse: collapse;
  font-size: 0.78em;
  width: 100%;
}
.moduli-table th {
  background: #f0f0f0;
  color: #555;
  padding: 4px 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1em;
}
.moduli-table td {
  padding: 3px 8px;
  border-bottom: 1px solid #f0f0f0;
  color: #444;
}
.moduli-unreachable  { font-size: 0.85em; color: #b83014; font-style: italic; }
.moduli-nomodule     { font-size: 0.85em; color: #b87014; font-style: italic; }
.moduli-notdolibarr  { font-size: 0.85em; color: #888;    font-style: italic; }
.moduli-empty        { font-size: 0.85em; color: #888;    font-style: italic; }

.moduli-table-wrap { margin-top: 0.5em; overflow-x: auto; }
.moduli-detail-table { font-size: 0.85em; }
.moduli-detail-table th { white-space: nowrap; }
.modulo-ver-cell {
  font-family: monospace;
  font-size: 0.95em;
  color: #4a6fa5;
  background: #e8eef5;
  border: 1px solid #c0d0e8;
  border-radius: 3px;
  padding: 0 5px;
}

/* === info versioni dolibarr === */
.dolibarr-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.15em 0;
  font-size: 0.8em;
  margin: 0.4em 0 0.6em;
}
.dolibarr-meta dt {
  background: #e8eef5;
  color: #4a6fa5;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px 0 0 3px;
  border: 1px solid #c0d0e8;
  border-right: none;
  margin-left: 0.5em;
}
.dolibarr-meta dt:first-child { margin-left: 0; }
.dolibarr-meta dd {
  background: #f5f8fc;
  color: #333;
  padding: 2px 7px;
  border-radius: 0 3px 3px 0;
  border: 1px solid #c0d0e8;
}

/* === topbar nav === */
.topbar-nav { display: flex; gap: 1.2em; }
.topbar-nav a { color: #aaa; font-size: 0.9em; }
.topbar-nav a:hover { color: #fff; text-decoration: none; }
.topbar-nav a.active { color: #fff; font-weight: 600; }

/* === filtri input text === */
#filtri input[type="text"] {
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
  font-size: 0.95em;
  outline: none;
  transition: border-color 0.2s;
}
#filtri input[type="text"]:focus { border-color: #b83014; }

#f-count { font-size: 0.85em; color: #888; margin-left: 0.5em; }

.modulo-modo-wrap { display: inline-flex; gap: 0.75em; margin-left: 0.4em; }
.radio-inline { font-size: 0.9em; color: #555; display: flex; align-items: center; gap: 0.25em; font-weight: normal; }

/* === header ordinabili (tutte le tabelle) === */
th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { background: #3a3a3a; }
th.sortable::after       { content: ' ↕'; opacity: 0.3; font-size: 0.85em; }
th.sorted-asc::after     { content: ' ↑'; opacity: 0.8; font-size: 0.85em; }
th.sorted-desc::after    { content: ' ↓'; opacity: 0.8; font-size: 0.85em; }

/* === dolibarr overview table === */
#dol-table {
  width: 100%;
  border-collapse: collapse;
}
#dol-table th {
  background: #282828;
  color: #fff;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
#dol-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  line-height: 1.4;
}
#dol-table tr:last-child td { border-bottom: none; }
#dol-table tr:hover td { background: #fafafa; }

.ver { font-family: monospace; font-size: 0.9em; color: #444; }

/* === stato badges === */
.stato-badge {
  display: inline-block;
  font-size: 0.78em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.stato-ok           { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.stato-nomodule     { background: #fff3e0; color: #e65100; border: 1px solid #ffcc80; }
.stato-unreachable  { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.stato-not_dolibarr { background: #f5f5f5; color: #888;    border: 1px solid #ddd; }

/* === moduli tags === */
.moduli-tags { display: flex; flex-wrap: wrap; gap: 3px; }
/* === installazione path === */
.inst { font-family: monospace; font-size: 0.85em; white-space: nowrap; }
.inst-git {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: help;
}
.inst-direct {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: help;
}
.inst-htdocs {
  background: #fffbe6;
  color: #a07800;
  border: 1px solid #ffe082;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: help;
}
.inst-unknown {
  color: #bbb;
  cursor: help;
}

.modulo-tag {
  display: inline-flex;
  border: 1px solid #c0d0e8;
  border-radius: 3px;
  overflow: hidden;
  font-size: 0.75em;
  white-space: nowrap;
}
.modulo-nome {
  background: #e8eef5;
  color: #4a6fa5;
  padding: 1px 6px;
}
.modulo-ver {
  background: #f5f8fc;
  color: #7a90b5;
  padding: 1px 6px;
  font-family: monospace;
  border-left: 1px solid #c0d0e8;
}

/* === login === */
#login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #282828;
}
#login {
  background: #fff;
  border-radius: 8px;
  padding: 2.5em 2em;
  width: 320px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.3);
}
#login .logo {
  font-size: 1.6em;
  font-weight: 800;
  color: #b83014;
  text-align: center;
  margin-bottom: 0.2em;
}
#login .subtitle {
  text-align: center;
  color: #888;
  font-size: 0.85em;
  margin-bottom: 1.5em;
}
#login label {
  display: block;
  font-size: 0.85em;
  color: #555;
  margin-bottom: 1em;
}
#login input {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1em;
  outline: none;
  transition: border-color 0.2s;
}
#login input:focus { border-color: #b83014; }
#login button {
  width: 100%;
  padding: 10px;
  margin-top: 0.5em;
  background: #b83014;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
#login button:hover { background: #9a2710; }
.login-error {
  background: #fff0ee;
  border: 1px solid #f5c6bc;
  color: #b83014;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.88em;
  margin-bottom: 1em;
}
