:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #eef4ff;
  --text: #172033;
  --muted: #6d7789;
  --line: #dce4ef;
  --primary: #2457d6;
  --primary-2: #153b93;
  --accent: #0d9488;
  --warning: #b45309;
  --danger: #b91c1c;
  --success: #147a4a;
  --shadow: 0 18px 50px rgba(23, 32, 51, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--primary);
  color: #fff;
  padding: .75rem 1rem;
  z-index: 10;
}
.skip-link:focus { top: 1rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem clamp(1rem, 4vw, 2.5rem);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  color: var(--text);
  min-width: 12rem;
  font-weight: 850;
}
.brand:hover { text-decoration: none; }
.brand img {
  display: block;
  width: 2.9rem;
  height: 2.9rem;
  flex: 0 0 auto;
  border-radius: .65rem;
}
.brand strong {
  display: block;
  font-size: 1.16rem;
  letter-spacing: 0;
  line-height: 1;
}
.brand strong span {
  color: var(--accent);
}
.brand small {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 600;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  justify-content: flex-end;
}
nav a, .button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.55rem;
  padding: .62rem .82rem;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}
button, input, select, textarea { font: inherit; }
.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.primary:hover { background: var(--primary-2); }

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.25rem auto 3rem;
}

.hero-card, .login-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .8rem;
  box-shadow: var(--shadow);
}
.hero-card {
  padding: clamp(1.3rem, 4vw, 2.5rem);
  margin-bottom: 1rem;
  background:
    linear-gradient(135deg, rgba(36, 87, 214, .95), rgba(13, 148, 136, .86)),
    var(--primary);
  color: #fff;
}
.hero-card.compact { padding: 1.5rem; }
.hero-card p { max-width: 68ch; margin-bottom: 0; color: rgba(255,255,255,.88); }
.hero-card h1, .login-card h1 { margin: .2rem 0 .55rem; font-size: clamp(1.65rem, 4vw, 2.8rem); line-height: 1.05; letter-spacing: 0; }
.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .78rem;
  font-weight: 800;
}

.login-card {
  max-width: 520px;
  margin: 8vh auto;
  padding: clamp(1.25rem, 5vw, 2.5rem);
}

.panel {
  padding: 1.1rem;
  margin: 1rem 0;
}
summary {
  cursor: pointer;
  font-weight: 800;
  min-height: 2.5rem;
}

.notice {
  margin: 1rem 0;
  padding: .9rem 1rem;
  border-radius: .6rem;
  border: 1px solid rgba(13, 148, 136, .3);
  background: #e8fff8;
  color: #075f56;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .9rem;
  margin: 1rem 0;
}
.metrics article, .card-link {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: 1rem;
  box-shadow: 0 12px 32px rgba(23, 32, 51, .06);
}
.metrics strong {
  display: block;
  font-size: 2rem;
  color: var(--primary);
}
.metrics span, .muted, small { color: var(--muted); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: .5rem 0 1rem;
}
.section-head h1, .section-head h2 { margin: 0; }

