:root {
  /* Palette allineata al brand Innhova (logo in public/images/innhova_logo.png):
     grigio antracite del wordmark al posto del blu navy, rosso corallo del
     cerchio/tagline come accento. Nomi delle variabili invariati (usati in
     tutto questo file, in origine per un blu navy) — sono i VALORI ad essere
     allineati al brand attuale. */
  --navy: #3a3a3a;
  --navy-dark: #262626;
  --bg: #eef1f4;
  --card: #ffffff;
  --border: #dbe1e8;
  --text: #1c232c;
  --text-muted: #6b7280;
  --accent: #e2574f; /* rosso Innhova */
  --danger: #b3261e;
  --ok: #2e7d32;
  --warning: #d97706;
  --urgent: #ea580c;
  --overdue: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: var(--navy); }

header.app-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

header.app-header .brand {
  font-weight: 700;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}
header.app-header .brand img#orgLogo {
  max-height: 32px;
  max-width: 160px;
  object-fit: contain;
}
header.app-header .brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: #c9d6e3;
}
header.app-header .brand .home-link {
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.85;
}
header.app-header .brand .home-link:hover {
  opacity: 1;
}
header.app-header .brand-restricted-icon {
  font-size: 18px;
  line-height: 1;
}

header.app-header nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

header.app-header nav button, header.app-header .user-chip {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
header.app-header nav button.active { background: #fff; color: var(--navy); font-weight: 600; }
header.app-header nav button:hover { background: rgba(255,255,255,0.22); }

.lang-switcher { display: flex; gap: 2px; }
.lang-switcher button { padding: 8px 10px !important; font-weight: 600; }

main.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

.landing-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
/* Griglia a 3 colonne fisse per il Cruscotto (più mattonelle di quante ne serva alla
   pagina pubblica, che resta sul layout auto-fit sopra). */
.landing-tiles.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 760px) {
  .landing-tiles.cols-3 { grid-template-columns: 1fr; }
}
/* Cruscotto: un ambito normativo per colonna, tessere impilate sotto il titolo */
.hub-ambiti { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
@media (max-width: 1200px) { .hub-ambiti { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .hub-ambiti { grid-template-columns: 1fr; } }
.hub-section { background: var(--bg, #f6f7f9); border: 1px solid var(--border, #e5e7eb); border-radius: var(--radius); padding: 14px; }
.hub-section-head { margin-bottom: 12px; min-height: 44px; }
.hub-section-head h3 { margin: 0 0 2px; font-size: 15px; color: var(--navy); }
.hub-section-head .muted { font-size: 11.5px; line-height: 1.35; display: block; }
.hub-tiles { display: flex; flex-direction: column; gap: 12px; }
.landing-tile.compact { padding: 18px 14px; }
.landing-tile.compact .landing-tile-icon { width: 42px; height: 42px; margin-bottom: 10px; }
.landing-tile.compact h3 { font-size: 15px; margin-bottom: 6px; }
.landing-tile.compact p { font-size: 12.5px; line-height: 1.4; }
.landing-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s, transform 0.15s;
}
.landing-tile:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.14);
  transform: translateY(-2px);
}
.landing-tile-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}
.landing-tile h3 {
  margin: 0 0 8px;
  font-size: 17px;
  color: var(--navy);
}
.landing-tile p {
  margin: 0;
  font-size: 13px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card h2, .card h3 { margin-top: 0; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
textarea { min-height: 90px; resize: vertical; }

button.btn {
  background: var(--navy);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
button.btn:hover { background: var(--navy-dark); }
button.btn.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }
button.btn.danger { background: var(--danger); }
button.btn.success { background: var(--ok); }
button.btn.warning { background: var(--warning); }
button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn-small { padding: 5px 10px; font-size: 12px; border-radius: 5px; }
/* Pulsanti "Archiviate" / "+ Nuova richiesta" nell'header della dashboard: più stretti in
   orizzontale e più alti in verticale rispetto al normale .btn-small. */
button.btn-compact { padding: 12px 6px; font-size: 11px; border-radius: 5px; max-width: 96px; white-space: normal; line-height: 1.25; }

.msg { padding: 10px 14px; border-radius: 6px; font-size: 13px; margin: 10px 0; }
.msg.error { background: #fee2e2; color: #991b1b; }
.msg.success { background: #dcfce7; color: #166534; }
.msg.info { background: #dbeafe; color: #1e40af; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
}
.badge.ok { background: var(--ok); }
.badge.warning { background: var(--warning); }
.badge.urgent { background: var(--urgent); }
.badge.overdue { background: var(--overdue); }
.badge.neutral { background: var(--text-muted); }

/* Semaforo dello stato nei registri (statusDot/statusLegend in api.js) */
.sdot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; }
.sdot i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sdot-verde i { background: var(--ok); }
.sdot-arancione i { background: var(--warning); }
.sdot-rosso i { background: var(--overdue); }
.sdot-grigio i { background: var(--text-muted); }
.sdot-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 10px; color: var(--text-muted); }
.sdot-legend .sdot { font-size: 11.5px; }

/* Kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  align-items: start;
}
.kanban-col {
  background: #e9eef4;
  border-radius: var(--radius);
  padding: 10px;
  min-height: 200px;
}
.kanban-col h4 {
  margin: 4px 6px 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}
.tile {
  background: var(--card);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  cursor: pointer;
  border-left: 4px solid var(--ok);
}
.tile.urgency-warning { border-left-color: var(--warning); }
.tile.urgency-urgent { border-left-color: var(--urgent); }
.tile.urgency-overdue { border-left-color: var(--overdue); }
.tile:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.14); }
.tile[draggable="true"] { cursor: grab; }
.tile.dragging { opacity: 0.4; }
.kanban-col.drag-over { background: #dbe4ee; outline: 2px dashed var(--navy); outline-offset: -2px; }
.tile .code { font-weight: 700; font-size: 13px; }
.tile .subject { font-size: 12px; color: var(--text-muted); margin: 4px 0; }
.tile .type { font-size: 11px; color: var(--text-muted); }
.tile .depts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tile .dept-chip { font-size: 10px; padding: 2px 6px; border-radius: 999px; background: var(--border); }
.tile .dept-chip.done { background: #dcfce7; color: #166534; }

.thread { display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.bubble .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.bubble.out { align-self: flex-end; background: #dbeafe; }
.bubble.in { align-self: flex-start; background: var(--bg); }
.bubble.internal { align-self: stretch; background: #fef9c3; border: 1px dashed #ca8a04; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: var(--border); border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.tabs button.active { background: var(--navy); color: #fff; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
/* Le label di lunghezza diversa nella stessa riga possono andare a capo su un numero
   diverso di righe: allineando ogni colonna in basso (anziché in alto, il default),
   i campi di input restano tutti sulla stessa linea orizzontale a prescindere
   dall'altezza della label sopra di essi. */
.row > div { display: flex; flex-direction: column; justify-content: flex-end; }
.row > * { flex: 1; min-width: 180px; }

.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 12px; }

@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
}

footer.app-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 32px 0 16px;
}
.footer-policies {
  display: flex; justify-content: center; gap: 20px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.footer-policies a { color: var(--navy); text-decoration: none; font-size: 0.85rem; font-weight: 600; }
.footer-policies a:hover { text-decoration: underline; }
.footer-innhova {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding-top: 14px; border-top: 1px solid var(--border);
  font-size: 0.85rem; color: var(--text-muted);
}
.footer-innhova a { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; }
.footer-innhova img { height: 28px; }
.footer-innhova a:hover { color: var(--navy); }

#notifBellBtn {
  position: relative;
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
}
#notifBellBtn:hover { background: rgba(255,255,255,0.22); }
#notifBadge {
  position: absolute; top: 2px; right: 2px;
  background: var(--overdue); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