.compact-search,
.manual-search {
  display: grid;
  gap: .35rem;
}
.compact-search {
  width: min(22rem, 100%);
}
.manual-search {
  margin-top: .9rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
}
.support-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
  padding: clamp(1.15rem, 3vw, 1.7rem);
  margin-bottom: 1rem;
  border: 1px solid rgba(36, 87, 214, .22);
  border-radius: .8rem;
  background:
    linear-gradient(135deg, rgba(16, 34, 53, .96), rgba(36, 87, 214, .86));
  color: #fff;
  box-shadow: var(--shadow);
}
.support-hero h1 {
  margin: .2rem 0 .5rem;
  max-width: 16ch;
  font-size: clamp(1.75rem, 3.2vw, 2.65rem);
  line-height: 1.06;
  letter-spacing: 0;
}
.support-hero p {
  max-width: 72ch;
  margin: 0;
  color: rgba(255,255,255,.86);
}
.support-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2.2rem;
  padding: .45rem .7rem;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  color: #fff;
  font-weight: 850;
  white-space: nowrap;
}
.help-callout {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  background:
    linear-gradient(135deg, rgba(36, 87, 214, .08), rgba(13, 148, 136, .08)),
    var(--surface);
}
.help-callout h2,
.help-callout p {
  margin: .2rem 0;
}
.manual-home {
  display: grid;
  grid-template-columns: minmax(18rem, .8fr) minmax(0, 1.2fr);
  gap: 1rem;
  margin: 1rem 0;
}
.manual-nav-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .8rem;
  padding: 1rem;
  box-shadow: 0 12px 32px rgba(23, 32, 51, .07);
}
.manual-nav-panel h2,
.manual-summary h2 {
  margin: .2rem 0;
}
.manual-list {
  display: grid;
  gap: .65rem;
  margin-top: .9rem;
}
.manual-list-item {
  display: grid;
  gap: .15rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #f8fbff;
  color: var(--text);
}
.manual-list-item span {
  font-weight: 850;
}
.manual-list-item:hover {
  text-decoration: none;
  border-color: rgba(36, 87, 214, .42);
  background: #fff;
}
.manual-summary {
  margin: 0;
}
.support-flow {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}
.support-flow span {
  padding: .55rem .7rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--primary);
  font-weight: 800;
}
.manual-layout {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.manual-toc {
  position: sticky;
  top: 6rem;
  display: grid;
  gap: .45rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(23, 32, 51, .06);
}
.manual-toc h2 {
  margin: .4rem 0 .2rem;
  font-size: 1rem;
}
.manual-toc a:not(.button) {
  display: block;
  padding: .55rem .65rem;
  border-radius: .5rem;
  color: var(--text);
  font-weight: 750;
}
.manual-toc a:not(.button):hover {
  background: var(--surface-2);
  text-decoration: none;
}
.manual-doc {
  min-width: 0;
}
.manual-title {
  grid-template-columns: 1fr;
}
.manual-intro {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(20rem, 1.1fr);
  gap: 1.25rem;
  align-items: center;
}
.manual-figure {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--line);
  border-radius: .8rem;
}
.manual-steps {
  display: grid;
  gap: .7rem;
  margin: 1rem 0 0;
  padding-left: 1.35rem;
}
.manual-steps li {
  padding-left: .25rem;
  font-weight: 650;
}
.manual-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.manual-sections .panel {
  margin: 0;
}
.check-list {
  display: grid;
  gap: .65rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.check-list li {
  position: relative;
  padding: .8rem .9rem .8rem 2.35rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: #f8fbff;
  font-weight: 650;
}
.check-list li::before {
  content: "";
  position: absolute;
  left: .85rem;
  top: 1rem;
  width: .65rem;
  height: .65rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}
.permission-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .7rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}
.permission-list li {
  padding: .8rem .9rem;
  border: 1px solid var(--line);
  border-radius: .6rem;
  background: linear-gradient(135deg, rgba(36, 87, 214, .06), rgba(13, 148, 136, .06));
  font-weight: 650;
}
.faq-list {
  display: grid;
  gap: .65rem;
  margin-top: 1rem;
}
.faq-list details {
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #f8fbff;
  padding: .85rem .95rem;
}
.faq-list summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 850;
}
.faq-list p {
  margin: .7rem 0 0;
  color: var(--muted);
}
.empty-state {
  margin: 1rem 0 0;
  padding: .9rem 1rem;
  border: 1px dashed var(--line);
  border-radius: .65rem;
  background: #f8fbff;
  color: var(--muted);
  font-weight: 700;
}
[hidden] {
  display: none !important;
}
.dossier-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  margin-top: 1rem;
}
.dossier-card {
  display: grid;
  gap: .35rem;
  min-height: 6rem;
  padding: .95rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: #f8fbff;
}
.dossier-card strong { overflow-wrap: anywhere; }
.dossier-card span {
  color: var(--muted);
  font-weight: 800;
}
.dossier-card.ready {
  border-color: rgba(20, 122, 74, .28);
  background: #f0fdf8;
}
.dossier-card.ready span { color: var(--success); }
.dossier-card.missing {
  border-color: rgba(180, 83, 9, .25);
  background: #fffaf0;
}
.dossier-card.missing span { color: var(--warning); }
.card-link {
  display: grid;
  gap: .55rem;
  color: var(--text);
}
.card-link:hover {
  text-decoration: none;
  border-color: rgba(36, 87, 214, .45);
}

.tag, .status {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 1.65rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--primary);
}
.status-caricato { background: #eef4ff; color: var(--primary); }
.status-in_verifica { background: #fff7ed; color: var(--warning); }
.status-osservazioni, .status-retrocesso { background: #fff1f2; color: var(--danger); }
.status-revisionato { background: #ecfeff; color: #0e7490; }
.status-approvato { background: #ecfdf5; color: var(--success); }

.form-grid {
  display: grid;
  gap: .9rem;
  margin-top: 1rem;
}
.full-row { grid-column: 1 / -1; }
.inline-form {
  display: grid;
  grid-template-columns: 1fr 16rem auto;
  gap: .85rem;
  align-items: end;
  margin-top: 1rem;
}
label span {
  display: block;
  margin-bottom: .35rem;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
}
input, select, textarea {
  width: 100%;
  min-height: 2.9rem;
  border: 1px solid var(--line);
  border-radius: .55rem;
  background: #fff;
  color: var(--text);
  padding: .75rem .85rem;
}
input[type="search"] {
  appearance: none;
}
textarea { min-height: 7rem; resize: vertical; }
hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
}
input:focus, select:focus, textarea:focus, button:focus, a:focus {
  outline: 3px solid rgba(36, 87, 214, .25);
  outline-offset: 2px;
}
button:disabled {
  cursor: not-allowed;
  opacity: .62;
}

.upload-queue {
  display: grid;
  gap: .75rem;
}
.upload-row {
  display: grid;
  gap: .45rem;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: #f8fbff;
}
.upload-row strong {
  overflow-wrap: anywhere;
}
.upload-row .upload-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}
.upload-progress {
  height: .65rem;
  overflow: hidden;
  border-radius: 999px;
  background: #d9e3f2;
}
.upload-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .2s ease;
}
.upload-row.done {
  border-color: rgba(20, 122, 74, .35);
  background: #effdf6;
}
.upload-row.error {
  border-color: rgba(185, 28, 28, .35);
  background: #fff5f5;
}
.upload-row.error .upload-meta {
  color: var(--danger);
}
.upload-error {
  margin: 0;
  padding: .8rem .9rem;
  border: 1px solid rgba(185, 28, 28, .35);
  border-radius: .6rem;
  background: #fff5f5;
  color: var(--danger);
  font-weight: 800;
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
th, td {
  padding: .85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.timeline {
  display: grid;
  gap: .75rem;
}
.timeline article {
  border-left: 4px solid var(--primary);
  background: #f8fbff;
  padding: .85rem 1rem;
  border-radius: .45rem;
}
.timeline p { margin: .45rem 0; }

.search {
  display: flex;
  align-items: end;
  gap: .65rem;
}
.search label { min-width: min(22rem, 65vw); }

.footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: .9rem;
}

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  nav { justify-content: flex-start; }
  nav a, .button, button { min-height: 2.45rem; padding: .58rem .72rem; }
  .metrics, .cards, .dossier-grid, .manual-home, .manual-layout, .manual-intro, .manual-sections, .permission-list, .help-callout, .support-hero { grid-template-columns: 1fr; }
  .manual-toc { position: static; }
  .support-badge { width: fit-content; }
  .section-head, .search, .inline-form { display: grid; grid-template-columns: 1fr; }
  .compact-search { width: 100%; }
  .shell { width: min(100% - 1rem, 1180px); }
}

@media (max-width: 1180px) {
  .brand { min-width: auto; }
  .brand small { display: none; }
  nav a { font-size: .94rem; }
}