#codaEmailBadge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--overdue); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
  padding: 0 4px; margin-left: 6px;
}
#notifDropdown {
  position: absolute; right: 0; top: calc(100% + 6px); width: 340px; max-height: 420px; overflow-y: auto;
  background: #fff; color: var(--text); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); z-index: 60;
}
#notifDropdown .notif-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
#notifDropdown .notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
#notifDropdown .notif-item:hover { background: #f8fafc; }
#notifDropdown .notif-item.unread { background: #eff6ff; }
#notifDropdown .notif-title { font-weight: 600; margin-bottom: 2px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal-box {
  position: relative;
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 780px; max-height: calc(100vh - 80px); overflow-y: auto;
}
.modal-box .close-x { float: right; cursor: pointer; font-size: 20px; color: var(--text-muted); border: none; background: none; }
.modal-side-tabs {
  position: absolute; top: 20px; right: 56px;
  display: flex; gap: 4px;
}
.modal-side-tabs .side-tab-icon {
  background: var(--bg); border: 1px solid var(--border); border-radius: 6px;
  font-size: 15px; padding: 5px 9px; cursor: pointer; color: var(--text-muted);
}
.modal-side-tabs .side-tab-icon.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.deadline-indicator {
  position: absolute; top: 56px; right: 20px;
  font-size: 12px; font-weight: 700; padding: 5px 10px;
}

fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 10px 0; }
fieldset legend { padding: 0 6px; font-weight: 600; font-size: 13px; }

.section-block { margin-top: 22px; }
.section-block:first-of-type { margin-top: 14px; }
.section-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px; padding-bottom: 6px;
  font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--navy); border-bottom: 2px solid var(--navy);
}
.section-title .icon { font-size: 16px; }
.section-block.section-chiusura .section-title { color: var(--ok); border-bottom-color: var(--ok); }
.section-block.section-chat .section-title { color: #ca8a04; border-bottom-color: #ca8a04; }
.section-block.section-audit .section-title { color: var(--text-muted); border-bottom-color: var(--border); }
.section-block fieldset { margin-top: 8px; }

/* Scheda DPIA (public/js/dpia.js): sezioni ben distinguibili — barra colorata con
   numero, corpo separato, indice fisso in alto per saltare da una sezione all'altra. */
.ra-toc {
  position: sticky; top: 0; z-index: 20; display: flex; gap: 6px; flex-wrap: wrap;
  padding: 8px 10px; margin: 0 0 4px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}
.ra-toc a {
  padding: 4px 11px; border-radius: 14px; background: var(--bg); color: var(--navy);
  text-decoration: none; font-size: 12px; font-weight: 600; border: 1px solid var(--border);
}
.ra-toc a:hover { background: var(--navy); color: #fff; }
.ra-sec {
  border: 1px solid var(--border); border-radius: var(--radius); margin: 22px 0; overflow: hidden;
  background: var(--card); box-shadow: 0 2px 6px rgba(0, 0, 0, .07); scroll-margin-top: 64px;
}
.ra-sec-h {
  background: var(--navy); color: #fff; padding: 11px 16px; display: flex; align-items: center;
  gap: 10px; flex-wrap: wrap; font-size: 16px; font-weight: 700; border-bottom: 3px solid var(--accent);
}
.ra-sec-num {
  background: #fff; color: var(--navy); border-radius: 50%; width: 27px; height: 27px; flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.ra-sec-h .ra-ai { margin-left: auto; }
.ra-sec-h button.btn { background: #fff; color: var(--navy); border: 1px solid #fff; }
.ra-sec-b { padding: 16px 18px 18px; }
.ra-sub {
  margin: 20px 0 8px; padding: 7px 12px; background: var(--bg); border-left: 4px solid var(--accent);
  font-weight: 700; font-size: 14px; color: var(--navy-dark); border-radius: 0 6px 6px 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ra-sub .ra-ai { margin-left: auto; }
.ra-sec-b > label:first-child, .ra-sub + label { margin-top: 4px; }
.ra-checks { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.ra-checks label { font-weight: 400; display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.ra-checks input { width: auto; }
